Merge branch 'blender-v2.82-release'

This commit is contained in:
2020-01-27 19:48:54 +11:00
3 changed files with 95 additions and 1 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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) {