focus: Added "focus_part" support on elm widget.
authorAmitesh Singh <amitesh.sh@samsung.com>
Mon, 3 Feb 2014 08:44:16 +0000 (17:44 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Mon, 3 Feb 2014 08:52:02 +0000 (17:52 +0900)
Summary:
Currently, focus highlight comes on the widget's geometry. Elementary does not have option to provide the focus highlight on widget's part.
This patch provides the option to provide focus highlight on the widget's part.
e.g.  data.item: "focus_part" "part";
The focus highlight would come on part's geometry instead of widget's geometry. This patch only works on widgets which uses
resize_obj.

Reviewers: seoz, woohyun

Differential Revision: https://phab.enlightenment.org/D499

data/objects/Makefile.am
data/objects/test_focus_style.edc
src/bin/test.c
src/bin/test_focus_style.c
src/lib/elm_win.c

index 35bbf1c..f8f3778 100644 (file)
@@ -83,6 +83,7 @@ test_prefs.epb: Makefile test_prefs.epc
 
 test_focus_style.edj: Makefile test_focus_style.edc
        $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) \
+       -id $(top_srcdir)/data/themes/img \
        $(top_srcdir)/data/objects/test_focus_style.edc \
        $(top_builddir)/data/objects/test_focus_style.edj
 
index caa4d9c..2ab4072 100644 (file)
@@ -386,4 +386,66 @@ collections {
          }
       } //programs ends
    } //group ends
+
+   group { name: "elm/layout/focus/example";
+      data.item: "focus_part" "focus_area";
+      parts {
+         part { name: "bg"; type: RECT;
+            scale: 1;
+            description { state: "default" 0.0;
+               color: 255 255 0 255;
+               min: 150 40;
+               max: 150 40;
+            }
+         }
+         part { name: "elm.text"; type: TEXT;
+            scale: 1;
+            description { state: "default" 0.0;
+               rel1.to: "bg";
+               rel2.to: "bg";
+               text.text: "layout";
+               text.size: 9;
+               color: 0 0 0 255;
+            }
+         }
+         part { name: "focus_area"; type: RECT;
+            scale: 1;
+            description { state: "default" 0.0;
+               rel1.to: "bg";
+               rel2.to: "bg";
+               rel2.relative: 0 0;
+               align: 0 0;
+               min: 60 30;
+               max: 60 30;
+               fixed: 1 1;
+               color: 125 125 125 125;
+            }
+         }
+         part { name: "elm.text1"; type: TEXT;
+            scale: 1;
+            description { state: "default" 0.0;
+               rel1.to: "focus_area";
+               rel2.to: "focus_area";
+               text.text: "focus_part";
+               text.size: 9;
+               color: 255 0 255 255;
+            }
+         }
+      }
+   } //group ends
+
+// to customize check default style
+#include "../../data/themes/macros.edc"
+#include "../../data/themes/edc/elm/check.edc"
+   group { name: "elm/check/base/focus_text";
+      data.item: "focus_part" "elm.text";
+      inherit: "elm/check/base/default";
+   }
+
+// to customize button default style
+#include "../../data/themes/edc/elm/button.edc"
+   group { name: "elm/button/base/focus_icon";
+      data.item: "focus_part" "elm.swallow.content";
+      inherit: "elm/button/base/default";
+   }
 }
index 4c9e790..c270bd6 100644 (file)
@@ -188,6 +188,7 @@ void test_focus2(void *data, Evas_Object *obj, void *event_info);
 void test_focus_hide_del(void *data, Evas_Object *obj, void *event_info);
 void test_focus_custom_chain(void *data, Evas_Object *obj, void *event_info);
 void test_focus_style(void *data, Evas_Object *obj, void *event_info);
+void test_focus_part(void *data, Evas_Object *obj, void *event_info);
 void test_flipselector(void *data, Evas_Object *obj, void *event_info);
 void test_diskselector(void *data, Evas_Object *obj, void *event_info);
 void test_colorselector(void *data, Evas_Object *obj, void *event_info);
@@ -753,6 +754,7 @@ add_tests:
    ADD_TEST(NULL, "Focus", "Focus Hide/Del", test_focus_hide_del);
    ADD_TEST(NULL, "Focus", "Focus Custom Chain", test_focus_custom_chain);
    ADD_TEST(NULL, "Focus", "Focus Style", test_focus_style);
+   ADD_TEST(NULL, "Focus", "Focus On Part", test_focus_part);
 
    //------------------------------//
    ADD_TEST(NULL, "Naviframe", "Naviframe", test_naviframe);
