2
import Unity.Application 0.1
8
property alias surface: surfaceItem.surface
9
property bool touchMode: false
11
width: surfaceItem.width + (borderThickness*2)
12
height: surfaceItem.height + titleBar.height + (borderThickness*2)
14
signal cloneRequested()
18
x -= borderThicknessTouch - borderThicknessMouse;
19
width += 2*(borderThicknessTouch - borderThicknessMouse);
20
y -= borderThicknessTouch - borderThicknessMouse;
21
height += 2*(borderThicknessTouch - borderThicknessMouse);
23
x += borderThicknessTouch - borderThicknessMouse;
24
width -= 2*(borderThicknessTouch - borderThicknessMouse);
25
y += borderThicknessTouch - borderThicknessMouse;
26
height -= 2*(borderThicknessTouch - borderThicknessMouse);
30
readonly property real minWidth: 100
31
readonly property real minHeight: 100
33
property real borderThickness: touchMode ? borderThicknessTouch : borderThicknessMouse
34
readonly property real borderThicknessMouse: 10
35
readonly property real borderThicknessTouch: 40
40
when: (surface && !surface.live) || titleBar.closeRequested
45
from: ""; to: "closed"
50
easing.type: Easing.InBack
55
ScriptAction { script: { root.destroy(); } }
68
property real startWidth
69
property real startHeight
70
property bool leftBorder
71
property bool rightBorder
72
property bool topBorder
73
property bool bottomBorder
74
property bool dragging
77
var pos = mapToItem(root.parent, mouseX, mouseY);
80
startWidth = surfaceItem.width;
81
startHeight = surfaceItem.height;
82
leftBorder = mouseX > 0 && mouseX < root.borderThickness;
83
rightBorder = mouseX > (root.width - root.borderThickness) && mouseX < root.width;
84
topBorder = mouseY > 0 && mouseY < root.borderThickness;
85
bottomBorder = mouseY > (root.height - root.borderThickness) && mouseY < root.height;
93
if (!pressed || !dragging) {
97
var pos = mapToItem(root.parent, mouseX, mouseY);
99
var deltaX = pos.x - startX;
101
if (startWidth - deltaX >= root.minWidth) {
102
surfaceItem.surfaceWidth = startWidth - deltaX;
104
surfaceItem.surfaceWidth = root.minWidth;
106
} else if (rightBorder) {
107
if (startWidth + deltaX >= root.minWidth) {
108
surfaceItem.surfaceWidth = startWidth + deltaX;
110
surfaceItem.surfaceWidth = root.minWidth;
116
if (!pressed || !dragging) {
120
var pos = mapToItem(root.parent, mouseX, mouseY);
122
var deltaY = pos.y - startY;
124
if (startHeight - deltaY >= root.minHeight) {
125
surfaceItem.surfaceHeight = startHeight - deltaY;
127
surfaceItem.surfaceHeight = root.minHeight;
129
} else if (bottomBorder) {
130
if (startHeight + deltaY >= root.minHeight) {
131
surfaceItem.surfaceHeight = startHeight + deltaY;
133
surfaceItem.surfaceHeight = root.minHeight;
141
anchors.left: parent.left
142
anchors.leftMargin: root.borderThickness
143
anchors.right: parent.right
144
anchors.rightMargin: root.borderThickness
145
anchors.top: parent.top
146
anchors.topMargin: root.borderThickness
150
onCloneRequested: { root.cloneRequested(); }
156
width: surface ? surface.size.width : 50
157
height: surface ? surface.size.height : 50
160
if (resizeArea.dragging && resizeArea.leftBorder) {
161
root.x = resizeArea.startX + resizeArea.startWidth - surfaceItem.width;
166
if (resizeArea.dragging && resizeArea.topBorder) {
167
root.y = resizeArea.startY + resizeArea.startHeight - surfaceItem.height;
171
anchors.top: titleBar.bottom
172
anchors.left: parent.left
173
anchors.leftMargin: root.borderThickness