mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-03 02:04:45 +00:00
actiondrawer: Improve openToPinnedMode to have drawer already maximized when dragging
This commit is contained in:
parent
2f4938059b
commit
7ecb92d3dd
2 changed files with 41 additions and 15 deletions
|
|
@ -115,10 +115,6 @@ Item {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset >= contentContainerLoader.minimizedQuickSettingsOffset && !openToPinnedMode) {
|
|
||||||
root.opened = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
root.direction = (oldOffset === offset)
|
root.direction = (oldOffset === offset)
|
||||||
? MobileShell.Direction.None
|
? MobileShell.Direction.None
|
||||||
: (offset > oldOffset ? MobileShell.Direction.Down : MobileShell.Direction.Up);
|
: (offset > oldOffset ? MobileShell.Direction.Down : MobileShell.Direction.Up);
|
||||||
|
|
@ -136,23 +132,32 @@ Item {
|
||||||
closeAnim.stop();
|
closeAnim.stop();
|
||||||
openAnim.stop();
|
openAnim.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
openAnim.restart();
|
if (openToPinnedMode) {
|
||||||
|
openAnim.restart(); // go to pinned height
|
||||||
|
} else {
|
||||||
|
expandAnim.restart(); // go to maximized height
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeImmediately() {
|
function closeImmediately() {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
offset = 0;
|
offset = 0;
|
||||||
closeAnim.finished();
|
closeAnim.finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
closeAnim.restart();
|
closeAnim.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
function expand() {
|
function expand() {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
expandAnim.restart();
|
expandAnim.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateState() {
|
function updateState() {
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
let openThreshold = PlasmaCore.Units.gridUnit;
|
let openThreshold = PlasmaCore.Units.gridUnit;
|
||||||
|
|
@ -162,22 +167,27 @@ Item {
|
||||||
root.visible = false;
|
root.visible = false;
|
||||||
close();
|
close();
|
||||||
} else if (root.direction === MobileShell.Direction.None || !root.opened) {
|
} else if (root.direction === MobileShell.Direction.None || !root.opened) {
|
||||||
if (root.offset < openThreshold) {
|
|
||||||
close();
|
// if the panel has not been opened yet, run open animation only if drag passed threshold
|
||||||
} else {
|
(root.offset < openThreshold) ? close() : open();
|
||||||
open();
|
|
||||||
}
|
|
||||||
} else if (root.offset > contentContainerLoader.maximizedQuickSettingsOffset) {
|
} else if (root.offset > contentContainerLoader.maximizedQuickSettingsOffset) {
|
||||||
|
// if drag has gone past the fully expanded view
|
||||||
expand();
|
expand();
|
||||||
} else if (root.offset > contentContainerLoader.minimizedQuickSettingsOffset) {
|
} else if (root.offset > contentContainerLoader.minimizedQuickSettingsOffset) {
|
||||||
|
// if drag is between pinned view and fully expanded view
|
||||||
if (root.direction === MobileShell.Direction.Down) {
|
if (root.direction === MobileShell.Direction.Down) {
|
||||||
expand();
|
expand();
|
||||||
} else {
|
} else {
|
||||||
open();
|
// go back to pinned, or close if pinned mode is disabled
|
||||||
|
openToPinnedMode ? open() : close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (root.direction === MobileShell.Direction.Down) {
|
} else if (root.direction === MobileShell.Direction.Down) {
|
||||||
|
// if drag is between pinned view and open view, and dragging down
|
||||||
open();
|
open();
|
||||||
} else {
|
} else {
|
||||||
|
// if drag is between pinned view and open view, and dragging up
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ PlasmaCore.ColorScope {
|
||||||
|
|
||||||
required property var actionDrawer
|
required property var actionDrawer
|
||||||
|
|
||||||
|
// pinned position (disabled when openToPinnedMode is false)
|
||||||
readonly property real minimizedQuickSettingsOffset: quickSettings.minimizedHeight
|
readonly property real minimizedQuickSettingsOffset: quickSettings.minimizedHeight
|
||||||
|
|
||||||
|
// fully open position
|
||||||
readonly property real maximizedQuickSettingsOffset: minimizedQuickSettingsOffset + quickSettings.maxAddedHeight
|
readonly property real maximizedQuickSettingsOffset: minimizedQuickSettingsOffset + quickSettings.maxAddedHeight
|
||||||
|
|
||||||
colorGroup: PlasmaCore.Theme.ViewColorGroup
|
colorGroup: PlasmaCore.Theme.ViewColorGroup
|
||||||
|
|
@ -54,25 +57,38 @@ PlasmaCore.ColorScope {
|
||||||
|
|
||||||
actionDrawer: root.actionDrawer
|
actionDrawer: root.actionDrawer
|
||||||
|
|
||||||
// opacity and move animation
|
// opacity and move animation (disabled when openToPinnedMode is false)
|
||||||
property real offsetDist: actionDrawer.offset - minimizedQuickSettingsOffset
|
property real offsetDist: actionDrawer.offset - minimizedQuickSettingsOffset
|
||||||
property real totalOffsetDist: maximizedQuickSettingsOffset - minimizedQuickSettingsOffset
|
property real totalOffsetDist: maximizedQuickSettingsOffset - minimizedQuickSettingsOffset
|
||||||
minimizedToFullProgress: actionDrawer.opened ? applyMinMax(offsetDist / totalOffsetDist) : 0
|
minimizedToFullProgress: actionDrawer.openToPinnedMode ? (actionDrawer.opened ? applyMinMax(offsetDist / totalOffsetDist) : 0) : 1
|
||||||
|
|
||||||
|
// this drawer opens in two stages when pinned mode is enabled:
|
||||||
|
// ---
|
||||||
|
// stage 1: the transform effect is used, the drawer physically moves down to the pinned mode
|
||||||
|
// stage 2: the rectangle increases height to reveal content, but the content stays still
|
||||||
|
// when pinned mode is disabled, only stage 1 happens
|
||||||
|
|
||||||
|
// increase height of drawer when between pinned mode <-> maximized mode
|
||||||
addedHeight: {
|
addedHeight: {
|
||||||
if (!actionDrawer.opened) {
|
if (!actionDrawer.openToPinnedMode) {
|
||||||
|
// if pinned mode disabled, just go to full height
|
||||||
|
return quickSettings.maxAddedHeight;
|
||||||
|
} else if (!actionDrawer.opened) {
|
||||||
// over-scroll effect for initial opening
|
// over-scroll effect for initial opening
|
||||||
let progress = (root.actionDrawer.offset - minimizedQuickSettingsOffset) / quickSettings.maxAddedHeight;
|
let progress = (root.actionDrawer.offset - minimizedQuickSettingsOffset) / quickSettings.maxAddedHeight;
|
||||||
let effectProgress = Math.atan(Math.max(0, progress));
|
let effectProgress = Math.atan(Math.max(0, progress));
|
||||||
return quickSettings.maxAddedHeight * 0.25 * effectProgress;
|
return quickSettings.maxAddedHeight * 0.25 * effectProgress;
|
||||||
} else {
|
} else {
|
||||||
|
// as the drawer opens, add height to the rectangle, revealing content
|
||||||
return Math.max(0, Math.min(quickSettings.maxAddedHeight, root.actionDrawer.offset - minimizedQuickSettingsOffset));
|
return Math.max(0, Math.min(quickSettings.maxAddedHeight, root.actionDrawer.offset - minimizedQuickSettingsOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// physically move the drawer when between closed <-> pinned mode
|
||||||
transform: Translate {
|
transform: Translate {
|
||||||
id: translate
|
id: translate
|
||||||
y: Math.min(root.actionDrawer.offset - minimizedQuickSettingsOffset, 0)
|
readonly property real offsetHeight: actionDrawer.openToPinnedMode ? minimizedQuickSettingsOffset : maximizedQuickSettingsOffset
|
||||||
|
y: Math.min(root.actionDrawer.offset - offsetHeight, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue