diff options
author | Leon Schittek <leon.schittek@gmx.net> | 2022-04-01 07:51:22 +0300 |
---|---|---|
committer | Leon Schittek <leon.schittek@gmx.net> | 2022-04-01 07:51:22 +0300 |
commit | aab9047f9d6234dc4e692cb062541f85c80cc64e (patch) | |
tree | ab5120a559362d21a95de6fe721a1d5e62954e47 /source/blender/editors | |
parent | 42853bacc9734f6559d8429b2001039e81d11c17 (diff) |
Fix T88785: Keep value slider from clipping
Keep the value slider from clipping through rounded corners for
low values by ensuring the width of the slider rectangle is at least
twice the corner radius.
Reviewed By: Hans Goudey
Differential Revision: https://developer.blender.org/D11474
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 23883feed71..ca07c97b987 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -3801,21 +3801,24 @@ static void widget_numslider( const float width = (float)BLI_rcti_size_x(rect); factor_ui = factor * width; + /* The rectangle width needs to be at least twice the corner radius for the round corners + * to be drawn properly. */ + const float min_width = 2.0f * ofs; - if (factor_ui <= ofs) { - /* Left part only. */ - roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); - rect1.xmax = rect1.xmin + ofs; - factor_discard = factor_ui / ofs; + if (factor_ui > width - ofs) { + /* Left part + middle part + right part. */ + factor_discard = factor; } - else if (factor_ui <= width - ofs) { + else if (factor_ui > min_width) { /* Left part + middle part. */ roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); rect1.xmax = rect1.xmin + factor_ui; } else { - /* Left part + middle part + right part. */ - factor_discard = factor; + /* Left part */ + roundboxalign_slider &= ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT); + rect1.xmax = rect1.xmin + min_width; + factor_discard = factor_ui / min_width; } round_box_edges(&wtb1, roundboxalign_slider, &rect1, ofs); |