From 34e749beef0e0ece7ee857207358aac1fd3e59bc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Oct 2015 00:23:57 +1100 Subject: Fix popup menu glitch, scrolling at high dpi Popups were clamped be screen-margin, then clipped by UI_POPUP_MENU_TOP, causing regular popups not to have enough room & add scroll buttons. --- source/blender/editors/interface/interface.c | 37 +++++++++++----------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 78021612195..ff92ddb69f2 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -368,9 +368,11 @@ static void ui_block_bounds_calc_popup( wmWindow *window, uiBlock *block, eBlockBoundsCalc bounds_calc, const int xy[2]) { - int startx, starty, endx, endy, width, height, oldwidth, oldheight; + int width, height, oldwidth, oldheight; int oldbounds, xmax, ymax; const int margin = UI_SCREEN_MARGIN; + rcti rect, rect_bounds; + int ofs_dummy[2]; oldbounds = block->bounds; @@ -405,27 +407,18 @@ static void ui_block_bounds_calc_popup( /* offset block based on mouse position, user offset is scaled * along in case we resized the block in ui_block_bounds_calc_text */ - startx = xy[0] + block->rect.xmin + (block->mx * width) / oldwidth; - starty = xy[1] + block->rect.ymin + (block->my * height) / oldheight; - - if (startx < margin) - startx = margin; - if (starty < margin) - starty = margin; - - endx = startx + width; - endy = starty + height; - - if (endx > xmax) { - endx = xmax - margin; - startx = endx - width; - } - if (endy > ymax - margin) { - endy = ymax - margin; - starty = endy - height; - } - - ui_block_translate(block, startx - block->rect.xmin, starty - block->rect.ymin); + rect.xmin = xy[0] + block->rect.xmin + (block->mx * width) / oldwidth; + rect.ymin = xy[1] + block->rect.ymin + (block->my * height) / oldheight; + rect.xmax = rect.xmin + width; + rect.ymax = rect.ymin + height; + + rect_bounds.xmin = margin; + rect_bounds.ymin = margin; + rect_bounds.xmax = xmax - margin; + rect_bounds.ymax = ymax - UI_POPUP_MENU_TOP; + + BLI_rcti_clamp(&rect, &rect_bounds, ofs_dummy); + ui_block_translate(block, rect.xmin - block->rect.xmin, rect.ymin - block->rect.ymin); /* now recompute bounds and safety */ ui_block_bounds_calc(block); -- cgit v1.2.3