~lukas-kde/miral/shellchrome-windowinfo

« back to all changes in this revision

Viewing changes to miral-qt/demos/qml-demo-shell/Window.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.0
2
 
import Unity.Application 0.1
3
 
 
4
 
Rectangle {
5
 
    id: root
6
 
    color: "red"
7
 
 
8
 
    property alias surface: surfaceItem.surface
9
 
    property bool touchMode: false
10
 
 
11
 
    width: surfaceItem.implicitWidth + 2*borderThickness
12
 
    height: surfaceItem.implicitHeight + 2*borderThickness + titleBar.height
13
 
 
14
 
    signal cloneRequested()
15
 
    property bool cloned: false
16
 
 
17
 
    onTouchModeChanged: {
18
 
        if (touchMode) {
19
 
            x -= borderThicknessTouch - borderThicknessMouse;
20
 
            width += 2*(borderThicknessTouch - borderThicknessMouse);
21
 
            y -= borderThicknessTouch - borderThicknessMouse;
22
 
            height += 2*(borderThicknessTouch - borderThicknessMouse);
23
 
        } else {
24
 
            x += borderThicknessTouch - borderThicknessMouse;
25
 
            width -= 2*(borderThicknessTouch - borderThicknessMouse);
26
 
            y += borderThicknessTouch - borderThicknessMouse;
27
 
            height -= 2*(borderThicknessTouch - borderThicknessMouse);
28
 
        }
29
 
    }
30
 
 
31
 
    readonly property real minWidth: 100
32
 
    readonly property real minHeight: 100
33
 
 
34
 
    property real borderThickness: touchMode ? borderThicknessTouch : borderThicknessMouse
35
 
    readonly property real borderThicknessMouse: 10
36
 
    readonly property real borderThicknessTouch: 40
37
 
 
38
 
    states: [
39
 
        State {
40
 
            name: "closed"
41
 
            when: (surface && !surface.live) || titleBar.closeRequested
42
 
        }
43
 
    ]
44
 
    transitions: [
45
 
        Transition {
46
 
            from: ""; to: "closed"
47
 
            SequentialAnimation {
48
 
                PropertyAnimation {
49
 
                    target: root
50
 
                    property: "scale"
51
 
                    easing.type: Easing.InBack
52
 
                    duration: 400
53
 
                    from: 1.0
54
 
                    to: 0.0
55
 
                }
56
 
                ScriptAction { script: { root.destroy(); } }
57
 
            }
58
 
        }
59
 
    ]
60
 
 
61
 
    ResizeArea {
62
 
        anchors.fill: root
63
 
        borderThickness: root.borderThickness
64
 
        target: root
65
 
    }
66
 
 
67
 
    TitleBar {
68
 
        id: titleBar
69
 
        anchors.left: parent.left
70
 
        anchors.leftMargin: root.borderThickness
71
 
        anchors.right: parent.right
72
 
        anchors.rightMargin: root.borderThickness
73
 
        anchors.top: parent.top
74
 
        anchors.topMargin: root.borderThickness
75
 
 
76
 
        target: root
77
 
        cloned: root.cloned
78
 
        onCloneRequested: { root.cloneRequested(); }
79
 
    }
80
 
 
81
 
    MirSurfaceItem {
82
 
        id: surfaceItem
83
 
 
84
 
        anchors.top: titleBar.bottom
85
 
        anchors.left: parent.left
86
 
        anchors.leftMargin: root.borderThickness
87
 
        anchors.right: parent.right
88
 
        anchors.rightMargin: root.borderThickness
89
 
        anchors.bottom: parent.bottom
90
 
        anchors.bottomMargin: root.borderThickness
91
 
 
92
 
        consumesInput: !root.cloned
93
 
        surfaceWidth: root.cloned ? -1 : width
94
 
        surfaceHeight: root.cloned ? -1 : height
95
 
    }
96
 
}