summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJee-Yong Um <jc9.um@samsung.com>2015-10-04 15:09:22 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-12 10:15:03 +0100
commitfc4345e8ee4dcaaaff428a23d80524816e2cd215 (patch)
tree2aaf86c38882273464b2469d9746e9dfbc14afc8
parent42d8fda3967c2e13d4b87df28cedcad40ffa878a (diff)
elm_hoversel: add elm_hoversel_label_auto_changed_set/get() API
Summary: Hoversel can be used like dropdown or pulldown menu. In that case, changing hoversel label into selected item lable can be considered as common usage of hoversel. This API automatizes changing label. Reviewers: SanghyeonLee, Hermet, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2963 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/bin/test_hoversel.c1
-rw-r--r--src/lib/elc_hoversel.c37
-rw-r--r--src/lib/elm_hoversel.eo10
-rw-r--r--src/lib/elm_widget_hoversel.h1
4 files changed, 49 insertions, 0 deletions
diff --git a/src/bin/test_hoversel.c b/src/bin/test_hoversel.c
index 87f9e5528..e65efd98d 100644
--- a/src/bin/test_hoversel.c
+++ b/src/bin/test_hoversel.c
@@ -182,6 +182,7 @@ test_hoversel(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
182 182
183 hoversel = elm_hoversel_add(win); 183 hoversel = elm_hoversel_add(win);
184 elm_hoversel_scrollable_set(hoversel, EINA_TRUE); 184 elm_hoversel_scrollable_set(hoversel, EINA_TRUE);
185 elm_hoversel_label_auto_changed_set(hoversel, EINA_TRUE);
185 elm_hoversel_hover_parent_set(hoversel, win); 186 elm_hoversel_hover_parent_set(hoversel, win);
186 elm_object_text_set(hoversel, "Some Icons"); 187 elm_object_text_set(hoversel, "Some Icons");
187 elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL); 188 elm_hoversel_item_add(hoversel, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL);
diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c
index 5f7d0a83e..6628bf5d8 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -110,8 +110,33 @@ _on_item_clicked(void *data EINA_UNUSED,
110 Evas_Object *obj2 = WIDGET(item); 110 Evas_Object *obj2 = WIDGET(item);
111 Elm_Object_Item *eo_it = EO_OBJ(item); 111 Elm_Object_Item *eo_it = EO_OBJ(item);
112 112
113 ELM_HOVERSEL_DATA_GET(obj2, sd);
114
113 if (item->func) item->func((void *)WIDGET_ITEM_DATA_GET(eo_it), obj2, eo_it); 115 if (item->func) item->func((void *)WIDGET_ITEM_DATA_GET(eo_it), obj2, eo_it);
114 eo_do(obj2, eo_event_callback_call(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, eo_it)); 116 eo_do(obj2, eo_event_callback_call(EVAS_SELECTABLE_INTERFACE_EVENT_SELECTED, eo_it));
117
118 if (sd->auto_changed)
119 {
120 Evas_Object *ic;
121
122 ic = elm_object_part_content_unset(obj2, "icon");
123 ELM_SAFE_FREE(ic, evas_object_del);
124
125 if (item->icon_file)
126 {
127 ic = elm_icon_add(obj2);
128 elm_image_resizable_set(ic, EINA_FALSE, EINA_TRUE);
129 if (item->icon_type == ELM_ICON_FILE)
130 elm_image_file_set(ic, item->icon_file, item->icon_group);
131 else if (item->icon_type == ELM_ICON_STANDARD)
132 elm_icon_standard_set(ic, item->icon_file);
133 elm_object_part_content_set(obj2, "icon", ic);
134 }
135
136 if(item->label)
137 elm_object_text_set(obj2, item->label);
138 }
139
115 elm_hoversel_hover_end(obj2); 140 elm_hoversel_hover_end(obj2);
116 141
117 return EINA_TRUE; 142 return EINA_TRUE;
@@ -901,5 +926,17 @@ _elm_hoversel_scrollable_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
901 return sd->scroll_enabled; 926 return sd->scroll_enabled;
902} 927}
903 928
929EOLIAN void
930_elm_hoversel_label_auto_changed_set(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd, Eina_Bool auto_changed)
931{
932 sd->auto_changed = !!auto_changed;
933}
934
935EOLIAN Eina_Bool
936_elm_hoversel_label_auto_changed_get(Eo *obj EINA_UNUSED, Elm_Hoversel_Data *sd)
937{
938 return sd->auto_changed;
939}
940
904#include "elm_hoversel_item.eo.c" 941#include "elm_hoversel_item.eo.c"
905#include "elm_hoversel.eo.c" 942#include "elm_hoversel.eo.c"
diff --git a/src/lib/elm_hoversel.eo b/src/lib/elm_hoversel.eo
index 878b45401..ca24396b7 100644
--- a/src/lib/elm_hoversel.eo
+++ b/src/lib/elm_hoversel.eo
@@ -57,6 +57,16 @@ class Elm.Hoversel (Elm.Button, Evas.Selectable_Interface,
57 scrollable: bool; [[$true if scrollable $false otherwise.]] 57 scrollable: bool; [[$true if scrollable $false otherwise.]]
58 } 58 }
59 } 59 }
60 @property label_auto_changed {
61 [[Change the label of hoversel to that of selected item automatically.]]
62 get{
63 }
64 set{
65 }
66 values {
67 auto_changed: bool; [[$true if the label is changed automatically or $false otherwise]]
68 }
69 }
60 hover_begin { 70 hover_begin {
61 [[This triggers the hoversel popup from code, the same as if the user had clicked the button.]] 71 [[This triggers the hoversel popup from code, the same as if the user had clicked the button.]]
62 } 72 }
diff --git a/src/lib/elm_widget_hoversel.h b/src/lib/elm_widget_hoversel.h
index ff625129b..2b977281a 100644
--- a/src/lib/elm_widget_hoversel.h
+++ b/src/lib/elm_widget_hoversel.h
@@ -42,6 +42,7 @@ struct _Elm_Hoversel_Data
42 Eina_Bool horizontal : 1; 42 Eina_Bool horizontal : 1;
43 Eina_Bool expanded : 1; 43 Eina_Bool expanded : 1;
44 Eina_Bool scroll_enabled: 1; 44 Eina_Bool scroll_enabled: 1;
45 Eina_Bool auto_changed : 1;
45}; 46};
46 47
47typedef struct _Elm_Hoversel_Item_Data Elm_Hoversel_Item_Data; 48typedef struct _Elm_Hoversel_Item_Data Elm_Hoversel_Item_Data;