~cemil-azizoglu/miral/mir-0.26.1-compat

« back to all changes in this revision

Viewing changes to miral-qt/demos/qml-demo-shell/TitleBar.qml

  • Committer: Larry Price
  • Date: 2016-09-13 16:19:29 UTC
  • mto: (330.4.1 miral)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: larry.price@canonical.com-20160913161929-vs9ka1capmljq1es
Removing miral-qt from release branch, updating copyright file, and adding GPL3 license to root dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import QtQuick 2.4
2
 
import Unity.Application 0.1
3
 
 
4
 
Rectangle {
5
 
    id: root
6
 
    color: "brown"
7
 
    height: 25
8
 
 
9
 
    property Item target
10
 
    property bool cloned: false
11
 
    property bool closeRequested: false
12
 
    signal cloneRequested()
13
 
 
14
 
    MouseArea {
15
 
        anchors.fill: parent
16
 
        property real distanceX
17
 
        property real distanceY
18
 
        property bool dragging
19
 
        onPressedChanged: {
20
 
            if (pressed) {
21
 
                var pos = mapToItem(root.target, mouseX, mouseY);
22
 
                distanceX = pos.x;
23
 
                distanceY = pos.y;
24
 
                dragging = true;
25
 
                Mir.cursorName = "grabbing";
26
 
            } else {
27
 
                dragging = false;
28
 
                Mir.cursorName = "";
29
 
            }
30
 
        }
31
 
        onMouseXChanged: {
32
 
            if (dragging) {
33
 
                var pos = mapToItem(root.target.parent, mouseX, mouseY);
34
 
                root.target.x = pos.x - distanceX;
35
 
                root.target.y = pos.y - distanceY;
36
 
            }
37
 
        }
38
 
    }
39
 
 
40
 
    Text {
41
 
        visible: !root.cloned
42
 
        anchors.top: parent.top
43
 
        anchors.bottom: parent.bottom
44
 
        text: "CLONE"
45
 
        MouseArea {
46
 
            anchors.fill: parent
47
 
            onClicked: {
48
 
                root.cloneRequested();
49
 
            }
50
 
        }
51
 
    }
52
 
 
53
 
    Text {
54
 
        anchors.top: parent.top
55
 
        anchors.bottom: parent.bottom
56
 
        anchors.right: parent.right
57
 
        width: contentWidth
58
 
        text: "X"
59
 
        fontSizeMode: Text.VerticalFit
60
 
        minimumPixelSize: 10; font.pixelSize: 72
61
 
        font.weight: Font.Bold
62
 
        horizontalAlignment: Text.AlignRight
63
 
        verticalAlignment: Text.AlignVCenter
64
 
        MouseArea {
65
 
            anchors.fill: parent
66
 
            onClicked: {
67
 
                root.closeRequested = true;
68
 
            }
69
 
        }
70
 
    }
71
 
}
72