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.
This commit is contained in:
Antony Riakiotakis 2014-10-10 17:02:47 +02:00
parent 067f70cff7
commit 65e1600cf3

@ -8521,14 +8521,6 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo
} }
if (menu->menuretval) { 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; return WM_UI_HANDLER_CONTINUE;
} }
else { 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) 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; 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); ui_apply_button(C, but->block, but, but->active, false);
button_activate_exit((bContext *)C, but, but->active, false, true); 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 { else {
menu->menuretval = UI_RETURN_CANCEL; menu->menuretval = UI_RETURN_CANCEL;
}
ED_region_tag_redraw(menu->region); 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; 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; 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_exit(C, active_but, active_but->active, false, false);
button_activate_init(C, menu->region, but, BUTTON_ACTIVATE_OVER); 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) 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 { else {
uiBut *but = ui_but_find_activated(menu->region); 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; break;
case LEFTMOUSE: case LEFTMOUSE:
if (event->val == KM_RELEASE) { if (is_click_style) {
uiBut *but = ui_but_find_activated(menu->region); if (block->pie_data.flags & UI_PIE_INVALID_DIR) {
retval = ui_but_pie_menu_apply(C, menu, but, false, is_click_style); menu->menuretval = UI_RETURN_CANCEL;
}
else {
retval = ui_handle_menu_button(C, event, menu);
}
} }
break; 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) { for (but = block->buttons.first; but; but = but->next) {
if (but->menu_key == event->type) { 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); CASE_NUM_TO_DIR(9, UI_RADIAL_NE);
{ {
but = ui_block_pie_dir_activate(block, event, num_dir); 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; break;
} }
#undef CASE_NUM_TO_DIR #undef CASE_NUM_TO_DIR