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:
@@ -109,19 +109,9 @@ Item {
|
||||
readonly property bool _focused: trigger.activeFocus
|
||||
readonly property bool _hot: triggerHover.hovered || root.hasCursor
|
||||
|
||||
color: trigger._focused
|
||||
? Style.focusFillFor(root.foreground, root.accent)
|
||||
: (trigger._hot
|
||||
? Style.hoverFillFor(root.foreground, root.accent)
|
||||
: Style.normalFillFor(root.foreground, root.accent))
|
||||
border.color: trigger._focused
|
||||
? Style.focusBorderFor(root.foreground, root.accent)
|
||||
: (trigger._hot
|
||||
? Style.hoverBorderFor(root.foreground, root.accent)
|
||||
: Style.normalBorderFor(root.foreground, root.accent))
|
||||
border.width: trigger._focused
|
||||
? Style.focusBorderWidth
|
||||
: (trigger._hot ? Style.hoverBorderWidth : Style.normalBorderWidth)
|
||||
color: Style.controlFill(trigger._focused, trigger._hot, root.foreground, root.accent)
|
||||
border.color: Style.controlBorder(trigger._focused, trigger._hot, root.foreground, root.accent)
|
||||
border.width: Style.controlBorderWidth(trigger._focused, trigger._hot)
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user