on xenial help sign in
Respect Fitt's law wrt the window control buttons in panel (LP: #1611959)
cfbfce2Lukáš Tinkl
qml/Components/WindowControlButtons.qml+7−4
@@ -19,7 +19,7 @@ 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 }
@@ -48,13 +48,14 @@ Row {
48
48
49 Rectangle {
49 Rectangle {
50 anchors.fill: parent
50 anchors.fill: parent
51+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
51 radius: height / 2
52 radius: height / 2
52 color: theme.palette.normal.negative
53 color: theme.palette.normal.negative
53 visible: parent.containsMouse && !overlayShown
54 visible: parent.containsMouse && !overlayShown
54 }
55 }
55 Icon {
56 Icon {
56 anchors.fill: parent
57 anchors.fill: parent
57− anchors.margins: units.dp(3)
58+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
58 source: "graphics/window-close.svg"
59 source: "graphics/window-close.svg"
59 color: root.active ? "white" : UbuntuColors.slate
60 color: root.active ? "white" : UbuntuColors.slate
60 }
61 }
@@ -70,13 +71,14 @@ Row {
70
71
71 Rectangle {
72 Rectangle {
72 anchors.fill: parent
73 anchors.fill: parent
74+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
73 radius: height / 2
75 radius: height / 2
74 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
76 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
75 visible: parent.containsMouse && !overlayShown
77 visible: parent.containsMouse && !overlayShown
76 }
78 }
77 Icon {
79 Icon {
78 anchors.fill: parent
80 anchors.fill: parent
79− anchors.margins: units.dp(3)
81+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
80 source: "graphics/window-minimize.svg"
82 source: "graphics/window-minimize.svg"
81 color: root.active ? "white" : UbuntuColors.slate
83 color: root.active ? "white" : UbuntuColors.slate
82 }
84 }
@@ -102,13 +104,14 @@ Row {
102
104
103 Rectangle {
105 Rectangle {
104 anchors.fill: parent
106 anchors.fill: parent
107+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
105 radius: height / 2
108 radius: height / 2
106 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
109 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
107 visible: parent.containsMouse && !overlayShown
110 visible: parent.containsMouse && !overlayShown
108 }
111 }
109 Icon {
112 Icon {
110 anchors.fill: parent
113 anchors.fill: parent
111− anchors.margins: units.dp(3)
114+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
112 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
115 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
113 color: root.active ? "white" : UbuntuColors.slate
116 color: root.active ? "white" : UbuntuColors.slate
114 }
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
@@ -117,11 +117,8 @@ Item {
117 anchors {
117 anchors {
118 left: parent.left
118 left: parent.left
119 top: parent.top
119 top: parent.top
120− leftMargin: units.gu(1)
121− topMargin: units.gu(0.5)
122− bottomMargin: units.gu(0.5)
123 }
120 }
124− height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
121+ height: indicators.minimizedPanelHeight
125
122
126 visible: ((PanelState.buttonsVisible && parent.containsMouse) || PanelState.buttonsAlwaysVisible)
123 visible: ((PanelState.buttonsVisible && parent.containsMouse) || PanelState.buttonsAlwaysVisible)
127 && !root.locked && !callHint.visible
124 && !root.locked && !callHint.visible
@@ -180,13 +177,15 @@ Item {
180 }
177 }
181 color: "white"
178 color: "white"
182 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
179 height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
183− visible: !windowControlButtons.visible && !root.locked && !callHint.visible
180+ opacity: !windowControlButtons.visible && !root.locked && !callHint.visible ? 1 : 0
181+ visible: opacity != 0
184 verticalAlignment: Text.AlignVCenter
182 verticalAlignment: Text.AlignVCenter
185 fontSize: "medium"
183 fontSize: "medium"
186 font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
184 font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
187 text: PanelState.title
185 text: PanelState.title
188 elide: Text.ElideRight
186 elide: Text.ElideRight
189 maximumLineCount: 1
187 maximumLineCount: 1
188+ Behavior on opacity { UbuntuNumberAnimation {} }
190 }
189 }
191
190
192 // TODO here would the Locally integrated menus come
191 // TODO here would the Locally integrated menus come
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) {
@@ -492,5 +500,16 @@ IndicatorTest {
492 compare(panel.indicators.shown, false);
500 compare(panel.indicators.shown, false);
493 tryCompare(panel.indicators, "fullyClosed", true);
501 tryCompare(panel.indicators, "fullyClosed", true);
494 }
502 }
503+
504+ // https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1611959
505+ function test_windowControlButtonsFittsLaw() {
506+ var buttonsVisible = PanelState.buttonsVisible;
507+ PanelState.buttonsVisible = true;
508+ // click in very topleft corner and verify the close button got clicked too
509+ mouseMove(panel, 0, 0);
510+ mouseClick(panel, 0, 0, undefined /*button*/, undefined /*modifiers*/, 100 /*short delay*/);
511+ compare(windowControlButtonsSpy.count, 1);
512+ PanelState.buttonsVisible = buttonsVisible;
513+ }
495 }
514 }
496}
515}