diff options
author | Yevgeny Makarov <jenkm> | 2020-02-28 17:58:14 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-02-28 18:03:53 +0300 |
commit | fe3ce615287ae8c6fa5694c03a07d8699d7c8aff (patch) | |
tree | fc8b07118c4e916a36a75713eb1712b089d1cc71 /source | |
parent | 0cea9353fdfef4ae736d9894e4f6a0a8cef99619 (diff) |
Fix T65351: visual glitches when scrolling in popovers
Diffstat (limited to 'source')
4 files changed, 30 insertions, 20 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 8fc73327432..4183f9226d9 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9197,24 +9197,27 @@ static char ui_menu_scroll_test(uiBlock *block, int my) static void ui_menu_scroll_apply_offset_y(ARegion *ar, uiBlock *block, float dy) { BLI_assert(dy != 0.0f); - if (dy < 0.0f) { - /* stop at top item, extra 0.5 unit Y makes it snap nicer */ - float ymax = -FLT_MAX; - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { - ymax = max_ff(ymax, bt->rect.ymax); - } - if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) { - dy = block->rect.ymax - ymax - UI_MENU_SCROLL_PAD; - } - } - else { - /* stop at bottom item, extra 0.5 unit Y makes it snap nicer */ - float ymin = FLT_MAX; - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { - ymin = min_ff(ymin, bt->rect.ymin); + + if (ui_block_is_menu(block)) { + if (dy < 0.0f) { + /* Stop at top item, extra 0.5 UI_UNIT_Y makes it snap nicer. */ + float ymax = -FLT_MAX; + for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + ymax = max_ff(ymax, bt->rect.ymax); + } + if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) { + dy = block->rect.ymax - ymax - UI_MENU_SCROLL_PAD; + } } - if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) { - dy = block->rect.ymin - ymin + UI_MENU_SCROLL_PAD; + else { + /* Stop at bottom item, extra 0.5 UI_UNIT_Y makes it snap nicer. */ + float ymin = FLT_MAX; + for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + ymin = min_ff(ymin, bt->rect.ymin); + } + if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) { + dy = block->rect.ymin - ymin + UI_MENU_SCROLL_PAD; + } } } diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c index 2042c15ed96..bfd33a69b3b 100644 --- a/source/blender/editors/interface/interface_region_popover.c +++ b/source/blender/editors/interface/interface_region_popover.c @@ -111,7 +111,7 @@ static void ui_popover_create_block(bContext *C, uiPopover *pup, int opcontext) 0, pup->ui_size_x, 0, - UI_MENU_PADDING, + 0, style); uiLayoutSetOperatorContext(pup->layout, opcontext); diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index b509f5e352b..462f4871764 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -706,6 +706,15 @@ uiBlock *ui_popup_block_refresh(bContext *C, } } else { + /* Add an offset to draw the popover arrow. */ + if ((block->flag & UI_BLOCK_POPOVER) && ELEM(block->direction, UI_DIR_UP, UI_DIR_DOWN)) { + /* Keep sync with 'ui_draw_popover_back_impl'. */ + const float unit_size = U.widget_unit / block->aspect; + const float unit_half = unit_size * (block->direction == UI_DIR_DOWN ? 0.5 : -0.5); + + UI_block_translate(block, 0, -unit_half); + } + /* clip block with window boundary */ ui_popup_block_clip(window, block); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 92032c3b18c..8c28b29f5ab 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -4970,8 +4970,6 @@ static void ui_draw_popover_back_impl(const uiWidgetColors *wcol, rect->xmin + unit_size, rect->xmax - unit_size) : BLI_rcti_cent_x(rect); - rect->ymax -= unit_half; - rect->ymin += unit_half; GPU_blend(true); |