diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-27 11:48:54 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-27 11:48:54 +0300 |
commit | 649659aa24604ba1af7da4d2e2c896b6402d6270 (patch) | |
tree | 359f9a0282b334c9ff291843d8121deb93b21ee1 /source/blender | |
parent | 65e42d7b32ae244368e54c9676d354f4a5f1ae8b (diff) | |
parent | 756b9acaf552bb82596f2239f522467372e4e661 (diff) |
Merge branch 'blender-v2.82-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/BLI_rect.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/rct.c | 84 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 8 |
3 files changed, 95 insertions, 1 deletions
diff --git a/source/blender/blenlib/BLI_rect.h b/source/blender/blenlib/BLI_rect.h index fdb4fe30f1c..2b11213d351 100644 --- a/source/blender/blenlib/BLI_rect.h +++ b/source/blender/blenlib/BLI_rect.h @@ -83,6 +83,10 @@ bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, cons bool BLI_rcti_compare(const struct rcti *rect_a, const struct rcti *rect_b); bool BLI_rctf_isect(const struct rctf *src1, const struct rctf *src2, struct rctf *dest); bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest); +bool BLI_rctf_isect_rect_x(const struct rctf *src1, const struct rctf *src2, float range_x[2]); +bool BLI_rctf_isect_rect_y(const struct rctf *src1, const struct rctf *src2, float range_y[2]); +bool BLI_rcti_isect_rect_x(const struct rcti *src1, const struct rcti *src2, int range_x[2]); +bool BLI_rcti_isect_rect_y(const struct rcti *src1, const struct rcti *src2, int range_y[2]); bool BLI_rcti_isect_x(const rcti *rect, const int x); bool BLI_rcti_isect_y(const rcti *rect, const int y); bool BLI_rcti_isect_pt(const struct rcti *rect, const int x, const int y); diff --git a/source/blender/blenlib/intern/rct.c b/source/blender/blenlib/intern/rct.c index 8fab4ed8e6a..2ed7d7d7345 100644 --- a/source/blender/blenlib/intern/rct.c +++ b/source/blender/blenlib/intern/rct.c @@ -923,6 +923,90 @@ bool BLI_rcti_isect(const rcti *src1, const rcti *src2, rcti *dest) } } +bool BLI_rctf_isect_rect_x(const rctf *src1, const rctf *src2, float range_x[2]) +{ + const float xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin); + const float xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax); + + if (xmax >= xmin) { + if (range_x) { + range_x[0] = xmin; + range_x[1] = xmax; + } + return true; + } + else { + if (range_x) { + range_x[0] = 0; + range_x[1] = 0; + } + return false; + } +} + +bool BLI_rctf_isect_rect_y(const rctf *src1, const rctf *src2, float range_y[2]) +{ + const float ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin); + const float ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax); + + if (ymax >= ymin) { + if (range_y) { + range_y[0] = ymin; + range_y[1] = ymax; + } + return true; + } + else { + if (range_y) { + range_y[0] = 0; + range_y[1] = 0; + } + return false; + } +} + +bool BLI_rcti_isect_rect_x(const rcti *src1, const rcti *src2, int range_x[2]) +{ + const int xmin = (src1->xmin) > (src2->xmin) ? (src1->xmin) : (src2->xmin); + const int xmax = (src1->xmax) < (src2->xmax) ? (src1->xmax) : (src2->xmax); + + if (xmax >= xmin) { + if (range_x) { + range_x[0] = xmin; + range_x[1] = xmax; + } + return true; + } + else { + if (range_x) { + range_x[0] = 0; + range_x[1] = 0; + } + return false; + } +} + +bool BLI_rcti_isect_rect_y(const rcti *src1, const rcti *src2, int range_y[2]) +{ + const int ymin = (src1->ymin) > (src2->ymin) ? (src1->ymin) : (src2->ymin); + const int ymax = (src1->ymax) < (src2->ymax) ? (src1->ymax) : (src2->ymax); + + if (ymax >= ymin) { + if (range_y) { + range_y[0] = ymin; + range_y[1] = ymax; + } + return true; + } + else { + if (range_y) { + range_y[0] = 0; + range_y[1] = 0; + } + return false; + } +} + void BLI_rcti_rctf_copy(rcti *dst, const rctf *src) { dst->xmin = floorf(src->xmin + 0.5f); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 16996681695..ab70d4b87e1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -10616,7 +10616,13 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE (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))) { + (ELEM(but_other->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU)) && + /* Hover-opening menu's doesn't work well for buttons over one another + * along the same axis the menu is opening on (see T71719). */ + (((data->menu->direction & (UI_DIR_LEFT | UI_DIR_RIGHT)) && + BLI_rctf_isect_rect_x(&but->rect, &but_other->rect, NULL)) || + ((data->menu->direction & (UI_DIR_DOWN | UI_DIR_UP)) && + BLI_rctf_isect_rect_y(&but->rect, &but_other->rect, NULL)))) { /* if mouse moves to a different root-level menu button, * open it to replace the current menu */ if ((but_other->flag & UI_BUT_DISABLED) == 0) { |