on xenial help sign in
implement resizing \o/
dce2835Lukáš Tinkl
qml/Stages/DesktopStage.qml+1
@@ -547,6 +547,7 @@ AbstractStage {
547 WindowControlsOverlay {
547 WindowControlsOverlay {
548 anchors.fill: resizeArea
548 anchors.fill: resizeArea
549 target: appDelegate
549 target: appDelegate
550+ resizeTarget: resizeArea
550 borderThickness: resizeArea.borderThickness
551 borderThickness: resizeArea.borderThickness
551 }
552 }
552
553
qml/Stages/ResizeGrip.qml+11
@@ -23,10 +23,21 @@ Rectangle {
23 radius: height / 2
23 radius: height / 2
24 color: theme.palette.normal.background
24 color: theme.palette.normal.background
25
25
26+ // to be set from outside
27+ property Item resizeTarget
28+
26 Image {
29 Image {
27 source: "graphics/arrows.png"
30 source: "graphics/arrows.png"
28 anchors.centerIn: parent
31 anchors.centerIn: parent
29 width: units.gu(2)
32 width: units.gu(2)
30 height: width
33 height: width
31 }
34 }
35+
36+ MouseArea {
37+ anchors.fill: parent
38+ hoverEnabled: true
39+
40+ Mouse.enabled: resizeTarget
41+ Mouse.forwardTo: resizeTarget
42+ }
32}
43}
qml/Stages/WindowControlsOverlay.qml+20−11
@@ -23,6 +23,7 @@ Item {
23 id: root
23 id: root
24 // to be set from outside
24 // to be set from outside
25 property Item target // appDelegate
25 property Item target // appDelegate
26+ property Item resizeTarget // WindowResizeArea
26 property int borderThickness
27 property int borderThickness
27
28
28 TabletSideStageTouchGesture {
29 TabletSideStageTouchGesture {
@@ -47,6 +48,7 @@ Item {
47 Timer { // dismiss timer
48 Timer { // dismiss timer
48 id: overlayTimer
49 id: overlayTimer
49 interval: 2000
50 interval: 2000
51+ repeat: priv.dragging || root.resizeTarget.dragging
50 }
52 }
51
53
52 InverseMouseArea { // dismiss area
54 InverseMouseArea { // dismiss area
@@ -62,7 +64,7 @@ Item {
62 }
64 }
63
65
64 MouseArea {
66 MouseArea {
65− anchors.fill: parent
67+ anchors.fill: overlay
66 visible: overlay.visible
68 visible: overlay.visible
67 enabled: visible
69 enabled: visible
68
70
@@ -89,8 +91,7 @@ Item {
89 Item {
91 Item {
90 id: overlay
92 id: overlay
91 anchors.fill: parent
93 anchors.fill: parent
92− visible: (overlayTimer.running || priv.dragging) &&
93− target && !target.maximized && !target.fullscreen
94+ visible: overlayTimer.running && target && !target.maximized && !target.fullscreen
94 enabled: visible
95 enabled: visible
95
96
96 Image {
97 Image {
@@ -105,7 +106,8 @@ Item {
105 anchors.horizontalCenterOffset: borderThickness
106 anchors.horizontalCenterOffset: borderThickness
106 anchors.verticalCenter: parent.top
107 anchors.verticalCenter: parent.top
107 anchors.verticalCenterOffset: borderThickness
108 anchors.verticalCenterOffset: borderThickness
108− visible: target && !target.maximizedLeft && !target.maximizedRight
109+ visible: resizeTarget && !resizeTarget.maximizedLeft && !resizeTarget.maximizedRight
110+ resizeTarget: root.resizeTarget
109 }
111 }
110
112
111 ResizeGrip { // top center
113 ResizeGrip { // top center
@@ -113,7 +115,8 @@ Item {
113 anchors.verticalCenter: parent.top
115 anchors.verticalCenter: parent.top
114 anchors.verticalCenterOffset: borderThickness
116 anchors.verticalCenterOffset: borderThickness
115 rotation: 45
117 rotation: 45
116− visible: target && !target.maximizedLeft && !target.maximizedRight
118+ visible: resizeTarget && !resizeTarget.maximizedLeft && !resizeTarget.maximizedRight
119+ resizeTarget: root.resizeTarget
117 }
120 }
118
121
119 ResizeGrip { // top right
122 ResizeGrip { // top right
@@ -122,7 +125,8 @@ Item {
122 anchors.verticalCenter: parent.top
125 anchors.verticalCenter: parent.top
123 anchors.verticalCenterOffset: borderThickness
126 anchors.verticalCenterOffset: borderThickness
124 rotation: 90
127 rotation: 90
125− visible: target && !target.maximizedLeft && !target.maximizedRight
128+ visible: resizeTarget && !resizeTarget.maximizedLeft && !resizeTarget.maximizedRight
129+ resizeTarget: root.resizeTarget
126 }
130 }
127
131
128 ResizeGrip { // right
132 ResizeGrip { // right
@@ -130,7 +134,8 @@ Item {
130 anchors.horizontalCenterOffset: -borderThickness
134 anchors.horizontalCenterOffset: -borderThickness
131 anchors.verticalCenter: parent.verticalCenter
135 anchors.verticalCenter: parent.verticalCenter
132 rotation: 135
136 rotation: 135
133− visible: target && !target.maximizedRight
137+ visible: resizeTarget && !resizeTarget.maximizedRight
138+ resizeTarget: root.resizeTarget
134 }
139 }
135
140
136 ResizeGrip { // bottom right
141 ResizeGrip { // bottom right
@@ -138,7 +143,8 @@ Item {
138 anchors.horizontalCenterOffset: -borderThickness
143 anchors.horizontalCenterOffset: -borderThickness
139 anchors.verticalCenter: parent.bottom
144 anchors.verticalCenter: parent.bottom
140 anchors.verticalCenterOffset: -borderThickness
145 anchors.verticalCenterOffset: -borderThickness
141− visible: target && !target.maximizedLeft && !target.maximizedRight
146+ visible: resizeTarget && !resizeTarget.maximizedLeft && !resizeTarget.maximizedRight
147+ resizeTarget: root.resizeTarget
142 }
148 }
143
149
144 ResizeGrip { // bottom center
150 ResizeGrip { // bottom center
@@ -146,7 +152,8 @@ Item {
146 anchors.verticalCenter: parent.bottom
152 anchors.verticalCenter: parent.bottom
147 anchors.verticalCenterOffset: -borderThickness
153 anchors.verticalCenterOffset: -borderThickness
148 rotation: 45
154 rotation: 45
149− visible: target && !target.maximizedLeft && !target.maximizedRight
155+ visible: resizeTarget && !resizeTarget.maximizedLeft && !resizeTarget.maximizedRight
156+ resizeTarget: root.resizeTarget
150 }
157 }
151
158
152 ResizeGrip { // bottom left
159 ResizeGrip { // bottom left
@@ -155,7 +162,8 @@ Item {
155 anchors.verticalCenter: parent.bottom
162 anchors.verticalCenter: parent.bottom
156 anchors.verticalCenterOffset: -borderThickness
163 anchors.verticalCenterOffset: -borderThickness
157 rotation: 90
164 rotation: 90
158− visible: target && !target.maximizedLeft && !target.maximizedRight
165+ visible: resizeTarget && !resizeTarget.maximizedLeft && !resizeTarget.maximizedRight
166+ resizeTarget: root.resizeTarget
159 }
167 }
160
168
161 ResizeGrip { // left
169 ResizeGrip { // left
@@ -163,7 +171,8 @@ Item {
163 anchors.horizontalCenterOffset: borderThickness
171 anchors.horizontalCenterOffset: borderThickness
164 anchors.verticalCenter: parent.verticalCenter
172 anchors.verticalCenter: parent.verticalCenter
165 rotation: 135
173 rotation: 135
166− visible: target && !target.maximizedLeft
174+ visible: resizeTarget && !resizeTarget.maximizedLeft
175+ resizeTarget: root.resizeTarget
167 }
176 }
168 }
177 }
169}
178}
qml/Stages/WindowResizeArea.qml+2−1
@@ -28,6 +28,7 @@ MouseArea {
28 hoverEnabled: target && !target.maximized // don't grab the resize under the panel
28 hoverEnabled: target && !target.maximized // don't grab the resize under the panel
29
29
30 property var windowStateStorage: WindowStateStorage
30 property var windowStateStorage: WindowStateStorage
31+ readonly property alias dragging: d.dragging
31
32
32 // The target item managed by this. Must be a parent or a sibling
33 // The target item managed by this. Must be a parent or a sibling
33 // The area will anchor to it and manage move and resize events
34 // The area will anchor to it and manage move and resize events
@@ -180,7 +181,7 @@ MouseArea {
180 property real currentWidth
181 property real currentWidth
181 property real currentHeight
182 property real currentHeight
182
183
183− property string cursorName: {
184+ readonly property string cursorName: {
184 if (root.containsMouse || root.pressed) {
185 if (root.containsMouse || root.pressed) {
185 if (leftBorder && !topBorder && !bottomBorder) {
186 if (leftBorder && !topBorder && !bottomBorder) {
186 return "left_side";
187 return "left_side";