[Bf-blender-cvs] [34e749b] master: Fix popup menu glitch, scrolling at high dpi
Campbell Barton
noreply at git.blender.org
Fri Oct 16 15:40:11 CEST 2015
Commit: 34e749beef0e0ece7ee857207358aac1fd3e59bc
Author: Campbell Barton
Date: Sat Oct 17 00:23:57 2015 +1100
Branches: master
https://developer.blender.org/rB34e749beef0e0ece7ee857207358aac1fd3e59bc
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.
===================================================================
M source/blender/editors/interface/interface.c
===================================================================
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 7802161..ff92ddb 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);
More information about the Bf-blender-cvs
mailing list