on e668975 help sign in
unity8/qml/Components/WindowControlButtons.qml
103 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: TouchControlsState.overlayShown ? units.gu(2) : units.gu(1)
24 Behavior on spacing {
25 UbuntuNumberAnimation {}
26 }
28 // to be set from outside
29 property bool active: false
30 property bool windowIsMaximized: false
31 property bool closeButtonShown: true
33 signal close()
34 signal minimize()
35 signal maximize()
37 MouseArea {
38 id: closeWindowButton
39 objectName: "closeWindowButton"
40 hoverEnabled: true
41 height: parent.height
42 width: height
43 onClicked: root.close()
44 visible: root.closeButtonShown
46 Rectangle {
47 anchors.fill: parent
48 radius: height / 2
49 color: UbuntuColors.red
50 visible: parent.containsMouse && !TouchControlsState.overlayShown
51 }
52 Icon {
53 anchors.fill: parent
54 anchors.margins: units.dp(3)
55 source: "graphics/window-close.svg"
56 color: root.active ? "white" : UbuntuColors.slate
57 }
58 }
60 MouseArea {
61 id: minimizeWindowButton
62 objectName: "minimizeWindowButton"
63 hoverEnabled: true
64 height: parent.height
65 width: height
66 onClicked: root.minimize()
68 Rectangle {
69 anchors.fill: parent
70 radius: height / 2
71 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
72 visible: parent.containsMouse && !TouchControlsState.overlayShown
73 }
74 Icon {
75 anchors.fill: parent
76 anchors.margins: units.dp(3)
77 source: "graphics/window-minimize.svg"
78 color: root.active ? "white" : UbuntuColors.slate
79 }
80 }
82 MouseArea {
83 id: maximizeWindowButton
84 objectName: "maximizeWindowButton"
85 hoverEnabled: true
86 height: parent.height
87 width: height
88 onClicked: root.maximize()
90 Rectangle {
91 anchors.fill: parent
92 radius: height / 2
93 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
94 visible: parent.containsMouse && !TouchControlsState.overlayShown
95 }
96 Icon {
97 anchors.fill: parent
98 anchors.margins: units.dp(3)
99 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
100 color: root.active ? "white" : UbuntuColors.slate
101 }
102 }