Add channelinfo search layout 17/42917/2
authorjinwoo.shin <jw0227.shin@samsung.com>
Mon, 6 Jul 2015 01:49:04 +0000 (10:49 +0900)
committerjinwoo.shin <jw0227.shin@samsung.com>
Mon, 6 Jul 2015 04:23:36 +0000 (13:23 +0900)
Change-Id: I8c823e6e12c468a89f0e89ddb4cd9ac861cb16fe
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
CMakeLists.txt
data/view/channelinfo.edc
include/define.h
include/layout_channelinfo_search.h [new file with mode: 0644]
src/layout_channelinfo.c
src/layout_channelinfo_list.c
src/layout_channelinfo_search.c [new file with mode: 0644]
src/view_channelinfo.c

index 58ce3f2..9bdcd5b 100644 (file)
@@ -42,6 +42,7 @@ SET(SRCS src/main.c
                src/view_channelinfo.c
                src/layout_channelinfo.c
                src/layout_channelinfo_list.c
+               src/layout_channelinfo_search.c
                src/util.c
                src/tv_service.c)
 
index 4d8bafe..b97ee55 100644 (file)
@@ -25,8 +25,8 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               rel1.relative, 1.0 0.5;
-                               rel2.relative, 1.0 0.5;
+                               rel1.relative, 1.0 0.0;
+                               rel2.relative, 1.0 1.0;
                                min, 536 0;
                                align, 1.0 0.5;
                                fixed, 1 0;
@@ -48,6 +48,8 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
+                               rel1.relative, 0.0 0.5;
+                               rel2.relative, 0.0 0.5;
                                min, 536 486;
                                align, 0.0 0.5;
                                fixed, 1 1;
@@ -224,9 +226,10 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
+                               rel1.relative, 0.0 0.5;
+                               rel2.relative, 0.0 0.5;
                                min, 536 174;
                                align, 0.0 0.5;
-                               fixed, 1 1;
                        }
                        description {
                                state, "focused" 0.0;
@@ -454,7 +457,7 @@ group {
                        description {
                                state, "default" 0.0;
                                min, 536 70;
-                               align, 1.0 0.5;
+                               align, 0.0 0.0;
                                fixed, 1 1;
                                visible, 0;
                        }
index 83dd802..8b4760f 100644 (file)
@@ -47,6 +47,7 @@
 #define VIEW_CHANNELINFO "VIEW_CHANNELINFO"
 #define LAYOUT_CHANNELINFO "LAYOUT_CHANNELINFO"
 #define LAYOUT_CHANNELINFO_LIST "LAYOUT_CHANNELINFO_LIST"
+#define LAYOUT_CHANNELINFO_SEARCH "LAYOUT_CHANNELINFO_SEARCH"
 
 #define GRP_VIEW_CHANNELINFO "grp.view.channelinfo"
 
diff --git a/include/layout_channelinfo_search.h b/include/layout_channelinfo_search.h
new file mode 100644 (file)
index 0000000..f2507c3
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LAYOUT_CHANNELINFO_SEARCH_H__
+#define __LAYOUT_CHANNELINFO_SEARCH_H__
+
+layout_class *layout_channelinfo_search_get_lclass(void);
+
+#endif /* __LAYOUT_CHANNELINFO_SEARCH_H__*/
index 345adb7..00a58e0 100644 (file)
@@ -67,12 +67,9 @@ static bool _create(layoutmgr *lmgr, void *data)
                _ERR("failed to create layout");
                return false;
        }
-
        if (!elm_layout_file_set(layout, EDJEFILE, GRP_CHANNELINFO))
                goto error;
 
-       elm_object_content_set(base, layout);
-
        priv->base = base;
        priv->layout = layout;
        priv->lmgr = lmgr;
@@ -118,7 +115,10 @@ static void _show(void *layout_data)
 
        _update_channel_info(priv);
 
+       elm_object_content_set(priv->base, priv->layout);
        evas_object_show(priv->layout);
+
+       elm_object_focus_allow_set(priv->base, EINA_TRUE);
 }
 
 static void _hide(void *layout_data)
