Skip to content

Commit

Permalink
Change style to look more like the spinbox from QtQuick.Controls1
Browse files Browse the repository at this point in the history
This leaves more real estate for the numbers and addresses a reviewer
feedback where the down button overlapped with the number.

Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Feb 6, 2025
1 parent 8eae434 commit 7330c06
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions include/gz/gui/qml/GzSpinBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Item {
anchors.fill : parent
bottomPadding: 0
topPadding: 0
leftPadding: 5
implicitHeight: 40
clip: true

Expand Down Expand Up @@ -93,12 +94,43 @@ Item {
contentItem: TextInput {
font.pointSize: 10
text: spinBox.textFromValue(spinBox.value, spinBox.locale)
horizontalAlignment: Qt.AlignHCenter
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
readOnly: !spinBox.editable
validator: spinBox.validator
inputMethodHints: Qt.ImhFormattedNumbersOnly
selectByMouse: true
clip: true
}

up.indicator: Rectangle {
x: spinBox.mirrored ? 0 : parent.width - width
implicitWidth: 20
implicitHeight: 20
color: "transparent"

Text {
text: ""
opacity: spinBox.up.pressed ? 1: 0.6
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignBottom
}
}
down.indicator: Rectangle {
x: spinBox.mirrored ? 0 : parent.width - width
y: 20
implicitWidth: 20
implicitHeight: 20
color: "transparent"

Text {
text: ""
opacity: spinBox.down.pressed ? 1: 0.6
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop
}
}

validator: DoubleValidator {
Expand All @@ -117,9 +149,9 @@ Item {
}

background: Rectangle {
implicitWidth: 70
implicitWidth: 40
implicitHeight: parent.implicitHeight
border.color: "gray"
}
}
}
}

0 comments on commit 7330c06

Please sign in to comment.