Merge lp:~uriboni/unity/unity-drag-shadow into lp:unity

Proposed by Ugo Riboni
Status: Rejected
Rejected by: Andrea Azzarone
Proposed branch: lp:~uriboni/unity/unity-drag-shadow
Merge into: lp:unity
Diff against target: 84 lines (+35/-4)
2 files modified
launcher/LauncherDragWindow.cpp (+34/-4)
launcher/LauncherDragWindow.h (+1/-0)
To merge this branch: bzr merge lp:~uriboni/unity/unity-drag-shadow
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Needs Fixing
Review via email: mp+119106@code.launchpad.net

Description of the change

Add a shadow below the icon when it's being dragged out from the launcher.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks for the branch, however it simply does not work as expected here: when I drag an icon out from the launcher, I get nothing painted on the screen, but one small pixel.
The problems seems to be in
SetBaseSize(DROP_SHADOW_SIZE * widthFactor, DROP_SHADOW_SIZE * heightFactor);

Also:
31 + glib::Error error;
32 + glib::Object<GdkPixbuf> pbuf(gdk_pixbuf_new_from_file_at_size(PKGDATADIR "/ordering_shadow.png",
33 + DROP_SHADOW_SIZE, DROP_SHADOW_SIZE, &error));

Since you don't LOG_ERROR the error, you can avoid to use it... Just pass nullptr to gdk_pixbuf_new_from_file_at_size

Also, instead of adding a new pixbuf, what about using the PKGDATADIR"/launcher_icon_shadow_200.png" or PKGDATADIR"/launcher_icon_shadow_62.png" textures that the AbstractIconRender is alredy using? So they will always match...

34 + if (GDK_IS_PIXBUF(pbuf.RawPtr()))

Use the nwe pbuf.IsType(GDK_TYPE_PIXBUF)

+ nux::BaseTexture* texture = nux::CreateTexture2DFromPixbuf(pbuf, true);

This should be unreferenced... You can just use a nux::ObjectPtr to handle it and forget.

PS: instead of checking != nullptr we prefer to have simple (check) or (!check) ;)

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

Ugo, FYI this diff fixes the issues above: http://paste.ubuntu.com/1144653/ (the size problem I had was caused by a division with an integer).

However, I'm still not getting the correct design when dragging the icon outside the launcher: http://i.imgur.com/ALpcH.png

lp:~uriboni/unity/unity-drag-shadow updated
2546. By Ugo Riboni

Merge changes from trunk

2547. By Ugo Riboni

Use proper flat math and properly handle adopted textures. Thanks Treviño.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

Fixed in trunk.

Unmerged revisions

2547. By Ugo Riboni

Use proper flat math and properly handle adopted textures. Thanks Treviño.

2546. By Ugo Riboni

Merge changes from trunk

2545. By Ugo Riboni

Remove another unnecessary include

2544. By Ugo Riboni

Minimize whitespace changes

2543. By Ugo Riboni

Use same indent style as the rest of the file

2542. By Ugo Riboni

Remove useless includes and use constants instead of defines

2541. By Ugo Riboni

Add a drop shadow below the icon when it's dragged out from the launcher

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherDragWindow.cpp'
2--- launcher/LauncherDragWindow.cpp 2012-06-18 02:57:23 +0000
3+++ launcher/LauncherDragWindow.cpp 2012-08-20 15:04:27 +0000
4@@ -17,6 +17,7 @@
5 * Authored by: Jason Smith <jason.smith@canonical.com>
6 */
7
8+#include "config.h"
9 #include <Nux/Nux.h>
10 #include <Nux/BaseWindow.h>
11 #include <NuxGraphics/GraphicsEngine.h>
12@@ -29,13 +30,32 @@
13 namespace launcher
14 {
15
16+static const int DEFAULT_TILE_HEIGHT = 56;
17+static const int DEFAULT_TILE_WIDTH = 56;
18+static const int DROP_SHADOW_SIZE = 76;
19+
20 NUX_IMPLEMENT_OBJECT_TYPE(LauncherDragWindow);
21
22 LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> icon)
23 : nux::BaseWindow("")
24 , _icon(icon)
25 {
26- SetBaseSize(_icon->GetWidth(), _icon->GetHeight());
27+ float heightFactor = _icon->GetHeight() / static_cast<float>(DEFAULT_TILE_HEIGHT);
28+ float widthFactor = _icon->GetWidth() / static_cast<float>(DEFAULT_TILE_WIDTH);
29+ SetBaseSize(DROP_SHADOW_SIZE * widthFactor, DROP_SHADOW_SIZE * heightFactor);
30+
31+ glib::Object<GdkPixbuf> pbuf(gdk_pixbuf_new_from_file_at_size(PKGDATADIR "/ordering_shadow.png",
32+ DROP_SHADOW_SIZE, DROP_SHADOW_SIZE, nullptr));
33+ if (pbuf.IsType(GDK_TYPE_PIXBUF))
34+ {
35+ nux::ObjectPtr<nux::BaseTexture> texture;
36+ texture.Adopt(nux::CreateTexture2DFromPixbuf(pbuf, true));
37+
38+ if (texture)
39+ {
40+ _drop_shadow = texture->GetDeviceTexture();
41+ }
42+ }
43 }
44
45 LauncherDragWindow::~LauncherDragWindow()
46@@ -105,10 +125,20 @@
47 GfxContext.PushClippingRectangle(geo);
48
49 nux::TexCoordXForm texxform;
50+ if (_drop_shadow)
51+ {
52+ GfxContext.QRP_1Tex(0,
53+ 0,
54+ geo.width,
55+ geo.height,
56+ _drop_shadow,
57+ texxform,
58+ nux::color::White);
59+ }
60+
61 texxform.FlipVCoord(true);
62-
63- GfxContext.QRP_1Tex(0,
64- 0,
65+ GfxContext.QRP_1Tex((geo.width - _icon->GetWidth()) / 2.0f,
66+ (geo.height - _icon->GetHeight()) / 2.0f,
67 _icon->GetWidth(),
68 _icon->GetHeight(),
69 _icon,
70
71=== modified file 'launcher/LauncherDragWindow.h'
72--- launcher/LauncherDragWindow.h 2012-06-18 02:57:23 +0000
73+++ launcher/LauncherDragWindow.h 2012-08-20 15:04:27 +0000
74@@ -54,6 +54,7 @@
75 bool OnAnimationTimeout();
76
77 nux::ObjectPtr<nux::IOpenGLBaseTexture> _icon;
78+ nux::ObjectPtr<nux::IOpenGLBaseTexture> _drop_shadow;
79 nux::Point2 _animation_target;
80 glib::Source::UniquePtr animation_timer_;
81 };
82
83=== added file 'plugins/unityshell/resources/ordering_shadow.png'
84Binary files plugins/unityshell/resources/ordering_shadow.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/ordering_shadow.png 2012-08-20 15:04:27 +0000 differ