forked from Shinonome/dots-hyprland
left sidebar: bouncy command buttons
This commit is contained in:
@@ -14,12 +14,13 @@ Rectangle {
|
||||
default property alias content: rowLayout.data
|
||||
property real spacing: 5
|
||||
property real padding: 5
|
||||
property int clickIndex: rowLayout.clickIndex
|
||||
|
||||
property real contentWidth: {
|
||||
let total = 0;
|
||||
for (let i = 0; i < rowLayout.children.length; ++i) {
|
||||
if (rowLayout.children[i].baseWidth !== undefined)
|
||||
total += rowLayout.children[i].baseWidth;
|
||||
const child = rowLayout.children[i];
|
||||
total += child.baseWidth ?? child.implicitWidth ?? child.width;
|
||||
}
|
||||
return total + rowLayout.spacing * (rowLayout.children.length - 1);
|
||||
}
|
||||
@@ -27,23 +28,20 @@ Rectangle {
|
||||
topLeftRadius: rowLayout.children.length > 0 ? (rowLayout.children[0].radius + padding) :
|
||||
Appearance?.rounding?.small
|
||||
bottomLeftRadius: topLeftRadius
|
||||
topRightRadius: {
|
||||
console.log(rowLayout.children.length > 0 ? (rowLayout.children[rowLayout.children.length - 1].radius + padding) :
|
||||
Appearance?.rounding?.small)
|
||||
return rowLayout.children.length > 0 ? (rowLayout.children[rowLayout.children.length - 1].radius + padding) :
|
||||
Appearance?.rounding?.small
|
||||
}
|
||||
topRightRadius: rowLayout.children.length > 0 ? (rowLayout.children[rowLayout.children.length - 1].radius + padding) :
|
||||
Appearance?.rounding?.small
|
||||
bottomRightRadius: topRightRadius
|
||||
|
||||
color: "transparent"
|
||||
width: root.contentWidth + padding * 2
|
||||
implicitHeight: rowLayout.implicitHeight + padding * 2
|
||||
implicitWidth: root.contentWidth + padding * 2
|
||||
|
||||
children: [RowLayout {
|
||||
id: rowLayout
|
||||
anchors.fill: parent
|
||||
anchors.margins: root.padding
|
||||
spacing: root.spacing
|
||||
property int clickIndex: -1
|
||||
property int clickIndex: -1
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ Button {
|
||||
property real buttonRadius: Appearance?.rounding?.small ?? 4
|
||||
property real buttonRadiusPressed: buttonRadius
|
||||
property var altAction
|
||||
property bool bounce: true
|
||||
property real baseWidth: 40
|
||||
property real baseHeight: 40
|
||||
property real clickedWidth: baseWidth + 20
|
||||
@@ -23,8 +24,8 @@ Button {
|
||||
property int clickIndex: parentGroup?.clickIndex ?? -1
|
||||
|
||||
Layout.fillWidth: (clickIndex - 1 <= parentGroup.children.indexOf(button) && parentGroup.children.indexOf(button) <= clickIndex + 1)
|
||||
implicitWidth: button.down ? clickedWidth : baseWidth
|
||||
implicitHeight: button.down ? clickedHeight : baseHeight
|
||||
implicitWidth: (button.down && bounce) ? clickedWidth : baseWidth
|
||||
implicitHeight: (button.down && bounce) ? clickedHeight : baseHeight
|
||||
|
||||
Behavior on implicitWidth {
|
||||
animation: Appearance.animation.clickBounce.numberAnimation.createObject(this)
|
||||
|
||||
Reference in New Issue
Block a user