mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
taskswitcher: Add darken effect for not centered tasks
This commit is contained in:
parent
264de1b6df
commit
fd88eb36e9
2 changed files with 20 additions and 8 deletions
|
|
@ -25,10 +25,11 @@ Item {
|
||||||
required property real previewHeight
|
required property real previewHeight
|
||||||
required property real previewWidth
|
required property real previewWidth
|
||||||
|
|
||||||
readonly property point taskScreenPoint: model ? Qt.point(model.ScreenGeometry.x, model.ScreenGeometry.y) : Qt.point(0, 0)
|
readonly property point taskScreenPoint: (model && model.ScreenGeometry) ? Qt.point(model.ScreenGeometry.x, model.ScreenGeometry.y) : Qt.point(0, 0)
|
||||||
readonly property real dragOffset: -control.y
|
readonly property real dragOffset: -control.y
|
||||||
|
|
||||||
property bool showHeader: true
|
property bool showHeader: true
|
||||||
|
property real darken: 0
|
||||||
|
|
||||||
opacity: 1 - dragOffset / taskSwitcher.height
|
opacity: 1 - dragOffset / taskSwitcher.height
|
||||||
|
|
||||||
|
|
@ -58,16 +59,11 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.Control {
|
Item {
|
||||||
id: control
|
id: control
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
topPadding: 0
|
|
||||||
bottomPadding: 0
|
|
||||||
|
|
||||||
// drag up gesture
|
// drag up gesture
|
||||||
DragHandler {
|
DragHandler {
|
||||||
id: dragHandler
|
id: dragHandler
|
||||||
|
|
@ -105,8 +101,9 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
// application
|
// application
|
||||||
contentItem: ColumnLayout {
|
ColumnLayout {
|
||||||
id: column
|
id: column
|
||||||
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
// header
|
// header
|
||||||
|
|
@ -193,6 +190,13 @@ Item {
|
||||||
source: Qt.resolvedUrl("./Thumbnail.qml")
|
source: Qt.resolvedUrl("./Thumbnail.qml")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// darken effect
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "black"
|
||||||
|
opacity: delegate.darken
|
||||||
|
}
|
||||||
|
|
||||||
TapHandler {
|
TapHandler {
|
||||||
onTapped: delegate.activateApp()
|
onTapped: delegate.activateApp()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,8 +83,16 @@ Item {
|
||||||
// ensure current task is above others
|
// ensure current task is above others
|
||||||
z: taskSwitcherState.currentTaskIndex === currentIndex ? 1 : 0
|
z: taskSwitcherState.currentTaskIndex === currentIndex ? 1 : 0
|
||||||
|
|
||||||
|
// only show header once task switcher is opened
|
||||||
showHeader: !taskSwitcherState.currentlyBeingOpened
|
showHeader: !taskSwitcherState.currentlyBeingOpened
|
||||||
|
|
||||||
|
// darken effect as task gets away from the centre of the screen
|
||||||
|
darken: {
|
||||||
|
let distFromCentreProgress = Math.abs(x - repeater.leftMargin) / taskSwitcherState.taskWidth;
|
||||||
|
let upperBoundAdjust = Math.min(0.5, distFromCentreProgress) - 0.2;
|
||||||
|
return Math.max(0, upperBoundAdjust);
|
||||||
|
}
|
||||||
|
|
||||||
width: taskSwitcherState.taskWidth
|
width: taskSwitcherState.taskWidth
|
||||||
height: taskSwitcherState.taskHeight
|
height: taskSwitcherState.taskHeight
|
||||||
previewWidth: taskSwitcherState.previewWidth
|
previewWidth: taskSwitcherState.previewWidth
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue