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
33 signal minimizeClicked()
34 signal maximizeClicked()
35 signal maximizeHorizontallyClicked()
36 signal maximizeVerticallyClicked()
38 onDoubleClicked: root.maximizeClicked()
42 property real distanceX
43 property real distanceY
44 property bool dragging
49 var pos = mapToItem(root.target, mouseX, mouseY);
50 priv.distanceX = pos.x;
51 priv.distanceY = pos.y;
54 priv.dragging = false;
61 Mir.cursorName = "grabbing";
62 var pos = mapToItem(root.target.parent, mouseX, mouseY);
63 root.target.x = pos.x - priv.distanceX;
64 root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
70 anchors.bottomMargin: -radius
72 color: theme.palette.normal.background
78 leftMargin: units.gu(1)
79 rightMargin: units.gu(1)
80 topMargin: units.gu(0.5)
81 bottomMargin: units.gu(0.5)
85 WindowControlButtons {
89 onCloseClicked: root.closeClicked();
90 onMinimizeClicked: root.minimizeClicked();
91 onMaximizeClicked: root.maximizeClicked();
92 onMaximizeHorizontallyClicked: root.maximizeHorizontallyClicked();
93 onMaximizeVerticallyClicked: root.maximizeVerticallyClicked();
94 closeButtonShown: root.target.application.appId !== "unity8-dash"
99 objectName: "windowDecorationTitle"
100 color: root.active ? "white" : UbuntuColors.slate
101 height: parent.height
102 width: parent.width - buttons.width - parent.anchors.rightMargin - parent.anchors.leftMargin
103 verticalAlignment: Text.AlignVCenter
105 font.weight: root.active ? Font.Light : Font.Medium
106 elide: Text.ElideRight