Merge lp:~3v1n0/unity/hud-padding-fixes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2202
Proposed branch: lp:~3v1n0/unity/hud-padding-fixes
Merge into: lp:unity
Diff against target: 327 lines (+45/-92)
6 files modified
plugins/unityshell/src/HudController.cpp (+1/-1)
plugins/unityshell/src/HudIcon.cpp (+11/-18)
plugins/unityshell/src/HudIcon.h (+2/-19)
plugins/unityshell/src/HudView.cpp (+24/-47)
plugins/unityshell/src/HudView.h (+0/-6)
plugins/unityshell/src/IconTexture.cpp (+7/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/hud-padding-fixes
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) design Approve
Tim Penhey (community) Approve
Thomi Richards (community) Needs Fixing
Review via email: mp+100317@code.launchpad.net

Commit message

Hud: fixed the paddings and geometries, remove the icon glitches

I've fixed all the paddings and geometries to match design (and the dash, then), plus I've fixed a size mismatch that caused some drawing glitches of the icon.

HUD before the fix: http://i.imgur.com/b7BO0.png | http://i.imgur.com/9vpmv.png
HUD after the fix: http://i.imgur.com/wDxPO.png | http://i.imgur.com/kSLch.png

Description of the change

The HUD padding was not correct and this caused it not to match the dash geometries, especially when using a locked launcher.

I've fixed all the paddings and geometries to match design (and the dash, then), plus I've fixed a size mismatch that caused some drawing glitches of the icon.

HUD before the fix: http://i.imgur.com/b7BO0.png | http://i.imgur.com/9vpmv.png
HUD after the fix: http://i.imgur.com/wDxPO.png | http://i.imgur.com/kSLch.png

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) :
review: Approve (design)
Revision history for this message
Andrea Cimitan (cimi) :
review: Needs Resubmitting
Revision history for this message
Andrea Cimitan (cimi) :
review: Abstain
Revision history for this message
Andrea Cimitan (cimi) wrote :

how can I cancel my review? :) The hud visuals seems fine, but you're affecting the launcher, so this seems leading to regressions. But I didn't test on my pc to prove them

Revision history for this message
Andrea Cimitan (cimi) wrote :

Looking closely it seems you're right, there's 1px gap between the hud and the launcher. I should not do reviews on sunday morning - I will compile and test tomorrow

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> how can I cancel my review? :) The hud visuals seems fine, but you're
> affecting the launcher, so this seems leading to regressions.

I'm not modifying the launcher, I've modified the default parameter used by the HUD to set the launcher size.
But that parameter was wrong (maybe it has been put there as workaround to make the HUD to be close to the dash geometries).

> Looking closely it seems you're right, there's 1px gap between the hud and the launcher.

That's what I meant. Compare my two screenshots, this is totally wrong.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Needs a test.

Should be pretty easy to construct an autopilot test that changes the launcher to different sizes, reveals the hud, and checks that it's X position is correct?

Cheers,

review: Needs Fixing
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thomi, this is a pure visual change, so tests are not needed.

Of course it's possible to integrate some checks in AP, but this shouldn't be required.

Revision history for this message
Tim Penhey (thumper) wrote :

I'm OK with these changes. I was talking with Thomi about the tests. While it is desirable to have some AP tests around the layout, which we should be able to do relatively easily, I don't want to change the goal posts during the last four weeks of the cycle, so this can land without tests due to the visual nature of the change.

In the future (i.e. next cycle), I expect that we'll start to add some AP tests around layout.