@@ -131,6 +131,7 @@ static void _hide(void *layout_data)
        priv = layout_data;
 
        evas_object_hide(priv->layout);
+       elm_object_content_unset(priv->base);
 }
 
 static void _update(void *layout_data, int update_type, void *data)
index eb37091..61c85f1 100644 (file)
@@ -70,7 +70,6 @@ static bool _create(layoutmgr *lmgr, void *data)
        }
        if (!elm_layout_file_set(priv->layout, EDJEFILE, GRP_CHANNELINFO_LIST))
                goto error;
-       elm_object_content_set(priv->base, priv->layout);
 
        priv->next_channel = util_add_layout(priv->layout,
                        GRP_CHANNELINFO_SIMPLE);
@@ -139,6 +138,7 @@ static void _show(void *layout_data)
 
        _update_channel_info(priv);
 
+       elm_object_content_set(priv->base, priv->layout);
        evas_object_show(priv->layout);
 }
 
@@ -152,6 +152,7 @@ static void _hide(void *layout_data)
        priv = layout_data;
 
        evas_object_hide(priv->layout);
+       elm_object_content_unset(priv->base);
 }
 
 static void _update(void *layout_data, int update_type, void *data)
diff --git a/src/layout_channelinfo_search.c b/src/layout_channelinfo_search.c
new file mode 100644 (file)
index 0000000..315f35d
--- /dev/null
@@ -0,0 +1,208 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <Elementary.h>
+#include <layoutmgr.h>
+#include <inputmgr.h>
+#include <viewmgr.h>
+#include <app_debug.h>
+
+#include "define.h"
+#include "util.h"
+#include "tv.h"
+#include "view_channelinfo.h"
+
+#define DIVIDER_WIDTH 536
+#define DIVIDER_HEIGHT 1
+#define DIVIDER_COLOR_R 0
+#define DIVIDER_COLOR_G 0
+#define DIVIDER_COLOR_B 0
+#define DIVIDER_COLOR_A (255 * 0.1)
+
+struct _priv {
+       Evas_Object *base;
+       Evas_Object *scroll;
+       Evas_Object *box;
+
+       layoutmgr *lmgr;
+       Eina_List *channel_list;
+};
+
+static void _load_channel_list(struct _priv *priv, Eina_List *channel_list)
+{
+       Evas_Object *ly, *divider;
+       Evas *e;
+       Eina_List *l;
+       const struct tv_channel_info *channel_info;
+       int r;
+       int current_service;
+
+       r = tv_get_current_service_id(&current_service);
+       if (r < 0)
+               current_service = -1;
+
+       e = evas_object_evas_get(priv->base);
+
+       divider = evas_object_rectangle_add(e);
+       evas_object_color_set(divider, DIVIDER_COLOR_R,
+                       DIVIDER_COLOR_G, DIVIDER_COLOR_B, DIVIDER_COLOR_A);
+       evas_object_size_hint_min_set(divider,
+                       DIVIDER_WIDTH, DIVIDER_HEIGHT);
+       evas_object_show(divider);
+
+       elm_box_clear(priv->box);
+
+       EINA_LIST_FOREACH(channel_list, l, channel_info) {
+               if (!channel_info->remembered)
+                       continue;
+
+               ly = util_add_layout(priv->box, GRP_CHANNELINFO);
+               if (!ly)
+                       continue;
+               elm_object_focus_allow_set(ly, EINA_TRUE);
+               draw_channel_info(ly, channel_info);
+
+               elm_box_pack_end(priv->box, ly);
+
+               if (eina_list_next(l))
+                       elm_box_pack_end(priv->box, divider);
+       }
+}
+
+static void _update_channel_list(struct _priv *priv)
+{
+       if (!priv) {
+               _ERR("failed to get priv");
+               return;
+       }
+
+       if (priv->channel_list)
+               tv_channel_del_list(priv->channel_list);
+
+       priv->channel_list = tv_channel_get_list();
+       if (!priv->channel_list) {
+               _ERR("failed to get channel list");
+               return;
+       }
+
+       _load_channel_list(priv, priv->channel_list);
+}
+
+static bool _create(layoutmgr *lmgr, void *data)
+{
+       struct _priv *priv;
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("failed to allocate priv");
+               return false;
+       }
+
+       priv->base = layoutmgr_get_base(lmgr);
+
+       priv->scroll = elm_scroller_add(priv->base);
+       if (!priv->scroll) {
+               _ERR("failed to create scroll");
+               goto error;
+       }
+       evas_object_size_hint_weight_set(priv->scroll,
+                       EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       priv->box = util_add_box(priv->scroll, false);
+       if (!priv->box) {
+               _ERR("failed to create box");
+               goto error;
+       }
+       elm_box_align_set(priv->box, 0.0, 0.5);
+       elm_box_padding_set(priv->box, 0, DIVIDER_HEIGHT);
+       evas_object_color_set(priv->box, DIVIDER_COLOR_R,
+                       DIVIDER_COLOR_G, DIVIDER_COLOR_B, DIVIDER_COLOR_A);
+
+       priv->lmgr = lmgr;
+
+       layoutmgr_set_layout_data(lmgr, LAYOUT_CHANNELINFO_SEARCH, priv);
+
+       return true;
+
+error:
+       evas_object_del(priv->scroll);
+       evas_object_del(priv->box);
+       free(priv);
+
+       return false;
+}
+
+static void _destroy(void *layout_data)
+{
+       struct _priv *priv;
+
+       if (!layout_data)
+               return;
+
+       priv = layout_data;
+
+       if (priv->channel_list)
+               tv_channel_del_list(priv->channel_list);
+
+       evas_object_del(priv->scroll);
+       free(priv);
+}
+
+static void _show(void *layout_data)
+{
+       struct _priv *priv;
+
+       if (!layout_data)
+               return;
+
+       priv = layout_data;
+
+       _update_channel_list(priv);
+
+       elm_object_content_set(priv->base, priv->scroll);
+       evas_object_show(priv->scroll);
+}
+
+static void _hide(void *layout_data)
+{
+       struct _priv *priv;
+
+       if (!layout_data)
+               return;
+
+       priv = layout_data;
+
+       elm_object_content_unset(priv->base);
+       evas_object_hide(priv->scroll);
+}
+
+static void _update(void *layout_data, int update_type, void *data)
+{
+}
+
+static layout_class lclass = {
+       .layout_id = LAYOUT_CHANNELINFO_SEARCH,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy,
+       .update = _update,
+};
+
+layout_class *layout_channelinfo_search_get_lclass(void)
+{
+       return &lclass;
+}
index aab1685..cf5396c 100644 (file)
@@ -24,6 +24,7 @@
 #include "tv.h"
 #include "layout_channelinfo.h"
 #include "layout_channelinfo_list.h"
+#include "layout_channelinfo_search.h"
 
 #define HIDE_DUR 10.0
 #define BUF_MAX 128
@@ -274,6 +275,8 @@ static Evas_Object *_create(Evas_Object *win, void *data)
        layoutmgr_add_layout(priv->lmgr, layout_channelinfo_get_lclass(), NULL);
        layoutmgr_add_layout(priv->lmgr,
                        layout_channelinfo_list_get_lclass(), NULL);
+       layoutmgr_add_layout(priv->lmgr,
+                       layout_channelinfo_search_get_lclass(), NULL);
 
        viewmgr_set_view_data(VIEW_CHANNELINFO, priv);
 
@@ -323,6 +326,7 @@ static void _destroy(void *view_data)
 
        layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO);
        layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_LIST);
+       layoutmgr_remove_layout(priv->lmgr, LAYOUT_CHANNELINFO_SEARCH);
        layoutmgr_destroy(priv->lmgr);
 
        evas_object_del(priv->base);