summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordivyesh purohit <div.purohit@samsung.com>2016-01-22 11:07:01 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-01-22 12:10:14 -0800
commite0b40113b43569da26c8a218153059a5e850332e (patch)
tree168f1336d5e853907af66121abcd27e54eb0b61a /src
parent8800fbc8394547e2a5c904b696328d493faa644a (diff)
combobox: apply proper style
Summary: Initially combobox used hover's default style, this patch would make combobox use hoversel_vertical style. @Fix T3075 for 2nd point. Signed-off-by: divyesh purohit <div.purohit@samsung.com> Test Plan: please run combobox example from elementary_test Reviewers: shilpasingh, cedric, raster Subscribers: rajeshps, govi Maniphest Tasks: T3075 Differential Revision: https://phab.enlightenment.org/D3596 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/bin/test_combobox.c1
-rw-r--r--src/lib/elc_combobox.c86
-rw-r--r--src/lib/elc_hoversel.c2
3 files changed, 68 insertions, 21 deletions
diff --git a/src/bin/test_combobox.c b/src/bin/test_combobox.c
index b8ef5db15..720e3c6b2 100644
--- a/src/bin/test_combobox.c
+++ b/src/bin/test_combobox.c
@@ -41,6 +41,7 @@ _combobox_item_pressed_cb(void *data EINA_UNUSED, Evas_Object *obj,
41 printf("'item,pressed' callback is called. (selected item : %s)\n", txt); 41 printf("'item,pressed' callback is called. (selected item : %s)\n", txt);
42 elm_object_text_set(obj, txt); 42 elm_object_text_set(obj, txt);
43 elm_combobox_hover_end(obj); 43 elm_combobox_hover_end(obj);
44 elm_entry_cursor_end_set(obj);
44} 45}
45 46
46static char * 47static char *
diff --git a/src/lib/elc_combobox.c b/src/lib/elc_combobox.c
index 3d1a80818..bac259d79 100644
--- a/src/lib/elc_combobox.c
+++ b/src/lib/elc_combobox.c
@@ -65,7 +65,7 @@ _elm_combobox_elm_widget_theme_apply(Eo *obj, Elm_Combobox_Data *sd)
65 65
66 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); 66 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
67 67
68 style = elm_widget_style_get(obj); 68 style = eina_stringshare_add(elm_widget_style_get(obj));
69 69
70 snprintf(buf, sizeof(buf), "combobox_vertical/%s", style); 70 snprintf(buf, sizeof(buf), "combobox_vertical/%s", style);
71 71
@@ -75,6 +75,8 @@ _elm_combobox_elm_widget_theme_apply(Eo *obj, Elm_Combobox_Data *sd)
75 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply()); 75 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
76 if (!int_ret) return EINA_FALSE; 76 if (!int_ret) return EINA_FALSE;
77 77
78 eina_stringshare_replace(&(wd->style), style);
79
78 mirrored = elm_widget_mirrored_get(obj); 80 mirrored = elm_widget_mirrored_get(obj);
79 81
80 if (sd->hover) 82 if (sd->hover)
@@ -82,18 +84,43 @@ _elm_combobox_elm_widget_theme_apply(Eo *obj, Elm_Combobox_Data *sd)
82 84
83 elm_widget_mirrored_set(sd->genlist, mirrored); 85 elm_widget_mirrored_set(sd->genlist, mirrored);
84 elm_widget_mirrored_set(sd->entry, mirrored); 86 elm_widget_mirrored_set(sd->entry, mirrored);
87 eina_stringshare_del(style);
85 88
86 elm_combobox_hover_end(obj); 89 elm_combobox_hover_end(obj);
87 90
88 return EINA_TRUE; 91 return EINA_TRUE;
89} 92}
90 93
91static void 94static Eina_Bool
92_on_hover_clicked(void *data, 95_on_hover_clicked(void *data,
93 Evas_Object *obj EINA_UNUSED, 96 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED,
94 void *event_info EINA_UNUSED) 97 void *event_info EINA_UNUSED)
95{ 98{
96 elm_combobox_hover_end(data); 99 const char *dismissstr;
100
101 dismissstr = elm_layout_data_get(obj, "dismiss");
102
103 if (!dismissstr || strcmp(dismissstr, "on"))
104 elm_combobox_hover_end(data); // for backward compatibility
105
106 return EINA_TRUE;
107}
108
109static void
110_hover_end_finished(void *data,
111 Evas_Object *obj EINA_UNUSED,
112 const char *emission EINA_UNUSED,
113 const char *source EINA_UNUSED)
114{
115 const char *dismissstr;
116 ELM_COMBOBOX_DATA_GET(data, sd);
117 dismissstr = elm_layout_data_get(sd->hover, "dismiss");
118 if (dismissstr && !strcmp(dismissstr, "on"))
119 {
120 sd->expanded = EINA_FALSE;
121 evas_object_hide(sd->hover);
122 eo_do(data, eo_event_callback_call(ELM_COMBOBOX_EVENT_DISMISSED, NULL));
123 }
97} 124}
98 125
99static void 126static void
@@ -151,13 +178,18 @@ _activate(Evas_Object *obj)
151{ 178{
152 ELM_COMBOBOX_DATA_GET(obj, sd); 179 ELM_COMBOBOX_DATA_GET(obj, sd);
153 if (elm_widget_disabled_get(obj)) return; 180 if (elm_widget_disabled_get(obj)) return;
181 if (sd->expanded)
182 {
183 elm_combobox_hover_end(obj);
184 return;
185 }
154 sd->expanded = EINA_TRUE; 186 sd->expanded = EINA_TRUE;
155 eo_do(obj, eo_event_callback_call(ELM_COMBOBOX_EVENT_EXPANDED, NULL));
156 _table_resize(obj); 187 _table_resize(obj);
157 elm_object_part_content_set(sd->hover, elm_hover_best_content_location_get 188 elm_object_part_content_set(sd->hover, elm_hover_best_content_location_get
158 (sd->hover, ELM_HOVER_AXIS_VERTICAL), sd->tbl); 189 (sd->hover, ELM_HOVER_AXIS_VERTICAL), sd->tbl);
159 evas_object_show(sd->genlist); 190 evas_object_show(sd->genlist);
160 evas_object_show(sd->hover); 191 evas_object_show(sd->hover);
192 eo_do(obj, eo_event_callback_call(ELM_COMBOBOX_EVENT_EXPANDED, NULL));
161} 193}
162 194
163static void 195static void
@@ -193,9 +225,8 @@ _gl_filter_finished_cb(void *data, Eo *obj EINA_UNUSED,
193 225
194 if (sd->count > 0) 226 if (sd->count > 0)
195 { 227 {
196 if (sd->expanded == EINA_TRUE) 228 if (!sd->expanded) _activate(data);
197 elm_combobox_hover_end(data); 229 else _table_resize(data);
198 _activate(data);
199 } 230 }
200 else elm_combobox_hover_end(data); 231 else elm_combobox_hover_end(data);
201 return EINA_TRUE; 232 return EINA_TRUE;
@@ -218,12 +249,13 @@ _on_changed(void *data, Eo *obj EINA_UNUSED,
218 return EINA_TRUE; 249 return EINA_TRUE;
219} 250}
220 251
221static void 252static Eina_Bool
222_on_clicked(void *data EINA_UNUSED, 253_on_clicked(void *data,
223 Evas_Object *obj, 254 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
224 void *event_info EINA_UNUSED) 255 void *event_info EINA_UNUSED)
225{ 256{
226 elm_combobox_hover_begin(obj); 257 elm_combobox_hover_begin(data);
258 return EINA_TRUE;
227} 259}
228 260
229EOLIAN static void 261EOLIAN static void
@@ -234,7 +266,8 @@ _elm_combobox_evas_object_smart_add(Eo *obj, Elm_Combobox_Data *sd EINA_UNUSED)
234 266
235 elm_widget_mirrored_automatic_set(obj, EINA_FALSE); 267 elm_widget_mirrored_automatic_set(obj, EINA_FALSE);
236 268
237 evas_object_smart_callback_add(obj, "clicked", _on_clicked, obj); 269 eo_do(obj, eo_event_callback_add(
270 EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_clicked, obj));
238 271
239 //What are you doing here? 272 //What are you doing here?
240 eo_do(obj, elm_obj_widget_theme_apply()); 273 eo_do(obj, elm_obj_widget_theme_apply());
@@ -299,6 +332,15 @@ _elm_combobox_eo_base_constructor(Eo *obj, Elm_Combobox_Data *sd)
299 sd->hover = eo_add(ELM_HOVER_CLASS, sd->hover_parent); 332 sd->hover = eo_add(ELM_HOVER_CLASS, sd->hover_parent);
300 elm_widget_mirrored_automatic_set(sd->hover, EINA_FALSE); 333 elm_widget_mirrored_automatic_set(sd->hover, EINA_FALSE);
301 elm_hover_target_set(sd->hover, obj); 334 elm_hover_target_set(sd->hover, obj);
335 elm_widget_sub_object_add(obj, sd->hover);
336 snprintf(buf, sizeof(buf), "combobox_vertical/%s",
337 elm_widget_style_get(obj));
338 elm_object_style_set(sd->hover, buf);
339
340 eo_do(sd->hover, eo_event_callback_add
341 (EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_hover_clicked, obj));
342 elm_layout_signal_callback_add
343 (sd->hover, "elm,action,hide,finished", "elm", _hover_end_finished, obj);
302 344
303 //table 345 //table
304 sd->tbl = elm_table_add(obj); 346 sd->tbl = elm_table_add(obj);
@@ -341,9 +383,6 @@ _elm_combobox_eo_base_constructor(Eo *obj, Elm_Combobox_Data *sd)
341 _on_aborted, obj)); 383 _on_aborted, obj));
342 evas_object_show(entry); 384 evas_object_show(entry);
343 385
344 snprintf(buf, sizeof(buf), "combobox_vertical/%s", elm_widget_style_get(obj));
345 elm_object_style_set(sd->hover, buf);
346 evas_object_smart_callback_add(sd->hover, "clicked", _on_hover_clicked, obj);
347 eo_do(obj, 386 eo_do(obj,
348 eo_composite_attach(gl), 387 eo_composite_attach(gl),
349 eo_composite_attach(entry)); 388 eo_composite_attach(entry));
@@ -363,11 +402,18 @@ _elm_combobox_hover_begin(Eo *obj, Elm_Combobox_Data *sd)
363EOLIAN static void 402EOLIAN static void
364_elm_combobox_hover_end(Eo *obj, Elm_Combobox_Data *sd) 403_elm_combobox_hover_end(Eo *obj, Elm_Combobox_Data *sd)
365{ 404{
405 const char *dismissstr;
366 if (!sd->hover) return; 406 if (!sd->hover) return;
407 dismissstr = elm_layout_data_get(sd->hover, "dismiss");
367 408
368 sd->expanded = EINA_FALSE; 409 if (dismissstr && !strcmp(dismissstr, "on"))
369 evas_object_hide(sd->hover); 410 elm_hover_dismiss(sd->hover);
370 eo_do(obj, eo_event_callback_call(ELM_COMBOBOX_EVENT_DISMISSED, NULL)); 411 else
412 {
413 sd->expanded = EINA_FALSE;
414 evas_object_hide(sd->hover);
415 eo_do(obj, eo_event_callback_call(ELM_COMBOBOX_EVENT_DISMISSED, NULL));
416 } // for backward compatibility
371} 417}
372 418
373EOLIAN static Eina_Bool 419EOLIAN static Eina_Bool
diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c
index eaa760be9..2dfb5878a 100644
--- a/src/lib/elc_hoversel.c
+++ b/src/lib/elc_hoversel.c
@@ -107,7 +107,7 @@ _elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd)
107} 107}
108 108
109static Eina_Bool 109static Eina_Bool
110_on_hover_clicked(void *data EINA_UNUSED, 110_on_hover_clicked(void *data,
111 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, 111 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED,
112 void *event_info EINA_UNUSED) 112 void *event_info EINA_UNUSED)
113{ 113{