Layout: Draw channel layout 10/48710/6
authorHyojung Jo <hj903.jo@samsung.com>
Fri, 25 Sep 2015 07:38:31 +0000 (16:38 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Wed, 30 Sep 2015 05:24:32 +0000 (14:24 +0900)
Change-Id: Ic2e5bd8c3a49a8f3db38da29185592c7986475b3
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
include/view_base.h
res/layout/channel.edc
res/widget/button.edc
src/layout/layout_channel.c
src/view/view_base.c

index 47ba619..f9fdc3c 100644 (file)
 #define PART_SUBTEXT1 "part.subtext1"
 #define PART_SUBTEXT2 "part.subtext2"
 #define PART_BUTTON "part.button"
+#define PART_PROGRESSBAR "part.progressbar"
 
 /* Style */
 #define STYLE_MENU_BTN "style.menu.button"
+#define STYLE_BASE_BTN "style.base.button"
 
 /* Signal */
-#define SIG_FOCUSED "focused"
-#define SIG_UNFOCUSED "unfocused"
+#define SIG_FOCUSED "elm,action,focus"
+#define SIG_UNFOCUSED "elm,action,unfocus"
 #define SIG_SELECTED "selected"
+#define SIG_GUIDE "signal.guide"
+#define SIG_SEARCHING "signal.searching"
+#define SIG_SEARCH_COMPLETE "signal.search.complete"
+
+/* Source */
+#define SRC_ELM "elm"
 
 /* Font */
 #define FONT_REGULAR "BreezeSans"
 
 /* String for channel layout */
 #define STR_CHANNEL_TITLE "Auto Program"
-#define STR_CHANNEL_SUBTEXT1 "Connect TV cable to antenna / cable input socket<br>"\
+#define STR_SEARCH_GUIDE1 "Connect TV cable to antenna / cable input socket<br>"\
        "behind the TV to start tuning.<br>You can search all available channels."
-#define STR_CHANNEL_SUBTEXT2 "Press start to search and store channels."
+#define STR_SEARCH_GUIDE2 "Press start to search and store channels."
+#define STR_SEARCHING1 "Auto Program is finding channels for you.<br>"\
+       "To skip current step, Press stop."
+#define STR_SEARCHING2 "%d Ch found"
+#define STR_SEARCH_COMPLETE "Auto Program complete.<br>%d Channels are memorized."
+#define STR_START "Start"
+#define STR_STOP "Stop"
+#define STR_OK "OK"
 
 /* Size */
+#define SIZE_STR 1024
 #define SIZE_MENU_BOX_PAD_H (40 + 40)
 #define SIZE_MENU_BOX_PAD_V 0
 
index 3c9ff5e..7a55b1d 100644 (file)
@@ -19,4 +19,8 @@
 
 view_class *view_base_get_vclass(void);
 
+enum update_type {
+       UPDATE_FOCUS = 0,
+};
+
 #endif /* __AIR_SETTINGS_VIEW_BASE_H__ */
index 69fdeae..50418d8 100644 (file)
@@ -110,6 +110,11 @@ group {
                                        style, "style.subtext1";
                                }
                        }
+                       description {
+                               state, "searching" 0.0;
+                               inherit, "default" 0.0;
+                               min, 0 78;
+                       }
                }
 
                part {
@@ -127,6 +132,51 @@ group {
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
+                       description {
+                               state, "searching" 0.0;
+                               inherit, "default" 0.0;
+                               min, 0 100;
+                       }
+               }
+
+               part {
+                       name, "padding.progressbar";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 54;
+                               rel1.to, PART_SUBTEXT2;
+                               rel2 {
+                                       to, PART_SUBTEXT2;
+                                       relative, 1.0 0.0;
+                               }
+                               align, 0.5 1.0;
+                               fixed, 0 1;
+                       }
+               }
+
+               part {
+                       name, PART_PROGRESSBAR;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 4;
+                               rel1.to, "padding.progressbar";
+                               rel2 {
+                                       to, "padding.progressbar";
+                                       relative, 1.0 0.0;
+                               }
+                               align, 0.5 1.0;
+                               fixed, 0 1;
+                               visible, 0;
+                       }
+                       description {
+                               state, "searching" 0.0;
+                               inherit, "default" 0.0;
+                               visible, 1;
+                       }
                }
 
                part {
@@ -158,7 +208,7 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
-                               min, 0 260;
+                               min, 0 278;
                                rel1 {
                                        to, PART_SUBTEXT2;
                                        relative, 0.0 1.0;
@@ -167,6 +217,11 @@ group {
                                align, 0.5 0.0;
                                fixed, 0 1;
                        }
+                       description {
+                               state, "searching" 0.0;
+                               inherit, "default" 0.0;
+                               min, 0 260;
+                       }
                }
 
                part {
@@ -189,4 +244,36 @@ group {
                        }
                }
        }
