Collapse focus/hover/normal ternaries into Style.controlFill helpers
TextField, NumberField, Dropdown, SearchableDropdown, and Toggle all painted their background, border color, and border width with the same three-line ternary ladder (`_focused ? focusFill : _hot ? hoverFill : normalFill`). Five components × three properties × three branches is a lot of room for one of them to drift from the others when a new state ever gets added. Add controlFill / controlBorder / controlBorderWidth on Style and rewrite each call site as a single binding. No visual change.
This commit is contained in:
+3
-13
@@ -53,19 +53,9 @@ Rectangle {
|
||||
|
||||
readonly property bool _hot: hasCursor || mouse.containsMouse
|
||||
|
||||
color: activeFocus
|
||||
? Style.focusFillFor(foreground, accent)
|
||||
: (_hot
|
||||
? Style.hoverFillFor(foreground, accent)
|
||||
: Style.normalFillFor(foreground, accent))
|
||||
border.color: activeFocus
|
||||
? Style.focusBorderFor(foreground, accent)
|
||||
: (_hot
|
||||
? Style.hoverBorderFor(foreground, accent)
|
||||
: Style.normalBorderFor(foreground, accent))
|
||||
border.width: activeFocus
|
||||
? Style.focusBorderWidth
|
||||
: (_hot ? Style.hoverBorderWidth : Style.normalBorderWidth)
|
||||
color: Style.controlFill(activeFocus, _hot, foreground, accent)
|
||||
border.color: Style.controlBorder(activeFocus, _hot, foreground, accent)
|
||||
border.width: Style.controlBorderWidth(activeFocus, _hot)
|
||||
|
||||
Behavior on color { ColorAnimation { duration: 100 } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user