From d256ec9d2405416c7a8a26862fa2196f13dabb6b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Oct 2010 14:17:28 +0000 Subject: [PATCH] bugfix [#23311] Half a colour picker appears all popups which are positioned based on an existing button are now clamped to window bounds. --- source/blender/editors/interface/interface_regions.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 50b85360196..ff079a4b9e0 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1116,6 +1116,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if(but) { int left=0, right=0, top=0, down=0; int winx, winy; + int offscreen; wm_window_get_size(window, &winx, &winy); @@ -1206,6 +1207,12 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, // apply requested offset in the block xof += block->xofs/block->aspect; yof += block->yofs/block->aspect; + + /* clamp to window bounds, could be made into an option if its ever annoying */ + if( (offscreen= (block->miny+yof)) < 0) yof -= offscreen; /* bottom */ + else if((offscreen= (block->maxy+yof)-winy) > 0) yof -= offscreen; /* top */ + if( (offscreen= (block->minx+xof)) < 0) xof -= offscreen; /* left */ + else if((offscreen= (block->maxx+xof)-winx) > 0) xof -= offscreen; /* right */ } /* apply */