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
=== modified file 'plugins/unityshell/src/HudController.cpp'
--- plugins/unityshell/src/HudController.cpp 2012-03-26 13:12:08 +0000
+++ plugins/unityshell/src/HudController.cpp 2012-04-01 01:00:26 +0000
@@ -39,7 +39,7 @@
39}39}
4040
41Controller::Controller()41Controller::Controller()
42 : launcher_width(65)42 : launcher_width(64)
43 , launcher_locked_out(false)43 , launcher_locked_out(false)
44 , multiple_launchers(true)44 , multiple_launchers(true)
45 , hud_service_("com.canonical.hud", "/com/canonical/hud")45 , hud_service_("com.canonical.hud", "/com/canonical/hud")
4646
=== modified file 'plugins/unityshell/src/HudIcon.cpp'
--- plugins/unityshell/src/HudIcon.cpp 2012-03-27 14:10:40 +0000
+++ plugins/unityshell/src/HudIcon.cpp 2012-04-01 01:00:26 +0000
@@ -19,9 +19,13 @@
1919
20#include "HudIcon.h"20#include "HudIcon.h"
21#include "NuxCore/Logger.h"21#include "NuxCore/Logger.h"
22#include "config.h"
23
22namespace24namespace
23{25{
24 nux::logging::Logger logger("unity.hud.icon");26 nux::logging::Logger logger("unity.hud.icon");
27 const unsigned int tile_margin = 4;
28 const unsigned int minimum_width = 64;
25}29}
2630
27namespace unity31namespace unity
@@ -29,23 +33,13 @@
29namespace hud33namespace hud
30{34{
3135
32Icon::Icon(nux::BaseTexture* texture, guint width, guint height)36Icon::Icon(std::string const& icon_name, unsigned int size)
33 : unity::IconTexture(texture, width, height)37 : IconTexture(icon_name, size, true)
34{38{
35 Init();39 int tile_size = size + tile_margin * 2;
36 icon_renderer_.SetTargetSize(54, 46, 0);40 SetMinimumWidth(minimum_width);
37}41 SetMinimumHeight(tile_size);
3842 icon_renderer_.SetTargetSize(tile_size, size, 0);
39Icon::Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
40 : unity::IconTexture(icon_name, size, defer_icon_loading)
41{
42 Init();
43}
44
45void Icon::Init()
46{
47 SetMinimumWidth(66);
48 SetMinimumHeight(66);
49 background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));43 background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));
50 gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));44 gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));
51 edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true));45 edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true));
@@ -80,7 +74,6 @@
8074
8175
82 auto toplevel = GetToplevel();76 auto toplevel = GetToplevel();
83 icon_renderer_.SetTargetSize(54, 46, 0);
84 icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());77 icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
85 icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());78 icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());
86}79}
8780
=== modified file 'plugins/unityshell/src/HudIcon.h'
--- plugins/unityshell/src/HudIcon.h 2012-03-27 14:10:40 +0000
+++ plugins/unityshell/src/HudIcon.h 2012-04-01 01:00:26 +0000
@@ -21,22 +21,6 @@
21#ifndef HUDICON_H21#ifndef HUDICON_H
22#define HUDICON_H22#define HUDICON_H
2323
24#include <set>
25#include <string>
26
27#include "config.h"
28
29#include <Nux/Nux.h>
30#include <Nux/BaseWindow.h>
31#include <NuxCore/Math/MathInc.h>
32
33#include <sigc++/trackable.h>
34#include <sigc++/signal.h>
35#include <sigc++/functors/ptr_fun.h>
36#include <sigc++/functors/mem_fun.h>
37
38#include <gtk/gtk.h>
39
40#include "IconTexture.h"24#include "IconTexture.h"
41#include "HudIconTextureSource.h"25#include "HudIconTextureSource.h"
42#include "IconRenderer.h"26#include "IconRenderer.h"
@@ -51,15 +35,14 @@
51{35{
52public:36public:
53 typedef nux::ObjectPtr<IconTexture> Ptr;37 typedef nux::ObjectPtr<IconTexture> Ptr;
54 Icon(nux::BaseTexture* texture, guint width, guint height);38 Icon(std::string const& icon_name, unsigned int size);
55 Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading = false);
5639
57protected:40protected:
58 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);41 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
59 void Init();
6042
61 std::string GetName() const;43 std::string GetName() const;
6244
45private:
63 nux::ObjectPtr<nux::BaseTexture> background_;46 nux::ObjectPtr<nux::BaseTexture> background_;
64 nux::ObjectPtr<nux::BaseTexture> gloss_;47 nux::ObjectPtr<nux::BaseTexture> gloss_;
65 nux::ObjectPtr<nux::BaseTexture> edge_;48 nux::ObjectPtr<nux::BaseTexture> edge_;
6649
=== modified file 'plugins/unityshell/src/HudView.cpp'
--- plugins/unityshell/src/HudView.cpp 2012-03-29 21:23:51 +0000
+++ plugins/unityshell/src/HudView.cpp 2012-04-01 01:00:26 +0000
@@ -20,19 +20,11 @@
2020
21#include <math.h>21#include <math.h>
2222
23#include <gio/gdesktopappinfo.h>
24#include <glib/gi18n-lib.h>23#include <glib/gi18n-lib.h>
25#include <gtk/gtk.h>
26#include <Nux/Button.h>
27#include <iostream>
28#include <sstream>
29
30#include <NuxCore/Logger.h>24#include <NuxCore/Logger.h>
31#include <UnityCore/GLibWrapper.h>25#include <UnityCore/GLibWrapper.h>
32#include <UnityCore/RadioOptionFilter.h>
33#include <UnityCore/Variant.h>26#include <UnityCore/Variant.h>
34#include <Nux/HLayout.h>27#include <Nux/HLayout.h>
35#include <Nux/LayeredLayout.h>
3628
37#include <NuxCore/Logger.h>29#include <NuxCore/Logger.h>
38#include "HudButton.h"30#include "HudButton.h"
@@ -47,10 +39,19 @@
47namespace39namespace
48{40{
49nux::logging::Logger logger("unity.hud.view");41nux::logging::Logger logger("unity.hud.view");
50int icon_size = 42;42const int icon_size = 46;
51const std::string default_text = _("Type your command");43const std::string default_text = _("Type your command");
52const int grow_anim_length = 90 * 1000;44const int grow_anim_length = 90 * 1000;
53const int pause_before_grow_length = 32 * 1000;45const int pause_before_grow_length = 32 * 1000;
46
47const int default_width = 1024;
48const int default_height = 276;
49const int content_width = 941;
50
51const int top_padding = 11;
52const int bottom_padding = 9;
53const int left_padding = 11;
54const int right_padding = 0;
54}55}
5556
56NUX_IMPLEMENT_OBJECT_TYPE(View);57NUX_IMPLEMENT_OBJECT_TYPE(View);
@@ -185,8 +186,7 @@
185 LOG_DEBUG(logger) << "content_geo: " << content_geo_.width << "x" << content_geo_.height;186 LOG_DEBUG(logger) << "content_geo: " << content_geo_.width << "x" << content_geo_.height;
186187
187 layout_->SetMinimumWidth(content_geo_.width);188 layout_->SetMinimumWidth(content_geo_.width);
188 layout_->SetMaximumWidth(content_geo_.width);189 layout_->SetMaximumSize(content_geo_.width, content_geo_.height);
189 layout_->SetMaximumHeight(content_geo_.height);
190190
191 QueueDraw();191 QueueDraw();
192}192}
@@ -258,7 +258,7 @@
258 button->is_rounded = (query == --(queries.end())) ? true : false;258 button->is_rounded = (query == --(queries.end())) ? true : false;
259 button->fake_focused = (query == (queries.begin())) ? true : false;259 button->fake_focused = (query == (queries.begin())) ? true : false;
260260
261 button->SetMinimumWidth(941);261 button->SetMinimumWidth(content_width);
262 found_items++;262 found_items++;
263 }263 }
264 if (found_items)264 if (found_items)
@@ -285,14 +285,13 @@
285285
286 if (show_embedded_icon_)286 if (show_embedded_icon_)
287 {287 {
288 layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP,288 layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT,
289 nux::MINOR_SIZE_MATCHCONTENT, 100.0f, nux::LayoutPosition::NUX_LAYOUT_BEGIN);289 nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition::NUX_LAYOUT_BEGIN);
290
291 AddChild(icon_.GetPointer());290 AddChild(icon_.GetPointer());
292 }291 }
293 else292 else
294 {293 {
295 layout_->RemoveChildObject(static_cast<nux::Area*>(icon_layout_.GetPointer()));294 layout_->RemoveChildObject(icon_.GetPointer());
296 RemoveChild(icon_.GetPointer());295 RemoveChild(icon_.GetPointer());
297 }296 }
298297
@@ -306,13 +305,12 @@
306{305{
307 //FIXME - remove magic values, replace with scalable text depending on DPI306 //FIXME - remove magic values, replace with scalable text depending on DPI
308 // requires smarter font settings really...307 // requires smarter font settings really...
309 int width, height = 0;308 int width = default_width;
310 width = 1024;309 int height = default_height;
311 height = 276;
312310
313 if (!show_embedded_icon_)311 if (!show_embedded_icon_)
314 {312 {
315 width -= icon_layout_->GetGeometry().width;313 width -= icon_->GetGeometry().width;
316 }314 }
317315
318 LOG_DEBUG (logger) << "best fit is, " << width << ", " << height;316 LOG_DEBUG (logger) << "best fit is, " << width << ", " << height;
@@ -338,15 +336,6 @@
338 absolute_window_geometry_ = absolute_geo;336 absolute_window_geometry_ = absolute_geo;
339}337}
340338
341namespace
342{
343 const int top_spacing = 11;
344 const int content_width = 941;
345 const int icon_vertical_margin = 5;
346 const int spacing_between_icon_and_content = 8;
347 const int bottom_padding = 10;
348}
349
350void View::SetupViews()339void View::SetupViews()
351{340{
352 dash::Style& style = dash::Style::Instance();341 dash::Style& style = dash::Style::Instance();
@@ -354,27 +343,19 @@
354 nux::VLayout* super_layout = new nux::VLayout(); 343 nux::VLayout* super_layout = new nux::VLayout();
355 layout_ = new nux::HLayout();344 layout_ = new nux::HLayout();
356 {345 {
357 // fill icon layout with icon346 // fill layout with icon
358 icon_ = new Icon("", icon_size, true);347 icon_ = new Icon("", icon_size);
359 icon_layout_ = new nux::VLayout();
360 {348 {
361 AddChild(icon_.GetPointer());349 AddChild(icon_.GetPointer());
362 icon_layout_->SetVerticalExternalMargin(icon_vertical_margin);350 layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
363 icon_layout_->AddView(icon_.GetPointer(), 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);
364 layout_->AddLayout(icon_layout_.GetPointer(), 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_MATCHCONTENT);
365 }351 }
366352
367 // add padding to layout between icon and content
368 layout_->AddLayout(new nux::SpaceLayout(spacing_between_icon_and_content,
369 spacing_between_icon_and_content,
370 spacing_between_icon_and_content,
371 spacing_between_icon_and_content), 0);
372
373 // fill the content layout353 // fill the content layout
374 content_layout_ = new nux::VLayout();354 content_layout_ = new nux::VLayout();
375 {355 {
376 // add the top spacing356 // Set the layout paddings
377 content_layout_->AddLayout(new nux::SpaceLayout(top_spacing,top_spacing,top_spacing,top_spacing), 0);357 content_layout_->SetLeftAndRightPadding(left_padding, right_padding);
358 content_layout_->SetTopAndBottomPadding(top_padding, bottom_padding);
378359
379 // add the search bar to the composite360 // add the search bar to the composite
380 search_bar_ = new unity::SearchBar(true);361 search_bar_ = new unity::SearchBar(true);
@@ -389,10 +370,6 @@
389 button_views_->SetMaximumWidth(content_width);370 button_views_->SetMaximumWidth(content_width);
390371
391 content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT);372 content_layout_->AddLayout(button_views_.GetPointer(), 1, nux::MINOR_POSITION_LEFT);
392 content_layout_->AddLayout(new nux::SpaceLayout(bottom_padding,
393 bottom_padding,
394 bottom_padding,
395 bottom_padding), 0);
396 }373 }
397374
398 layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP);375 layout_->AddLayout(content_layout_.GetPointer(), 1, nux::MINOR_POSITION_TOP);
399376
=== modified file 'plugins/unityshell/src/HudView.h'
--- plugins/unityshell/src/HudView.h 2012-03-25 10:14:37 +0000
+++ plugins/unityshell/src/HudView.h 2012-04-01 01:00:26 +0000
@@ -21,14 +21,9 @@
2121
22#include <string>22#include <string>
2323
24#include <NuxGraphics/GraphicsEngine.h>
25#include <Nux/Nux.h>24#include <Nux/Nux.h>
26#include <Nux/PaintLayer.h>
27#include <Nux/View.h>25#include <Nux/View.h>
28#include <Nux/VLayout.h>26#include <Nux/VLayout.h>
29#include <StaticCairoText.h>
30
31#include <glib.h>
3227
33#include <UnityCore/Hud.h>28#include <UnityCore/Hud.h>
34#include "Introspectable.h"29#include "Introspectable.h"
@@ -105,7 +100,6 @@
105 //FIXME - replace with dash search bar once modifications to dash search bar land100 //FIXME - replace with dash search bar once modifications to dash search bar land
106 SearchBar::Ptr search_bar_;101 SearchBar::Ptr search_bar_;
107 Icon::Ptr icon_;102 Icon::Ptr icon_;
108 nux::ObjectPtr<nux::Layout> icon_layout_;
109 bool visible_;103 bool visible_;
110104
111 Hud::Queries queries_;105 Hud::Queries queries_;
112106
=== modified file 'plugins/unityshell/src/IconTexture.cpp'
--- plugins/unityshell/src/IconTexture.cpp 2012-03-27 14:10:40 +0000
+++ plugins/unityshell/src/IconTexture.cpp 2012-04-01 01:00:26 +0000
@@ -81,6 +81,12 @@
81 _icon_name = icon_name;81 _icon_name = icon_name;
82 _size = size;82 _size = size;
8383
84 if (_size == 0)
85 {
86 _texture_cached = nullptr;
87 return;
88 }
89
84 LoadIcon();90 LoadIcon();
85}91}
8692
@@ -95,7 +101,7 @@
95 LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;101 LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
96 static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";102 static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
97103
98 if (_loading)104 if (_loading || _size == 0)
99 return;105 return;
100106
101 _loading = true;107 _loading = true;