2 * Copyright (C) 2014-2015 Canonical, Ltd.
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.
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.
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/>.
16 * Authors: Michael Zanetti <michael.zanetti@canonical.com>
20 import Ubuntu.Components 1.3
21 import Unity.Application 0.1
26 width: !counterRotate ? applicationWindow.width : applicationWindow.height
27 height: visibleDecorationHeight + (!counterRotate ? applicationWindow.height : applicationWindow.width)
29 property alias application: applicationWindow.application
30 property alias surface: applicationWindow.surface
31 property alias active: decoration.active
32 readonly property alias title: applicationWindow.title
33 property alias fullscreen: applicationWindow.fullscreen
35 readonly property bool decorationShown: !fullscreen
36 property bool highlightShown: false
37 property real shadowOpacity: 1
39 property real requestedWidth
40 property real requestedHeight
41 property alias surfaceOrientationAngle: applicationWindow.surfaceOrientationAngle
42 readonly property real visibleDecorationHeight: root.decorationShown ? decoration.height : 0
43 readonly property bool counterRotate: surfaceOrientationAngle != 0 && surfaceOrientationAngle != 180
45 readonly property int minimumWidth: !counterRotate ? applicationWindow.minimumWidth : applicationWindow.minimumHeight
46 readonly property int minimumHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.minimumHeight : applicationWindow.minimumWidth)
47 readonly property int maximumWidth: !counterRotate ? applicationWindow.maximumWidth : applicationWindow.maximumHeight
48 readonly property int maximumHeight: visibleDecorationHeight + (!counterRotate ? applicationWindow.maximumHeight : applicationWindow.maximumWidth)
49 readonly property int widthIncrement: !counterRotate ? applicationWindow.widthIncrement : applicationWindow.heightIncrement
50 readonly property int heightIncrement: !counterRotate ? applicationWindow.heightIncrement : applicationWindow.widthIncrement
52 property alias overlayShown: decoration.overlayShown
55 signal maximizeClicked()
56 signal maximizeHorizontallyClicked()
57 signal maximizeVerticallyClicked()
58 signal minimizeClicked()
59 signal decorationPressed()
62 id: selectionHighlight
64 anchors.margins: -units.gu(1)
66 opacity: highlightShown ? 0.15 : 0
70 anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
72 color: theme.palette.normal.focus
73 visible: highlightShown
79 margins: active ? -units.gu(2) : -units.gu(1.5)
81 source: "graphics/dropshadow2gu.sci"
82 opacity: root.shadowOpacity * .3
89 objectName: "appWindowDecoration"
90 anchors { left: parent.left; top: parent.top; right: parent.right }
93 title: applicationWindow.title
94 visible: root.decorationShown
96 onCloseClicked: root.closeClicked();
97 onMaximizeClicked: { root.decorationPressed(); root.maximizeClicked(); }
98 onMaximizeHorizontallyClicked: { root.decorationPressed(); root.maximizeHorizontallyClicked(); }
99 onMaximizeVerticallyClicked: { root.decorationPressed(); root.maximizeVerticallyClicked(); }
100 onMinimizeClicked: root.minimizeClicked();
101 onPressed: root.decorationPressed();
105 id: applicationWindow
106 objectName: "appWindow"
107 anchors.top: parent.top
108 anchors.topMargin: decoration.height
109 anchors.left: parent.left
110 readonly property real requestedHeightMinusDecoration: root.requestedHeight - root.visibleDecorationHeight
111 requestedHeight: !counterRotate ? requestedHeightMinusDecoration : root.requestedWidth
112 requestedWidth: !counterRotate ? root.requestedWidth : requestedHeightMinusDecoration
116 transform: Rotation {
117 readonly property int rotationAngle: applicationWindow.application &&
118 applicationWindow.application.rotatesWindowContents
119 ? ((360 - applicationWindow.surfaceOrientationAngle) % 360) : 0
121 if (rotationAngle == 90) return applicationWindow.height / 2;
122 else if (rotationAngle == 270) return applicationWindow.width / 2;
123 else if (rotationAngle == 180) return applicationWindow.width / 2;
127 if (rotationAngle == 90) return applicationWindow.height / 2;
128 else if (rotationAngle == 270) return applicationWindow.width / 2;
129 else if (rotationAngle == 180) return applicationWindow.height / 2;