+
+       programs {
+               program {
+                       name, SIG_GUIDE;
+                       signal, SIG_GUIDE;
+                       source, SRC_ELM;
+                       action, STATE_SET "default" 0.0;
+                       target, PART_SUBTEXT1;
+                       target, "padding.subtext2";
+                       target, PART_PROGRESSBAR;
+                       target, "padding.button";
+               }
+
+               program {
+                       name, SIG_SEARCHING;
+                       signal, SIG_SEARCHING;
+                       source, SRC_ELM;
+                       action, STATE_SET "searching" 0.0;
+                       target, PART_SUBTEXT1;
+                       target, "padding.subtext2";
+                       target, PART_PROGRESSBAR;
+                       target, "padding.button";
+               }
+
+               program {
+                       name, SIG_SEARCH_COMPLETE;
+                       signal, SIG_SEARCH_COMPLETE;
+                       source, SRC_ELM;
+                       action, STATE_SET "default" 0.0;
+                       target, PART_PROGRESSBAR;
+               }
+       }
 }
index 66dd003..994d203 100644 (file)
@@ -162,8 +162,8 @@ group {
        programs{
                program {
                        name, SIG_FOCUSED;
-                       signal, "elm,action,focus";
-                       source, "elm";
+                       signal, SIG_FOCUSED;
+                       source, SRC_ELM;
                        script {
                                set_int(cur_state, STATE_NORMAL);
                                run_program(PROGRAM:"focused,anim");
@@ -172,8 +172,8 @@ group {
 
                program {
                        name, SIG_UNFOCUSED;
-                       signal, "elm,action,unfocus";
-                       source, "elm";
+                       signal, SIG_UNFOCUSED;
+                       source, SRC_ELM;
                        script {
                                new state;
                                state = get_int(cur_state);
@@ -226,3 +226,215 @@ group {
                }
        }
 }
+
+group {
+       name, "elm/button/base/style.base.button";
+       data.item, "focus_highlight" "on";
+
+       parts {
+               part {
+                       name, "part.bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 255 255 255 255;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               color, 0 119 246 255;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.up";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 87 87 87 255;
+                               min, 0 2;
+                               rel1.to, "part.bg";
+                               rel2 {
+                                       to, "part.bg";
+                                       relative, 1.0 0.0;
+                               }
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.left";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 87 87 87 255;
+                               min, 2 0;
+                               rel1 {
+                                       to, "part.inside.line.up";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2 {
+                                       to, "part.bg";
+                                       relative, 0.0 1.0;
+                               }
+                               align, 0.0 0.5;
+                               fixed, 1 0;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.right";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 87 87 87 255;
+                               min, 2 0;
+                               rel1 {
+                                       to, "part.inside.line.up";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2.to, "part.bg";
+                               align, 1.0 0.5;
+                               fixed, 1 0;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.down";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 87 87 87 255;
+                               min, 0 2;
+                               rel1 {
+                                       to, "part.inside.line.left";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2 {
+                                       to, "part.inside.line.right";
+                                       relative, 0.0 1.0;
+                               }
+                               align, 0.5 1.0;
+                               fixed, 0 1;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "padding.text.left";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 20 0;
+                               rel1.to, "part.bg";
+                               rel2 {
+                                       to, "part.bg";
+                                       relative, 0.0 1.0;
+                               }
+                               align, 0.0 0.5;
+                               fixed, 1 0;
+                       }
+               }
+
+               part {
+                       name, "padding.text.right";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 20 0;
+                               rel1 {
+                                       to, "part.bg";
+                                       relative, 1.0 0.0;
+                               }
+                               rel2.to, "part.bg";
+                               align, 1.0 0.5;
+                               fixed, 1 0;
+                       }
+               }
+
+               part {
+                       name, "elm.text";
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 87 87 87 255;
+                               rel1 {
+                                       to, "padding.text.left";
+                                       relative, 1.0 0.0;
+                               }
+                               rel2 {
+                                       to, "padding.text.right";
+                                       relative, 0.0 1.0;
+                               }
+                               text {
+                                       font, FONT_LIGHT;
+                                       size, 32;
+                                       align, 0.5 0.5;
+                               }
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               color, 255 255 255 255;
+                       }
+               }
+       }
+
+       programs {
+               program {
+                       name, SIG_FOCUSED;
+                       signal, SIG_FOCUSED;
+                       source, SRC_ELM;
+                       action, STATE_SET "focused" 0.0;
+                       target, "part.bg";
+                       target, "part.inside.line.up";
+                       target, "part.inside.line.down";
+                       target, "part.inside.line.left";
+                       target, "part.inside.line.right";
+                       target, "elm.text";
+                       transition, TRANSITION_FOCUS;
+               }
+
+               program {
+                       name, SIG_UNFOCUSED;
+                       signal, SIG_UNFOCUSED;
+                       source, SRC_ELM;
+                       action, STATE_SET "default" 0.0;
+                       target, "part.bg";
+                       target, "part.inside.line.up";
+                       target, "part.inside.line.down";
+                       target, "part.inside.line.left";
+                       target, "part.inside.line.right";
+                       target, "elm.text";
+                       transition, TRANSITION_FOCUS;
+               }
+       }
+}
index 9c85b26..5e4a4b7 100644 (file)
  */
 
 #include <Elementary.h>
+#include <viewmgr.h>
 #include <layoutmgr.h>
+#include <inputmgr.h>
 #include <app_debug.h>
 
 #include "define.h"
 #include "layout.h"
 #include "utils.h"
+#include "view_base.h"
+
+enum search_state {
+       STATE_INIT,
+       STATE_SEARCHING,
+       STATE_COMPLETE,
+};
 
 struct _priv {
        Evas_Object *base;
        Evas_Object *ly;
+       Evas_Object *btn;
+       enum search_state cur_state;
        layoutmgr *lmgr;
 };
 
-static bool _add_layout_contents(struct _priv *priv)
+static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Mouse_Move *ev)
 {
-       elm_object_part_text_set(priv->ly, PART_TITLE, STR_CHANNEL_TITLE);
-       elm_object_part_text_set(priv->ly, PART_SUBTEXT1, STR_CHANNEL_SUBTEXT1);
-       elm_object_part_text_set(priv->ly, PART_SUBTEXT2, STR_CHANNEL_SUBTEXT2);
+       if (!obj) {
+               _ERR("Invalid argument.");
+               return;
+       }
 
-       /* It will be implemented more later. */
+       if (!elm_object_focus_get(obj))
+               elm_object_focus_set(obj, EINA_TRUE);
+}
 
-       return true;
+static void _update_layout_text(struct _priv *priv, const char *emission,
+               const char *subtext1, const char *subtext2, const char *btntext)
+{
+       elm_object_signal_emit(priv->ly, emission, SRC_ELM);
+
+       elm_object_part_text_set(priv->ly, PART_SUBTEXT1, subtext1);
+       elm_object_part_text_set(priv->ly, PART_SUBTEXT2, subtext2);
+
+       elm_object_text_set(priv->btn, btntext);
+}
+
+static void _channel_search_start(struct _priv *priv)
+{
+       char str[SIZE_STR];
+
+       /* channel search start should be implemented. */
+
+       snprintf(str, sizeof(str), STR_SEARCHING2, 0);
+
+       _update_layout_text(priv, SIG_SEARCHING, STR_SEARCHING1, str, STR_STOP);
+
+       priv->cur_state = STATE_SEARCHING;
+}
+
+static void _channel_search_stop(struct _priv *priv)
+{
+       char str[SIZE_STR];
+
+       /* channel search stop should be implemented. */
+
+       snprintf(str, sizeof(str), STR_SEARCH_COMPLETE, 0);
+
+       _update_layout_text(priv, SIG_SEARCH_COMPLETE, str, NULL, STR_OK);
+
+       priv->cur_state = STATE_COMPLETE;
+}
+
+static void _channel_search_init(struct _priv *priv)
+{
+       _update_layout_text(priv, SIG_GUIDE, STR_SEARCH_GUIDE1,
+                       STR_SEARCH_GUIDE2, STR_START);
+
+       priv->cur_state = STATE_INIT;
+}
+
+static void _button_selected(struct _priv *priv)
+{
+       switch (priv->cur_state) {
+       case STATE_INIT:
+               _channel_search_start(priv);
+               break;
+
+       case STATE_SEARCHING:
+               _channel_search_stop(priv);
+               break;
+
+       case STATE_COMPLETE:
+               _channel_search_init(priv);
+               break;
+
+       default:
+               _ERR("Unhandled state.");
+       }
 }
 
+static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Key_Down *ev)
+{
+       struct _priv *priv;
+
+       if (!data || !ev || !obj) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = data;
+
+       if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC))
+               viewmgr_update_view(VIEW_BASE, UPDATE_FOCUS, NULL);
+       else if (!strcmp(ev->keyname, KEY_ENTER))
+               _button_selected(priv);
+}
+
+static input_handler _input_handler = {
+       .mouse_move = _mouse_move_cb,
+       .key_down = _key_down_cb,
+};
+
 static bool _create(layoutmgr *lmgr, void *data)
 {
        struct _priv *priv;
-       Evas_Object *base, *ly;
+       Evas_Object *base, *ly, *btn;
 
        if (!lmgr) {
                _ERR("Invalid argument.");
@@ -61,6 +161,15 @@ static bool _create(layoutmgr *lmgr, void *data)
                return false;
        }
 
+       elm_object_part_text_set(ly, PART_TITLE, STR_CHANNEL_TITLE);
+
+       btn = utils_add_button(ly, PART_BUTTON, STYLE_BASE_BTN, NULL);
+       if (!btn) {
+               _ERR("Add button failed.");
+               evas_object_del(ly);
+               return false;
+       }
+
        priv = calloc(1, sizeof(*priv));
        if (!priv) {
                _ERR("Calloc failed.");
@@ -71,14 +180,9 @@ static bool _create(layoutmgr *lmgr, void *data)
        priv->lmgr = lmgr;
        priv->base = base;
        priv->ly = ly;
+       priv->btn = btn;
 
-       if (!_add_layout_contents(priv)) {
-               _ERR("Add channel layout contents failed.");
-               evas_object_del(ly);
-               free(priv);
-               return false;
-       }
-
+       inputmgr_add_callback(btn, 0, &_input_handler, priv);
        layoutmgr_set_layout_data(lmgr, LAYOUT_ID_CHANNEL, priv);
 
        return true;
@@ -96,6 +200,8 @@ static void _show(void *layout_data)
        priv = layout_data;
 
        if (priv->ly) {
+               _channel_search_init(priv);
+
                evas_object_show(priv->ly);
                elm_object_part_content_set(priv->base, PART_CONTENT, priv->ly);
        }
@@ -129,6 +235,8 @@ static void _destroy(void *layout_data)
 
        priv = layout_data;
 
+       inputmgr_remove_callback(priv->btn, &_input_handler);
+
        evas_object_del(priv->ly);
 
        free(priv);
index 6bf3e33..414879c 100644 (file)
@@ -24,6 +24,7 @@
 #include "define.h"
 #include "layout.h"
 #include "utils.h"
+#include "view_base.h"
 
 struct _priv {
        Evas_Object *win;
@@ -284,6 +285,20 @@ static void _hide(void *data)
                evas_object_hide(priv->base);
 }
 
+static void _update(void *view_data, int update_type, void *data)
+{
+       struct _priv *priv;
+
+       if (!view_data) {
+               _ERR("Get data failed.");
+               return;
+       }
+       priv = view_data;
+
+       if (update_type == UPDATE_FOCUS)
+               elm_object_focus_set(priv->menu[priv->cur_menu], EINA_TRUE);
+}
+
 static void _destroy(void *data)
 {
        struct _priv *priv;
@@ -311,6 +326,7 @@ static view_class _vclass = {
        .create = _create,
        .show = _show,
        .hide = _hide,
+       .update = _update,
        .destroy = _destroy,
 };