on xenial help sign in
reorganize to be able to show multiple touch controls at once
commite6be1241e3df1b6f8f12c1dd9a3b3db2c906bac2 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 20 May 2016, 13:58 (10 years ago) parent3f949e9
8 files changed+39−49
qml/Components/TouchControlsState/TouchControlsState.qml−2 qml/Components/WindowControlButtons.qml+1−3 qml/Panel/Panel.qml+1−2 qml/Shell.qml−10 qml/Stages/DecoratedWindow.qml+2 qml/Stages/DesktopStage.qml+15−15 qml/Stages/WindowControlsOverlay.qml+16−13 qml/Stages/WindowDecoration.qml+4−4
qml/Components/TouchControlsState/TouchControlsState.qml−2
@@ -20,7 +20,5 @@ import QtQuick 2.4
2020QtObject {
2121 id: root
2222
23− property bool overlayShown: false
2423 property bool buttonsShownInPanel: false
25− property var surface: null
2624}
qml/Components/WindowControlButtons.qml+1−3
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
19−import "../Components/TouchControlsState"
2019
2120Row {
2221 id: root
@@ -30,8 +29,7 @@ Row {
3029 property bool active: false
3130 property bool windowIsMaximized: false
3231 property bool closeButtonShown: true
33−
34− readonly property bool overlayShown: TouchControlsState.overlayShown && target && target.surface === TouchControlsState.surface
32+ property bool overlayShown
3533
3634 signal closeClicked()
3735 signal minimizeClicked()
qml/Panel/Panel.qml+1−2
@@ -126,8 +126,7 @@ Item {
126126 }
127127 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
128128
129− visible: ((PanelState.buttonsVisible && parent.containsMouse) ||
130− (TouchControlsState.overlayShown && TouchControlsState.buttonsShownInPanel))
129+ visible: ((PanelState.buttonsVisible && parent.containsMouse) || TouchControlsState.buttonsShownInPanel)
131130 && !root.locked && !callHint.visible
132131 active: PanelState.buttonsVisible || TouchControlsState.overlayShown
133132 windowIsMaximized: true
qml/Shell.qml−10
@@ -548,16 +548,6 @@ Item {
548548 locked: greeter && greeter.active
549549 }
550550
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−
561551 Launcher {
562552 id: launcher
563553 objectName: "launcher"
qml/Stages/DecoratedWindow.qml+2
@@ -46,6 +46,8 @@ FocusScope {
4646 property alias widthIncrement: applicationWindow.widthIncrement
4747 property alias heightIncrement: applicationWindow.heightIncrement
4848
49+ property alias overlayShown: decoration.overlayShown
50+
4951 signal closeClicked()
5052 signal maximizeClicked()
5153 signal maximizeHorizontallyClicked()
qml/Stages/DesktopStage.qml+15−15
@@ -206,19 +206,6 @@ AbstractStage {
206206 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && priv.focusedAppDelegate.application.appId !== "unity8-dash"
207207 }
208208
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−
222209 Component.onDestruction: {
223210 PanelState.title = "";
224211 PanelState.buttonsVisible = false;
@@ -340,13 +327,13 @@ AbstractStage {
340327 return;
341328
342329 if (focus) {
343− priv.focusedAppDelegate = appDelegate;
344−
345330 // If we're orphan (!parent) it means this stage is no longer the current one
346331 // and will be deleted shortly. So we should no longer have a say over the model
347332 if (root.parent) {
348333 topLevelSurfaceList.raiseId(model.id);
349334 }
335+
336+ priv.focusedAppDelegate = appDelegate;
350337 } else if (!focus && priv.focusedAppDelegate === appDelegate) {
351338 priv.focusedAppDelegate = null;
352339 // FIXME: No idea why the Binding{} doens't update when focusedAppDelegate turns null
@@ -589,6 +576,12 @@ AbstractStage {
589576 when: index == spread.highlightedIndex && spread.ready
590577 }
591578
579+ Binding {
580+ target: TouchControlsState
581+ property: "buttonsShownInPanel"
582+ value: appDelegate && appDelegate.maximized
583+ }
584+
592585 WindowResizeArea {
593586 id: resizeArea
594587 objectName: "windowResizeArea"
@@ -632,6 +625,7 @@ AbstractStage {
632625 surface: model.surface
633626 active: appDelegate.focus
634627 focus: true
628+ overlayShown: touchControls.overlayShown
635629
636630 requestedWidth: appDelegate.requestedWidth
637631 requestedHeight: appDelegate.requestedHeight
@@ -646,6 +640,12 @@ AbstractStage {
646640 onDecorationPressed: { appDelegate.focus = true; }
647641 }
648642
643+ WindowControlsOverlay {
644+ id: touchControls
645+ anchors.fill: appDelegate
646+ target: appDelegate
647+ }
648+
649649 WindowedFullscreenPolicy {
650650 id: fullscreenPolicy
651651 active: true
qml/Stages/WindowControlsOverlay.qml+16−13
@@ -27,14 +27,16 @@ Item {
2727 // to be set from outside
2828 property Item target // appDelegate
2929
30+ readonly property bool overlayShown: overlay.visible
31+
3032 TouchGestureArea {
3133 id: gestureArea
3234 anchors.fill: parent
3335
3436 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
35− minimumTouchPoints: 3
37+ minimumTouchPoints: 2
3638 maximumTouchPoints: minimumTouchPoints
37− recognitionPeriod: 500
39+ releaseRejectPeriod: 500
3840
3941 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
4042 touchPoints.length >= minimumTouchPoints &&
@@ -47,12 +49,18 @@ Item {
4749
4850 readonly property bool recognizedDrag: recognizedPress && dragging
4951 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+ }
5157 }
5258
5359 readonly property point tp: recognizedPress ? Qt.point(touchPoints[0].x, touchPoints[0].y) : Qt.point(-1, -1)
5460 onUpdated: {
55− priv.handlePositionChanged(tp.x, tp.y)
61+ if (recognizedDrag) {
62+ priv.handlePositionChanged(tp.x, tp.y);
63+ }
5664 }
5765 }
5866
@@ -85,24 +93,18 @@ Item {
8593 function handlePositionChanged(mouseX, mouseY) {
8694 if (priv.dragging) {
8795 var pos = mapToItem(root.target.parent, mouseX, mouseY);
88− root.target.x = pos.x - priv.distanceX;
89− root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
96+ root.target.x = Math.round(pos.x - priv.distanceX);
97+ root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
9098 }
9199 }
92100 }
93101
94− Binding {
95− target: TouchControlsState
96− property: "overlayShown"
97− value: overlay.visible
98− }
99−
100102 // the visual overlay
101103 Item {
102104 id: overlay
103105 objectName: "windowControlsOverlay"
104106 anchors.fill: parent
105− enabled: target.surface == MirFocusController.focusedSurface && overlayTimer.running
107+ enabled: target && overlayTimer.running
106108 visible: opacity > 0
107109 opacity: enabled ? 0.95 : 0
108110
@@ -123,6 +125,7 @@ Item {
123125
124126 // move handler
125127 MouseArea {
128+ id: moveHandler
126129 anchors.fill: parent
127130 visible: overlay.visible
128131 enabled: visible
qml/Stages/WindowDecoration.qml+4−4
@@ -28,6 +28,8 @@ MouseArea {
2828 property Item target
2929 property alias title: titleLabel.text
3030 property bool active: false
31+ property alias overlayShown: buttons.overlayShown
32+
3133 hoverEnabled: true
3234
3335 signal closeClicked()
@@ -43,8 +45,6 @@ MouseArea {
4345 property real distanceX
4446 property real distanceY
4547 property bool dragging
46−
47− readonly property bool overlayShown: TouchControlsState.overlayShown && target && target.surface === TouchControlsState.surface
4848 }
4949
5050 onPressedChanged: {
@@ -78,7 +78,7 @@ MouseArea {
7878 Row {
7979 anchors {
8080 fill: parent
81− leftMargin: priv.overlayShown ? units.gu(5) : units.gu(1)
81+ leftMargin: overlayShown ? units.gu(5) : units.gu(1)
8282 rightMargin: units.gu(1)
8383 topMargin: units.gu(0.5)
8484 bottomMargin: units.gu(0.5)
@@ -112,7 +112,7 @@ MouseArea {
112112 fontSize: "medium"
113113 font.weight: root.active ? Font.Light : Font.Medium
114114 elide: Text.ElideRight
115− opacity: priv.overlayShown ? 0 : 1
115+ opacity: overlayShown ? 0 : 1
116116 visible: opacity == 1
117117 Behavior on opacity {
118118 OpacityAnimator { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }