Enlightenment CVS committal Author : moom Project : e17 Module : proto
Dir : e17/proto/etk/src/lib Modified Files: etk_menu.c etk_menu.h etk_popup_window.c etk_popup_window.h etk_widget.c Log Message: * [Menu] Add etk_menu_popup_in_direction() and etk_menu_popup_at_xy_in_direction() to make a menu pop up in a given direction =================================================================== RCS file: /cvs/e/e17/proto/etk/src/lib/etk_menu.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- etk_menu.c 3 Sep 2006 18:36:11 -0000 1.19 +++ etk_menu.c 3 Sep 2006 22:29:03 -0000 1.20 @@ -1,7 +1,6 @@ /** @file etk_menu.c */ #include "etk_menu.h" #include <stdlib.h> -#include "etk_popup_window.h" #include "etk_menu_item.h" #include "etk_utils.h" #include "etk_signal.h" @@ -76,6 +75,29 @@ } /** + * @brief Pops up the menu at the mouse position + * @param menu a menu + */ +void etk_menu_popup(Etk_Menu *menu) +{ + if (!menu) + return; + etk_popup_window_popup(menu->window); +} + +/** + * @brief Pops up the menu at the mouse position, in the given direction + * @param menu a menu + * @param direction the direction to which the menu should be popped up + */ +void etk_menu_popup_in_direction(Etk_Menu *menu, Etk_Popup_Direction direction) +{ + if (!menu) + return; + etk_popup_window_popup_in_direction(menu->window, direction); +} + +/** * @brief Pops up the menu at the position (x, y) * @param menu a menu * @param x the x component of the position where to popup the menu @@ -89,14 +111,17 @@ } /** - * @brief Pops up the menu at the mouse position + * @brief Pops up the menu at the position (x, y), in the given direction * @param menu a menu + * @param x the x component of the position where to popup the menu + * @param y the y component of the position where to popup the menu + * @param direction the direction to which the menu should be popped up */ -void etk_menu_popup(Etk_Menu *menu) +void etk_menu_popup_at_xy_in_direction(Etk_Menu *menu, int x, int y, Etk_Popup_Direction direction) { if (!menu) return; - etk_popup_window_popup(menu->window); + etk_popup_window_popup_at_xy_in_direction(menu->window, x, y, direction); } /** @@ -131,7 +156,11 @@ ETK_WIDGET(menu)->size_request = _etk_menu_size_request; ETK_WIDGET(menu)->size_allocate = _etk_menu_size_allocate; - etk_signal_connect("item_added", ETK_OBJECT(menu), ETK_CALLBACK(_etk_menu_item_added_cb), menu); + /* We make sure the menu widget is always visible */ + etk_widget_show(ETK_WIDGET(menu)); + etk_signal_connect_swapped("hide", ETK_OBJECT(menu), ETK_CALLBACK(etk_widget_show), menu); + + etk_signal_connect("item_added", ETK_OBJECT(menu), ETK_CALLBACK(_etk_menu_item_added_cb), NULL); etk_signal_connect("item_removed", ETK_OBJECT(menu), ETK_CALLBACK(_etk_menu_item_removed_cb), NULL); } @@ -233,7 +262,6 @@ if (!(menu_widget = ETK_WIDGET(data))) return; - etk_widget_show(menu_widget); etk_signal_emit(_etk_menu_signals[ETK_MENU_POPPED_UP_SIGNAL], ETK_OBJECT(menu_widget), NULL); if (ETK_MENU_SHELL(menu_widget)->parent) etk_signal_emit_by_name("submenu_popped_up", ETK_OBJECT(ETK_MENU_SHELL(menu_widget)->parent), NULL); @@ -282,7 +310,7 @@ etk_signal_connect("selected", item_object, ETK_CALLBACK(_etk_menu_item_selected_cb), NULL); etk_signal_connect("deselected", item_object, ETK_CALLBACK(_etk_menu_item_deselected_cb), NULL); etk_signal_connect("activated", item_object, ETK_CALLBACK(_etk_menu_item_activated_cb), NULL); - etk_object_notification_callback_add(item_object, "submenu", _etk_menu_item_submenu_changed_cb, data); + etk_object_notification_callback_add(item_object, "submenu", _etk_menu_item_submenu_changed_cb, object); } /* Called when an item is removed from the menu */ =================================================================== RCS file: /cvs/e/e17/proto/etk/src/lib/etk_menu.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- etk_menu.h 3 Sep 2006 18:36:11 -0000 1.7 +++ etk_menu.h 3 Sep 2006 22:29:03 -0000 1.8 @@ -3,6 +3,7 @@ #define _ETK_MENU_H_ #include "etk_menu_shell.h" +#include "etk_popup_window.h" #include "etk_types.h" /* TODO/FIXME list: @@ -43,8 +44,10 @@ Etk_Type *etk_menu_type_get(); Etk_Widget *etk_menu_new(); -void etk_menu_popup_at_xy(Etk_Menu *menu, int x, int y); void etk_menu_popup(Etk_Menu *menu); +void etk_menu_popup_in_direction(Etk_Menu *menu, Etk_Popup_Direction direction); +void etk_menu_popup_at_xy(Etk_Menu *menu, int x, int y); +void etk_menu_popup_at_xy_in_direction(Etk_Menu *menu, int x, int y, Etk_Popup_Direction direction); void etk_menu_popdown(Etk_Menu *menu); /** @} */ =================================================================== RCS file: /cvs/e/e17/proto/etk/src/lib/etk_popup_window.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- etk_popup_window.c 3 Sep 2006 18:36:11 -0000 1.9 +++ etk_popup_window.c 3 Sep 2006 22:29:03 -0000 1.10 @@ -174,11 +174,35 @@ } /** + * @brief Pops up the popup window at the mouse pointer position + * @param popup_window a popup window + * @note This is equivalent to etk_popup_window_popup_in_direction(popup_window, ETK_POPUP_BELOW_RIGHT) + */ +void etk_popup_window_popup(Etk_Popup_Window *popup_window) +{ + etk_popup_window_popup_in_direction(popup_window, ETK_POPUP_BELOW_RIGHT); +} + +/** + * @brief Pops up the popup window at the mouse pointer position, in the given direction + * @param popup_window a popup window + * @param direction the direction to which the window should be popped up + */ +void etk_popup_window_popup_in_direction(Etk_Popup_Window *popup_window, Etk_Popup_Direction direction) +{ + int x, y; + + etk_engine_mouse_position_get(&x, &y); + etk_popup_window_popup_at_xy_in_direction(popup_window, x, y, direction); +} + +/** * @brief Pops up the popup window at the position (x, y). If the parent of the popup window has already a child which * is popped up, the child will be automatically popped down * @param popup_window a popup window - * @param x the x component of the position where to pop up the popup window - * @param y the y component of the position where to pop up the popup window + * @param x the x position where to pop up the popup window + * @param y the y position where to pop up the popup window + * @note This is equivalent to etk_popup_window_popup_at_xy_in_direction(popup_window, x, y, ETK_POPUP_BELOW_RIGHT) */ void etk_popup_window_popup_at_xy(Etk_Popup_Window *popup_window, int x, int y) { @@ -226,16 +250,40 @@ } /** - * @brief Pops up the popup window at the mouse pointer position + * @brief Pops up the popup window at the position (x, y). If the parent of the popup window has already a child which + * is popped up, the child will be automatically popped down * @param popup_window a popup window + * @param x the x position where to pop up the popup window + * @param y the y position where to pop up the popup window + * @param direction the direction to which the window should be popped up + * @note This is equivalent to etk_popup_window_popup_at_xy_in_direction(popup_window, x, y, ETK_POPUP_BELOW_RIGHT) */ -void etk_popup_window_popup(Etk_Popup_Window *popup_window) +void etk_popup_window_popup_at_xy_in_direction(Etk_Popup_Window *popup_window, int x, int y, Etk_Popup_Direction direction) { - int x, y; + Etk_Size size; - etk_engine_mouse_position_get(&x, &y); + if (!popup_window) + return; + + etk_widget_size_request_full(ETK_WIDGET(popup_window), &size, ETK_FALSE); + switch (direction) + { + case ETK_POPUP_BELOW_LEFT: + x -= size.w; + break; + case ETK_POPUP_ABOVE_RIGHT: + y -= size.h; + break; + case ETK_POPUP_ABOVE_LEFT: + x -= size.w; + y -= size.h; + break; + default: + break; + } etk_popup_window_popup_at_xy(popup_window, x, y); } + /** * @brief Pops down the popup window and its children =================================================================== RCS file: /cvs/e/e17/proto/etk/src/lib/etk_popup_window.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- etk_popup_window.h 3 Sep 2006 18:36:11 -0000 1.5 +++ etk_popup_window.h 3 Sep 2006 22:29:03 -0000 1.6 @@ -19,6 +19,15 @@ /** Check if the object is an Etk_Popup_Window */ #define ETK_IS_POPUP_WINDOW(obj) (ETK_OBJECT_CHECK_TYPE((obj), ETK_POPUP_WINDOW_TYPE)) +/** @brief The directions to which the popup window is popped up */ +typedef enum Etk_Popup_Direction +{ + ETK_POPUP_BELOW_RIGHT, /**< The window is popped up on the right, below the given position (default) */ + ETK_POPUP_BELOW_LEFT, /**< The window is popped up on the left, below the given position */ + ETK_POPUP_ABOVE_RIGHT, /**< The window is popped up on the right, above the given position */ + ETK_POPUP_ABOVE_LEFT, /**< The window is popped up on the left, above the given position */ +} Etk_Popup_Direction; + /** * @brief @widget A borderless window that can be popped up/down * @structinfo @@ -42,8 +51,10 @@ void etk_popup_window_focused_window_set(Etk_Popup_Window *popup_window); Etk_Popup_Window *etk_popup_window_focused_window_get(); -void etk_popup_window_popup_at_xy(Etk_Popup_Window *popup_window, int x, int y); void etk_popup_window_popup(Etk_Popup_Window *popup_window); +void etk_popup_window_popup_in_direction(Etk_Popup_Window *popup_window, Etk_Popup_Direction direction); +void etk_popup_window_popup_at_xy(Etk_Popup_Window *popup_window, int x, int y); +void etk_popup_window_popup_at_xy_in_direction(Etk_Popup_Window *popup_window, int x, int y, Etk_Popup_Direction direction); void etk_popup_window_popdown(Etk_Popup_Window *popup_window); void etk_popup_window_popdown_all(); Etk_Bool etk_popup_window_is_popped_up(Etk_Popup_Window *popup_window); =================================================================== RCS file: /cvs/e/e17/proto/etk/src/lib/etk_widget.c,v retrieving revision 1.81 retrieving revision 1.82 diff -u -3 -r1.81 -r1.82 --- etk_widget.c 2 Sep 2006 14:21:09 -0000 1.81 +++ etk_widget.c 3 Sep 2006 22:29:03 -0000 1.82 @@ -931,15 +931,21 @@ size_requisition->w = 0; else if (widget->requested_size.w >= 0) size_requisition->w = widget->requested_size.w; - else if (!widget->need_size_recalc && widget->last_size_requisition.w >= 0) + else if (widget->last_size_requisition.w >= 0 && + !widget->need_size_recalc && (widget->visible || hidden_has_no_size)) + { size_requisition->w = widget->last_size_requisition.w; + } if (!widget->visible && hidden_has_no_size) size_requisition->h = 0; else if (widget->requested_size.h >= 0) size_requisition->h = widget->requested_size.h; - else if (!widget->need_size_recalc && widget->last_size_requisition.h >= 0) + else if (widget->last_size_requisition.h >= 0 && + !widget->need_size_recalc && (widget->visible || hidden_has_no_size)) + { size_requisition->h = widget->last_size_requisition.h; + } /* We need to recalc it */ if (size_requisition->w < 0 || size_requisition->h < 0) ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs