From 65e1600cf3ec6ebbc5a3a9531607ffbc57da8d9a Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Fri, 10 Oct 2014 17:02:47 +0200 Subject: [PATCH] Change interaction of pie menus slightly. In drag style pie menus clicking is ignored now. This is done because if we want to ensure that pie menus will not respawn, we had to not destroy and keep the pie menu invisble while the button is pressed. This opened a can of worms where pie items that would spawn popups could steal the focus from the invisible pies and then the former pies would be stuck in an invisible state, stealing all input unless user did a right click to cancel the pie. Invisible state is still kept for cancelling and strictly for that only. This still allows nested layouts but only in click style, while hold style is used for faster interaction. As a plus, it should also be possible to tweak slider properties now, though menu will close after that. --- .../editors/interface/interface_handlers.c | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4b692cfd741..5bd85f855ba 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8521,14 +8521,6 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo } if (menu->menuretval) { - /* pie menus should not close but wait for release instead */ - if ((block->flag & UI_BLOCK_RADIAL) && - !(block->pie_data.flags & UI_PIE_CLICK_STYLE)) - { - menu->menuretval = 0; - block->pie_data.flags |= UI_PIE_FINISHED; - } - return WM_UI_HANDLER_CONTINUE; } else { @@ -8538,10 +8530,10 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo static bool ui_but_pie_menu_supported_apply(uiBut *but) { - return (but->type != NUMSLI); + return (!ELEM(but->type, NUMSLI, NUM)); } -static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *but, bool force_close, bool click_style) +static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *but, bool force_close) { int retval = WM_UI_HANDLER_BREAK; @@ -8566,24 +8558,11 @@ static int ui_but_pie_menu_apply(bContext *C, uiPopupBlockHandle *menu, uiBut *b ui_apply_button(C, but->block, but, but->active, false); button_activate_exit((bContext *)C, but, but->active, false, true); - if (!(click_style || force_close)) { - but->block->pie_data.flags |= UI_PIE_FINISHED; - menu->menuretval = 0; - } - else { - menu->menuretval = UI_RETURN_OK; - } + menu->menuretval = UI_RETURN_OK; } } else { - uiBlock *block = menu->region->uiblocks.first; - - if (!(click_style || force_close)) { - block->pie_data.flags |= UI_PIE_FINISHED; - } - else { - menu->menuretval = UI_RETURN_CANCEL; - } + menu->menuretval = UI_RETURN_CANCEL; ED_region_tag_redraw(menu->region); } @@ -8606,7 +8585,7 @@ static uiBut *ui_block_pie_dir_activate(uiBlock *block, const wmEvent *event, Ra return NULL; } -static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandle *menu, bool is_click_style) +static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandle *menu) { uiBut *active_but; @@ -8619,7 +8598,7 @@ static int ui_but_pie_button_activate(bContext *C, uiBut *but, uiPopupBlockHandl button_activate_exit(C, active_but, active_but->active, false, false); button_activate_init(C, menu->region, but, BUTTON_ACTIVATE_OVER); - return ui_but_pie_menu_apply(C, menu, but, false, is_click_style); + return ui_but_pie_menu_apply(C, menu, but, false); } static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle *menu) @@ -8737,7 +8716,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle else { uiBut *but = ui_but_find_activated(menu->region); - retval = ui_but_pie_menu_apply(C, menu, but, true, is_click_style); + retval = ui_but_pie_menu_apply(C, menu, but, true); } } } @@ -8759,9 +8738,13 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle break; case LEFTMOUSE: - if (event->val == KM_RELEASE) { - uiBut *but = ui_but_find_activated(menu->region); - retval = ui_but_pie_menu_apply(C, menu, but, false, is_click_style); + if (is_click_style) { + if (block->pie_data.flags & UI_PIE_INVALID_DIR) { + menu->menuretval = UI_RETURN_CANCEL; + } + else { + retval = ui_handle_menu_button(C, event, menu); + } } break; @@ -8810,7 +8793,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle { for (but = block->buttons.first; but; but = but->next) { if (but->menu_key == event->type) { - ui_but_pie_button_activate(C, but, menu, is_click_style); + ui_but_pie_button_activate(C, but, menu); } } } @@ -8831,7 +8814,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle CASE_NUM_TO_DIR(9, UI_RADIAL_NE); { but = ui_block_pie_dir_activate(block, event, num_dir); - retval = ui_but_pie_button_activate(C, but, menu, is_click_style); + retval = ui_but_pie_button_activate(C, but, menu); break; } #undef CASE_NUM_TO_DIR