This commit is contained in:
ari committed 2026-09-23 13:09:53 -04:00
1 parent 44d0491183
commit 8426b53251
7 files changed
+269 -100

No files matched your search

+52 -1
View File
@@ -32,12 +32,32 @@ Item {
return Math.max(root.theme.loopMinRadius, Math.min(natural, widest));
}
// About how far the loop reaches sideways from its center, card edges
// included. Sampled over the front half so it stays still while turning.
readonly property real reachX: {
const half = root.theme.loopCardWidth / 2;
if (root.count <= 1)
return half;
const focal = root.theme.loopFocalLength;
let widest = half;
for (let i = 1; i <= 16; i++) {
const angle = i / 16 * Math.PI / 2;
const depthScale = focal / (focal + root.radius * (1 - Math.cos(angle)));
const edge = (root.radius * Math.sin(angle) + half * Math.cos(angle)) * depthScale;
widest = Math.max(widest, edge);
}
return widest;
}
// Selected step. It is not wrapped, so the loop can keep turning the
// same way. Use selectedIndex for the position in the window list.
property int targetStep: 0
// Follows targetStep smoothly and drives every card position.
property real turn: 0
property bool animate: false
// Offset and fade of the loop while it slides in after a workspace switch.
property real slideY: 0
property real switchFade: 1
readonly property int selectedIndex: root.wrapIndex(root.targetStep)
@@ -65,6 +85,24 @@ Item {
}
}
ParallelAnimation {
id: switchAnim
NumberAnimation {
target: root
property: "slideY"
to: 0
duration: root.theme.loopSwitchDuration
easing.type: Easing.OutCubic
}
NumberAnimation {
target: root
property: "switchFade"
to: 1
duration: root.theme.loopSwitchDuration
}
}
function wrapIndex(step: int): int {
if (root.count === 0)
return 0;
@@ -96,6 +134,16 @@ Item {
root.compositor.takeScreenshots(list.map(w => w.key));
}
// Show another workspace. The new windows slide in from below when
// direction is positive, from above when negative.
function switchIn(direction: int): void {
switchAnim.stop();
root.slideY = direction * root.theme.loopSwitchOffset;
root.switchFade = 0;
root.seed();
switchAnim.start();
}
function step(delta: int): void {
if (root.count === 0)
return;
@@ -118,6 +166,8 @@ Item {
Text {
anchors.centerIn: parent
anchors.verticalCenterOffset: root.slideY
opacity: root.switchFade
visible: root.count === 0
color: root.theme.labelColor
font.pixelSize: root.theme.loopEmptySize
@@ -129,7 +179,8 @@ Item {
Item {
id: stage
anchors.centerIn: parent
anchors.verticalCenterOffset: root.theme.loopBackLift / 2
anchors.verticalCenterOffset: root.theme.loopBackLift / 2 + root.slideY
opacity: root.switchFade
Repeater {
model: root.windows