This patch improves the scaling of some ui elemenwidgets when zooming by
making the radius of the rounded corners dependent on the element's
sizescale.
This improvement is most noticeable in the node editor.
---
| **master** | **patch** |
|------------|-----------|
| {F11019420} | {F11019425} |
**Issue**
Most UI widgets have a fixed corner radius based on the constant
`U.widget_unit` that is scaled by the `roundness` defined in the theme.
This means that, when the size of these widgets changes (e.g. when
zooming into nodes or scaling regions with `ctrl + mousewheel`) the
absolute corner radius in screen space stays the same, but changes
relatively to the element.
**Approach**
Instead of a constant corner radius, the corner rounding can usuallyshould be
be inferred fromscaled by the widgets height. This is an small change and simply`aspect` of the block the widget is in.
replaces `U.widget_unit` for `BLI_recti_size_y`, when calculating the
corner radius.
In most parts of the UI it shouldwon't make a difference.
These are the widgets that are updated in this patch:
- **menu buttons** using `widget_menubut` !!Breaks the brush layout!!
- **text fields** using `widget_textbut`In principle this approach should work for all widgets, but there are
- **menu buttons** using `widget_menuiconbut`some that don't have access to the `aspect` or have a special shape
- **UI list items** using `widget_list_itembut`
- **radio buttons** using `widget_radiobut`
- **regular buttons** using `widget_but`
**Side Effects**(like the scrollbars) where basing it on `U.widget_unit` wouldn't
I still have to check mormake sense. Those widgets use areas of blender to see weather there are unchanged and calculate the
some unintended side effects of this change.
Another area I found where this changes things is the header in the file
browser that scaled by a factor of 1.3, which means the updated widgets
would have a larger corner radius than the rest of the UI.
So any part of the UI (e.g.corner radius based on the height on the element, add-ons) where scaling is used to increase
the button size of elements would result in larger rounded corners.
The change is subtle but visible when flipping between the images:
| **master** | **patch** |
|------------|-----------|which works
| {F11019460} | {F11019462} |
---with any zoom level.
**Excluded Widgets****Limitations**
There are some other widgets that are in scalable regions and could useCurrently panel corners and popovers stay with a fixed (in screen
updating.space) corner radius, But doing so is a bit more involved so I excludedthat doesn't adjust to them for now zoom.
- **operator buttons** using `widget_roundbut`: the `widget_roundbut`
draw function is also used by the tool bar in the viewport that is
generally wider. Making the corner radius dependent on the button
size increases the rounding of those buttons relative to all other**Side Effects**
UI elements, which looks weird.I still have to check more areas of blender to see whether I missed
We could split this into their own function in another patch.
- **color field** using `widgetbase_draw`: this would be nice to update,
because there are quite a few nodes that use the color field, but the
color picker seems to be using the `widgetbase` draw function.
`widgetbase_draw` is also used to draw the pulldown menu backdrop,
layout boxes and UI lists.something, Those can have wildly varying sizes and
therefore the heuristic of using the rectangle height to deduce thebut so far I haven't found any unintended side effects.
corner radius doesn't work.