review: Approve
Revision history for this message
Andrea Cimitan (cimi) :
review: Approve (design)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/HudController.cpp'
2--- plugins/unityshell/src/HudController.cpp 2012-03-26 13:12:08 +0000
3+++ plugins/unityshell/src/HudController.cpp 2012-04-01 01:00:26 +0000
4@@ -39,7 +39,7 @@
5 }
6
7 Controller::Controller()
8- : launcher_width(65)
9+ : launcher_width(64)
10 , launcher_locked_out(false)
11 , multiple_launchers(true)
12 , hud_service_("com.canonical.hud", "/com/canonical/hud")
13
14=== modified file 'plugins/unityshell/src/HudIcon.cpp'
15--- plugins/unityshell/src/HudIcon.cpp 2012-03-27 14:10:40 +0000
16+++ plugins/unityshell/src/HudIcon.cpp 2012-04-01 01:00:26 +0000
17@@ -19,9 +19,13 @@
18
19 #include "HudIcon.h"
20 #include "NuxCore/Logger.h"
21+#include "config.h"
22+
23 namespace
24 {
25 nux::logging::Logger logger("unity.hud.icon");
26+ const unsigned int tile_margin = 4;
27+ const unsigned int minimum_width = 64;
28 }
29
30 namespace unity
31@@ -29,23 +33,13 @@
32 namespace hud
33 {
34
35-Icon::Icon(nux::BaseTexture* texture, guint width, guint height)
36- : unity::IconTexture(texture, width, height)
37-{
38- Init();
39- icon_renderer_.SetTargetSize(54, 46, 0);
40-}
41-
42-Icon::Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
43- : unity::IconTexture(icon_name, size, defer_icon_loading)
44-{
45- Init();
46-}
47-
48-void Icon::Init()
49-{
50- SetMinimumWidth(66);
51- SetMinimumHeight(66);
52+Icon::Icon(std::string const& icon_name, unsigned int size)
53+ : IconTexture(icon_name, size, true)
54+{
55+ int tile_size = size + tile_margin * 2;
56+ SetMinimumWidth(minimum_width);
57+ SetMinimumHeight(tile_size);
58+ icon_renderer_.SetTargetSize(tile_size, size, 0);
59 background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));
60 gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));
61 edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true));
62@@ -80,7 +74,6 @@
63
64
65 auto toplevel = GetToplevel();
66- icon_renderer_.SetTargetSize(54, 46, 0);
67 icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
68 icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());
69 }
70
71=== modified file 'plugins/unityshell/src/HudIcon.h'
72--- plugins/unityshell/src/HudIcon.h 2012-03-27 14:10:40 +0000
73+++ plugins/unityshell/src/HudIcon.h 2012-04-01 01:00:26 +0000
74@@ -21,22 +21,6 @@
75 #ifndef HUDICON_H
76 #define HUDICON_H
77
78-#include <set>
79-#include <string>
80-
81-#include "config.h"
82-
83-#include <Nux/Nux.h>
84-#include <Nux/BaseWindow.h>
85-#include <NuxCore/Math/MathInc.h>
86-
87-#include <sigc++/trackable.h>
88-#include <sigc++/signal.h>
89-#include <sigc++/functors/ptr_fun.h>
90-#include <sigc++/functors/mem_fun.h>
91-
92-#include <gtk/gtk.h>
93-
94 #include "IconTexture.h"
95 #include "HudIconTextureSource.h"
96 #include "IconRenderer.h"
97@@ -51,15 +35,14 @@
98 {
99 public:
100 typedef nux::ObjectPtr<IconTexture> Ptr;
101- Icon(nux::BaseTexture* texture, guint width, guint height);
102- Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading = false);
103+ Icon(std::string const& icon_name, unsigned int size);
104
105 protected:
106 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
107- void Init();
108
109 std::string GetName() const;
110
111+private:
112 nux::ObjectPtr<nux::BaseTexture> background_;
113 nux::ObjectPtr<nux::BaseTexture> gloss_;
114 nux::ObjectPtr<nux::BaseTexture> edge_;
115
116=== modified file 'plugins/unityshell/src/HudView.cpp'
117--- plugins/unityshell/src/HudView.cpp 2012-03-29 21:23:51 +0000
118+++ plugins/unityshell/src/HudView.cpp 2012-04-01 01:00:26 +0000
119@@ -20,19 +20,11 @@
120
121 #include <math.h>
122
123-#include <gio/gdesktopappinfo.h>
124 #include <glib/gi18n-lib.h>
125-#include <gtk/gtk.h>
126-#include <Nux/Button.h>
127-#include <iostream>
128-#include <sstream>
129-
130 #include <NuxCore/Logger.h>
131 #include <UnityCore/GLibWrapper.h>
132-#include <UnityCore/RadioOptionFilter.h>
133 #include <UnityCore/Variant.h>
134 #include <Nux/HLayout.h>
135-#include <Nux/LayeredLayout.h>
136
137 #include <NuxCore/Logger.h>
138 #include "HudButton.h"
139@@ -47,10 +39,19 @@
140 namespace
141 {
142 nux::logging::Logger logger("unity.hud.view");
143-int icon_size = 42;
144+const int icon_size = 46;
145 const std::string default_text = _("Type your command");
146 const int grow_anim_length = 90 * 1000;
147 const int pause_before_grow_length = 32 * 1000;
148+
149+const int default_width = 1024;
150+const int default_height = 276;
151+const int content_width = 941;
152+
153+const int top_padding = 11;
154+const int bottom_padding = 9;
155+const int left_padding = 11;
156+const int right_padding = 0;
157 }
158
159 NUX_IMPLEMENT_OBJECT_TYPE(View);
160@@ -185,8 +186,7 @@
161 LOG_DEBUG(logger) << "content_geo: " << content_geo_.width << "x" << content_geo_.height;
162
163 layout_->SetMinimumWidth(content_geo_.width);
164- layout_->SetMaximumWidth(content_geo_.width);
165- layout_->SetMaximumHeight(content_geo_.height);
166+ layout_->SetMaximumSize(content_geo_.width, content_geo_.height);
167
168 QueueDraw();
169 }
170@@ -258,7 +258,7 @@
171 button->is_rounded = (query == --(queries.end())) ? true : false;
172 button->fake_focused = (query == (queries.begin())) ? true : false;
173
174- button->SetMinimumWidth(941);
175+ button->SetMinimumWidth(content_width);
176 found_items++;
177 }
178 if (found_items)
179@@ -285,14 +285,13 @@
180
181 if (show_embedded_icon_)
182 {
183- layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP,
184- nux::MINOR_SIZE_MATCHCONTENT, 100.0f, nux::LayoutPosition::NUX_LAYOUT_BEGIN);
185-
186+ layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT,
187+ nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition::NUX_LAYOUT_BEGIN);
188 AddChild(icon_.GetPointer());
189 }
190 else
191 {
192- layout_->RemoveChildObject(static_cast<nux::Area*>(icon_layout_.GetPointer()));
193+ layout_->RemoveChildObject(icon_.GetPointer());
194 RemoveChild(icon_.GetPointer());
195 }
196
197@@ -306,13 +305,12 @@
198 {
199 //FIXME - remove magic values, replace with scalable text depending on DPI
200 // requires smarter font settings really...
201- int width, height = 0;
202- width = 1024;
203- height = 276;
204+ int width = default_width;
205+ int height = default_height;
206
207 if (!show_embedded_icon_)
208 {
209- width -= icon_layout_->GetGeometry().width;
210+ width -= icon_->GetGeometry().width;
211 }
212
213 LOG_DEBUG (logger) << "best fit is, " << width << ", " << height;
214@@ -338,15 +336,6 @@
215 absolute_window_geometry_ = absolute_geo;
216 }
217
218-namespace
219-{
220- const int top_spacing = 11;
221- const int content_width = 941;
222- const int icon_vertical_margin = 5;
223- const int spacing_between_icon_and_content = 8;
224- const int bottom_padding = 10;
225-}
226-
227 void View::SetupViews()
228 {
229 dash::Style& style = dash::Style::Instance();
230@@ -354,27 +343,19 @@
231 nux::VLayout* super_layout = new nux::VLayout();
232 layout_ = new nux::HLayout();
233 {
234- // fill icon layout with icon
235- icon_ = new Icon("", icon_size, true);
236- icon_layout_ = new nux::VLayout();
237+ // fill layout with icon
238+ icon_ = new Icon("", icon_size);
239 {
240 AddChild(icon_.GetPointer());
241- icon_layout_->SetVerticalExternalMargin(icon_vertical_margin);
242- icon_layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
243- layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT);
244+ layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
245 }
246
247- // add padding to layout between icon and content
248- layout_->AddLayout(new nux::SpaceLayout(spacing_between_icon_and_content,
249- spacing_between_icon_and_content,
250- spacing_between_icon_and_content,
251- spacing_between_icon_and_content), 0);
252-
253 // fill the content layout
254 content_layout_ = new nux::VLayout();
255 {
256- // add the top spacing
257- content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0);
258+ // Set the layout paddings
259+ content_layout_->SetLeftAndRightPadding(left_padding, right_padding);
260+ content_layout_->SetTopAndBottomPadding(top_padding, bottom_padding);
261
262 // add the search bar to the composite
263 search_bar_ = new unity::SearchBar(true);
264@@ -389,10 +370,6 @@
265 button_views_->SetMaximumWidth(content_width);
266
267 content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT);
268- content_layout_->AddLayout(new nux::SpaceLayout(bottom_padding,
269- bottom_padding,
270- bottom_padding,
271- bottom_padding), 0);
272 }
273
274 layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP);
275
276=== modified file 'plugins/unityshell/src/HudView.h'
277--- plugins/unityshell/src/HudView.h 2012-03-25 10:14:37 +0000
278+++ plugins/unityshell/src/HudView.h 2012-04-01 01:00:26 +0000
279@@ -21,14 +21,9 @@
280
281 #include <string>
282
283-#include <NuxGraphics/GraphicsEngine.h>
284 #include <Nux/Nux.h>
285-#include <Nux/PaintLayer.h>
286 #include <Nux/View.h>
287 #include <Nux/VLayout.h>
288-#include <StaticCairoText.h>
289-
290-#include <glib.h>
291
292 #include <UnityCore/Hud.h>
293 #include "Introspectable.h"
294@@ -105,7 +100,6 @@
295 //FIXME - replace with dash search bar once modifications to dash search bar land
296 SearchBar::Ptr search_bar_;
297 Icon::Ptr icon_;
298- nux::ObjectPtr<nux::Layout> icon_layout_;
299 bool visible_;
300
301 Hud::Queries queries_;
302
303=== modified file 'plugins/unityshell/src/IconTexture.cpp'
304--- plugins/unityshell/src/IconTexture.cpp 2012-03-27 14:10:40 +0000
305+++ plugins/unityshell/src/IconTexture.cpp 2012-04-01 01:00:26 +0000
306@@ -81,6 +81,12 @@
307 _icon_name = icon_name;
308 _size = size;
309
310+ if (_size == 0)
311+ {
312+ _texture_cached = nullptr;
313+ return;
314+ }
315+
316 LoadIcon();
317 }
318
319@@ -95,7 +101,7 @@
320 LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
321 static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
322
323- if (_loading)
324+ if (_loading || _size == 0)
325 return;
326
327 _loading = true;