window cycle
This commit is contained in:
1 parent
3aa8a8a455
commit
60afd11cda
3 files changed
+100
-52
No files matched your search
@@ -164,9 +164,8 @@ PanelWindow {
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: root.theme.rowSpacing
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
model: root.rows
|
||||
@@ -181,6 +180,23 @@ PanelWindow {
|
||||
selectedIndex: index === root.selectedRow ? root.selectedCol : -1
|
||||
live: root.visible
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.verticalCenterOffset: (index - root.selectedRow) * root.theme.carouselStepY
|
||||
opacity: 1 - Math.min(Math.abs(index - root.selectedRow) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||
scale: 1 - Math.min(Math.abs(index - root.selectedRow) * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||
|
||||
Behavior on anchors.verticalCenterOffset {
|
||||
NumberAnimation { duration: root.theme.carouselDuration; easing.type: Easing.OutCubic }
|
||||
}
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
|
||||
onCardClicked: colIndex => {
|
||||
root.selectedRow = index;
|
||||
root.selectedCol = colIndex;
|
||||
|
||||
@@ -10,5 +10,15 @@ QtObject {
|
||||
readonly property real cornerRadius: 10
|
||||
readonly property real cardHeight: 180
|
||||
readonly property real cardSpacing: 20
|
||||
readonly property real rowSpacing: 28
|
||||
|
||||
// Carousel layout: fixed step distances between slots on each axis, and
|
||||
// per-step falloff for opacity/scale as items recede from the centered
|
||||
// (selected) slot.
|
||||
readonly property real carouselStepX: cardHeight * 2.6 + cardSpacing
|
||||
readonly property real carouselStepY: cardHeight + 70
|
||||
readonly property real carouselFadeStep: 0.35
|
||||
readonly property real carouselMaxFade: 0.85
|
||||
readonly property real carouselScaleStep: 0.08
|
||||
readonly property real carouselMaxScaleReduction: 0.3
|
||||
readonly property int carouselDuration: 220
|
||||
}
|
||||
@@ -11,61 +11,83 @@ Item {
|
||||
|
||||
signal cardClicked(int index)
|
||||
|
||||
implicitWidth: content.implicitWidth
|
||||
implicitHeight: content.implicitHeight
|
||||
// Slot cards are centered on when nothing in this row is selected (e.g.
|
||||
// it's not the active row), so an inactive row still reads as centered.
|
||||
readonly property int centerIndex: selectedIndex >= 0 ? selectedIndex : Math.floor((toplevels.length - 1) / 2)
|
||||
|
||||
Column {
|
||||
id: content
|
||||
spacing: root.theme.cardSpacing * 0.5
|
||||
height: label.implicitHeight + theme.cardSpacing * 0.5 + theme.cardHeight
|
||||
|
||||
Text {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Workspace " + (root.workspace ? root.workspace.id : "?")
|
||||
color: root.theme.textColor
|
||||
font.pixelSize: 14
|
||||
font.bold: root.workspace && root.workspace.active
|
||||
Text {
|
||||
id: label
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: "Workspace " + (root.workspace ? root.workspace.id : "?")
|
||||
color: root.theme.textColor
|
||||
font.pixelSize: 14
|
||||
font.bold: root.workspace && root.workspace.active
|
||||
}
|
||||
|
||||
Item {
|
||||
id: cardArea
|
||||
anchors.top: label.bottom
|
||||
anchors.topMargin: root.theme.cardSpacing * 0.5
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: root.theme.cardHeight
|
||||
|
||||
Repeater {
|
||||
model: root.toplevels
|
||||
|
||||
WindowCard {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
toplevel: modelData
|
||||
selected: index === root.selectedIndex
|
||||
live: root.live
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.horizontalCenterOffset: (index - root.centerIndex) * root.theme.carouselStepX
|
||||
opacity: 1 - Math.min(Math.abs(index - root.centerIndex) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||
scale: 1 - Math.min(Math.abs(index - root.centerIndex) * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||
|
||||
Behavior on anchors.horizontalCenterOffset {
|
||||
NumberAnimation { duration: root.theme.carouselDuration; easing.type: Easing.OutCubic }
|
||||
}
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
|
||||
onActivated: root.cardClicked(index)
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: root.theme.cardSpacing
|
||||
// Placeholder for an empty workspace so the row stays visible
|
||||
// and selectable even with no windows.
|
||||
Rectangle {
|
||||
visible: root.toplevels.length === 0
|
||||
anchors.centerIn: parent
|
||||
width: root.theme.cardHeight * 1.6
|
||||
height: root.theme.cardHeight
|
||||
radius: root.theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.width: root.selectedIndex === 0 ? 3 : 1
|
||||
border.color: root.selectedIndex === 0 ? root.theme.selectedBorder : root.theme.cardBorder
|
||||
|
||||
Repeater {
|
||||
model: root.toplevels
|
||||
|
||||
WindowCard {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
toplevel: modelData
|
||||
selected: index === root.selectedIndex
|
||||
live: root.live
|
||||
|
||||
onActivated: root.cardClicked(index)
|
||||
}
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Empty"
|
||||
color: root.theme.emptyTextColor
|
||||
}
|
||||
|
||||
// Placeholder for an empty workspace so the row stays visible
|
||||
// and selectable even with no windows.
|
||||
Rectangle {
|
||||
visible: root.toplevels.length === 0
|
||||
width: root.theme.cardHeight * 1.6
|
||||
height: root.theme.cardHeight
|
||||
radius: root.theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.width: root.selectedIndex === 0 ? 3 : 1
|
||||
border.color: root.selectedIndex === 0 ? root.theme.selectedBorder : root.theme.cardBorder
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "Empty"
|
||||
color: root.theme.emptyTextColor
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.cardClicked(0)
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.cardClicked(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user