on 3d3fb96 help sign in
unity8/qml/Components/WindowControlButtons.qml
106 lines 3.2 kB history raw
1/*
2 * Copyright (C) 2014-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 "../Components/TouchControlsState"
21Row {
22 id: root
23 spacing: overlayShown ? units.gu(2) : units.gu(1)
24 Behavior on spacing {
25 UbuntuNumberAnimation {}
26 }
28 // to be set from outside
29 property Item target
30 property bool active: false
31 property bool windowIsMaximized: false
32 property bool closeButtonShown: true
34 readonly property bool overlayShown: TouchControlsState.overlayShown && target && target.surface === TouchControlsState.surface
36 signal close()
37 signal minimize()
38 signal maximize()
40 MouseArea {
41 id: closeWindowButton
42 objectName: "closeWindowButton"
43 hoverEnabled: true
44 height: parent.height
45 width: height
46 onClicked: root.close()
47 visible: root.closeButtonShown
49 Rectangle {
50 anchors.fill: parent
51 radius: height / 2
52 color: UbuntuColors.red
53 visible: parent.containsMouse && !overlayShown
54 }
55 Icon {
56 anchors.fill: parent
57 anchors.margins: units.dp(3)
58 source: "graphics/window-close.svg"
59 color: root.active ? "white" : UbuntuColors.slate
60 }
61 }
63 MouseArea {
64 id: minimizeWindowButton
65 objectName: "minimizeWindowButton"
66 hoverEnabled: true
67 height: parent.height
68 width: height
69 onClicked: root.minimize()
71 Rectangle {
72 anchors.fill: parent
73 radius: height / 2
74 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
75 visible: parent.containsMouse && !overlayShown
76 }
77 Icon {
78 anchors.fill: parent
79 anchors.margins: units.dp(3)
80 source: "graphics/window-minimize.svg"
81 color: root.active ? "white" : UbuntuColors.slate
82 }
83 }
85 MouseArea {
86 id: maximizeWindowButton
87 objectName: "maximizeWindowButton"
88 hoverEnabled: true
89 height: parent.height
90 width: height
91 onClicked: root.maximize()
93 Rectangle {
94 anchors.fill: parent
95 radius: height / 2
96 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
97 visible: parent.containsMouse && !overlayShown
98 }
99 Icon {
100 anchors.fill: parent
101 anchors.margins: units.dp(3)
102 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
103 color: root.active ? "white" : UbuntuColors.slate
104 }
105 }