Repository navigation
fix(spinbox): redesign indicator background with combined container #752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| import QtQuick | ||
| import org.deepin.dtk 1.0 as D | ||
| import org.deepin.dtk.style 1.0 as DS | ||
| import org.deepin.dtk.private as P | ||
|
|
||
| Control { | ||
| id: control | ||
|
|
@@ -19,90 +18,61 @@ Control { | |
| property bool singleIndicator: false | ||
| property int direction | ||
| property D.Palette inactiveBackgroundColor: DS.Style.spinBox.indicator.background | ||
| property D.Palette indicatorBackground: DS.Style.spinBox.indicatorBackground | ||
| property D.Palette indicatorInnerShadow: DS.Style.spinBox.indicatorInnerShadow | ||
|
|
||
| palette.windowText: control.D.ColorSelector.inactiveBackgroundColor | ||
| // Background stays full opacity; only the icon dims when disabled. | ||
| hoverEnabled: true | ||
| implicitWidth: DS.Style.spinBox.indicator.width | ||
| implicitHeight: spinBox.activeFocus ? spinBox.implicitHeight / 2 : DS.Style.spinBox.indicator.height | ||
| opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1 | ||
| implicitHeight: (spinBox.implicitHeight - 2 * DS.Style.spinBox.indicatorContainerVMargin) / 2 | ||
|
|
||
| Component { | ||
| id: inactiveComponent | ||
| D.DciIcon { | ||
| id: icon | ||
| smooth: control.smooth | ||
| sourceSize.width: DS.Style.spinBox.indicator.iconSize | ||
| palette: D.DTK.makeIconPalette(control.palette) | ||
| name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "entry_spinbox_up" : "entry_spinbox_down" | ||
| mode: control.D.ColorSelector.controlState | ||
| theme: control.D.ColorSelector.controlTheme | ||
| fallbackToQIcon: false | ||
| } | ||
| } | ||
|
|
||
| Component { | ||
| id: activeComponent | ||
| Item { | ||
| Item { | ||
| id: btnBackground | ||
| width: parent.width + DS.Style.control.radius | ||
| height: parent.height + DS.Style.control.radius | ||
| anchors { | ||
| right: parent.right | ||
| top: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? parent.top : undefined | ||
| bottom: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? undefined : parent.bottom | ||
| } | ||
|
|
||
| Button { | ||
| id: btn | ||
| anchors { | ||
| right: parent.right | ||
| top: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? parent.top : undefined | ||
| bottom: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? undefined : parent.bottom | ||
| } | ||
| width: DS.Style.spinBox.indicatorWidth | ||
| height: spinBox.implicitHeight / 2 | ||
| icon { | ||
| name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "arrow_ordinary_up" : "arrow_ordinary_down" | ||
| width: DS.Style.spinBox.indicator.focusIconSize | ||
| height: DS.Style.spinBox.indicator.focusIconSize | ||
| } | ||
| activeFocusOnTab: false | ||
| opacity: 1 | ||
| background: P.ButtonPanel { | ||
| button: btn | ||
| radius: 0 | ||
| } | ||
| onClicked: { | ||
| if (direction === SpinBoxIndicator.IndicatorDirection.UpIndicator) { | ||
| spinBox.increase() | ||
| } else { | ||
| spinBox.decrease() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // Each indicator draws its own half of the combined background. | ||
| // The up indicator has rounded top corners; the down indicator has | ||
| // rounded bottom corners. Together they form a seamless whole with | ||
| // no overlap and no gap. | ||
| background: Rectangle { | ||
| radius: DS.Style.spinBox.indicatorContainerRadius | ||
| color: control.D.ColorSelector.indicatorBackground | ||
| topLeftRadius: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0 | ||
| topRightRadius: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0 | ||
| bottomLeftRadius: direction === SpinBoxIndicator.IndicatorDirection.DownIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0 | ||
| bottomRightRadius: direction === SpinBoxIndicator.IndicatorDirection.DownIndicator ? DS.Style.spinBox.indicatorContainerRadius : 0 | ||
|
|
||
| D.ItemViewport { | ||
| id: viewport | ||
| sourceItem: btnBackground | ||
| radius: DS.Style.control.radius | ||
| fixed: true | ||
| width: btnBackground.width | ||
| height: btnBackground.height | ||
| anchors { | ||
| right: parent.right | ||
| top: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? parent.top : undefined | ||
| bottom: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? undefined : parent.bottom | ||
| } | ||
| hideSource: true | ||
| Loader { | ||
| active: D.DTK.themeType === D.ApplicationHelper.DarkType && direction === SpinBoxIndicator.IndicatorDirection.DownIndicator | ||
| anchors.fill: parent | ||
| sourceComponent: BoxInsetShadow { | ||
| shadowBlur: 1 | ||
| shadowOffsetY: -1 | ||
| spread: 0 | ||
| shadowColor: control.D.ColorSelector.indicatorInnerShadow | ||
| cornerRadius: DS.Style.spinBox.indicatorContainerRadius | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Loader { | ||
| ToolButton { | ||
| opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1 | ||
| anchors.fill: parent | ||
| sourceComponent: spinBox.activeFocus ? activeComponent : inactiveComponent | ||
| topPadding: 0 | ||
| bottomPadding: 0 | ||
| leftPadding: 0 | ||
| rightPadding: 0 | ||
| focusPolicy: Qt.NoFocus | ||
| background: null | ||
| icon { | ||
| name: direction === SpinBoxIndicator.IndicatorDirection.UpIndicator ? "arrow_ordinary_up" : "arrow_ordinary_down" | ||
| width: DS.Style.spinBox.indicator.focusIconSize | ||
| height: DS.Style.spinBox.indicator.focusIconSize | ||
|
Comment on lines
+66
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Idle arrows render too small When the spin box is displayed, especially while it is not focused, Use the configured icon size for unfocused indicators and reserve Also at Prompt for AI agentsIn `qt6/src/qml/SpinBoxIndicator.qml` at lines 42-43:
**Idle arrows render too small**
When the spin box is displayed, especially while it is not focused, `Button.icon` always uses `focusIconSize` (10 px), replacing the unfocused 24 px source size; configured indicator icon sizes also no longer affect the control, so the arrows render too small.
Use the configured icon size for unfocused indicators and reserve `focusIconSize` for the focused state.
Also at `qt6/src/qml/SpinBoxIndicator.qml:30`. |
||
| } | ||
| activeFocusOnTab: false | ||
| onClicked: { | ||
| if (direction === SpinBoxIndicator.IndicatorDirection.UpIndicator) { | ||
| spinBox.increase() | ||
| } else { | ||
| spinBox.decrease() | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.