View: Draw sort option popup 03/43703/1
authorHyojung Jo <hj903.jo@samsung.com>
Mon, 13 Jul 2015 08:49:51 +0000 (17:49 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Mon, 13 Jul 2015 08:49:51 +0000 (17:49 +0900)
Change-Id: I11f267fffef801dc53ebef5baf90c565f1a79263
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
res/apps-theme.edc
res/widget/button.edc
res/widget/ctxpopup.edc [new file with mode: 0644]
src/view/view_base.c

index 4da1c132aae70e567b04ed0f4cbd81c56ba65341..fb7c275bdd004e5aa8d4e5cb708a60ca3327b452 100644 (file)
@@ -40,6 +40,8 @@
 /* Style */
 #define STYLE_MENU_BTN "style.menu.button"
 #define STYLE_SORT_BTN "style.sort.button"
+#define STYLE_OPTION_BTN "style.option.button"
+#define STYLE_SORT_CTXPOPUP "style.sort.ctxpopup"
 #define STYLE_APP "style.app"
 
 /* Signal */
 
 /* Count */
 #define MENU_COUNT 2
+#define SORT_COUNT 3
 
 /* Size */
 #define SIZE_GRID_WIDTH (212 + 26)
 #define SIZE_GRID_HEIGHT (294 + 26)
 #define SIZE_STR 1024
-#define SIZE_BOX_PAD_H (40 + 40)
-#define SIZE_BOX_PAD_V 0
+#define SIZE_MENU_BOX_PAD_H (40 + 40)
+#define SIZE_MENU_BOX_PAD_V 0
+#define SIZE_SORT_BOX_PAD_H 0
+#define SIZE_SORT_BOX_PAD_V 0
 
 /* Image */
 #define FAVORITE_ICON_PNG "ic_thumbnail_favorite_01.png"
index abc2484a4202b6f35971ef64eee2ab261954db4f..e04a32b8538974d4497690d1c3235258b36c5a96 100644 (file)
@@ -19,4 +19,5 @@
 collections {
        #include "widget/button.edc"
        #include "widget/gengrid.edc"
+       #include "widget/ctxpopup.edc"
 }
index d63b4559f37d58a348b8ea59e61372c9546f4ac0..23eeab4735f9c085388ae0e0f6925804447f517e 100644 (file)
@@ -242,6 +242,7 @@ group {
                        scale, 1;
                        description {
                                state, "default" 0.0;
+                               color, 255 255 255 255;
                                min, 218 64;
                        }
                        description {
@@ -471,3 +472,126 @@ group {
                }
        }
 }
+
+group {
+       name, "elm/button/base/style.option.button";
+       inherit, "elm/button/base/style.sort.button";
+       parts {
+               part {
+                       name, "part.bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 218 56;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               color, 0 119 246 255;
+                       }
+                       description {
+                               state, "selected" 0.0;
+                               inherit, "default" 0.0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.up";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                       }
+                       description {
+                               state, "selected" 0.0;
+                               inherit, "default" 0.0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.left";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                       }
+                       description {
+                               state, "selected" 0.0;
+                               inherit, "default" 0.0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.down";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                       }
+                       description {
+                               state, "selected" 0.0;
+                               inherit, "default" 0.0;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.right";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                       }
+                       description {
+                               state, "selected" 0.0;
+                               inherit, "default" 0.0;
+                       }
+               }
+
+               part {
+                       name, "elm.text";
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 87 87 87 255;
+                               min, 158 0;
+                               text {
+                                       font, FONT_TIZENSANS_LIGHT;
+                                       size, 28;
+                                       align, 0.0 0.5;
+                               }
+                       }
+                       description {
+                               state, "focused" 0.0;
+                               inherit, "default" 0.0;
+                               color, 255 255 255 255;
+                       }
+                       description {
+                               state, "selected" 0.0;
+                               inherit, "default" 0.0;
+                               color, 64 136 211 255;
+                       }
+               }
+       }
+}
diff --git a/res/widget/ctxpopup.edc b/res/widget/ctxpopup.edc
new file mode 100644 (file)
index 0000000..aeef58d
--- /dev/null
@@ -0,0 +1,104 @@
+group {
+       name, "elm/ctxpopup/base/style.sort.ctxpopup";
+       data.item, "focus_hightlight" "on";
+       parts {
+               part {
+                       name, "part.bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 255 255 255 255;
+                               min, 220 170;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.up";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 154 154 154 255;
+                               min, 220 1;
+                               rel2.relative, 0.0 0.0;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.left";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 154 154 154 255;
+                               min, 1 170;
+                               rel2.relative, 0.0 0.0;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.down";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 154 154 154 255;
+                               min, 220 1;
+                               rel1.relative, 0.0 1.0;
+                               rel2.relative, 0.0 1.0;
+                               align, 0.0 1.0;
+                               fixed, 1 1;
+                       }
+               }
+
+               part {
+                       name, "part.inside.line.right";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 154 154 154 255;
+                               min, 1 170;
+                               rel1.relative, 1.0 0.0;
+                               rel2.relative, 1.0 0.0;
+                               align, 1.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+
+               part {
+                       name, "padding.elm.swallow.content";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 1 1;
+                               rel2.relative, 0.0 0.0;
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+
+               part {
+                       name, "elm.swallow.content";
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 218 168;
+                               rel1 {
+                                       to, "padding.elm.swallow.content";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2.to, "padding.elm.swallow.content";
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+       }
+}
index 2c35054b408bfe24e920712cc11258bd91f4ed97..644484e1be52a1c05c242aae28dadcbbf61958f9 100644 (file)
@@ -58,12 +58,14 @@ struct _priv {
        Evas_Object *menu_btn[MENU_COUNT];
        Evas_Object *focused_menu;
        Evas_Object *sort_btn;
+       Evas_Object *sort_popup;
        Evas_Object *grid;
        Elm_Object_Item *cur_grid_item;
        struct gridmgr *gmgr;
        Eina_List *app_list;
        enum sort_type sort_type;
 };
+
 static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
                Evas_Event_Mouse_Move *ev)
 {
@@ -144,15 +146,136 @@ static void _menu_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
        }
 }
 
+static void _destroy_sort_ctxpopup(struct _priv *priv)
+{
+       if (!priv || !priv->sort_popup) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       evas_object_hide(priv->sort_popup);
+       evas_object_del(priv->sort_popup);
+       priv->sort_popup = NULL;
+}
+
+static void _option_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Key_Down *ev)
+{
+       struct _priv *priv;
+
+       if (!data || !ev) {
+               _ERR("Invalid argument.");
+               return;
+       }
+       priv = data;
+
+       if (!strcmp(ev->key, KEY_BACK)) {
+               _destroy_sort_ctxpopup(priv);
+       } else if (!strcmp(ev->key, KEY_ENTER)) {
+               switch (id) {
+               case SORT_RECENT:
+                       /* It should be implemented later. */
+                       break;
+
+               case SORT_A_TO_Z:
+                       /* It should be implemented later. */
+                       break;
+
+               case SORT_Z_TO_A:
+                       /* It should be implemented later. */
+                       break;
+
+               default:
+                       _ERR("Invalid sort type.");
+               }
+
+               _destroy_sort_ctxpopup(priv);
+       }
+}
+
+static input_handler _option_input_handler = {
+       .mouse_move = _mouse_move_cb,
+       .key_down = _option_key_down_cb
+       /* It will be implemented later. */
+};
+
+static bool _draw_sort_option(struct _priv *priv)
+{
+       Evas_Object *ctxpopup, *box, *btn, *firstbtn;
+       Evas_Coord x, y, w, h;
+       int i;
+
+       if (!priv) {
+               _ERR("Invalid argument.");
+               return false;
+       }
+
+       ctxpopup = elm_ctxpopup_add(priv->base);
+       if (!ctxpopup) {
+               _ERR("elm_ctxpopup_add failed.");
+               return false;
+       }
+
+       box = add_box(ctxpopup, NULL, EINA_FALSE,
+                       SIZE_SORT_BOX_PAD_H, SIZE_SORT_BOX_PAD_V);
+       if (!box) {
+               _ERR("elm_box_add failed.");
+               evas_object_del(ctxpopup);
+               return false;
+       }
+
+       elm_object_style_set(ctxpopup, STYLE_SORT_CTXPOPUP);
+       elm_object_content_set(ctxpopup, box);
+
+       elm_ctxpopup_direction_priority_set(ctxpopup, 0, 0, 0, 0);
+       evas_object_geometry_get(priv->sort_btn, &x, &y, &w, &h);
+       evas_object_move(ctxpopup, (x + w / 2) * elm_config_scale_get(),
+                       y * elm_config_scale_get());
+       evas_object_show(ctxpopup);
+
+       priv->sort_popup = ctxpopup;
+
+       for (i = 0; i < SORT_COUNT; i++) {
+               btn = add_button(box, NULL, str_sort[i], STYLE_OPTION_BTN);
+               if (!btn) {
+                       _ERR("Add button failed.");
+                       evas_object_del(ctxpopup);
+                       return false;
+               }
+
+               elm_box_pack_end(box, btn);
+
+               inputmgr_add_callback(btn, i, &_option_input_handler, priv);
+
+               if (i == 0)
+                       firstbtn = btn;
+       }
+
+       if (firstbtn && btn) {
+               elm_object_focus_set(firstbtn, EINA_TRUE);
+               elm_object_focus_next_object_set(firstbtn, btn, ELM_FOCUS_UP);
+               elm_object_focus_next_object_set(btn, firstbtn, ELM_FOCUS_DOWN);
+       }
+
+       return true;
+}
+
 static void _sort_clicked_cb(int id, void *data, Evas_Object *obj)
 {
-       if (!obj) {
+       struct _priv *priv;
+
+       if (!data || !obj) {
                _ERR("Invalid argument.");
                return;
        }
+       priv = data;
+
+       if (!_draw_sort_option(priv)) {
+               _ERR("Draw sort ctxpopup failed.");
+               return;
+       }
 
        elm_object_signal_emit(obj, SIG_SELECTED, "");
-       /* It will be implemented later. */
 }
 
 static void _sort_focused_cb(int id, void *data, Evas_Object *obj,
@@ -161,6 +284,18 @@ static void _sort_focused_cb(int id, void *data, Evas_Object *obj,
        /* It will be implemented later. */
 }
 
+static void _sort_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Key_Down *ev)
+{
+       if (!ev) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       if (!strcmp(ev->key, KEY_BACK))
+               ui_app_exit();
+}
+
 static void _grid_focused_cb(int id, void *data, Evas_Object *obj,
                Elm_Object_Item *item)
 {
@@ -281,7 +416,8 @@ static input_handler _menu_input_handler = {
 static input_handler _sort_input_handler = {
        .mouse_move = _mouse_move_cb,
        .clicked = _sort_clicked_cb,
-       .focused = _sort_focused_cb
+       .focused = _sort_focused_cb,
+       .key_down = _sort_key_down_cb
        /* It will be implemented later. */
 };
 
@@ -306,7 +442,7 @@ static bool _draw_top_area(struct _priv *priv)
        elm_object_part_text_set(priv->base, PART_TOP_TITLE, STR_APPS);
 
        box = add_box(priv->base, PART_MENU, EINA_TRUE,
-                       SIZE_BOX_PAD_H, SIZE_BOX_PAD_V);
+                       SIZE_MENU_BOX_PAD_H, SIZE_MENU_BOX_PAD_V);
        if (!box) {
                _ERR("Add box failed.");
                return false;
@@ -329,7 +465,7 @@ static bool _draw_top_area(struct _priv *priv)
 
        elm_object_focus_next_object_set(priv->menu_btn[0],
                        priv->menu_btn[MENU_COUNT - 1], ELM_FOCUS_LEFT);
-       elm_object_focus_next_object_set(priv->menu_btn[MENU_COUNT -1],
+       elm_object_focus_next_object_set(priv->menu_btn[MENU_COUNT - 1],
                        priv->menu_btn[0], ELM_FOCUS_RIGHT);
 
        elm_object_focus_set(priv->menu_btn[0], EINA_TRUE);