Enlightenment CVS committal
Author : lordchaos
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_menu.c ewl_menu.h ewl_menubar.c ewl_menubar.h
Log Message:
* Menu-active-mouseover-activate. Menus behave more realistically now.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menu.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_menu.c 17 Dec 2005 21:40:53 -0000 1.19
+++ ewl_menu.c 7 Jan 2006 06:45:23 -0000 1.20
@@ -3,6 +3,7 @@
#include "ewl_macros.h"
#include "ewl_private.h"
+
/**
* @param image: the image icon to use for this menu
* @param title: the text to place in the menu
@@ -49,6 +50,9 @@
ewl_widget_inherit(EWL_WIDGET(menu), "menu");
+ ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_MOUSE_MOVE,
+ ewl_menu_expand_mouse_move_cb, NULL);
+
ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_FOCUS_IN,
ewl_menu_expand_cb, NULL);
ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_REALIZE,
@@ -56,6 +60,8 @@
ewl_callback_append(EWL_WIDGET(menu), EWL_CALLBACK_CONFIGURE,
ewl_menu_configure_cb, NULL);
+ menu->menubar_parent = NULL;
+
/*
* Create the popup menu portion of the widget.
*/
@@ -63,8 +69,7 @@
ewl_window_keyboard_grab_set(EWL_WINDOW(menu->base.popup), TRUE);
ewl_window_pointer_grab_set(EWL_WINDOW(menu->base.popup), TRUE);
- /*Turn this off until we can figure out why this stops windows being
moved*/
- /*ewl_window_override_set(EWL_WINDOW(menu->base.popup), TRUE); */
+ ewl_window_override_set(EWL_WINDOW(menu->base.popup), TRUE);
ewl_window_borderless_set(EWL_WINDOW(menu->base.popup));
ewl_widget_internal_set(menu->base.popup, TRUE);
ewl_widget_appearance_set(EWL_WIDGET(menu->base.popup), "menu");
@@ -73,7 +78,11 @@
ewl_object_alignment_set(EWL_OBJECT(menu->base.popup),
EWL_FLAG_ALIGN_LEFT | EWL_FLAG_ALIGN_TOP);
ewl_callback_append(menu->base.popup, EWL_CALLBACK_MOUSE_DOWN,
- ewl_menu_hide_cb, NULL);
+ ewl_menu_hide_cb, menu);
+
+ ewl_callback_append(menu->base.popup, EWL_CALLBACK_MOUSE_MOVE,
+ ewl_menu_mouse_move_cb, menu);
+
ewl_callback_prepend(menu->base.popup, EWL_CALLBACK_DESTROY,
ewl_menu_popup_destroy_cb, menu);
@@ -128,6 +137,46 @@
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
+
+void
+ewl_menu_expand_mouse_move_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
+ void *user_data __UNUSED__)
+{
+ Ewl_Menu* menu;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+
+ menu= EWL_MENU(w);
+
+ if (menu->menubar_parent) {
+ Ewl_Menu* sub;
+ int vis=0;
+ Ewl_Menu* hide_menu = NULL;
+ Ewl_Menubar* bar = EWL_MENUBAR(menu->menubar_parent);
+ ewl_container_child_iterate_begin(EWL_CONTAINER(bar));
+
+ while ( (sub =
EWL_MENU(ewl_container_child_next(EWL_CONTAINER(bar))))) {
+ if (sub != EWL_MENU(w) && sub->base.popup &&
+ VISIBLE(sub->base.popup)) {
+ hide_menu = sub;
+ vis++;
+ break;
+ }
+ }
+
+ if (vis && hide_menu) {
+ ewl_widget_hide(hide_menu->base.popup);
+ ewl_callback_call(w, EWL_CALLBACK_FOCUS_IN);
+ }
+ }
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+
+
void
ewl_menu_expand_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
void *user_data __UNUSED__)
@@ -139,6 +188,7 @@
DCHECK_TYPE("w", w, "widget");
menu = EWL_MENU(w);
+
ewl_widget_show(menu->base.popup);
ewl_window_raise(EWL_WINDOW(menu->base.popup));
@@ -178,15 +228,45 @@
}
void
+ewl_menu_mouse_move_cb(Ewl_Widget *w, void *ev_data, void *user_data)
+{
+
+ Ewl_Event_Mouse_Move* ev;
+ Ewl_Menu* menu;
+ Ewl_Embed* embed;
+ int wx, wy;
+ int x, y;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("w", w, "widget");
+ DCHECK_TYPE("user_data", user_data, "menu");
+
+ ev = ev_data;
+ menu = EWL_MENU(user_data);
+
+ embed = ewl_embed_widget_find(EWL_WIDGET(menu)->parent);
+ ewl_window_position_get(EWL_WINDOW(embed), &wx, &wy);
+ ewl_window_position_get(EWL_WINDOW(menu->base.popup), &x, &y);
+
+ if (menu->menubar_parent) {
+ ewl_embed_mouse_move_feed(embed, ev->x+x - wx, ev->y+y - wy,0);
+ }
+}
+
+
+void
ewl_menu_hide_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
- void *user_data __UNUSED__)
+ void *user_data )
{
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("w", w);
DCHECK_TYPE("w", w, "widget");
- if (w == ewl_embed_focused_widget_get(EWL_EMBED(w)))
+ if (w == ewl_embed_focused_widget_get(EWL_EMBED(w))) {
ewl_widget_hide(w);
+
+ }
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menu.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_menu.h 17 Dec 2005 21:40:53 -0000 1.7
+++ ewl_menu.h 7 Jan 2006 06:45:23 -0000 1.8
@@ -36,6 +36,8 @@
Ewl_Menu_Base base;
int popup_x;
int popup_y;
+
+ Ewl_Widget* menubar_parent;
};
Ewl_Widget *ewl_menu_new(void);
@@ -50,6 +52,9 @@
void ewl_menu_popup_move_cb(Ewl_Widget *w, void *ev_data, void *user_data);
void ewl_menu_hide_cb(Ewl_Widget *w, void *ev_data, void *user_data);
void ewl_menu_popup_destroy_cb(Ewl_Widget *w, void *ev, void *data);
+void ewl_menu_expand_mouse_move_cb(Ewl_Widget *w, void *ev_data, void
*user_data);
+void ewl_menu_mouse_move_cb(Ewl_Widget *w, void *ev_data, void *user_data);
+
/**
* @}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menubar.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_menubar.c 24 Oct 2005 04:39:57 -0000 1.7
+++ ewl_menubar.c 7 Jan 2006 06:45:23 -0000 1.8
@@ -92,6 +92,10 @@
ewl_container_redirect_set(EWL_CONTAINER(mb),
EWL_CONTAINER(mb->inner_box));
+ ewl_container_add_notify_set(EWL_CONTAINER(mb->inner_box),
+ ewl_menubar_cb_child_add);
+
+
ewl_menubar_orientation_set(mb, EWL_ORIENTATION_HORIZONTAL);
@@ -145,3 +149,22 @@
DRETURN_INT(ewl_box_orientation_get(EWL_BOX(mb)), DLEVEL_STABLE);
}
+
+void
+ewl_menubar_cb_child_add(Ewl_Container *c, Ewl_Widget *w)
+{
+ Ewl_Menubar *mb;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("c", c);
+ DCHECK_PARAM_PTR("w", w);
+ DCHECK_TYPE("c", c, "container");
+ DCHECK_TYPE("w", w, "widget");
+
+ mb = EWL_MENUBAR(c);
+ if (ewl_widget_type_is(w,"menu"))
+ EWL_MENU(w)->menubar_parent = EWL_WIDGET(mb);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_menubar.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_menubar.h 24 Oct 2005 04:39:57 -0000 1.5
+++ ewl_menubar.h 7 Jan 2006 06:45:23 -0000 1.6
@@ -43,6 +43,8 @@
void ewl_menubar_orientation_set(Ewl_Menubar *mb, Ewl_Orientation
o);
Ewl_Orientation ewl_menubar_orientation_get(Ewl_Menubar *mb);
+void ewl_menubar_cb_child_add(Ewl_Container *c, Ewl_Widget *w);
+
/**
* @}
*/
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs