2
import Unity.Application 0.1
7
// to be set from outside
9
property real borderThickness
11
property bool leftBorder: false
12
property bool rightBorder: false
13
property bool topBorder: false
14
property bool bottomBorder: false
16
property bool dragging: false
19
property real startWidth
20
property real startHeight
24
property string cursorName: {
25
if (containsMouse || pressed) {
26
if (leftBorder && !topBorder && !bottomBorder) {
28
} else if (rightBorder && !topBorder && !bottomBorder) {
30
} else if (topBorder && !leftBorder && !rightBorder) {
32
} else if (bottomBorder && !leftBorder && !rightBorder) {
34
} else if (leftBorder && topBorder) {
35
return "top_left_corner";
36
} else if (leftBorder && bottomBorder) {
37
return "bottom_left_corner";
38
} else if (rightBorder && topBorder) {
39
return "top_right_corner";
40
} else if (rightBorder && bottomBorder) {
41
return "bottom_right_corner";
49
onCursorNameChanged: {
50
Mir.cursorName = cursorName;
53
function updateBorders() {
54
leftBorder = mouseX <= borderThickness;
55
rightBorder = mouseX >= width - borderThickness;
56
topBorder = mouseY <= borderThickness;
57
bottomBorder = mouseY >= height - borderThickness;
62
var pos = mapToItem(target.parent, mouseX, mouseY);
65
startWidth = target.width;
66
startHeight = target.height;
91
var pos = mapToItem(target.parent, mouse.x, mouse.y);
94
if (startX + startWidth - pos.x > target.minWidth) {
96
target.width = startX + startWidth - target.x;
98
startWidth = target.width;
101
} else if (rightBorder) {
102
var deltaX = pos.x - startX;
103
if (startWidth + deltaX >= target.minWidth) {
104
target.width = startWidth + deltaX;
106
target.width = target.minWidth;
111
if (startY + startHeight - pos.y > target.minHeight) {
113
target.height = startY + startHeight - target.y;
115
startHeight = target.height;
118
} else if (bottomBorder) {
119
var deltaY = pos.y - startY;
120
if (startHeight + deltaY >= target.minHeight) {
121
target.height = startHeight + deltaY;
123
target.height = target.minHeight;