UI: Fix Vertical Jiggling of Category Tabs at Some Sizes

At some sizes (combination of Resolution Scale and local 2D scale) the
movement of sidebar regions can show their category tabs jiggling up
and down. This looks like the first tab moving up and down a single
pixel, the second tab moving by two, the third by three, etc. This is
because the calculation of the local "aspect" is using the block aspect
which can vary by a small amount and so at some sizes this difference
can straddle a pixel. This PR directly calculates the local aspect
based on the region sizes, which results in a stable value and
therefore fixes this glitch.

Pull Request: https://projects.blender.org/blender/blender/pulls/155729
This commit is contained in:
Nazir Galimov 2026-03-17 02:58:20 +01:00 • committed by Harley Acheson
parent df938d69e2
commit d2fe1d4302

View file

@ -1429,9 +1429,8 @@ void panel_category_tabs_draw_all(ARegion *region, const char *category_id_activ
fontstyle_set(fstyle);
const int fontid = fstyle->uifont_id;
float fstyle_points = fstyle->points;
const float aspect = BLI_listbase_is_empty(&region->runtime->uiblocks) ?
1.0f :
(static_cast<Block *>(region->runtime->uiblocks.first))->aspect;
const float aspect = BLI_rctf_size_y(&region->v2d.cur) /
(BLI_rcti_size_y(&region->v2d.mask) + 1);
const float zoom = 1.0f / aspect;
const int px = U.pixelsize;
const int category_tabs_width = round_fl_to_int(UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom);