e menus - keep parent menu items activated when browsing child items

devs/bu5hm4n/mixerfun
Carsten Haitzler 2 years ago
parent 308bab6750
commit 397a58137e
  1. 65
      src/bin/e_menu.c
  2. 1
      src/bin/e_menu.h

@ -456,6 +456,34 @@ e_menu_activate(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir)
if (pmi) e_menu_item_active_set(pmi, 0);
}
static void
_e_menu_item_unhilight(E_Menu_Item *mi)
{
if (!mi->hilighted) return;
mi->hilighted = 0;
if (mi->bg_object)
edje_object_signal_emit(mi->bg_object, "e,state,unselected", "e");
if (mi->icon_bg_object)
edje_object_signal_emit(mi->icon_bg_object, "e,state,unselected", "e");
if (isedje(mi->label_object))
edje_object_signal_emit(mi->label_object, "e,state,unselected", "e");
if (isedje(mi->submenu_object))
edje_object_signal_emit(mi->submenu_object, "e,state,unselected", "e");
if (isedje(mi->toggle_object))
edje_object_signal_emit(mi->toggle_object, "e,state,unselected", "e");
if (mi->icon_key)
{
if (mi->icon_object)
{
if (isedje(mi->icon_object))
edje_object_signal_emit(mi->icon_object, "e,state,unselected", "e");
else
e_icon_selected_set(mi->icon_object, EINA_FALSE);
}
}
edje_object_signal_emit(mi->menu->bg_object, "e,state,unselected", "e");
}
E_API void
e_menu_deactivate(E_Menu *m)
{
@ -475,6 +503,8 @@ e_menu_deactivate(E_Menu *m)
m->active = 0;
if (m->post_deactivate_cb.func)
m->post_deactivate_cb.func(m->post_deactivate_cb.data, m);
if (m->parent_item)
_e_menu_item_unhilight(m->parent_item);
}
E_API int
@ -1030,6 +1060,7 @@ e_menu_item_active_set(E_Menu_Item *mi, int active)
_e_menu_submenu_deactivate(_e_prev_active_menu_item);
}
mi->active = 1;
mi->hilighted = 1;
_e_active_menu_item = mi;
if (mi->bg_object)
edje_object_signal_emit(mi->bg_object, "e,state,selected", "e");
@ -1060,27 +1091,8 @@ e_menu_item_active_set(E_Menu_Item *mi, int active)
mi->active = 0;
_e_prev_active_menu_item = mi;
_e_active_menu_item = NULL;
if (mi->bg_object)
edje_object_signal_emit(mi->bg_object, "e,state,unselected", "e");
if (mi->icon_bg_object)
edje_object_signal_emit(mi->icon_bg_object, "e,state,unselected", "e");
if (isedje(mi->label_object))
edje_object_signal_emit(mi->label_object, "e,state,unselected", "e");
if (isedje(mi->submenu_object))
edje_object_signal_emit(mi->submenu_object, "e,state,unselected", "e");
if (isedje(mi->toggle_object))
edje_object_signal_emit(mi->toggle_object, "e,state,unselected", "e");
if (mi->icon_key)
{
if (mi->icon_object)
{
if (isedje(mi->icon_object))
edje_object_signal_emit(mi->icon_object, "e,state,unselected", "e");
else
e_icon_selected_set(mi->icon_object, EINA_FALSE);
}
}
edje_object_signal_emit(mi->menu->bg_object, "e,state,unselected", "e");
if (!((mi->submenu) && (mi->submenu->active)))
_e_menu_item_unhilight(mi);
}
_e_menu_list_free_unref(tmp);
}
@ -2355,6 +2367,17 @@ _e_menu_activate_previous(void)
{
if (mi->menu->parent_item)
{
Eina_List *l;
E_Menu_Item *mi2;
EINA_LIST_FOREACH(mi->menu->items, l, mi2)
{
if (!mi2->disable)
{
e_menu_item_active_set(mi2, 0);
_e_menu_item_unhilight(mi2);
}
}
mi = mi->menu->parent_item;
e_menu_item_active_set(mi, 1);
_e_menu_item_ensure_onscreen(mi);

@ -141,6 +141,7 @@ struct _E_Menu_Item
Eina_Bool changed E_BITFIELD;
Eina_Bool active E_BITFIELD;
Eina_Bool disable E_BITFIELD;
Eina_Bool hilighted E_BITFIELD;
};
struct _E_Menu_Category_Callback

Loading…
Cancel
Save