index 7533c2c..a9bfafd 100644 (file)
@@ -26,8 +26,7 @@ test_focus_style(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
    char win_focus_theme[PATH_MAX] = { 0 };
 
    sprintf(win_focus_theme, "%s/objects/test_focus_style.edj", elm_app_data_dir_get());
-
-   elm_theme_overlay_add(NULL, win_focus_theme);
+   elm_theme_extension_add(NULL, win_focus_theme);
 
    win = elm_win_util_standard_add("focus-style", "Focus Style");
    elm_win_autodel_set(win, EINA_TRUE);
@@ -114,3 +113,64 @@ test_focus_style(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *eve
    evas_object_resize(win, 320, 320);
    evas_object_show(win);
 }
+
+void
+test_focus_part(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Evas_Object *win, *fr, *bx, *chk, *layout, *ic, *btn;
+   char win_focus_theme[PATH_MAX] = {0}, buf[PATH_MAX] = {0};
+
+   sprintf(win_focus_theme, "%s/objects/test_focus_style.edj", elm_app_data_dir_get());
+   elm_theme_extension_add(NULL, win_focus_theme);
+
+   win = elm_win_util_standard_add("focus_part", "Focus On Part");
+   elm_win_autodel_set(win, EINA_TRUE);
+   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
+   elm_win_focus_highlight_animate_set(win, EINA_TRUE);
+
+   fr = elm_frame_add(win);
+   evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, fr);
+   elm_object_style_set(fr, "pad_large");
+   evas_object_show(fr);
+
+   bx = elm_box_add(fr);
+   elm_object_content_set(fr, bx);
+   evas_object_show(bx);
+
+   chk = elm_check_add(bx);
+   elm_object_style_set(chk, "focus_text");
+   evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(chk, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_object_text_set(chk, "Focus highlight on text part only");
+   elm_check_state_set(chk, EINA_TRUE);
+   elm_box_pack_end(bx, chk);
+   evas_object_show(chk);
+
+   layout = elm_layout_add(bx);
+   evas_object_size_hint_weight_set(chk, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(chk, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_layout_theme_set(layout, "layout", "focus", "example");
+   elm_box_pack_end(bx, layout);
+   elm_object_focus_allow_set(layout, EINA_TRUE);
+   evas_object_show(layout);
+
+   ic = elm_icon_add(win);
+   snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
+   elm_image_file_set(ic, buf, NULL);
+   evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+   btn = elm_button_add(win);
+   elm_object_style_set(btn, "focus_icon");
+   elm_object_text_set(btn, "Focus highlight on icon part only");
+   elm_object_part_content_set(btn, "icon", ic);
+   elm_box_pack_end(bx, btn);
+   evas_object_show(btn);
+
+   btn = elm_button_add(win);
+   elm_object_text_set(btn, "Button");
+   elm_box_pack_end(bx, btn);
+   evas_object_show(btn);
+
+   evas_object_resize(win, 320, 320);
+   evas_object_show(win);
+}
index 7e111c9..27baea5 100644 (file)
@@ -682,6 +682,38 @@ _elm_win_focus_highlight_visible_set(Elm_Win_Smart_Data *sd,
 }
 
 static void
+_elm_win_focus_highlight_geometry_get(Evas_Object *target, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
+{
+   Evas_Coord tx = 0, ty = 0, tw = 0, th = 0;
+   const char *target_hl_part = NULL;
+   Evas_Object *edje_obj = NULL;
+   ELM_WIDGET_DATA_GET_OR_RETURN(target, wd);
+
+   evas_object_geometry_get(target, x, y, w, h);
+   if (wd->resize_obj && eo_isa(wd->resize_obj, EDJE_OBJ_CLASS))
+     {
+        edje_obj = wd->resize_obj;
+        if (!(target_hl_part = edje_object_data_get(edje_obj, "focus_part")))
+          return;
+     }
+   else if (wd->resize_obj && eo_isa(wd->resize_obj, ELM_OBJ_LAYOUT_CLASS))
+     {
+        printf("inside layout\n");
+        edje_obj = elm_layout_edje_get(wd->resize_obj);
+        if (!(target_hl_part = elm_layout_data_get(wd->resize_obj, "focus_part")))
+          return;
+     }
+   else return;
+
+   edje_object_part_geometry_get(edje_obj, target_hl_part,
+                                 &tx, &ty, &tw, &th);
+   *x += tx;
+   *y += ty;
+   if (tw != *w) *w = tw;
+   if (th != *h) *h = th;
+}
+
+static void
 _elm_win_focus_highlight_anim_setup(Elm_Win_Smart_Data *sd,
                                     Evas_Object *obj)
 {
@@ -692,8 +724,8 @@ _elm_win_focus_highlight_anim_setup(Elm_Win_Smart_Data *sd,
    Evas_Object *target = sd->focus_highlight.cur.target;
 
    evas_object_geometry_get(sd->obj, NULL, NULL, &w, &h);
-   evas_object_geometry_get(target, &tx, &ty, &tw, &th);
-   evas_object_geometry_get(previous, &px, &py, &pw, &ph);
+   _elm_win_focus_highlight_geometry_get(target, &tx, &ty, &tw, &th);
+   _elm_win_focus_highlight_geometry_get(previous, &px, &py, &pw, &ph);
    evas_object_move(obj, tx, ty);
    evas_object_resize(obj, tw, th);
    evas_object_clip_unset(obj);
@@ -719,7 +751,7 @@ _elm_win_focus_highlight_simple_setup(Elm_Win_Smart_Data *sd,
    Evas_Coord x, y, w, h;
 
    clip = evas_object_clip_get(target);
-   evas_object_geometry_get(target, &x, &y, &w, &h);
+   _elm_win_focus_highlight_geometry_get(target, &x, &y, &w, &h);
 
    evas_object_move(obj, x, y);
    evas_object_resize(obj, w, h);