Fix T60358: popup clipping within window

Moving menu contents wasn't working properly.
This commit is contained in:
Campbell Barton 2019-01-10 11:18:18 +11:00
parent 5100e4419e
commit f974a02285
Notes: blender-bot 2023-02-14 10:29:30 +01:00
Referenced by issue #61142, Hair brushes doesn't work Blender 2.79 Particle edit mode
Referenced by issue #60358, Preferences
1 changed files with 14 additions and 12 deletions

View File

@ -356,8 +356,8 @@ static void ui_block_region_popup_window_listener(
static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
{
uiBut *bt;
float xofs = 0.0f;
int width = UI_SCREEN_MARGIN;
const float xmin_orig = block->rect.xmin;
const int margin = UI_SCREEN_MARGIN;
int winx, winy;
if (block->flag & UI_BLOCK_NO_WIN_CLIP) {
@ -367,30 +367,32 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
winx = WM_window_pixels_x(window);
winy = WM_window_pixels_y(window);
/* shift menus to right if outside of view */
if (block->rect.xmin < width) {
xofs = (width - block->rect.xmin);
/* shift to left if outside of view */
if (block->rect.xmax > winx - margin) {
const float xofs = winx - margin - block->rect.xmax;
block->rect.xmin += xofs;
block->rect.xmax += xofs;
}
/* or shift to left if outside of view */
if (block->rect.xmax > winx - width) {
xofs = winx - width - block->rect.xmax;
/* shift menus to right if outside of view */
if (block->rect.xmin < margin) {
const float xofs = (margin - block->rect.xmin);
block->rect.xmin += xofs;
block->rect.xmax += xofs;
}
if (block->rect.ymin < width)
block->rect.ymin = width;
if (block->rect.ymax > winy - UI_POPUP_MENU_TOP)
if (block->rect.ymin < margin) {
block->rect.ymin = margin;
}
if (block->rect.ymax > winy - UI_POPUP_MENU_TOP) {
block->rect.ymax = winy - UI_POPUP_MENU_TOP;
}
/* ensure menu items draw inside left/right boundary */
const float xofs = block->rect.xmin - xmin_orig;
for (bt = block->buttons.first; bt; bt = bt->next) {
bt->rect.xmin += xofs;
bt->rect.xmax += xofs;
}
}
void ui_popup_block_scrolltest(uiBlock *block)