summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/elm_menu.c143
1 files changed, 71 insertions, 72 deletions
diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c
index bda563dd8..3dd7ded21 100644
--- a/src/lib/elm_menu.c
+++ b/src/lib/elm_menu.c
@@ -71,24 +71,13 @@ _item_disable_hook(Elm_Object_Item *it)
71 71
72 if (elm_widget_item_disabled_get(item)) 72 if (elm_widget_item_disabled_get(item))
73 { 73 {
74 edje_object_signal_emit(VIEW(item), "elm,state,disabled", "elm"); 74 elm_layout_signal_emit(VIEW(item), "elm,state,disabled", "elm");
75 if (item->submenu.open) _submenu_hide(item); 75 if (item->submenu.open) _submenu_hide(item);
76 } 76 }
77 else 77 else
78 edje_object_signal_emit(VIEW(item), "elm,state,enabled", "elm"); 78 elm_layout_signal_emit(VIEW(item), "elm,state,enabled", "elm");
79 79
80 edje_object_message_signal_process(VIEW(item)); 80 edje_object_message_signal_process(elm_layout_edje_get(VIEW(item)));
81}
82
83static void
84_item_sizing_eval(Elm_Menu_Item *item)
85{
86 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
87
88 if (!item->separator) elm_coords_finger_size_adjust(1, &minw, 1, &minh);
89 edje_object_size_min_restricted_calc(VIEW(item), &minw, &minh, minw, minh);
90 evas_object_size_hint_min_set(VIEW(item), minw, minh);
91 evas_object_size_hint_max_set(VIEW(item), maxw, maxh);
92} 81}
93 82
94static void 83static void
@@ -101,7 +90,7 @@ _submenu_sizing_eval(Elm_Menu_Item *parent_it)
101 ELM_MENU_DATA_GET_OR_RETURN(WIDGET(parent_it), sd); 90 ELM_MENU_DATA_GET_OR_RETURN(WIDGET(parent_it), sd);
102 91
103 EINA_LIST_FOREACH(parent_it->submenu.items, l, item) 92 EINA_LIST_FOREACH(parent_it->submenu.items, l, item)
104 _item_sizing_eval(item); 93 elm_layout_sizing_eval(VIEW(item));
105 94
106 evas_object_geometry_get 95 evas_object_geometry_get
107 (parent_it->submenu.location, &x_p, &y_p, &w_p, &h_p); 96 (parent_it->submenu.location, &x_p, &y_p, &w_p, &h_p);
@@ -161,7 +150,7 @@ _sizing_eval(Evas_Object *obj)
161 if (!sd->parent) return; 150 if (!sd->parent) return;
162 151
163 EINA_LIST_FOREACH(sd->items, l, item) 152 EINA_LIST_FOREACH(sd->items, l, item)
164 _item_sizing_eval(item); 153 elm_layout_sizing_eval(VIEW(item));
165 154
166 evas_object_geometry_get(sd->location, NULL, NULL, &w_p, &h_p); 155 evas_object_geometry_get(sd->location, NULL, NULL, &w_p, &h_p);
167 evas_object_geometry_get(sd->parent, &x2, &y2, &w2, &h2); 156 evas_object_geometry_get(sd->parent, &x2, &y2, &w2, &h2);
@@ -213,20 +202,22 @@ _elm_menu_smart_theme(Eo *obj, void *_pd, va_list *list)
213 { 202 {
214 EINA_LIST_FOREACH(l, _l, item) 203 EINA_LIST_FOREACH(l, _l, item)
215 { 204 {
216 edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(obj));
217 ll = eina_list_append(ll, item->submenu.items); 205 ll = eina_list_append(ll, item->submenu.items);
218 if (item->separator) 206 if (item->separator)
219 elm_widget_theme_object_set 207 {
220 (obj, VIEW(item), "menu", "separator", 208 if (!elm_layout_theme_set(VIEW(item), "menu", "separator",
221 elm_widget_style_get(obj)); 209 elm_widget_style_get(obj)))
210 CRITICAL("Failed to set layout!");
211 }
222 else if (item->submenu.bx) 212 else if (item->submenu.bx)
223 { 213 {
224 if (sd->menu_bar && !item->parent) s = "main_menu_submenu"; 214 if (sd->menu_bar && !item->parent) s = "main_menu_submenu";
225 else s = "item_with_submenu"; 215 else s = "item_with_submenu";
226 216
227 elm_widget_theme_object_set 217 if (!elm_layout_theme_set(VIEW(item), "menu", s,
228 (obj, VIEW(item), "menu", s, 218 elm_widget_style_get(obj)))
229 elm_widget_style_get(obj)); 219 CRITICAL("Failed to set layout!");
220
230 elm_object_item_text_set((Elm_Object_Item *)item, 221 elm_object_item_text_set((Elm_Object_Item *)item,
231 item->label); 222 item->label);
232 if (item->icon_str) 223 if (item->icon_str)
@@ -235,9 +226,10 @@ _elm_menu_smart_theme(Eo *obj, void *_pd, va_list *list)
235 } 226 }
236 else 227 else
237 { 228 {
238 elm_widget_theme_object_set 229 if (!elm_layout_theme_set(VIEW(item), "menu", "item",
239 (obj, VIEW(item), "menu", "item", 230 elm_widget_style_get(obj)))
240 elm_widget_style_get(obj)); 231 CRITICAL("Failed to set layout!");
232
241 elm_object_item_text_set((Elm_Object_Item *)item, 233 elm_object_item_text_set((Elm_Object_Item *)item,
242 item->label); 234 item->label);
243 if (item->icon_str) 235 if (item->icon_str)
@@ -245,9 +237,11 @@ _elm_menu_smart_theme(Eo *obj, void *_pd, va_list *list)
245 item->icon_str); 237 item->icon_str);
246 } 238 }
247 _item_disable_hook((Elm_Object_Item *)item); 239 _item_disable_hook((Elm_Object_Item *)item);
240 /* SEOZ
248 edje_object_scale_set 241 edje_object_scale_set
249 (VIEW(item), elm_widget_scale_get(obj) * 242 (VIEW(item), elm_widget_scale_get(obj) *
250 elm_config_scale_get()); 243 elm_config_scale_get());
244 */
251 } 245 }
252 } 246 }
253 247
@@ -272,12 +266,12 @@ _item_text_set_hook(Elm_Object_Item *it,
272 eina_stringshare_replace(&item->label, label); 266 eina_stringshare_replace(&item->label, label);
273 267
274 if (label) 268 if (label)
275 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm"); 269 elm_layout_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
276 else 270 else
277 edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm"); 271 elm_layout_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
278 272
279 edje_object_message_signal_process(VIEW(item)); 273 edje_object_message_signal_process(elm_layout_edje_get(VIEW(item)));
280 edje_object_part_text_set(VIEW(item), "elm.text", label); 274 elm_layout_text_set(VIEW(item), "elm.text", label);
281 275
282 _sizing_eval(WIDGET(item)); 276 _sizing_eval(WIDGET(item));
283} 277}
@@ -306,10 +300,8 @@ _item_content_set_hook(Elm_Object_Item *it,
306 if (item->content) evas_object_del(item->content); 300 if (item->content) evas_object_del(item->content);
307 301
308 item->content = content; 302 item->content = content;
309 elm_widget_sub_object_add(WIDGET(item), item->content);
310 if (item->content) 303 if (item->content)
311 edje_object_part_swallow 304 elm_layout_content_set(VIEW(item), "elm.swallow.content", item->content);
312 (VIEW(item), "elm.swallow.content", item->content);
313 305
314 _sizing_eval(WIDGET(item)); 306 _sizing_eval(WIDGET(item));
315} 307}
@@ -488,38 +480,42 @@ _elm_menu_smart_show(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
488static void 480static void
489_item_obj_create(Elm_Menu_Item *item) 481_item_obj_create(Elm_Menu_Item *item)
490{ 482{
491 VIEW(item) = edje_object_add(evas_object_evas_get(WIDGET(item))); 483 VIEW(item) = elm_layout_add(WIDGET(item));
492 edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(WIDGET(item)));
493 evas_object_size_hint_weight_set 484 evas_object_size_hint_weight_set
494 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 485 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
495 evas_object_size_hint_fill_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL); 486 evas_object_size_hint_fill_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
496 elm_widget_theme_object_set 487 if (!elm_layout_theme_set(VIEW(item), "menu", "item",
497 (WIDGET(item), VIEW(item), "menu", "item", 488 elm_widget_style_get(WIDGET(item))))
498 elm_widget_style_get(WIDGET(item))); 489 CRITICAL("Failed to set layout!");
499 490 else
500 edje_object_signal_callback_add 491 {
501 (VIEW(item), "elm,action,click", "", _menu_item_select_cb, item); 492 elm_layout_signal_callback_add(VIEW(item), "elm,action,click", "",
502 edje_object_signal_callback_add 493 _menu_item_select_cb, item);
503 (VIEW(item), "elm,action,activate", "", _menu_item_activate_cb, item); 494 elm_layout_signal_callback_add(VIEW(item), "elm,action,activate", "",
504 edje_object_signal_callback_add 495 _menu_item_activate_cb, item);
505 (VIEW(item), "elm,action,inactivate", "", _menu_item_inactivate_cb, 496 elm_layout_signal_callback_add(VIEW(item), "elm,action,inactivate", "",
506 item); 497 _menu_item_inactivate_cb,
507 evas_object_show(VIEW(item)); 498 item);
499 evas_object_show(VIEW(item));
500 }
508} 501}
509 502
510static void 503static void
511_item_separator_obj_create(Elm_Menu_Item *item) 504_item_separator_obj_create(Elm_Menu_Item *item)
512{ 505{
513 VIEW(item) = edje_object_add(evas_object_evas_get(WIDGET(item))); 506 VIEW(item) = elm_layout_add(WIDGET(item));
514 evas_object_size_hint_weight_set 507 evas_object_size_hint_weight_set
515 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 508 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
516 evas_object_size_hint_fill_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL); 509 evas_object_size_hint_fill_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
517 elm_widget_theme_object_set 510 if (!elm_layout_theme_set(VIEW(item), "menu", "separator",
518 (WIDGET(item), VIEW(item), "menu", "separator", 511 elm_widget_style_get(WIDGET(item))))
519 elm_widget_style_get(WIDGET(item))); 512 CRITICAL("Failed to set layout!");
520 edje_object_signal_callback_add 513 else
521 (VIEW(item), "elm,action,activate", "", _menu_item_activate_cb, item); 514 {
522 evas_object_show(VIEW(item)); 515 elm_layout_signal_callback_add
516 (VIEW(item), "elm,action,activate", "", _menu_item_activate_cb, item);
517 evas_object_show(VIEW(item));
518 }
523} 519}
524 520
525static void 521static void
@@ -551,23 +547,27 @@ _item_submenu_obj_create(Elm_Menu_Item *item)
551 (item->submenu.hv, elm_hover_best_content_location_get 547 (item->submenu.hv, elm_hover_best_content_location_get
552 (item->submenu.hv, ELM_HOVER_AXIS_VERTICAL), item->submenu.bx); 548 (item->submenu.hv, ELM_HOVER_AXIS_VERTICAL), item->submenu.bx);
553 549
554 edje_object_mirrored_set(VIEW(item), elm_widget_mirrored_get(WIDGET(item)));
555
556 if (sd->menu_bar && !item->parent) 550 if (sd->menu_bar && !item->parent)
557 elm_widget_theme_object_set(WIDGET(item), VIEW(item), "menu", 551 {
558 "main_menu_submenu", 552 if (!elm_layout_theme_set(VIEW(item), "menu",
559 elm_widget_style_get(WIDGET(item))); 553 "main_menu_submenu",
554 elm_widget_style_get(WIDGET(item))))
555 CRITICAL("Failed to set layout!");
556 }
560 else 557 else
561 elm_widget_theme_object_set(WIDGET(item), VIEW(item), "menu", 558 {
562 "item_with_submenu", 559 if (!elm_layout_theme_set(VIEW(item), "menu",
563 elm_widget_style_get(WIDGET(item))); 560 "item_with_submenu",
561 elm_widget_style_get(WIDGET(item))))
562 CRITICAL("Failed to set layout!");
563 }
564 564
565 elm_object_item_text_set((Elm_Object_Item *)item, item->label); 565 elm_object_item_text_set((Elm_Object_Item *)item, item->label);
566 566
567 if (item->icon_str) 567 if (item->icon_str)
568 elm_menu_item_icon_name_set((Elm_Object_Item *)item, item->icon_str); 568 elm_menu_item_icon_name_set((Elm_Object_Item *)item, item->icon_str);
569 569
570 edje_object_signal_callback_add(VIEW(item), "elm,action,open", "", 570 elm_layout_signal_callback_add(VIEW(item), "elm,action,open", "",
571 _submenu_open_cb, item); 571 _submenu_open_cb, item);
572 evas_object_event_callback_add 572 evas_object_event_callback_add
573 (VIEW(item), EVAS_CALLBACK_MOVE, _item_move_resize_cb, item); 573 (VIEW(item), EVAS_CALLBACK_MOVE, _item_move_resize_cb, item);
@@ -967,9 +967,8 @@ _item_add(Eo *obj, void *_pd, va_list *list)
967 _item_obj_create(subitem); 967 _item_obj_create(subitem);
968 elm_object_item_text_set((Elm_Object_Item *)subitem, label); 968 elm_object_item_text_set((Elm_Object_Item *)subitem, label);
969 969
970 elm_widget_sub_object_add(WIDGET(subitem), subitem->content); 970 elm_layout_content_set(VIEW(subitem), "elm.swallow.content",
971 edje_object_part_swallow 971 subitem->content);
972 (VIEW(subitem), "elm.swallow.content", subitem->content);
973 972
974 if (icon) elm_menu_item_icon_name_set((Elm_Object_Item *)subitem, icon); 973 if (icon) elm_menu_item_icon_name_set((Elm_Object_Item *)subitem, icon);
975 974
@@ -1006,12 +1005,12 @@ elm_menu_item_icon_name_set(Elm_Object_Item *it,
1006 elm_icon_standard_set(item->content, icon))) 1005 elm_icon_standard_set(item->content, icon)))
1007 { 1006 {
1008 eina_stringshare_replace(&item->icon_str, icon); 1007 eina_stringshare_replace(&item->icon_str, icon);
1009 edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm"); 1008 elm_layout_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
1010 } 1009 }
1011 else 1010 else
1012 edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm"); 1011 elm_layout_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
1013 1012
1014 edje_object_message_signal_process(VIEW(item)); 1013 edje_object_message_signal_process(elm_layout_edje_get(VIEW(item)));
1015 _sizing_eval(WIDGET(item)); 1014 _sizing_eval(WIDGET(item));
1016} 1015}
1017 1016
@@ -1136,15 +1135,15 @@ elm_menu_item_selected_set(Elm_Object_Item *it,
1136 item->selected = selected; 1135 item->selected = selected;
1137 if (selected) 1136 if (selected)
1138 { 1137 {
1139 edje_object_signal_emit(VIEW(item), "elm,state,selected", "elm"); 1138 elm_layout_signal_emit(VIEW(item), "elm,state,selected", "elm");
1140 _menu_item_activate_cb(item, NULL, NULL, NULL); 1139 _menu_item_activate_cb(item, NULL, NULL, NULL);
1141 } 1140 }
1142 else 1141 else
1143 { 1142 {
1144 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm"); 1143 elm_layout_signal_emit(VIEW(item), "elm,state,unselected", "elm");
1145 _menu_item_inactivate_cb(item, NULL, NULL, NULL); 1144 _menu_item_inactivate_cb(item, NULL, NULL, NULL);
1146 } 1145 }
1147 edje_object_message_signal_process(VIEW(item)); 1146 edje_object_message_signal_process(elm_layout_edje_get(VIEW(item)));
1148} 1147}
1149 1148
1150EAPI Eina_Bool 1149EAPI Eina_Bool