much nicer preview

This commit is contained in:
ari committed 2026-09-23 13:53:17 -04:00
1 parent d13bfda1f9
commit fbe56658b6
8 files changed
+311 -26

No files matched your search

+45 -9
View File
@@ -12,6 +12,8 @@ Item {
required property int workspaceId
// Shown and taking input. Fades and grows in when this turns on.
required property bool expanded
// Shown on the top edge of the front window, "" for none.
required property string exitHint
// A window was focused.
signal windowChosen
@@ -43,12 +45,27 @@ Item {
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;
const faceWidth = Math.abs(Math.cos(root.faceTurn(angle) * Math.PI / 180));
const edge = (root.radius * Math.sin(angle) + half * faceWidth) * depthScale;
widest = Math.max(widest, edge);
}
return widest;
}
// Top and bottom edges of the front window, from the middle of the view.
readonly property real frontTop: root.theme.loopBackLift / 2 - root.theme.loopCardHeight / 2
readonly property real frontBottom: root.theme.loopBackLift / 2 + root.theme.loopCardHeight / 2
// Where round the loop, in degrees, cards turn edge-on. Halfway between
// two cards, so none rests edge-on.
readonly property real flipAngle: {
if (root.count <= 1)
return 90;
const stepDegrees = 360 / root.count;
const flip = (Math.floor(root.theme.loopFlipAngle / stepDegrees) + 0.5) * stepDegrees;
return Math.min(flip, 180);
}
// 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
@@ -121,6 +138,19 @@ Item {
return steps * root.angleStep;
}
// How far a card at this angle (radians) turns, in degrees. It turns
// from facing the viewer at the front to edge-on at flipAngle, then on
// round to face the viewer again at the back, showing its inner face.
function faceTurn(angle: real): real {
const degrees = Math.abs(angle) * 180 / Math.PI;
const side = angle < 0 ? -1 : 1;
const flip = root.flipAngle;
if (degrees <= flip || flip >= 180)
return -side * 90 * degrees / flip;
const turn = 90 + 90 * (degrees - flip) / (180 - flip);
return -side * (turn - 180);
}
// Select the focused window, or the first one, and turn into place.
function seed(): void {
const list = root.windows;
@@ -197,14 +227,9 @@ Item {
readonly property real back: (1 - card.cosA) / 2
// Simple perspective: cards farther away get smaller.
readonly property real depthScale: root.theme.loopFocalLength / (root.theme.loopFocalLength + 2 * root.radius * card.back)
// Turn so each card lies along the loop. The front half
// shows the outer face, the back half the inner face.
readonly property real faceAngle: {
const degrees = card.angle * 180 / Math.PI;
if (card.cosA >= 0)
return -degrees;
return degrees > 0 ? 180 - degrees : -180 - degrees;
}
// Turn so each card roughly lies along the loop, less so
// at the sides, so they can still be seen.
readonly property real faceAngle: root.faceTurn(card.angle)
theme: root.theme
title: card.modelData.title
@@ -238,5 +263,16 @@ Item {
onActivated: root.activateAt(card.index)
}
}
// Under the front window. Cards stay below z 1.
KeyHint {
id: exitHintText
x: root.theme.loopCardWidth / 2 - exitHintText.width
y: root.theme.loopCardHeight / 2 + root.theme.hintGap
z: 2
theme: root.theme
hint: root.exitHint
shown: root.count > 0
}
}
}