on xenial help sign in
reorganize to be able to show multiple touch controls at once
e6be124Lukáš Tinkl
qml/Components/TouchControlsState/TouchControlsState.qml−2
@@ -20,7 +20,5 @@ import QtQuick 2.4
20QtObject {
20QtObject {
21 id: root
21 id: root
22
22
23− property bool overlayShown: false
24 property bool buttonsShownInPanel: false
23 property bool buttonsShownInPanel: false
25− property var surface: null
26}
24}
qml/Components/WindowControlButtons.qml+1−3
@@ -16,7 +16,6 @@
16
16
17import QtQuick 2.4
17import QtQuick 2.4
18import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
19−import "../Components/TouchControlsState"
20
19
21Row {
20Row {
22 id: root
21 id: root
@@ -30,8 +29,7 @@ Row {
30 property bool active: false
29 property bool active: false
31 property bool windowIsMaximized: false
30 property bool windowIsMaximized: false
32 property bool closeButtonShown: true
31 property bool closeButtonShown: true
33−
32+ property bool overlayShown
34− readonly property bool overlayShown: TouchControlsState.overlayShown && target && target.surface === TouchControlsState.surface
35
33
36 signal closeClicked()
34 signal closeClicked()
37 signal minimizeClicked()
35 signal minimizeClicked()
qml/Panel/Panel.qml+1−2
@@ -126,8 +126,7 @@ Item {
126 }
126 }
127 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
127 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
128
128
129− visible: ((PanelState.buttonsVisible && parent.containsMouse) ||
129+ visible: ((PanelState.buttonsVisible && parent.containsMouse) || TouchControlsState.buttonsShownInPanel)
130− (TouchControlsState.overlayShown && TouchControlsState.buttonsShownInPanel))
131 && !root.locked && !callHint.visible
130 && !root.locked && !callHint.visible
132 active: PanelState.buttonsVisible || TouchControlsState.overlayShown
131 active: PanelState.buttonsVisible || TouchControlsState.overlayShown
133 windowIsMaximized: true
132 windowIsMaximized: true
qml/Shell.qml−10
@@ -548,16 +548,6 @@ Item {
548 locked: greeter && greeter.active
548 locked: greeter && greeter.active
549 }
549 }
550
550
551− WindowControlsOverlay {
552− x: target ? target.x : -1
553− y: target ? target.y : -1
554− width: target ? target.width : undefined
555− height: target? target.height : undefined
556− target: applicationsDisplayLoader.item && applicationsDisplayLoader.item.mainAppDelegate
557− ? applicationsDisplayLoader.item.mainAppDelegate
558− : null
559− }
560−
561 Launcher {
551 Launcher {
562 id: launcher
552 id: launcher
563 objectName: "launcher"
553 objectName: "launcher"
qml/Stages/DecoratedWindow.qml+2
@@ -46,6 +46,8 @@ FocusScope {
46 property alias widthIncrement: applicationWindow.widthIncrement
46 property alias widthIncrement: applicationWindow.widthIncrement
47 property alias heightIncrement: applicationWindow.heightIncrement
47 property alias heightIncrement: applicationWindow.heightIncrement
48
48
49+ property alias overlayShown: decoration.overlayShown
50+
49 signal closeClicked()
51 signal closeClicked()
50 signal maximizeClicked()
52 signal maximizeClicked()
51 signal maximizeHorizontallyClicked()
53 signal maximizeHorizontallyClicked()
qml/Stages/DesktopStage.qml+15−15
@@ -206,19 +206,6 @@ AbstractStage {
206 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && priv.focusedAppDelegate.application.appId !== "unity8-dash"
206 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && priv.focusedAppDelegate.application.appId !== "unity8-dash"
207 }
207 }
208
208
209− Binding {
210− target: TouchControlsState
211− property: "buttonsShownInPanel"
212− value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized
213− }
214−
215− Binding {
216− target: TouchControlsState
217− property: "surface"
218− value: priv.focusedAppDelegate.surface
219− when: priv.focusedAppDelegate && priv.focusedAppDelegate.surface
220− }
221−
222 Component.onDestruction: {
209 Component.onDestruction: {
223 PanelState.title = "";
210 PanelState.title = "";
224 PanelState.buttonsVisible = false;
211 PanelState.buttonsVisible = false;
@@ -340,13 +327,13 @@ AbstractStage {
340 return;
327 return;
341
328
342 if (focus) {
329 if (focus) {
343− priv.focusedAppDelegate = appDelegate;
344−
345 // If we're orphan (!parent) it means this stage is no longer the current one
330 // If we're orphan (!parent) it means this stage is no longer the current one
346 // and will be deleted shortly. So we should no longer have a say over the model
331 // and will be deleted shortly. So we should no longer have a say over the model
347 if (root.parent) {
332 if (root.parent) {
348 topLevelSurfaceList.raiseId(model.id);
333 topLevelSurfaceList.raiseId(model.id);
349 }
334 }
335+
336+ priv.focusedAppDelegate = appDelegate;
350 } else if (!focus && priv.focusedAppDelegate === appDelegate) {
337 } else if (!focus && priv.focusedAppDelegate === appDelegate) {
351 priv.focusedAppDelegate = null;
338 priv.focusedAppDelegate = null;
352 // FIXME: No idea why the Binding{} doens't update when focusedAppDelegate turns null
339 // FIXME: No idea why the Binding{} doens't update when focusedAppDelegate turns null
@@ -589,6 +576,12 @@ AbstractStage {
589 when: index == spread.highlightedIndex && spread.ready
576 when: index == spread.highlightedIndex && spread.ready
590 }
577 }
591
578
579+ Binding {
580+ target: TouchControlsState
581+ property: "buttonsShownInPanel"
582+ value: appDelegate && appDelegate.maximized
583+ }
584+
592 WindowResizeArea {
585 WindowResizeArea {
593 id: resizeArea
586 id: resizeArea
594 objectName: "windowResizeArea"
587 objectName: "windowResizeArea"
@@ -632,6 +625,7 @@ AbstractStage {
632 surface: model.surface
625 surface: model.surface
633 active: appDelegate.focus
626 active: appDelegate.focus
634 focus: true
627 focus: true
628+ overlayShown: touchControls.overlayShown
635
629
636 requestedWidth: appDelegate.requestedWidth
630 requestedWidth: appDelegate.requestedWidth
637 requestedHeight: appDelegate.requestedHeight
631 requestedHeight: appDelegate.requestedHeight
@@ -646,6 +640,12 @@ AbstractStage {
646 onDecorationPressed: { appDelegate.focus = true; }
640 onDecorationPressed: { appDelegate.focus = true; }
647 }
641 }
648
642
643+ WindowControlsOverlay {
644+ id: touchControls
645+ anchors.fill: appDelegate
646+ target: appDelegate
647+ }
648+
649 WindowedFullscreenPolicy {
649 WindowedFullscreenPolicy {
650 id: fullscreenPolicy
650 id: fullscreenPolicy
651 active: true
651 active: true
qml/Stages/WindowControlsOverlay.qml+16−13
@@ -27,14 +27,16 @@ Item {
27 // to be set from outside
27 // to be set from outside
28 property Item target // appDelegate
28 property Item target // appDelegate
29
29
30+ readonly property bool overlayShown: overlay.visible
31+
30 TouchGestureArea {
32 TouchGestureArea {
31 id: gestureArea
33 id: gestureArea
32 anchors.fill: parent
34 anchors.fill: parent
33
35
34 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
36 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
35− minimumTouchPoints: 3
37+ minimumTouchPoints: 2
36 maximumTouchPoints: minimumTouchPoints
38 maximumTouchPoints: minimumTouchPoints
37− recognitionPeriod: 500
39+ releaseRejectPeriod: 500
38
40
39 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
41 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
40 touchPoints.length >= minimumTouchPoints &&
42 touchPoints.length >= minimumTouchPoints &&
@@ -47,12 +49,18 @@ Item {
47
49
48 readonly property bool recognizedDrag: recognizedPress && dragging
50 readonly property bool recognizedDrag: recognizedPress && dragging
49 onRecognizedDragChanged: {
51 onRecognizedDragChanged: {
50− priv.handlePressedChanged(recognizedDrag, tp.x, tp.y);
52+ if (recognizedDrag) {
53+ priv.handlePressedChanged(true, tp.x, tp.y);
54+ } else if (!moveHandler.containsPress) { // prevent interfering with the central piece drag/move
55+ priv.dragging = false;
56+ }
51 }
57 }
52
58
53 readonly property point tp: recognizedPress ? Qt.point(touchPoints[0].x, touchPoints[0].y) : Qt.point(-1, -1)
59 readonly property point tp: recognizedPress ? Qt.point(touchPoints[0].x, touchPoints[0].y) : Qt.point(-1, -1)
54 onUpdated: {
60 onUpdated: {
61+ if (recognizedDrag) {
55− priv.handlePositionChanged(tp.x, tp.y)
62+ priv.handlePositionChanged(tp.x, tp.y);
63+ }
56 }
64 }
57 }
65 }
58
66
@@ -85,24 +93,18 @@ Item {
85 function handlePositionChanged(mouseX, mouseY) {
93 function handlePositionChanged(mouseX, mouseY) {
86 if (priv.dragging) {
94 if (priv.dragging) {
87 var pos = mapToItem(root.target.parent, mouseX, mouseY);
95 var pos = mapToItem(root.target.parent, mouseX, mouseY);
88− root.target.x = pos.x - priv.distanceX;
96+ root.target.x = Math.round(pos.x - priv.distanceX);
89− root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
97+ root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
90 }
98 }
91 }
99 }
92 }
100 }
93
101
94− Binding {
95− target: TouchControlsState
96− property: "overlayShown"
97− value: overlay.visible
98− }
99−
100 // the visual overlay
102 // the visual overlay
101 Item {
103 Item {
102 id: overlay
104 id: overlay
103 objectName: "windowControlsOverlay"
105 objectName: "windowControlsOverlay"
104 anchors.fill: parent
106 anchors.fill: parent
105− enabled: target.surface == MirFocusController.focusedSurface && overlayTimer.running
107+ enabled: target && overlayTimer.running
106 visible: opacity > 0
108 visible: opacity > 0
107 opacity: enabled ? 0.95 : 0
109 opacity: enabled ? 0.95 : 0
108
110
@@ -123,6 +125,7 @@ Item {
123
125
124 // move handler
126 // move handler
125 MouseArea {
127 MouseArea {
128+ id: moveHandler
126 anchors.fill: parent
129 anchors.fill: parent
127 visible: overlay.visible
130 visible: overlay.visible
128 enabled: visible
131 enabled: visible
qml/Stages/WindowDecoration.qml+4−4
@@ -28,6 +28,8 @@ MouseArea {
28 property Item target
28 property Item target
29 property alias title: titleLabel.text
29 property alias title: titleLabel.text
30 property bool active: false
30 property bool active: false
31+ property alias overlayShown: buttons.overlayShown
32+
31 hoverEnabled: true
33 hoverEnabled: true
32
34
33 signal closeClicked()
35 signal closeClicked()
@@ -43,8 +45,6 @@ MouseArea {
43 property real distanceX
45 property real distanceX
44 property real distanceY
46 property real distanceY
45 property bool dragging
47 property bool dragging
46−
47− readonly property bool overlayShown: TouchControlsState.overlayShown && target && target.surface === TouchControlsState.surface
48 }
48 }
49
49
50 onPressedChanged: {
50 onPressedChanged: {
@@ -78,7 +78,7 @@ MouseArea {
78 Row {
78 Row {
79 anchors {
79 anchors {
80 fill: parent
80 fill: parent
81− leftMargin: priv.overlayShown ? units.gu(5) : units.gu(1)
81+ leftMargin: overlayShown ? units.gu(5) : units.gu(1)
82 rightMargin: units.gu(1)
82 rightMargin: units.gu(1)
83 topMargin: units.gu(0.5)
83 topMargin: units.gu(0.5)
84 bottomMargin: units.gu(0.5)
84 bottomMargin: units.gu(0.5)
@@ -112,7 +112,7 @@ MouseArea {
112 fontSize: "medium"
112 fontSize: "medium"
113 font.weight: root.active ? Font.Light : Font.Medium
113 font.weight: root.active ? Font.Light : Font.Medium
114 elide: Text.ElideRight
114 elide: Text.ElideRight
115− opacity: priv.overlayShown ? 0 : 1
115+ opacity: overlayShown ? 0 : 1
116 visible: opacity == 1
116 visible: opacity == 1
117 Behavior on opacity {
117 Behavior on opacity {
118 OpacityAnimator { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
118 OpacityAnimator { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }