on bb09f86 help sign in
unity8/qml/Stage/ChildWindowTree.qml
127 lines 4.2 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19import Unity.Application 0.1
21Item {
22 id: root
24 property alias surface: childWindow.surface
25 property real displacementX: 0
26 property real displacementY: 0
27 property alias boundsItem: childWindow.boundsItem
29 x: surface ? surface.position.x + displacementX : 0
30 y: surface ? surface.position.y + displacementY : 0
31 width: childWindow.width
32 height: childWindow.height
34 ////
35 // API expected by MoveHandler (and some by WindowResizeArea as well)
36 readonly property bool maximized: false
37 readonly property bool maximizedLeft: false
38 readonly property bool maximizedRight: false
39 readonly property bool maximizedHorizontally: false
40 readonly property bool maximizedVertically: false
41 readonly property bool maximizedTopLeft: false
42 readonly property bool maximizedTopRight: false
43 readonly property bool maximizedBottomLeft: false
44 readonly property bool maximizedBottomRight: false
45 readonly property bool anyMaximized: maximized || maximizedLeft || maximizedRight || maximizedHorizontally || maximizedVertically ||
46 maximizedTopLeft || maximizedTopRight || maximizedBottomLeft || maximizedBottomRight
48 readonly property bool canBeCornerMaximized: false
49 readonly property bool canBeMaximizedLeftRight: false
50 readonly property bool canBeMaximized: false
52 readonly property var resizeArea: QtObject {
53 property real normalWidth: units.gu(1)
54 property real normalHeight: units.gu(1)
55 }
57 readonly property bool windowedTransitionRunning: false
59 // NB: those bindings will be overwritten by MoveHandler when you first move the window
60 property real windowedX: x
61 property real windowedY: y
64 property real restoredX
65 property real restoredY
67 state: "restored"
68 // end of API expected by MoveHandler
69 ////
71 ////
72 // API expected by WindowResizeArea
73 property real windowedWidth: childWindow.width
74 property real windowedHeight: childWindow.height
75 // end of API expected by WindowResizeArea
76 ////
78 ////
79 // API expected by WindowControlsOverlay
80 function activate() {
81 surface.activate();
82 }
83 // end of API expected by WindowControlsOverlay
84 ////
86 Binding {
87 target: root.surface
88 when: childWindow.dragging
89 property: "requestedPosition"
90 value: Qt.point(root.windowedX - root.displacementX,
91 root.windowedY - root.displacementY);
92 }
94 // It's a separate Item so that a window can be hid independently of its children
95 ChildWindow {
96 id: childWindow
97 target: root
98 requestedWidth: root.windowedWidth
99 requestedHeight: root.windowedHeight
100 }
102 Connections {
103 target: root.surface
104 onFocusRequested: {
105 root.surface.activate();
106 }
107 }
109 // Using a loader here mainly to circunvent the "ChildWindowTree is instantiated recursively" error from the QML engine
110 Loader {
111 id: childRepeaterLoader
112 source: "ChildWindowRepeater.qml"
113 active: root.surface && root.surface.childSurfaceList.count > 0
114 Binding {
115 target: childRepeaterLoader.item
116 when: childRepeaterLoader.item
117 property: "model"
118 value: root.surface ? root.surface.childSurfaceList : null
119 }
120 Binding {
121 target: childRepeaterLoader.item
122 when: childRepeaterLoader.item
123 property: "boundsItem"
124 value: root.boundsItem
125 }
126 }