[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56398] trunk/blender/source/blender/ editors/interface/interface_handlers.c: convert macro PASS_EVENT_TO_PARENT_IF_NONACTIVE into a static function.
Campbell Barton
ideasman42 at gmail.com
Mon Apr 29 23:44:28 CEST 2013
Revision: 56398
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56398
Author: campbellbarton
Date: 2013-04-29 21:44:28 +0000 (Mon, 29 Apr 2013)
Log Message:
-----------
convert macro PASS_EVENT_TO_PARENT_IF_NONACTIVE into a static function. (having flow control in a macro is bad practice), own doing.
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface_handlers.c
Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c 2013-04-29 20:52:27 UTC (rev 56397)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c 2013-04-29 21:44:28 UTC (rev 56398)
@@ -6893,6 +6893,28 @@
return 0;
}
+/**
+ * Special function to handle nested menus.
+ * let the parent menu get the event.
+ *
+ * This allows a menu to be open,
+ * but send key events to the parent if theres no active buttons.
+ *
+ * Without this keyboard navigation from menu's wont work.
+ */
+static bool ui_menu_pass_event_to_parent_if_nonactive(uiPopupBlockHandle *menu, const uiBut *but,
+ const int level, const int retval)
+{
+ if ((level != 0) && (but == NULL)) {
+ menu->menuretval = UI_RETURN_OUT | UI_RETURN_OUT_PARENT;
+ BLI_assert(retval == WM_UI_HANDLER_CONTINUE);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
static int ui_handle_menu_event(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu, int level)
{
ARegion *ar;
@@ -6944,16 +6966,6 @@
else if (but == NULL || (but->type != SEARCH_MENU && but->type != SEARCH_MENU_UNLINK)) {
switch (event->type) {
-
- /* let the parent menu get the event */
-#define PASS_EVENT_TO_PARENT_IF_NONACTIVE \
- if ((level != 0) && (but == NULL)) { \
- menu->menuretval = UI_RETURN_OUT | UI_RETURN_OUT_PARENT; \
- BLI_assert(retval == WM_UI_HANDLER_CONTINUE); \
- break; \
- } (void)0
-
-
/* closing sublevels of pulldowns */
case LEFTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP))
@@ -6967,7 +6979,8 @@
case RIGHTARROWKEY:
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
- PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ break;
but = ui_but_find_activated(ar);
@@ -7004,7 +7017,8 @@
if (val == KM_PRESS) {
const eButType type_flip = BUT | ROW;
- PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ break;
#ifdef USE_KEYNAV_LIMIT
ui_mouse_motion_keynav_init(&menu->keynav_state, event);
@@ -7093,7 +7107,8 @@
if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) {
- PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ break;
if (event->alt) act += 10;
@@ -7172,7 +7187,8 @@
(event->ctrl == FALSE) &&
(event->oskey == FALSE))
{
- PASS_EVENT_TO_PARENT_IF_NONACTIVE;
+ if (ui_menu_pass_event_to_parent_if_nonactive(menu, but, level, retval))
+ break;
for (but = block->buttons.first; but; but = but->next) {
More information about the Bf-blender-cvs
mailing list