This patch improves the scaling of some ui elements when zooming by
making the radius of the rounded corners dependent on the element's
size.
This improvement is most notable 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 widget 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 usually
be inferred from the widgets height. This is an small change and simply
replaces `U.widget_unit` for `BLI_recti_size_y`, when calculating the
corner radius.
In most parts of the UI it shouldn't make a difference.
These are the widgets that are updated in this patch:
- **menu buttons** using `widget_menubut`
- **text fields** using `widget_textbut`
- **menu buttons** using `widget_menuiconbut`
- **UI list items** using `widget_list_itembut`
- **radio buttons** using `widget_radiobut`
- **regular buttons** using `widget_but`
**Side Effects**
I still have to check more areas of blender to see weather there are
some unintended side effects of this change, but so far it seems fine.
The one 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. 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** |
|------------|-----------|
| {F11019460} | {F11019462} |
---
**Excluded Widgets**
There are some other widgets that are in scalable regions and could use
updating. But doing so is a bit more involved so I excluded them for now.
- **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
UI elements, which looks weird.
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. Those can have wildly varying sizes and
therefore the heuristic of using the rectangle height to deduce the
corner radius doesn't work.