2
import Unity.Application 0.1
6
readonly property int margin: 5
8
function setSurface(surface) {
9
surface.parent = root //windowContainer;
10
root.width = surface.width //+ 2*margin;
11
root.height = surface.height //+ margin + title.height;
13
surface.anchors.fill = root //windowContainer;
14
// surface.opacity = 0.99;
16
// title.text = surface.name;
23
// right: parent.right
26
// rightMargin: margin
8
property alias surface: surfaceItem.surface
9
property bool touchMode: false
11
width: surfaceItem.implicitWidth + 2*borderThickness
12
height: surfaceItem.implicitHeight + 2*borderThickness + titleBar.height
14
signal cloneRequested()
15
property bool cloned: false
19
x -= borderThicknessTouch - borderThicknessMouse;
20
width += 2*(borderThicknessTouch - borderThicknessMouse);
21
y -= borderThicknessTouch - borderThicknessMouse;
22
height += 2*(borderThicknessTouch - borderThicknessMouse);
24
x += borderThicknessTouch - borderThicknessMouse;
25
width -= 2*(borderThicknessTouch - borderThicknessMouse);
26
y += borderThicknessTouch - borderThicknessMouse;
27
height -= 2*(borderThicknessTouch - borderThicknessMouse);
31
readonly property real minWidth: 100
32
readonly property real minHeight: 100
34
property real borderThickness: touchMode ? borderThicknessTouch : borderThicknessMouse
35
readonly property real borderThicknessMouse: 10
36
readonly property real borderThicknessTouch: 40
41
when: (surface && !surface.live) || titleBar.closeRequested
46
from: ""; to: "closed"
51
easing.type: Easing.InBack
56
ScriptAction { script: { root.destroy(); } }
67
property real startWidth
68
property real startHeight
69
property bool leftBorder
70
property bool rightBorder
71
property bool topBorder
72
property bool bottomBorder
73
property bool dragging
76
var pos = mapToItem(root.parent, mouseX, mouseY);
81
leftBorder = mouseX > 0 && mouseX < root.borderThickness;
82
rightBorder = mouseX > (root.width - root.borderThickness) && mouseX < root.width;
83
topBorder = mouseY > 0 && mouseY < root.borderThickness;
84
bottomBorder = mouseY > (root.height - root.borderThickness) && mouseY < root.height;
92
if (!pressed || !dragging) {
96
var pos = mapToItem(root.parent, mouseX, mouseY);
100
if (startX + startWidth - pos.x > root.minWidth) {
102
root.width = startX + startWidth - root.x;
104
startWidth = root.width;
107
} else if (rightBorder) {
108
var deltaX = pos.x - startX;
109
if (startWidth + deltaX >= root.minWidth) {
110
root.width = startWidth + deltaX;
112
root.width = root.minWidth;
118
if (!pressed || !dragging) {
122
var pos = mapToItem(root.parent, mouseX, mouseY);
126
if (startY + startHeight - pos.y > root.minHeight) {
128
root.height = startY + startHeight - root.y;
130
startHeight = root.height;
133
} else if (bottomBorder) {
134
var deltaY = pos.y - startY;
135
if (startHeight + deltaY >= root.minHeight) {
136
root.height = startHeight + deltaY;
138
root.height = root.minHeight;
146
anchors.left: parent.left
147
anchors.leftMargin: root.borderThickness
148
anchors.right: parent.right
149
anchors.rightMargin: root.borderThickness
150
anchors.top: parent.top
151
anchors.topMargin: root.borderThickness
155
onCloneRequested: { root.cloneRequested(); }
161
anchors.top: titleBar.bottom
162
anchors.left: parent.left
163
anchors.leftMargin: root.borderThickness
164
anchors.right: parent.right
165
anchors.rightMargin: root.borderThickness
166
anchors.bottom: parent.bottom
167
anchors.bottomMargin: root.borderThickness
169
consumesInput: !root.cloned
170
surfaceWidth: root.cloned ? -1 : width
171
surfaceHeight: root.cloned ? -1 : height