Fix T41639, hierarchical pie menu - popup interaction is buggy.

Basically, this commit changes pie menu click interaction so that
confirmation is done on left click release instead of press. This allows
dragging on the pie menu to select different items, but most
importantly, there should be no left over click events passed on to
subsequent menus/pies. This means that pie menus should now be able to
spawn popups safely. Also, left clicking to spawn a second pie menu now
sets that menu to click style by default allowing for better interaction
between hierarhies of pie menus.
This commit is contained in:
Antonis Ryakiotakis 2014-10-09 18:37:54 +02:00
parent 9f18e4f0eb
commit 0609aee4db
Notes: blender-bot 2023-02-14 10:09:24 +01:00
Referenced by issue #41639, Pie menu : pie menu calling another pie menu : need to double click (on second menu)
2 changed files with 11 additions and 5 deletions

View File

@ -8687,7 +8687,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
mul_v2_fl(vec, pie_radius);
add_v2_v2(vec, center);
mul_v2_fl(vec, fac);
mul_v2_fl(vec, fac);
add_v2_v2(vec, block->pie_data.pie_center_spawned);
BLI_rctf_recenter(&but->rect, vec[0], vec[1]);
@ -8718,7 +8718,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
return WM_UI_HANDLER_BREAK;
}
if (event->type == block->pie_data.event) {
if (event->type == block->pie_data.event && !is_click_style) {
if (event->val != KM_RELEASE) {
ui_handle_menu_button(C, event, menu);
@ -8734,7 +8734,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
if (!(block->pie_data.flags & UI_PIE_DRAG_STYLE)) {
block->pie_data.flags |= UI_PIE_CLICK_STYLE;
}
else if (!is_click_style) {
else {
uiBut *but = ui_but_find_activated(menu->region);
retval = ui_but_pie_menu_apply(C, menu, but, true, is_click_style);
@ -8747,7 +8747,8 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
switch (event->type) {
case MOUSEMOVE:
if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) > PIE_CLICK_THRESHOLD_SQ) {
if (len_squared_v2v2(event_xy, block->pie_data.pie_center_init) > PIE_CLICK_THRESHOLD_SQ &&
!is_click_style) {
block->pie_data.flags |= UI_PIE_DRAG_STYLE;
}
ui_handle_menu_button(C, event, menu);
@ -8757,7 +8758,7 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
break;
case LEFTMOUSE:
if (event->val == KM_PRESS) {
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);
}

View File

@ -2720,6 +2720,11 @@ uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const
pie->block_radial->flag |= UI_BLOCK_RADIAL;
pie->block_radial->pie_data.event = event->type;
/* if pie is spawned by a left click, it is always assumed to be click style */
if (event->type == LEFTMOUSE) {
pie->block_radial->flag |= UI_PIE_CLICK_STYLE;
}
pie->layout = uiBlockLayout(pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
pie->mx = event->x;
pie->my = event->y;