~nick-dedekind/unity8/indicator-color-fixes

« back to all changes in this revision

Viewing changes to qml/Stages/WindowResizeArea.qml

  • Committer: Nick Dedekind
  • Date: 2016-02-29 14:24:55 UTC
  • mfrom: (2143.1.65 unity8)
  • Revision ID: nick.dedekind@canonical.com-20160229142455-ol76uyr8pin7l5r6
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        var windowGeometry = windowStateStorage.getGeometry(root.windowId,
73
73
                                                            Qt.rect(target.x, target.y, defaultWidth, defaultHeight));
74
74
 
75
 
        target.requestedWidth = Math.min(Math.max(windowGeometry.width, minWidth), screenWidth);
76
 
        target.requestedHeight = Math.min(Math.max(windowGeometry.height, minHeight), root.screenHeight - PanelState.panelHeight);
 
75
        target.requestedWidth = Math.min(Math.max(windowGeometry.width, d.minimumWidth), screenWidth);
 
76
        target.requestedHeight = Math.min(Math.max(windowGeometry.height, d.minimumHeight), root.screenHeight - PanelState.panelHeight);
77
77
        target.x = Math.max(Math.min(windowGeometry.x, root.screenWidth - target.requestedWidth), 0)
78
78
        target.y = Math.max(Math.min(windowGeometry.y, root.screenHeight - target.requestedHeight), PanelState.panelHeight)
79
79
 
91
91
 
92
92
    QtObject {
93
93
        id: d
 
94
 
 
95
        readonly property int maxSafeInt: 2147483647
 
96
        readonly property int maxSizeIncrement: units.gu(40)
 
97
 
 
98
        readonly property int minimumWidth: root.target ? Math.max(root.minWidth, root.target.minimumWidth) : root.minWidth
 
99
        onMinimumWidthChanged: {
 
100
            if (target.requestedWidth < minimumWidth) {
 
101
                target.requestedWidth = minimumWidth;
 
102
            }
 
103
        }
 
104
        readonly property int minimumHeight: root.target ? Math.max(root.minHeight, root.target.minimumHeight) : root.minHeight
 
105
        onMinimumHeightChanged: {
 
106
            if (target.requestedHeight < minimumHeight) {
 
107
                target.requestedHeight = minimumHeight;
 
108
            }
 
109
        }
 
110
        readonly property int maximumWidth: root.target && root.target.maximumWidth >= minimumWidth && root.target.maximumWidth > 0
 
111
            ? root.target.maximumWidth : maxSafeInt
 
112
        onMaximumWidthChanged: {
 
113
            if (target.requestedWidth > maximumWidth) {
 
114
                target.requestedWidth = maximumWidth;
 
115
            }
 
116
        }
 
117
        readonly property int maximumHeight: root.target && root.target.maximumHeight >= minimumHeight && root.target.maximumHeight > 0
 
118
            ? root.target.maximumHeight : maxSafeInt
 
119
        onMaximumHeightChanged: {
 
120
            if (target.requestedHeight > maximumHeight) {
 
121
                target.requestedHeight = maximumHeight;
 
122
            }
 
123
        }
 
124
        readonly property int widthIncrement: {
 
125
            if (!root.target) {
 
126
                return 1;
 
127
            }
 
128
            if (root.target.widthIncrement > 0) {
 
129
                if (root.target.widthIncrement < maxSizeIncrement) {
 
130
                    return root.target.widthIncrement;
 
131
                } else {
 
132
                    return maxSizeIncrement;
 
133
                }
 
134
            } else {
 
135
                return 1;
 
136
            }
 
137
        }
 
138
        readonly property int heightIncrement: {
 
139
            if (!root.target) {
 
140
                return 1;
 
141
            }
 
142
            if (root.target.heightIncrement > 0) {
 
143
                if (root.target.heightIncrement < maxSizeIncrement) {
 
144
                    return root.target.heightIncrement;
 
145
                } else {
 
146
                    return maxSizeIncrement;
 
147
                }
 
148
            } else {
 
149
                return 1;
 
150
            }
 
151
        }
 
152
 
94
153
        property bool leftBorder: false
95
154
        property bool rightBorder: false
96
155
        property bool topBorder: false
209
268
 
210
269
        var pos = mapToItem(target.parent, mouse.x, mouse.y);
211
270
 
212
 
        var deltaX = pos.x - d.startMousePosX;
213
 
        var deltaY = pos.y - d.startMousePosY;
 
271
        var deltaX = Math.floor((pos.x - d.startMousePosX) / d.widthIncrement) * d.widthIncrement;
 
272
        var deltaY = Math.floor((pos.y - d.startMousePosY) / d.heightIncrement) * d.heightIncrement;
214
273
 
215
274
        if (d.leftBorder) {
216
275
            var newTargetX = d.startX + deltaX;
217
 
            if (target.x + target.width > newTargetX + minWidth) {
218
 
                target.requestedWidth = target.x + target.width - newTargetX;
 
276
            var rightBorderX = target.x + target.width;
 
277
            if (rightBorderX > newTargetX + d.minimumWidth) {
 
278
                if (rightBorderX  < newTargetX + d.maximumWidth) {
 
279
                    target.requestedWidth = rightBorderX - newTargetX;
 
280
                } else {
 
281
                    target.requestedWidth = d.maximumWidth;
 
282
                }
219
283
            } else {
220
 
                target.requestedWidth = minWidth;
 
284
                target.requestedWidth = d.minimumWidth;
221
285
            }
222
286
 
223
287
        } else if (d.rightBorder) {
224
 
            if (d.startWidth + deltaX >= minWidth) {
225
 
                target.requestedWidth = d.startWidth + deltaX;
 
288
            var newWidth = d.startWidth + deltaX;
 
289
            if (newWidth > d.minimumWidth) {
 
290
                if (newWidth < d.maximumWidth) {
 
291
                    target.requestedWidth = newWidth;
 
292
                } else {
 
293
                    target.requestedWidth = d.maximumWidth;
 
294
                }
226
295
            } else {
227
 
                target.requestedWidth = minWidth;
 
296
                target.requestedWidth = d.minimumWidth;
228
297
            }
229
298
        }
230
299
 
231
300
        if (d.topBorder) {
232
301
            var newTargetY = d.startY + deltaY;
233
 
            if (target.y + target.height > newTargetY + minHeight) {
234
 
                target.requestedHeight = target.y + target.height - newTargetY;
 
302
            var bottomBorderY = target.y + target.height;
 
303
            if (bottomBorderY > newTargetY + d.minimumHeight) {
 
304
                if (bottomBorderY < newTargetY + d.maximumHeight) {
 
305
                    target.requestedHeight = bottomBorderY - newTargetY;
 
306
                } else {
 
307
                    target.requestedHeight = d.maximumHeight;
 
308
                }
235
309
            } else {
236
 
                target.requestedHeight = minHeight;
 
310
                target.requestedHeight = d.minimumHeight;
237
311
            }
238
312
 
239
313
        } else if (d.bottomBorder) {
240
 
            if (d.startHeight + deltaY >= minHeight) {
241
 
                target.requestedHeight = d.startHeight + deltaY;
 
314
            var newHeight = d.startHeight + deltaY;
 
315
            if (newHeight > d.minimumHeight) {
 
316
                if (newHeight < d.maximumHeight) {
 
317
                    target.requestedHeight = newHeight;
 
318
                } else {
 
319
                    target.requestedHeight = d.maximumHeight;
 
320
                }
242
321
            } else {
243
 
                target.requestedHeight = minHeight;
 
322
                target.requestedHeight = d.minimumHeight;
244
323
            }
245
324
        }
246
325
    }