on xenial help sign in
Respect Fitt's law wrt the window control buttons in panel (LP: #1611959)
3472f4dLukáš Tinkl
qml/Components/WindowControlButtons.qml+7−5
@@ -19,13 +19,12 @@ import Ubuntu.Components 1.3
19
19
20Row {
20Row {
21 id: root
21 id: root
22− spacing: overlayShown ? units.gu(2) : units.gu(1)
22+ spacing: overlayShown ? units.gu(2) : windowIsMaximized ? 0 : units.gu(1)
23 Behavior on spacing {
23 Behavior on spacing {
24 UbuntuNumberAnimation {}
24 UbuntuNumberAnimation {}
25 }
25 }
26
26
27 // to be set from outside
27 // to be set from outside
28− property Item target
29 property bool active: false
28 property bool active: false
30 property bool windowIsMaximized: false
29 property bool windowIsMaximized: false
31 property bool closeButtonShown: true
30 property bool closeButtonShown: true
@@ -49,13 +48,14 @@ Row {
49
48
50 Rectangle {
49 Rectangle {
51 anchors.fill: parent
50 anchors.fill: parent
51+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
52 radius: height / 2
52 radius: height / 2
53 color: theme.palette.normal.negative
53 color: theme.palette.normal.negative
54 visible: parent.containsMouse && !overlayShown
54 visible: parent.containsMouse && !overlayShown
55 }
55 }
56 Icon {
56 Icon {
57 anchors.fill: parent
57 anchors.fill: parent
58− anchors.margins: units.dp(3)
58+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
59 source: "graphics/window-close.svg"
59 source: "graphics/window-close.svg"
60 color: root.active ? "white" : UbuntuColors.slate
60 color: root.active ? "white" : UbuntuColors.slate
61 }
61 }
@@ -71,13 +71,14 @@ Row {
71
71
72 Rectangle {
72 Rectangle {
73 anchors.fill: parent
73 anchors.fill: parent
74+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
74 radius: height / 2
75 radius: height / 2
75 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
76 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
76 visible: parent.containsMouse && !overlayShown
77 visible: parent.containsMouse && !overlayShown
77 }
78 }
78 Icon {
79 Icon {
79 anchors.fill: parent
80 anchors.fill: parent
80− anchors.margins: units.dp(3)
81+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
81 source: "graphics/window-minimize.svg"
82 source: "graphics/window-minimize.svg"
82 color: root.active ? "white" : UbuntuColors.slate
83 color: root.active ? "white" : UbuntuColors.slate
83 }
84 }
@@ -103,13 +104,14 @@ Row {
103
104
104 Rectangle {
105 Rectangle {
105 anchors.fill: parent
106 anchors.fill: parent
107+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
106 radius: height / 2
108 radius: height / 2
107 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
109 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
108 visible: parent.containsMouse && !overlayShown
110 visible: parent.containsMouse && !overlayShown
109 }
111 }
110 Icon {
112 Icon {
111 anchors.fill: parent
113 anchors.fill: parent
112− anchors.margins: units.dp(3)
114+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
113 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
115 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
114 color: root.active ? "white" : UbuntuColors.slate
116 color: root.active ? "white" : UbuntuColors.slate
115 }
117 }
qml/Panel/Panel.qml+5−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013-2015 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -120,11 +120,8 @@ Item {
120 anchors {
120 anchors {
121 left: parent.left
121 left: parent.left
122 top: parent.top
122 top: parent.top
123− leftMargin: units.gu(1)
124− topMargin: units.gu(0.5)
125− bottomMargin: units.gu(0.5)
126 }
123 }
127− height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
124+ height: indicators.minimizedPanelHeight
128
125
129 visible: ((PanelState.buttonsVisible && parent.containsMouse) || PanelState.buttonsAlwaysVisible)
126 visible: ((PanelState.buttonsVisible && parent.containsMouse) || PanelState.buttonsAlwaysVisible)
130 && !root.locked && !callHint.visible
127 && !root.locked && !callHint.visible
@@ -183,13 +180,15 @@ Item {
183 }
180 }
184 color: "white"
181 color: "white"
185 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
182 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
186− visible: !windowControlButtons.visible && !root.locked && !callHint.visible
183+ opacity: !windowControlButtons.visible && !root.locked && !callHint.visible ? 1 : 0
184+ visible: opacity != 0
187 verticalAlignment: Text.AlignVCenter
185 verticalAlignment: Text.AlignVCenter
188 fontSize: "medium"
186 fontSize: "medium"
189 font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
187 font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
190 text: PanelState.title
188 text: PanelState.title
191 elide: Text.ElideRight
189 elide: Text.ElideRight
192 maximumLineCount: 1
190 maximumLineCount: 1
191+ Behavior on opacity { UbuntuNumberAnimation {} }
193 }
192 }
194
193
195 // TODO here would the Locally integrated menus come
194 // TODO here would the Locally integrated menus come
qml/Stages/WindowDecoration.qml+2−5
@@ -108,7 +108,6 @@ MouseArea {
108 onMaximizeHorizontallyClicked: root.maximizeHorizontallyClicked();
108 onMaximizeHorizontallyClicked: root.maximizeHorizontallyClicked();
109 onMaximizeVerticallyClicked: root.maximizeVerticallyClicked();
109 onMaximizeVerticallyClicked: root.maximizeVerticallyClicked();
110 closeButtonShown: root.target.application.appId !== "unity8-dash"
110 closeButtonShown: root.target.application.appId !== "unity8-dash"
111− target: root.target
112 }
111 }
113
112
114 Label {
113 Label {
@@ -122,10 +121,8 @@ MouseArea {
122 font.weight: root.active ? Font.Light : Font.Medium
121 font.weight: root.active ? Font.Light : Font.Medium
123 elide: Text.ElideRight
122 elide: Text.ElideRight
124 opacity: overlayShown ? 0 : 1
123 opacity: overlayShown ? 0 : 1
125− visible: opacity == 1
124+ visible: opacity != 0
126− Behavior on opacity {
125+ Behavior on opacity { UbuntuNumberAnimation {} }
127− OpacityAnimator { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
128− }
129 }
126 }
130 }
127 }
131}
128}
tests/qmltests/Panel/tst_Panel.qml+19
@@ -182,6 +182,12 @@ IndicatorTest {
182 signalName: "pressedChanged"
182 signalName: "pressedChanged"
183 }
183 }
184
184
185+ SignalSpy {
186+ id: windowControlButtonsSpy
187+ target: PanelState
188+ signalName: "closeClicked"
189+ }
190+
185 function init() {
191 function init() {
186 panel.fullscreenMode = false;
192 panel.fullscreenMode = false;
187 callManager.foregroundCall = null;
193 callManager.foregroundCall = null;
@@ -197,6 +203,8 @@ IndicatorTest {
197
203
198 backgroundPressedSpy.clear();
204 backgroundPressedSpy.clear();
199 compare(backgroundPressedSpy.valid, true);
205 compare(backgroundPressedSpy.valid, true);
206+ windowControlButtonsSpy.clear();
207+ compare(windowControlButtonsSpy.valid, true);
200 }
208 }
201
209
202 function get_indicator_item(index) {
210 function get_indicator_item(index) {
@@ -494,5 +502,16 @@ IndicatorTest {
494 compare(panel.indicators.shown, false);
502 compare(panel.indicators.shown, false);
495 tryCompare(panel.indicators, "fullyClosed", true);
503 tryCompare(panel.indicators, "fullyClosed", true);
496 }
504 }
505+
506+ // https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1611959
507+ function test_windowControlButtonsFittsLaw() {
508+ var buttonsVisible = PanelState.buttonsVisible;
509+ PanelState.buttonsVisible = true;
510+ // click in very topleft corner and verify the close button got clicked too
511+ mouseMove(panel, 0, 0);
512+ mouseClick(panel, 0, 0, undefined /*button*/, undefined /*modifiers*/, 100 /*short delay*/);
513+ compare(windowControlButtonsSpy.count, 1);
514+ PanelState.buttonsVisible = buttonsVisible;
515+ }
497 }
516 }
498}
517}