Merge lp:~gordallott/unity/fix-reflections into lp:unity

Proposed by Gord Allott
Status: Merged
Merged at revision: 1608
Proposed branch: lp:~gordallott/unity/fix-reflections
Merge into: lp:unity
Diff against target: 144 lines (+37/-12)
5 files modified
plugins/unityshell/src/DashView.cpp (+7/-5)
plugins/unityshell/src/ResultViewGrid.cpp (+19/-7)
plugins/unityshell/src/ResultViewGrid.h (+6/-0)
plugins/unityshell/src/UBusMessages.h (+2/-0)
tests/CMakeLists.txt (+3/-0)
To merge this branch: bzr merge lp:~gordallott/unity/fix-reflections
Reviewer Review Type Date Requested Status
Jason Smith (community) Approve
Andrea Cimitan (community) Approve
Review via email: mp+76536@code.launchpad.net

Description of the change

fixes the dash reflections, they were based on the basewindow size but at some point the basewindow size got increased to the size of the maximised dash at all times, which threw the reflections off.

this is a crappy way to fix this, we'll need something better in P

To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote :

Coding wise, I can't see anything wrong. If the math and the threshold you're using to calculate the offset are right, that's a +1 from me.

review: Approve
Revision history for this message
Jason Smith (jassmith) wrote :

