2 * Copyright (C) 2014-2016 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/>.
18 import Unity.Application 0.1 // For Mir singleton
19 import Ubuntu.Components 1.3
20 import "../Components"
21 import "../Components/PanelState"
28 property alias title: titleLabel.text
29 property bool active: false
30 property alias overlayShown: buttons.overlayShown
35 signal minimizeClicked()
36 signal maximizeClicked()
37 signal maximizeHorizontallyClicked()
38 signal maximizeVerticallyClicked()
40 onDoubleClicked: root.maximizeClicked()
44 property real distanceX
45 property real distanceY
46 property bool dragging
51 var pos = mapToItem(root.target, mouseX, mouseY);
52 priv.distanceX = pos.x;
53 priv.distanceY = pos.y;
56 priv.dragging = false;
63 Mir.cursorName = "grabbing";
64 var pos = mapToItem(root.target.parent, mouseX, mouseY);
65 // Use integer coordinate values to ensure that target is left in a pixel-aligned
66 // position. Mouse movement could have subpixel precision, yielding a fractional
68 root.target.x = Math.round(pos.x - priv.distanceX);
69 root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
75 anchors.bottomMargin: -radius
77 color: theme.palette.normal.background
83 leftMargin: overlayShown ? units.gu(5) : units.gu(1)
84 rightMargin: units.gu(1)
85 topMargin: units.gu(0.5)
86 bottomMargin: units.gu(0.5)
88 Behavior on anchors.leftMargin {
89 UbuntuNumberAnimation {}
94 WindowControlButtons {
98 onCloseClicked: root.closeClicked();
99 onMinimizeClicked: root.minimizeClicked();
100 onMaximizeClicked: root.maximizeClicked();
101 onMaximizeHorizontallyClicked: root.maximizeHorizontallyClicked();
102 onMaximizeVerticallyClicked: root.maximizeVerticallyClicked();
103 closeButtonShown: root.target.application.appId !== "unity8-dash"
109 objectName: "windowDecorationTitle"
110 color: root.active ? "white" : UbuntuColors.slate
111 height: parent.height
112 width: parent.width - buttons.width - parent.anchors.rightMargin - parent.anchors.leftMargin
113 verticalAlignment: Text.AlignVCenter
115 font.weight: root.active ? Font.Light : Font.Medium
116 elide: Text.ElideRight
117 opacity: overlayShown ? 0 : 1
118 visible: opacity == 1
119 Behavior on opacity {
120 OpacityAnimator { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }