mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
better behavior for the sliding panel
This commit is contained in:
parent
9ba5bf8db8
commit
afe58452ef
2 changed files with 30 additions and 16 deletions
|
|
@ -215,10 +215,18 @@ Item {
|
|||
font.pixelSize: height / 2
|
||||
}
|
||||
MouseArea {
|
||||
property int oldMouseY: 0
|
||||
|
||||
anchors.fill: parent
|
||||
onPressed: slidingPanel.visible = true;
|
||||
onPositionChanged: slidingPanel.offset = mouse.y;
|
||||
onReleased: slidingPanel.updateState(mouse.y);
|
||||
onPressed: {
|
||||
oldMouseY = mouse.y;
|
||||
slidingPanel.visible = true;
|
||||
}
|
||||
onPositionChanged: {
|
||||
slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY);
|
||||
oldMouseY = mouse.y;
|
||||
}
|
||||
onReleased: slidingPanel.updateState();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,14 +29,12 @@ Window {
|
|||
|
||||
color: "transparent"
|
||||
|
||||
function updateState(y) {
|
||||
function updateState() {
|
||||
var delta = offset - mouseArea.startOffset;
|
||||
if (delta > units.gridUnit * 8) {
|
||||
mouseArea.state = "open";
|
||||
mouseArea.startOffset = units.iconSizes.large;
|
||||
} else if (delta < -units.gridUnit * 8) {
|
||||
mouseArea.state = "closed";
|
||||
mouseArea.startOffset = units.iconSizes.large;
|
||||
} else {
|
||||
mouseArea.state = mouseArea.startState;
|
||||
}
|
||||
|
|
@ -45,7 +43,8 @@ Window {
|
|||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
mouseArea.state = "dragging";
|
||||
mouseArea.state = "draggingFromClosed";
|
||||
mouseArea.startOffset = units.gridUnit * 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,25 +56,27 @@ Window {
|
|||
clip: true
|
||||
state: "closed"
|
||||
|
||||
property int startY: 0
|
||||
property int oldMouseY: 0
|
||||
property int startOffset: units.iconSizes.large;
|
||||
property string startState: "closed"
|
||||
onPressed: {
|
||||
startState = state;
|
||||
startY = mouse.y;
|
||||
startOffset = window.offset;
|
||||
state = "dragging";
|
||||
oldMouseY = mouse.y;
|
||||
state = "draggingFromOpen";
|
||||
window.offset = startOffset;
|
||||
}
|
||||
onPositionChanged: {
|
||||
window.offset = Math.min(slidingArea.height, startOffset + (mouse.y - startY));
|
||||
window.offset = window.offset + (mouse.y - oldMouseY);
|
||||
oldMouseY = mouse.y;
|
||||
}
|
||||
onReleased: window.updateState(mouse.y)
|
||||
onReleased: window.updateState()
|
||||
|
||||
Rectangle {
|
||||
id: slidingArea
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
y: -height + window.offset
|
||||
y: Math.min(0, -height + window.offset)
|
||||
|
||||
color: Qt.rgba(0, 0, 0, 0.7)
|
||||
Rectangle {
|
||||
|
|
@ -106,16 +107,21 @@ Window {
|
|||
}
|
||||
},
|
||||
State {
|
||||
name: "dragging"
|
||||
name: "draggingFromOpen"
|
||||
},
|
||||
State {
|
||||
name: "draggingFromClosed"
|
||||
PropertyChanges {
|
||||
id: dragChange
|
||||
target: window
|
||||
offset: mouseArea.startOffset
|
||||
offset: units.gridUnit * 4
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "draggingFromOpen"
|
||||
},
|
||||
Transition {
|
||||
SequentialAnimation {
|
||||
PropertyAnimation {
|
||||
|
|
|
|||
Loading…
Reference in a new issue