Unity 8
SideStage.qml
1 /*
2  * Copyright (C) 2016 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 import QtQuick 2.4
18 import QtQuick.Layouts 1.1
19 import Ubuntu.Components 1.3
20 import Ubuntu.Gestures 0.1
21 import "../Components"
22 
23 Showable {
24  id: root
25  property bool showHint: true
26  property int panelWidth: units.gu(40)
27  readonly property alias dragging: hideSideStageDragArea.dragging
28  readonly property real progress: width / panelWidth
29 
30  width: 0
31  shown: false
32 
33  Item {
34  id: sideStageDragHandle
35  anchors {
36  right: root.left
37  top: root.top
38  bottom: root.bottom
39  }
40  width: units.gu(2)
41 
42  opacity: root.shown ? 1 : 0
43  Behavior on opacity { UbuntuNumberAnimation {} }
44 
45  Image {
46  anchors.centerIn: parent
47  width: hideSideStageDragArea.pressed ? parent.width * 2 : parent.width
48  height: parent.height
49  source: "graphics/sidestage_handle@20.png"
50  Behavior on width { UbuntuNumberAnimation {} }
51  }
52  }
53 
54  Rectangle {
55  anchors.fill: parent
56  color: Qt.rgba(0,0,0,0.95)
57  }
58 
59  Column {
60  anchors.verticalCenter: parent.verticalCenter
61  width: panelWidth - units.gu(6)
62  x: panelWidth/2 - width/2
63  spacing: units.gu(3)
64  opacity: 0.8
65  visible: showHint
66 
67  Icon {
68  width: units.gu(30)
69  anchors.horizontalCenter: parent.horizontalCenter
70  source: "graphics/sidestage_drag.svg"
71  color: enabled ? Qt.rgba(1,1,1,1) : Qt.rgba(1,0,0,1)
72  keyColor: Qt.rgba(1,1,1,1)
73  }
74 
75  Label {
76  text: i18n.tr("Drag using 3 fingers any application from one window to the other")
77  width: parent.width
78  wrapMode: Text.WordWrap
79  color: enabled ? Qt.rgba(1,1,1,1) : Qt.rgba(1,0,0,1)
80  }
81  }
82 
83  showAnimation: NumberAnimation {
84  property: "width"
85  to: panelWidth
86  duration: UbuntuAnimation.BriskDuration
87  easing.type: Easing.OutCubic
88  }
89 
90  hideAnimation: NumberAnimation {
91  property: "width"
92  to: 0
93  duration: UbuntuAnimation.BriskDuration
94  easing.type: Easing.OutCubic
95  }
96 
97  DragHandle {
98  id: hideSideStageDragArea
99  objectName: "hideSideStageDragArea"
100 
101  direction: Direction.Leftwards
102  rotation: 180
103  enabled: root.shown
104  anchors.right: root.left
105  width: sideStageDragHandle.width
106  height: root.height
107  stretch: true
108 
109  immediateRecognition: true
110  maxTotalDragDistance: panelWidth
111  autoCompleteDragThreshold: panelWidth / 2
112  }
113 
114  // SideStage mouse event eater
115  MouseArea {
116  anchors.fill: parent
117  }
118 }