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 Ubuntu.Components 1.3
19 import "../Components"
25 property Item target // appDelegate
26 property alias title: titleLabel.text
27 property alias maximizeButtonShown: buttons.maximizeButtonShown
28 property bool active: false
29 property alias overlayShown: buttons.overlayShown
31 readonly property real buttonsWidth: buttons.width + row.spacing
33 acceptedButtons: Qt.AllButtons // prevent leaking unhandled mouse events
37 signal minimizeClicked()
38 signal maximizeClicked()
39 signal maximizeHorizontallyClicked()
40 signal maximizeVerticallyClicked()
43 if (target.canBeMaximized && mouse.button == Qt.LeftButton) {
44 root.maximizeClicked();
48 // do not let unhandled wheel event pass thru the decoration
49 onWheel: wheel.accepted = true;
53 anchors.bottomMargin: -radius
55 color: theme.palette.normal.background
62 leftMargin: overlayShown ? units.gu(5) : units.gu(1)
63 rightMargin: units.gu(1)
64 topMargin: units.gu(0.5)
65 bottomMargin: units.gu(0.5)
67 Behavior on anchors.leftMargin {
68 UbuntuNumberAnimation {}
73 WindowControlButtons {
77 onCloseClicked: root.closeClicked();
78 onMinimizeClicked: root.minimizeClicked();
79 onMaximizeClicked: root.maximizeClicked();
80 onMaximizeHorizontallyClicked: if (root.target.canBeMaximizedHorizontally) root.maximizeHorizontallyClicked();
81 onMaximizeVerticallyClicked: if (root.target.canBeMaximizedVertically) root.maximizeVerticallyClicked();
82 closeButtonShown: root.target.application.appId !== "unity8-dash"
87 objectName: "windowDecorationTitle"
88 color: root.active ? "white" : UbuntuColors.slate
90 width: parent.width - buttons.width - parent.anchors.rightMargin - parent.anchors.leftMargin
91 verticalAlignment: Text.AlignVCenter
93 font.weight: root.active ? Font.Light : Font.Medium
94 elide: Text.ElideRight
95 opacity: overlayShown ? 0 : 1
97 Behavior on opacity { UbuntuNumberAnimation {} }