finish the behavior

This commit is contained in:
Marco Martin 2015-03-20 17:24:10 +01:00
parent 21a9355367
commit b720bbcb5c

View file

@ -1,7 +1,7 @@
import QtQuick 2.1 import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents
Rectangle { Rectangle {
id: root id: root
@ -15,8 +15,16 @@ Rectangle {
text: "Homescreen" text: "Homescreen"
} }
Rectangle {
anchors.fill: parent
color: "black"
opacity: 0.6 * Math.min(1, mainFlickable.contentY/(root.height*2))
}
Flickable { Flickable {
id: mainFlickable id: mainFlickable
//Scale adjusted in the 0-1 range
property real zoomFactor: Math.max(mainFlickable.scale/0.5, 1) - 1
width: root.width * 2 + 5 width: root.width * 2 + 5
height: root.height * 2 + 5 height: root.height * 2 + 5
@ -62,6 +70,7 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
root.state = "scrolling"
root.currentApp = appRect root.currentApp = appRect
root.state = "app" root.state = "app"
} }
@ -76,6 +85,7 @@ Rectangle {
} }
} }
Rectangle { Rectangle {
id: bottomBar
z: 99 z: 99
color: "blue" color: "blue"
anchors { anchors {
@ -123,6 +133,21 @@ Rectangle {
} }
} }
} }
Row {
PlasmaComponents.ToolButton {
height: bottomBar.height
width: height
iconSource: "applications-other"
onClicked: root.state = "switcher"
}
PlasmaComponents.ToolButton {
height: bottomBar.height
width: height
iconSource: "go-home"
onClicked: root.state = "homescreen"
}
}
} }
} }
states: [ states: [
@ -155,10 +180,10 @@ Rectangle {
PropertyChanges { PropertyChanges {
target: mainFlickable target: mainFlickable
scale: scale scale: scale
x: (-root.currentApp.x * (mainFlickable.scale/0.5 - 1) ) + (2 - mainFlickable.scale/0.5) * (-root.width / 2) x: (-root.currentApp.x * mainFlickable.zoomFactor ) + (1 - mainFlickable.zoomFactor) * (-root.width / 2)
y: (-root.height / 2) * (2 - mainFlickable.scale/0.5) y: (-root.height / 2) * (1 - mainFlickable.zoomFactor)
interactive: true interactive: true
contentY: (root.height*2 + (root.currentApp ? root.currentApp.y : 0)) * (2 - mainFlickable.scale/0.5) + (root.height*2 + root.currentApp.y) * (mainFlickable.scale/0.5 - 1) contentY: (root.height*2 + (root.currentApp ? root.currentApp.y : 0)) * (1 - mainFlickable.zoomFactor) + (root.height*2 + root.currentApp.y) * mainFlickable.zoomFactor
visible: true visible: true
} }
}, },
@ -190,6 +215,11 @@ Rectangle {
transitions: [ transitions: [
Transition { Transition {
to: "dragging" to: "dragging"
ScriptAction {
script: {
root.currentApp = null;
}
}
}, },
Transition { Transition {
to: "zooming" to: "zooming"