UI: simplify check for active menu button
Dragging to select another popup now checks the menus active button.
This commit is contained in:
@@ -10113,31 +10113,18 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
|
||||
|
||||
if (but) {
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
ARegion *ar_temp;
|
||||
uiBut *but_other;
|
||||
uiHandleButtonData *data;
|
||||
bool is_inside_menu = false;
|
||||
|
||||
/* look for a popup menu containing the mouse */
|
||||
for (ar_temp = screen->regionbase.first; ar_temp; ar_temp = ar_temp->next) {
|
||||
rcti winrct;
|
||||
|
||||
ui_region_winrct_get_no_margin(ar_temp, &winrct);
|
||||
|
||||
if (BLI_rcti_isect_pt_v(&winrct, &event->x) || ui_region_find_active_but(ar_temp)) {
|
||||
BLI_assert(ar_temp->type->regionid == RGN_TYPE_TEMPORARY);
|
||||
|
||||
is_inside_menu = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* handle activated button events */
|
||||
data = but->active;
|
||||
|
||||
if ((data->state == BUTTON_STATE_MENU_OPEN) &&
|
||||
/* Make sure this popup isn't dragging a button.
|
||||
* can happen with popovers (see T67882). */
|
||||
(ui_region_find_active_but(data->menu->region) == NULL) &&
|
||||
/* make sure mouse isn't inside another menu (see T43247) */
|
||||
(is_inside_menu == false) &&
|
||||
(ui_screen_region_find_mouse_over(screen, event) == NULL) &&
|
||||
(ELEM(but->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU)) &&
|
||||
(but_other = ui_but_find_mouse_over(ar, event)) && (but != but_other) &&
|
||||
(ELEM(but_other->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU))) {
|
||||
|
||||
@@ -938,6 +938,9 @@ uiBut *ui_region_find_active_but(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_region_contains_point_px(const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
|
||||
bool ui_region_contains_rect_px(const struct ARegion *ar, const rcti *rect_px);
|
||||
|
||||
ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y);
|
||||
ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const struct wmEvent *event);
|
||||
|
||||
/* interface_context_menu.c */
|
||||
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but);
|
||||
void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa);
|
||||
|
||||
@@ -570,3 +570,29 @@ bool ui_region_contains_rect_px(const ARegion *ar, const rcti *rect_px)
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Screen (#bScreen) Spatial
|
||||
* \{ */
|
||||
|
||||
/** Check if the cursor is over any popups. */
|
||||
ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y)
|
||||
{
|
||||
for (ARegion *ar = screen->regionbase.first; ar; ar = ar->next) {
|
||||
rcti winrct;
|
||||
|
||||
ui_region_winrct_get_no_margin(ar, &winrct);
|
||||
|
||||
if (BLI_rcti_isect_pt(&winrct, x, y)) {
|
||||
return ar;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const wmEvent *event)
|
||||
{
|
||||
return ui_screen_region_find_mouse_over_ex(screen, event->x, event->y);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
Reference in New Issue
Block a user