Merge lp:~aacid/unity-2d/unity-2d_panel-newbuttons into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 895
Merged at revision: 902
Proposed branch: lp:~aacid/unity-2d/unity-2d_panel-newbuttons
Merge into: lp:unity-2d
Diff against target: 404 lines (+220/-10)
6 files modified
debian/unity-2d-panel.install.in (+1/-0)
panel/applets/appname/CMakeLists.txt (+4/-0)
panel/applets/appname/appnameapplet.cpp (+62/-8)
tests/misc/lib/definitions.rb (+2/-0)
tests/panel/visual_verification.rb (+151/-0)
tests/places/fullscreen.rb (+0/-2)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_panel-newbuttons
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
MichaƂ Sawicz Pending
Review via email: mp+91442@code.launchpad.net

Description of the change

[panel] New artwork for the panel-dash buttons

To post a comment you must log in.
890. By Albert Astals Cid

merge

891. By Albert Astals Cid

merge

892. By Albert Astals Cid

merge

Revision history for this message
Gerry Boland (gerboland) wrote :
review: Needs Fixing
893. By Albert Astals Cid

New resources

894. By Albert Astals Cid

New verification images for the new assets

Revision history for this message
Albert Astals Cid (aacid) wrote :

New assets and tests pushed

895. By Albert Astals Cid

Forgot to add those files :-/

Revision history for this message
Gerry Boland (gerboland) wrote :

