mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
homescreens/folio: Add fade, stack, rotation transitions
This commit is contained in:
parent
fa8aa6e85f
commit
da142b608c
3 changed files with 73 additions and 19 deletions
|
|
@ -28,6 +28,9 @@ public:
|
||||||
enum PageTransitionEffect {
|
enum PageTransitionEffect {
|
||||||
SlideTransition = 0,
|
SlideTransition = 0,
|
||||||
CubeTransition = 1,
|
CubeTransition = 1,
|
||||||
|
FadeTransition = 2,
|
||||||
|
StackTransition = 3,
|
||||||
|
RotationTransition = 4,
|
||||||
};
|
};
|
||||||
Q_ENUM(PageTransitionEffect)
|
Q_ENUM(PageTransitionEffect)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,28 +39,76 @@ MouseArea {
|
||||||
readonly property real positionX: root.width * index + Folio.HomeScreenState.pageViewX
|
readonly property real positionX: root.width * index + Folio.HomeScreenState.pageViewX
|
||||||
readonly property real progressToCenter: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width))
|
readonly property real progressToCenter: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width))
|
||||||
|
|
||||||
opacity: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width))
|
visible: opacity > 0
|
||||||
|
opacity: {
|
||||||
|
switch (Folio.FolioSettings.pageTransitionEffect) {
|
||||||
|
case Folio.FolioSettings.StackTransition:
|
||||||
|
return (positionX < 0) ? progressToCenter :
|
||||||
|
((progressToCenter < 0.3) ? 0 : ((1 / 0.7) * (progressToCenter - 0.3)))
|
||||||
|
default:
|
||||||
|
return progressToCenter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// x position of page
|
// x position of page
|
||||||
transform: [
|
transform: {
|
||||||
Translate {
|
switch (Folio.FolioSettings.pageTransitionEffect) {
|
||||||
x: homeScreenPage.positionX
|
case Folio.FolioSettings.SlideTransition:
|
||||||
},
|
return [translate];
|
||||||
Rotation {
|
case Folio.FolioSettings.CubeTransition:
|
||||||
origin.x: (positionX < 0) ?
|
return [translate, cubeTransitionRotation];
|
||||||
(Folio.HomeScreenState.pageWidth / 2) * homeScreenPage.progressToCenter :
|
case Folio.FolioSettings.FadeTransition:
|
||||||
(Folio.HomeScreenState.pageWidth / 2) + (Folio.HomeScreenState.pageWidth / 2) * (1 - homeScreenPage.progressToCenter);
|
return [];
|
||||||
origin.y: Folio.HomeScreenState.pageHeight / 2;
|
case Folio.FolioSettings.StackTransition:
|
||||||
axis { x: 0; y: 1; z: 0 }
|
return [stackScale, stackTranslate];
|
||||||
angle: {
|
case Folio.FolioSettings.RotationTransition:
|
||||||
if (Folio.FolioSettings.pageTransitionEffect !== Folio.FolioSettings.CubeTransition) {
|
return [translate, rotationTransitionRotation];
|
||||||
return 0;
|
default:
|
||||||
}
|
return [translate];
|
||||||
|
|
||||||
return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
|
||||||
|
Translate {
|
||||||
|
id: translate
|
||||||
|
x: homeScreenPage.positionX
|
||||||
|
}
|
||||||
|
|
||||||
|
Scale {
|
||||||
|
id: stackScale
|
||||||
|
origin.x: Folio.HomeScreenState.pageWidth / 2
|
||||||
|
origin.y: Folio.HomeScreenState.pageHeight / 2
|
||||||
|
xScale: (homeScreenPage.positionX < 0) ? 1 : 0.5 + homeScreenPage.progressToCenter * 0.5
|
||||||
|
yScale: (homeScreenPage.positionX < 0) ? 1 : 0.5 + homeScreenPage.progressToCenter * 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
Translate {
|
||||||
|
id: stackTranslate
|
||||||
|
x: Math.min(0, homeScreenPage.positionX)
|
||||||
|
}
|
||||||
|
|
||||||
|
Rotation {
|
||||||
|
id: cubeTransitionRotation
|
||||||
|
origin.x: (positionX < 0) ?
|
||||||
|
(Folio.HomeScreenState.pageWidth / 2) * homeScreenPage.progressToCenter :
|
||||||
|
(Folio.HomeScreenState.pageWidth / 2) + (Folio.HomeScreenState.pageWidth / 2) * (1 - homeScreenPage.progressToCenter);
|
||||||
|
origin.y: Folio.HomeScreenState.pageHeight / 2;
|
||||||
|
axis { x: 0; y: 1; z: 0 }
|
||||||
|
angle: {
|
||||||
|
return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rotation {
|
||||||
|
id: rotationTransitionRotation
|
||||||
|
origin.x: (positionX < 0) ?
|
||||||
|
(Folio.HomeScreenState.pageWidth / 2) * homeScreenPage.progressToCenter :
|
||||||
|
(Folio.HomeScreenState.pageWidth / 2) + (Folio.HomeScreenState.pageWidth / 2) * (1 - homeScreenPage.progressToCenter);
|
||||||
|
origin.y: 0
|
||||||
|
axis { x: -0.2; y: 0.3; z: 0.5 }
|
||||||
|
angle: {
|
||||||
|
return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,9 @@ Kirigami.ApplicationWindow {
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
append({"name": i18n("Slide"), "value": Folio.FolioSettings.SlideTransition});
|
append({"name": i18n("Slide"), "value": Folio.FolioSettings.SlideTransition});
|
||||||
append({"name": i18n("Cube"), "value": Folio.FolioSettings.CubeTransition});
|
append({"name": i18n("Cube"), "value": Folio.FolioSettings.CubeTransition});
|
||||||
|
append({"name": i18n("Fade"), "value": Folio.FolioSettings.FadeTransition});
|
||||||
|
append({"name": i18n("Stack"), "value": Folio.FolioSettings.StackTransition});
|
||||||
|
append({"name": i18n("Rotation"), "value": Folio.FolioSettings.RotationTransition});
|
||||||
|
|
||||||
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
||||||
pageTransitionCombobox.currentIndex = pageTransitionCombobox.indexOfValue(Folio.FolioSettings.pageTransitionEffect)
|
pageTransitionCombobox.currentIndex = pageTransitionCombobox.indexOfValue(Folio.FolioSettings.pageTransitionEffect)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue