Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-10-16 16:23:57 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-16 16:31:11 +0300
commit34e749beef0e0ece7ee857207358aac1fd3e59bc (patch)
treebf66da93612a8da640afea5b07a9aacd4ad348c8
parentb6b15f07a1307c34db63c32d706656084353fa1d (diff)
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.
-rw-r--r--source/blender/editors/interface/interface.c37
1 files 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);