Works fine but the effect is VERY subtle. I wonder if it shouldn't be exagerated a bit more.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/DashView.cpp'
2--- plugins/unityshell/src/DashView.cpp 2011-09-21 20:22:09 +0000
3+++ plugins/unityshell/src/DashView.cpp 2011-09-22 10:00:29 +0000
4@@ -174,6 +174,8 @@
5 // Minus the padding that gets added to the left
6 style->SetDefaultNColumns(floorf((content_geo_.width - 32)/ (float)style->GetTileWidth()));
7
8+ ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height));
9+
10 QueueDraw();
11 }
12
13@@ -388,8 +390,8 @@
14 gfx_context.PushClippingRectangle(bg_clip);
15
16 gfx_context.GetRenderStates().SetBlend(false);
17- gfx_context.QRP_1Tex (content_geo_.x, content_geo_.y,
18- content_geo_.width, content_geo_.height,
19+ gfx_context.QRP_1Tex (content_geo_.x, content_geo_.y,
20+ content_geo_.width, content_geo_.height,
21 bg_blur_texture_, texxform_absolute_bg, color::White);
22 gPainter.PopBackground();
23
24@@ -411,10 +413,10 @@
25 gfx_context.GetRenderStates().SetColorMask(true, true, true, false);
26 gfx_context.GetRenderStates().SetBlend(true, GL_DST_COLOR, GL_ONE);
27
28- gfx_context.QRP_1Tex (content_geo_.x, content_geo_.y,
29- content_geo_.width, content_geo_.height,
30+ gfx_context.QRP_1Tex (content_geo_.x, content_geo_.y,
31+ content_geo_.width, content_geo_.height,
32 bg_shine_texture_, texxform_absolute_bg, color::White);
33-
34+
35
36 // Make round corners
37 nux::ROPConfig rop;
38
39=== modified file 'plugins/unityshell/src/ResultViewGrid.cpp'
40--- plugins/unityshell/src/ResultViewGrid.cpp 2011-09-21 11:25:04 +0000
41+++ plugins/unityshell/src/ResultViewGrid.cpp 2011-09-22 10:00:29 +0000
42@@ -57,6 +57,8 @@
43 , lazy_load_handle_(0)
44 , last_mouse_down_x_(-1)
45 , last_mouse_down_y_(-1)
46+ , recorded_dash_width_(-1)
47+ , recorded_dash_height_(-1)
48 {
49 auto needredraw_lambda = [&](int value)
50 {
51@@ -84,6 +86,12 @@
52 NeedRedraw();
53 });
54
55+ ubus_.RegisterInterest(UBUS_DASH_SIZE_CHANGED, [this] (GVariant* data) {
56+ // on dash size changed, we update our stored values, this sucks
57+ //FIXME in P - make dash size the size of our dash not the entire screen
58+ g_variant_get (data, "(ii)", &recorded_dash_width_, &recorded_dash_height_);
59+ });
60+
61 SetDndEnabled(true, false);
62 NeedRedraw();
63 }
64@@ -559,7 +567,6 @@
65 uint row_size = renderer_->height + vertical_spacing;
66
67 int y_position = padding + GetGeometry().y;
68- nux::Area* top_level_parent = GetToplevel();
69
70 ResultListBounds visible_bounds = GetVisableResults();
71
72@@ -590,12 +597,17 @@
73 state = ResultRenderer::RESULT_RENDERER_ACTIVE;
74 }
75
76- int half_width = top_level_parent->GetGeometry().width / 2;
77- // FIXME - we assume the height of the viewport is 600
78- int half_height = top_level_parent->GetGeometry().height;
79-
80- int offset_x = (x_position - half_width) / (half_width / 10);
81- int offset_y = ((y_position + absolute_y) - half_height) / (half_height / 10);
82+ int half_width = recorded_dash_width_ / 2;
83+ int half_height = recorded_dash_height_;
84+
85+ int offset_x = MAX(MIN((x_position - half_width) / (half_width / 10), 5), -5);
86+ int offset_y = MAX(MIN(((y_position + absolute_y) - half_height) / (half_height / 10), 5), -5);
87+
88+ if (recorded_dash_width_ < 1 || recorded_dash_height_ < 1)
89+ {
90+ offset_x = 0;
91+ offset_y = 0;
92+ }
93 nux::Geometry render_geo(x_position, y_position, renderer_->width, renderer_->height);
94 renderer_->Render(GfxContext, results_[index], state, render_geo, offset_x, offset_y);
95
96
97=== modified file 'plugins/unityshell/src/ResultViewGrid.h'
98--- plugins/unityshell/src/ResultViewGrid.h 2011-09-19 15:12:23 +0000
99+++ plugins/unityshell/src/ResultViewGrid.h 2011-09-22 10:00:29 +0000
100@@ -27,6 +27,7 @@
101
102 #include <UnityCore/Categories.h>
103 #include "ResultView.h"
104+#include "UBusWrapper.h"
105
106 namespace unity
107 {
108@@ -100,6 +101,11 @@
109 std::string current_drag_uri_;
110 std::string current_drag_icon_name_;
111
112+ int recorded_dash_width_;
113+ int recorded_dash_height_;
114+
115+ UBusManager ubus_;
116+
117 };
118
119 }
120
121=== modified file 'plugins/unityshell/src/UBusMessages.h'
122--- plugins/unityshell/src/UBusMessages.h 2011-09-05 14:00:26 +0000
123+++ plugins/unityshell/src/UBusMessages.h 2011-09-22 10:00:29 +0000
124@@ -67,4 +67,6 @@
125 #define UBUS_BACKGROUND_COLOR_CHANGED "BACKGROUND_COLOR_CHANGED"
126 #define UBUS_BACKGROUND_REQUEST_COLOUR_EMIT "REQUEST_BACKGROUND_COLOUR_EMIT"
127
128+#define UBUS_DASH_SIZE_CHANGED "DASH_SIZE_CHANGED"
129+
130 #endif // UBUS_MESSAGES_H
131
132=== modified file 'tests/CMakeLists.txt'
133--- tests/CMakeLists.txt 2011-09-19 06:05:54 +0000
134+++ tests/CMakeLists.txt 2011-09-22 10:00:29 +0000
135@@ -449,6 +449,9 @@
136 ${UNITY_SRC}/Timer.cpp
137 ${UNITY_SRC}/DashStyle.cpp
138 ${UNITY_SRC}/JSONParser.cpp
139+ ${UNITY_SRC}/UBusMessages.h
140+ ${UNITY_SRC}/UBusWrapper.cpp
141+ ${UNITY_SRC}/UBusWrapper.h
142 ${UNITY_SRC}/ubus-server.cpp
143 ${UNITY_SRC}/ubus-server.h
144 )