diff options
author | Julian Eisel <julian@blender.org> | 2021-11-12 20:23:44 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-11-12 20:23:44 +0300 |
commit | 8a8bf99717117ae4aa96b1efcd8327fe59f44e5c (patch) | |
tree | 60ce9b018534bc5a1409835f1c0090edc0af3bda /source/blender/editors/interface/interface.c | |
parent | a89529d8dbecffa663b3c23c621354f61e2ea292 (diff) | |
parent | 2b394e1108281bcfe6602b08b3e9cd230003d22b (diff) |
Merge remote-tracking branch 'origin/blender-v3.0-release'
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 82ea218baba..9e761d0d07a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2022,6 +2022,13 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *region, uiBlock *bloc BLI_rcti_translate(rect, -region->winrct.xmin, -region->winrct.ymin); } +static bool ui_but_pixelrect_in_view(const ARegion *region, const rcti *rect) +{ + rcti rect_winspace = *rect; + BLI_rcti_translate(&rect_winspace, region->winrct.xmin, region->winrct.ymin); + return BLI_rcti_isect(®ion->winrct, &rect_winspace, NULL); +} + /* uses local copy of style, to scale things down, and allow widgets to change stuff */ void UI_block_draw(const bContext *C, uiBlock *block) { @@ -2095,14 +2102,20 @@ void UI_block_draw(const bContext *C, uiBlock *block) /* widgets */ LISTBASE_FOREACH (uiBut *, but, &block->buttons) { - if (!(but->flag & (UI_HIDDEN | UI_SCROLLED))) { - ui_but_to_pixelrect(&rect, region, block, but); + if (but->flag & (UI_HIDDEN | UI_SCROLLED)) { + continue; + } - /* XXX: figure out why invalid coordinates happen when closing render window */ - /* and material preview is redrawn in main window (temp fix for bug T23848) */ - if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) { - ui_draw_but(C, region, &style, but, &rect); - } + ui_but_to_pixelrect(&rect, region, block, but); + /* Optimization: Don't draw buttons that are not visible (outside view bounds). */ + if (!ui_but_pixelrect_in_view(region, &rect)) { + continue; + } + + /* XXX: figure out why invalid coordinates happen when closing render window */ + /* and material preview is redrawn in main window (temp fix for bug T23848) */ + if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) { + ui_draw_but(C, region, &style, but, &rect); } } |