Oh all good, thank you

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/unity-2d-panel.install.in'
2--- debian/unity-2d-panel.install.in 2011-11-09 22:26:57 +0000
3+++ debian/unity-2d-panel.install.in 2012-02-07 15:52:43 +0000
4@@ -1,3 +1,4 @@
5 @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity-2d-panel
6 @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/unity-2d/plugins/panel/libpanelplugin-*.so*
7 @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/applications/unity-2d-panel.desktop
8+@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/panel/applets/appname/artwork/*.png
9
10=== modified file 'panel/applets/appname/CMakeLists.txt'
11--- panel/applets/appname/CMakeLists.txt 2011-11-09 21:28:49 +0000
12+++ panel/applets/appname/CMakeLists.txt 2012-02-07 15:52:43 +0000
13@@ -49,3 +49,7 @@
14 install(TARGETS panelplugin-appname
15 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/unity-2d/plugins/panel
16 )
17+
18+install(DIRECTORY artwork
19+ DESTINATION ${UNITY_2D_DIR}/panel/applets/appname
20+ )
21
22=== modified file 'panel/applets/appname/appnameapplet.cpp'
23--- panel/applets/appname/appnameapplet.cpp 2012-01-24 13:03:34 +0000
24+++ panel/applets/appname/appnameapplet.cpp 2012-02-07 15:52:43 +0000
25@@ -23,6 +23,7 @@
26 #include "appnameapplet.h"
27
28 // Local
29+#include "config.h"
30 #include "croppedlabel.h"
31 #include "menubarwidget.h"
32 #include "panelstyle.h"
33@@ -62,6 +63,7 @@
34 public:
35 WindowButton(const PanelStyle::WindowButtonType& buttonType, QWidget* parent = 0)
36 : QAbstractButton(parent)
37+ , m_isDashButton(false)
38 , m_initialized(false)
39 {
40 setButtonType(buttonType);
41@@ -76,10 +78,12 @@
42
43 void setButtonType(const PanelStyle::WindowButtonType& buttonType)
44 {
45- if (m_initialized && m_buttonType == buttonType) return;
46+ if (m_initialized && m_buttonType == buttonType) {
47+ return;
48+ }
49
50 m_buttonType = buttonType;
51- loadPixmaps();
52+ loadPixmaps(false);
53 update();
54 }
55
56@@ -88,11 +92,21 @@
57 return m_normalPix.size();
58 }
59
60+ void setIsDashButton(bool isDashButton)
61+ {
62+ if (m_initialized && m_isDashButton == isDashButton) {
63+ return;
64+ }
65+
66+ m_isDashButton = isDashButton;
67+ update();
68+ }
69+
70 protected:
71 bool event(QEvent* ev)
72 {
73 if (ev->type() == QEvent::PaletteChange) {
74- loadPixmaps();
75+ loadPixmaps(true);
76 }
77 return QAbstractButton::event(ev);
78 }
79@@ -103,14 +117,14 @@
80 QPixmap pix;
81 if (isEnabled()) {
82 if (isDown()) {
83- pix = m_downPix;
84+ pix = (m_isDashButton) ? m_dash_downPix : m_downPix;
85 } else if (underMouse()) {
86- pix = m_hoverPix;
87+ pix = (m_isDashButton) ? m_dash_hoverPix : m_hoverPix;
88 } else {
89- pix = m_normalPix;
90+ pix = (m_isDashButton) ? m_dash_normalPix : m_normalPix;
91 }
92 } else {
93- pix = m_normalPix;
94+ pix = (m_isDashButton) ? m_dash_normalPix : m_normalPix;
95 }
96 int posX;
97 if (m_buttonType == PanelStyle::CloseWindowButton) {
98@@ -123,17 +137,49 @@
99
100 private:
101 PanelStyle::WindowButtonType m_buttonType;
102+ bool m_isDashButton;
103 QPixmap m_normalPix;
104 QPixmap m_hoverPix;
105 QPixmap m_downPix;
106+ QPixmap m_dash_normalPix;
107+ QPixmap m_dash_hoverPix;
108+ QPixmap m_dash_downPix;
109 bool m_initialized;
110
111- void loadPixmaps()
112+ void loadPixmaps(bool loadOnlyStylePixmaps)
113 {
114 PanelStyle* style = PanelStyle::instance();
115 m_normalPix = style->windowButtonPixmap(m_buttonType, PanelStyle::NormalState);
116 m_hoverPix = style->windowButtonPixmap(m_buttonType, PanelStyle::PrelightState);
117 m_downPix = style->windowButtonPixmap(m_buttonType, PanelStyle::PressedState);
118+
119+ if (!loadOnlyStylePixmaps) {
120+ loadDashPixmaps(m_buttonType);
121+ }
122+ }
123+
124+ void loadDashPixmaps(PanelStyle::WindowButtonType buttonType)
125+ {
126+ QString iconPath = unity2dDirectory() + "/panel/applets/appname/artwork/";
127+
128+ switch (buttonType) {
129+ case PanelStyle::CloseWindowButton:
130+ iconPath += "close_dash";
131+ break;
132+ case PanelStyle::MinimizeWindowButton:
133+ iconPath += "minimize_dash";
134+ break;
135+ case PanelStyle::UnmaximizeWindowButton:
136+ iconPath += "unmaximize_dash";
137+ break;
138+ case PanelStyle::MaximizeWindowButton:
139+ iconPath += "maximize_dash";
140+ break;
141+ }
142+
143+ m_dash_normalPix.load(iconPath + ".png");
144+ m_dash_hoverPix.load(iconPath + "_prelight.png");
145+ m_dash_downPix.load(iconPath + "_pressed.png");
146 }
147 };
148
149@@ -178,8 +224,11 @@
150 layout->setMargin(0);
151 layout->setSpacing(0);
152 m_closeButton = new WindowButton(PanelStyle::CloseWindowButton);
153+ m_closeButton->setObjectName("AppNameApplet::CloseButton");
154 m_minimizeButton = new WindowButton(PanelStyle::MinimizeWindowButton);
155+ m_minimizeButton->setObjectName("AppNameApplet::MinimizeButton");
156 m_maximizeButton = new WindowButton(PanelStyle::UnmaximizeWindowButton);
157+ m_maximizeButton->setObjectName("AppNameApplet::MaximizeButton");
158 layout->addWidget(m_closeButton);
159 layout->addWidget(m_minimizeButton);
160 layout->addWidget(m_maximizeButton);
161@@ -269,13 +318,18 @@
162 bool showDesktopLabel = !app;
163
164 d->m_windowButtonWidget->setVisible(showWindowButtons);
165+ d->m_maximizeButton->setIsDashButton(dashIsVisible);
166 d->m_maximizeButton->setButtonType(isMaximized ?
167 PanelStyle::UnmaximizeWindowButton :
168 PanelStyle::MaximizeWindowButton);
169 /* disable the minimize button for the dash */
170 d->m_minimizeButton->setEnabled(!dashIsVisible);
171+ d->m_minimizeButton->setIsDashButton(dashIsVisible);
172 /* and the maximize button, if the dash is not resizeable */
173 d->m_maximizeButton->setEnabled(!dashIsVisible || dashCanResize);
174+ d->m_maximizeButton->setIsDashButton(dashIsVisible);
175+ /* make sure we use the right button for dash */
176+ d->m_closeButton->setIsDashButton(dashIsVisible);
177
178 if (showAppLabel || showDesktopLabel || dashIsVisible) {
179 d->m_label->setVisible(true);
180
181=== added directory 'panel/applets/appname/artwork'
182=== added file 'panel/applets/appname/artwork/close_dash.png'
183Binary files panel/applets/appname/artwork/close_dash.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/close_dash.png 2012-02-07 15:52:43 +0000 differ
184=== added file 'panel/applets/appname/artwork/close_dash_prelight.png'
185Binary files panel/applets/appname/artwork/close_dash_prelight.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/close_dash_prelight.png 2012-02-07 15:52:43 +0000 differ
186=== added file 'panel/applets/appname/artwork/close_dash_pressed.png'
187Binary files panel/applets/appname/artwork/close_dash_pressed.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/close_dash_pressed.png 2012-02-07 15:52:43 +0000 differ
188=== added file 'panel/applets/appname/artwork/maximize_dash.png'
189Binary files panel/applets/appname/artwork/maximize_dash.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/maximize_dash.png 2012-02-07 15:52:43 +0000 differ
190=== added file 'panel/applets/appname/artwork/maximize_dash_prelight.png'
191Binary files panel/applets/appname/artwork/maximize_dash_prelight.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/maximize_dash_prelight.png 2012-02-07 15:52:43 +0000 differ
192=== added file 'panel/applets/appname/artwork/maximize_dash_pressed.png'
193Binary files panel/applets/appname/artwork/maximize_dash_pressed.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/maximize_dash_pressed.png 2012-02-07 15:52:43 +0000 differ
194=== added file 'panel/applets/appname/artwork/minimize_dash.png'
195Binary files panel/applets/appname/artwork/minimize_dash.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/minimize_dash.png 2012-02-07 15:52:43 +0000 differ
196=== added file 'panel/applets/appname/artwork/minimize_dash_prelight.png'
197Binary files panel/applets/appname/artwork/minimize_dash_prelight.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/minimize_dash_prelight.png 2012-02-07 15:52:43 +0000 differ
198=== added file 'panel/applets/appname/artwork/minimize_dash_pressed.png'
199Binary files panel/applets/appname/artwork/minimize_dash_pressed.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/minimize_dash_pressed.png 2012-02-07 15:52:43 +0000 differ
200=== added file 'panel/applets/appname/artwork/unmaximize_dash.png'
201Binary files panel/applets/appname/artwork/unmaximize_dash.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/unmaximize_dash.png 2012-02-07 15:52:43 +0000 differ
202=== added file 'panel/applets/appname/artwork/unmaximize_dash_prelight.png'
203Binary files panel/applets/appname/artwork/unmaximize_dash_prelight.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/unmaximize_dash_prelight.png 2012-02-07 15:52:43 +0000 differ
204=== added file 'panel/applets/appname/artwork/unmaximize_dash_pressed.png'
205Binary files panel/applets/appname/artwork/unmaximize_dash_pressed.png 1970-01-01 00:00:00 +0000 and panel/applets/appname/artwork/unmaximize_dash_pressed.png 2012-02-07 15:52:43 +0000 differ
206=== modified file 'tests/misc/lib/definitions.rb'
207--- tests/misc/lib/definitions.rb 2012-01-26 12:54:51 +0000
208+++ tests/misc/lib/definitions.rb 2012-02-07 15:52:43 +0000
209@@ -1,3 +1,5 @@
210
211 LAUNCHER_WIDTH = 65
212 PANEL_HEIGHT = 24
213+DASH_MIN_SCREEN_WIDTH = 1280
214+DASH_MIN_SCREEN_HEIGHT = 1084
215
216=== added directory 'tests/panel/verification'
217=== added file 'tests/panel/verification/dash_close_button.png'
218Binary files tests/panel/verification/dash_close_button.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_close_button.png 2012-02-07 15:52:43 +0000 differ
219=== added file 'tests/panel/verification/dash_close_button_over.png'
220Binary files tests/panel/verification/dash_close_button_over.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_close_button_over.png 2012-02-07 15:52:43 +0000 differ
221=== added file 'tests/panel/verification/dash_close_button_pressed.png'
222Binary files tests/panel/verification/dash_close_button_pressed.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_close_button_pressed.png 2012-02-07 15:52:43 +0000 differ
223=== added file 'tests/panel/verification/dash_maximize_button.png'
224Binary files tests/panel/verification/dash_maximize_button.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_maximize_button.png 2012-02-07 15:52:43 +0000 differ
225=== added file 'tests/panel/verification/dash_maximize_button_fullscreen.png'
226Binary files tests/panel/verification/dash_maximize_button_fullscreen.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_maximize_button_fullscreen.png 2012-02-07 15:52:43 +0000 differ
227=== added file 'tests/panel/verification/dash_maximize_button_fullscreen_over.png'
228Binary files tests/panel/verification/dash_maximize_button_fullscreen_over.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_maximize_button_fullscreen_over.png 2012-02-07 15:52:43 +0000 differ
229=== added file 'tests/panel/verification/dash_maximize_button_fullscreen_pressed.png'
230Binary files tests/panel/verification/dash_maximize_button_fullscreen_pressed.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_maximize_button_fullscreen_pressed.png 2012-02-07 15:52:43 +0000 differ
231=== added file 'tests/panel/verification/dash_maximize_button_over.png'
232Binary files tests/panel/verification/dash_maximize_button_over.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_maximize_button_over.png 2012-02-07 15:52:43 +0000 differ
233=== added file 'tests/panel/verification/dash_maximize_button_pressed.png'
234Binary files tests/panel/verification/dash_maximize_button_pressed.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_maximize_button_pressed.png 2012-02-07 15:52:43 +0000 differ
235=== added file 'tests/panel/verification/dash_minimize_button.png'
236Binary files tests/panel/verification/dash_minimize_button.png 1970-01-01 00:00:00 +0000 and tests/panel/verification/dash_minimize_button.png 2012-02-07 15:52:43 +0000 differ
237=== added file 'tests/panel/visual_verification.rb'
238--- tests/panel/visual_verification.rb 1970-01-01 00:00:00 +0000
239+++ tests/panel/visual_verification.rb 2012-02-07 15:52:43 +0000
240@@ -0,0 +1,151 @@
241+#!/usr/bin/env ruby1.8
242+=begin
243+/*
244+ * This file is part of unity-2d
245+ *
246+ * Copyright 2012 Canonical Ltd.
247+ *
248+ * Authors:
249+ * - Albert Astals Cid <albert.astals@canonical.com>
250+ *
251+ * This program is free software; you can redistribute it and/or modify
252+ * it under the terms of the GNU General Public License as published by
253+ * the Free Software Foundation; version 3.
254+ *
255+ * This program is distributed in the hope that it will be useful,
256+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
257+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
258+ * GNU General Public License for more details.
259+ *
260+ * You should have received a copy of the GNU General Public License
261+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
262+ */
263+=end
264+
265+require '../run-tests.rb' unless $INIT_COMPLETED
266+require 'xdo/keyboard'
267+require 'xdo/mouse'
268+require 'xdo/xwindow'
269+
270+############################# Test Suite #############################
271+context "Panel visual verification tests" do
272+ pwd = File.expand_path(File.dirname(__FILE__)) + '/'
273+ old_value = ""
274+
275+ def dash_always_fullscreen
276+ out = XDo::XWindow.display_geometry()
277+ width = out[0]
278+ height = out[1]
279+ return width < DASH_MIN_SCREEN_WIDTH && height < DASH_MIN_SCREEN_HEIGHT
280+ end
281+
282+ # Run once at the beginning of this test suite
283+ startup do
284+ old_value = $SUT.execute_shell_command 'gsettings get com.canonical.Unity2d.Dash full-screen'
285+ $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Dash full-screen false'
286+
287+ $SUT.execute_shell_command 'killall unity-2d-panel'
288+ $SUT.execute_shell_command 'killall unity-2d-panel'
289+
290+ $SUT.execute_shell_command 'killall unity-2d-launcher'
291+ $SUT.execute_shell_command 'killall unity-2d-launcher'
292+ end
293+
294+ # Run once at the end of this test suite
295+ shutdown do
296+ $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Dash full-screen ' + old_value
297+ end
298+
299+ # Run before each test case begins
300+ setup do
301+ # Execute the application
302+ @app = $SUT.run( :name => UNITY_2D_PANEL,
303+ :arguments => "-testability",
304+ :sleeptime => 2 )
305+
306+ @launcher = $SUT.run( :name => UNITY_2D_LAUNCHER,
307+ :arguments => "-testability",
308+ :sleeptime => 2 )
309+
310+ end
311+
312+ # Run after each test case completes
313+ teardown do
314+ $SUT.execute_shell_command 'pkill -nf unity-2d-panel'
315+ $SUT.execute_shell_command 'pkill -nf unity-2d-launcher'
316+ end
317+
318+ #####################################################################################
319+ # Test cases
320+
321+ test "Visually compare dash buttons with reference" do
322+ XDo::Mouse.move(100, 100, 0, true)
323+ XDo::Keyboard.simulate('{SUPER}')
324+
325+ closeButton = @app.AppNameApplet().QAbstractButton( :name => 'AppNameApplet::CloseButton' )
326+ verify_true( TIMEOUT, 'close button not matching reference image' ) {
327+ closeButton.find_on_screen(pwd + 'verification/dash_close_button.png') != nil
328+ }
329+
330+ closeButton.move_mouse
331+ verify_true( TIMEOUT, 'close button not matching reference image' ) {
332+ closeButton.find_on_screen(pwd + 'verification/dash_close_button_over.png') != nil
333+ }
334+
335+ minimizeButton = @app.AppNameApplet().QAbstractButton( :name => 'AppNameApplet::MinimizeButton' )
336+ verify_true( TIMEOUT, 'minimize button not matching reference image' ) {
337+ minimizeButton.find_on_screen(pwd + 'verification/dash_minimize_button.png') != nil
338+ }
339+
340+ maximizeButton = @app.AppNameApplet().QAbstractButton( :name => 'AppNameApplet::MaximizeButton' )
341+ if dash_always_fullscreen
342+ verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
343+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen.png') != nil
344+ }
345+
346+ maximizeButton.move_mouse
347+ verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
348+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen_over.png') != nil
349+ }
350+ else
351+ verify_true( TIMEOUT, 'maximize button not matching reference image' ) {
352+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button.png') != nil
353+ }
354+
355+ maximizeButton.move_mouse()
356+ verify_true( TIMEOUT, 'maximize button not matching reference image' ) {
357+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_over.png') != nil
358+ }
359+
360+ XDo::Mouse.down()
361+ verify_true( TIMEOUT, 'maximize button pressed not matching reference image' ) {
362+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_pressed.png') != nil
363+ }
364+ XDo::Mouse.up()
365+
366+ minimizeButton.move_mouse() # move mouse away
367+
368+ verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
369+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen.png') != nil
370+ }
371+
372+ maximizeButton.move_mouse()
373+ verify_true( TIMEOUT, 'maximize button fullscreen not matching reference image' ) {
374+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen_over.png') != nil
375+ }
376+
377+ XDo::Mouse.down()
378+ verify_true( TIMEOUT, 'maximize button fullscreen pressed not matching reference image' ) {
379+ maximizeButton.find_on_screen(pwd + 'verification/dash_maximize_button_fullscreen_pressed.png') != nil
380+ }
381+ XDo::Mouse.up()
382+ end
383+
384+ closeButton.move_mouse()
385+ XDo::Mouse.down()
386+ verify_true( TIMEOUT, 'close button pressed not matching reference image' ) {
387+ closeButton.find_on_screen(pwd + 'verification/dash_close_button_pressed.png') != nil
388+ }
389+ XDo::Mouse.up()
390+ end
391+end
392
393=== modified file 'tests/places/fullscreen.rb'
394--- tests/places/fullscreen.rb 2012-01-31 15:13:25 +0000
395+++ tests/places/fullscreen.rb 2012-02-07 15:52:43 +0000
396@@ -38,8 +38,6 @@
397
398 DASH_FULLSCREEN_KEY = '/com/canonical/unity-2d/dash/full-screen'
399 DASH_FORMFACTOR_KEY = '/com/canonical/unity-2d/form-factor'
400- DASH_MIN_SCREEN_WIDTH = 1280;
401- DASH_MIN_SCREEN_HEIGHT = 1084;
402
403 # Run once at the beginning of this test suite
404 startup do

Subscribers

People subscribed via source and target branches