enh(ui): ui::qt::parameters slider styling
Description
We recently started to use ui::qt::parameters
vertical sliders in toolbars.
As it currently stands, there are some styling issues with this:
Image | Description |
---|---|
Label and vertical alignment issues in toolbar. | |
Label alignment issues in ex_parameters . |
- The label is always on the left, which isn't what we want when using a vertical slider, it should be at the top or at the bottom. I'd prefer the top.
- The alignment of value labels is broken for
double
sliders. - When set in a
toolbar
(like here), the size is always at its minimum (it doesn't expand)
Functional specifications
a) The label should be at the top when using a vertical slider. We could hardcode that or give a generic XML attribute option label="top/bottom/left/right"
. I'd like to go with hard-coding first.
b) The value labels should be aligned, regardless of the type of the slider (this is probably just some setAlignment
that was forgotten). Nothing should be exposed in the public API to fix this.
c) It should be possible to add a minimum size for the individual widgets in parameters
. This could go in an XML attribute tag, like min_width
/ min_height
.
Technical specifications
a) Change how create_xx_slider_widget
functions generate the layout. Generally speaking, QGridLayout
is extremely hard to align. I'd go for QH/VboxLayout
for the slider and the labels/reset button surrounding it depending on the slider orientation (that way, no need to perform some logic to put the widgets differently in the grid...). Ideally, we really shouldn't use a QGridLayout
as a top-level layout. But I won't fix that here.
b) This should "just work" with the fix above.
c) slider->setMinimumHeight()
/ slider->setMinimumWidth()
or slider->setMinimumSize()
Test plan
- Split
ex_parameters
bottom left hand corner so that at least two vertical sliders are shown (this will allow confirming the alignment) - Test in application using
qt::parameters
in a toolbar if it looks better or not.