on xenial help sign in
Respect Fitt's law wrt the window control buttons in panel (LP: #1611959)

Approved by: Albert Astals Cid

commitcfbfce2847b779b8aeab89000c25042fe56053d5 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateThu 22 Sep 2016, 07:42 (10 years ago) parent1951ac0024ffd8
3 files changed+31−10
qml/Components/WindowControlButtons.qml+7−4 qml/Panel/Panel.qml+5−6 tests/qmltests/Panel/tst_Panel.qml+19
qml/Components/WindowControlButtons.qml+7−4
@@ -19,7 +19,7 @@ import Ubuntu.Components 1.3
1919
2020Row {
2121 id: root
22− spacing: overlayShown ? units.gu(2) : units.gu(1)
22+ spacing: overlayShown ? units.gu(2) : windowIsMaximized ? 0 : units.gu(1)
2323 Behavior on spacing {
2424 UbuntuNumberAnimation {}
2525 }
@@ -48,13 +48,14 @@ Row {
4848
4949 Rectangle {
5050 anchors.fill: parent
51+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
5152 radius: height / 2
5253 color: theme.palette.normal.negative
5354 visible: parent.containsMouse && !overlayShown
5455 }
5556 Icon {
5657 anchors.fill: parent
57− anchors.margins: units.dp(3)
58+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
5859 source: "graphics/window-close.svg"
5960 color: root.active ? "white" : UbuntuColors.slate
6061 }
@@ -70,13 +71,14 @@ Row {
7071
7172 Rectangle {
7273 anchors.fill: parent
74+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
7375 radius: height / 2
7476 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
7577 visible: parent.containsMouse && !overlayShown
7678 }
7779 Icon {
7880 anchors.fill: parent
79− anchors.margins: units.dp(3)
81+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
8082 source: "graphics/window-minimize.svg"
8183 color: root.active ? "white" : UbuntuColors.slate
8284 }
@@ -102,13 +104,14 @@ Row {
102104
103105 Rectangle {
104106 anchors.fill: parent
107+ anchors.margins: windowIsMaximized ? units.dp(3) : 0
105108 radius: height / 2
106109 color: root.active ? UbuntuColors.graphite : UbuntuColors.ash
107110 visible: parent.containsMouse && !overlayShown
108111 }
109112 Icon {
110113 anchors.fill: parent
111− anchors.margins: units.dp(3)
114+ anchors.margins: windowIsMaximized ? units.dp(6) : units.dp(3)
112115 source: root.windowIsMaximized ? "graphics/window-window.svg" : "graphics/window-maximize.svg"
113116 color: root.active ? "white" : UbuntuColors.slate
114117 }
qml/Panel/Panel.qml+5−6
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2015 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -117,11 +117,8 @@ Item {
117117 anchors {
118118 left: parent.left
119119 top: parent.top
120− leftMargin: units.gu(1)
121− topMargin: units.gu(0.5)
122− bottomMargin: units.gu(0.5)
123120 }
124− height: indicators.minimizedPanelHeight - anchors.topMargin - anchors.bottomMargin
121+ height: indicators.minimizedPanelHeight
125122
126123 visible: ((PanelState.buttonsVisible && parent.containsMouse) || PanelState.buttonsAlwaysVisible)
127124 && !root.locked && !callHint.visible
@@ -180,13 +177,15 @@ Item {
180177 }
181178 color: "white"
182179 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
184182 verticalAlignment: Text.AlignVCenter
185183 fontSize: "medium"
186184 font.weight: PanelState.buttonsVisible ? Font.Light : Font.Medium
187185 text: PanelState.title
188186 elide: Text.ElideRight
189187 maximumLineCount: 1
188+ Behavior on opacity { UbuntuNumberAnimation {} }
190189 }
191190
192191 // TODO here would the Locally integrated menus come
tests/qmltests/Panel/tst_Panel.qml+19
@@ -182,6 +182,12 @@ IndicatorTest {
182182 signalName: "pressedChanged"
183183 }
184184
185+ SignalSpy {
186+ id: windowControlButtonsSpy
187+ target: PanelState
188+ signalName: "closeClicked"
189+ }
190+
185191 function init() {
186192 panel.fullscreenMode = false;
187193 callManager.foregroundCall = null;
@@ -197,6 +203,8 @@ IndicatorTest {
197203
198204 backgroundPressedSpy.clear();
199205 compare(backgroundPressedSpy.valid, true);
206+ windowControlButtonsSpy.clear();
207+ compare(windowControlButtonsSpy.valid, true);
200208 }
201209
202210 function get_indicator_item(index) {
@@ -492,5 +500,16 @@ IndicatorTest {
492500 compare(panel.indicators.shown, false);
493501 tryCompare(panel.indicators, "fullyClosed", true);
494502 }
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+ }
495514 }
496515}