mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
fix(nspinbox): replace the diamond hover by a simple rounded rectangle, fixes a lot of small glitches
This commit is contained in:
+24
-128
@@ -135,80 +135,28 @@ RowLayout {
|
|||||||
Item {
|
Item {
|
||||||
id: decreaseButton
|
id: decreaseButton
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: leftSemicircle.width + (leftDiamondContainer.width / 2)
|
width: height
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
opacity: (root.enabled && root.value > root.from) || decreaseArea.containsMouse ? 1.0 : 0.3
|
opacity: (root.enabled && root.value > root.from) || decreaseArea.containsMouse ? 1.0 : 0.3
|
||||||
clip: true
|
|
||||||
|
|
||||||
Item {
|
Rectangle {
|
||||||
id: leftSemicircle
|
anchors.centerIn: parent
|
||||||
width: Math.round(parent.height / 2)
|
width: parent.height
|
||||||
height: parent.height
|
height: width
|
||||||
clip: true
|
radius: spinBoxContainer.radius
|
||||||
anchors.left: parent.left
|
color: Color.mHover
|
||||||
Rectangle {
|
opacity: decreaseArea.containsMouse ? 1.0 : 0.0
|
||||||
width: Math.round(parent.height)
|
Behavior on opacity {
|
||||||
height: parent.height
|
NumberAnimation {
|
||||||
radius: Math.min(Style.iRadiusL, width / 2)
|
duration: Style.animationFast
|
||||||
anchors.left: parent.left
|
|
||||||
color: decreaseArea.containsMouse ? Color.mHover : "transparent"
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Style.animationFast
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
|
||||||
id: leftDiamondContainer
|
|
||||||
|
|
||||||
height: Math.round(parent.height / 2) * 2
|
|
||||||
width: height * Math.sqrt(2)
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.horizontalCenter: leftSemicircle.right
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: leftDiamondVisual
|
|
||||||
width: 100
|
|
||||||
height: 100
|
|
||||||
radius: width / 4
|
|
||||||
|
|
||||||
color: decreaseArea.containsMouse ? Color.mHover : "transparent"
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Style.animationFast
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
transform: [
|
|
||||||
Rotation {
|
|
||||||
angle: 45
|
|
||||||
origin.x: 50
|
|
||||||
origin.y: 50
|
|
||||||
},
|
|
||||||
Scale {
|
|
||||||
id: leftScaler
|
|
||||||
origin.x: 50
|
|
||||||
origin.y: 50
|
|
||||||
|
|
||||||
// This is the full formula for the height of the rotated, rounded square
|
|
||||||
readonly property real trueHeight: (leftDiamondVisual.width - 2 * leftDiamondVisual.radius) * Math.sqrt(2) + (2 * leftDiamondVisual.radius)
|
|
||||||
xScale: leftDiamondContainer.height / leftScaler.trueHeight
|
|
||||||
yScale: leftDiamondContainer.height / leftScaler.trueHeight
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NIcon {
|
NIcon {
|
||||||
anchors.left: parent.left
|
anchors.centerIn: parent
|
||||||
anchors.leftMargin: parent.width * 0.25
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
icon: "chevron-left"
|
icon: "chevron-left"
|
||||||
pointSize: Style.fontSizeS
|
pointSize: Style.fontSizeS
|
||||||
color: decreaseArea.containsMouse ? Color.mOnHover : Color.mPrimary
|
color: decreaseArea.containsMouse ? Color.mOnHover : Color.mPrimary
|
||||||
@@ -234,80 +182,28 @@ RowLayout {
|
|||||||
Item {
|
Item {
|
||||||
id: increaseButton
|
id: increaseButton
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: rightSemicircle.width + (rightDiamondContainer.width / 2)
|
width: height
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
opacity: (root.enabled && root.value < root.to) || increaseArea.containsMouse ? 1.0 : 0.3
|
opacity: (root.enabled && root.value < root.to) || increaseArea.containsMouse ? 1.0 : 0.3
|
||||||
clip: true
|
|
||||||
|
|
||||||
Item {
|
Rectangle {
|
||||||
id: rightSemicircle
|
anchors.centerIn: parent
|
||||||
width: Math.round(parent.height / 2)
|
width: parent.height
|
||||||
height: parent.height
|
height: width
|
||||||
clip: true
|
radius: spinBoxContainer.radius
|
||||||
anchors.right: parent.right
|
color: Color.mHover
|
||||||
Rectangle {
|
opacity: increaseArea.containsMouse ? 1.0 : 0.0
|
||||||
width: Math.round(parent.height)
|
Behavior on opacity {
|
||||||
height: parent.height
|
NumberAnimation {
|
||||||
radius: Math.min(Style.iRadiusL, width / 2)
|
duration: Style.animationFast
|
||||||
anchors.right: parent.right
|
|
||||||
color: increaseArea.containsMouse ? Color.mHover : "transparent"
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Style.animationFast
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
|
||||||
id: rightDiamondContainer
|
|
||||||
|
|
||||||
height: Math.round(parent.height / 2) * 2
|
|
||||||
width: height * Math.sqrt(2)
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.horizontalCenter: rightSemicircle.left
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: rightDiamondVisual
|
|
||||||
width: 100
|
|
||||||
height: 100
|
|
||||||
radius: width / 4
|
|
||||||
|
|
||||||
color: increaseArea.containsMouse ? Color.mHover : "transparent"
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Style.animationFast
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
transform: [
|
|
||||||
Rotation {
|
|
||||||
angle: 45
|
|
||||||
origin.x: 50
|
|
||||||
origin.y: 50
|
|
||||||
},
|
|
||||||
Scale {
|
|
||||||
id: rightScaler
|
|
||||||
origin.x: 50
|
|
||||||
origin.y: 50
|
|
||||||
|
|
||||||
// This is the full formula for the height of the rotated, rounded square
|
|
||||||
readonly property real trueHeight: (rightDiamondVisual.width - 2 * rightDiamondVisual.radius) * Math.sqrt(2) + (2 * rightDiamondVisual.radius)
|
|
||||||
xScale: rightDiamondContainer.height / rightScaler.trueHeight
|
|
||||||
yScale: rightDiamondContainer.height / rightScaler.trueHeight
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NIcon {
|
NIcon {
|
||||||
anchors.right: parent.right
|
anchors.centerIn: parent
|
||||||
anchors.rightMargin: parent.width * 0.25
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
icon: "chevron-right"
|
icon: "chevron-right"
|
||||||
pointSize: Style.fontSizeS
|
pointSize: Style.fontSizeS
|
||||||
color: increaseArea.containsMouse ? Color.mOnHover : Color.mPrimary
|
color: increaseArea.containsMouse ? Color.mOnHover : Color.mPrimary
|
||||||
|
|||||||
Reference in New Issue
Block a user