diff options
-rw-r--r-- | source/blender/editors/interface/interface.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 29 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 |
3 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4aece1ad8c8..515db9559ae 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -134,7 +134,7 @@ void ui_block_to_window(const ARegion *ar, uiBlock *block, int *x, int *y) *y = (int)(fy + 0.5f); } -void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, rctf *graph, rcti *winr) +void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, const rctf *graph, rcti *winr) { rctf tmpr; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b0f04792f90..787e79fe8b6 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -81,6 +81,8 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to); static void ui_add_link(bContext *C, uiBut *from, uiBut *to); +static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *menu, int mx, int my); + /***************** structs and defines ****************/ #define BUTTON_TOOLTIP_DELAY 0.500 @@ -5798,22 +5800,35 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) switch (event->type) { case MOUSEMOVE: { - uiBut *bt; + /* if the mouse is over the button, do nothing */ + if (ui_mouse_inside_button(data->region, but, event->x, event->y)) { + break; + } + /* if the mouse is over the menu, also do nothing */ if (data->menu && data->menu->region) { if (ui_mouse_inside_region(data->menu->region, event->x, event->y)) { break; } - } + else { + /* make a rectangle between the menu and the button that opened it, + * this avoids any space between them exiting the popup. see [#29072] - campbell */ + rctf rct_all = but->rect; + rctf rct_win; - bt = ui_but_find_mouse_over(ar, event->x, event->y); + ui_block_to_window_fl(ar, block, &rct_all.xmin, &rct_all.ymin); + ui_block_to_window_fl(ar, block, &rct_all.xmax, &rct_all.ymax); - if (bt && bt->active != data) { - if (but->type != COL) { /* exception */ - data->cancel = 1; + BLI_rctf_rcti_copy(&rct_win, &data->menu->region->winrct); + BLI_rctf_union(&rct_all, &rct_win); + + if (BLI_rctf_isect_pt(&rct_all, event->x, event->y)) { + break; + } } - button_activate_state(C, but, BUTTON_STATE_EXIT); } + + button_activate_state(C, but, BUTTON_STATE_EXIT); break; } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index d39fbbf7e61..e728c861933 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -348,7 +348,7 @@ void ui_fontscale(short *points, float aspect); extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y); -extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr); +extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, const rctf *graph, rcti *winr); extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y); extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y); extern void ui_window_to_region(const ARegion *ar, int *x, int *y); |