Merge lp:~nick-dedekind/unity/lp863412.dash-result-dnd-icon into lp:unity
- lp863412.dash-result-dnd-icon
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Francis Ginther |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2967 |
Proposed branch: | lp:~nick-dedekind/unity/lp863412.dash-result-dnd-icon |
Merge into: | lp:unity |
Diff against target: |
742 lines (+332/-124) 15 files modified
UnityCore/ModelRowAdaptor-inl.h (+3/-3) UnityCore/ModelRowAdaptor.cpp (+14/-0) UnityCore/ModelRowAdaptor.h (+11/-6) UnityCore/Result.cpp (+15/-7) UnityCore/Result.h (+9/-0) dash/ResultRenderer.cpp (+95/-0) dash/ResultRenderer.h (+3/-0) dash/ResultRendererHorizontalTile.cpp (+21/-1) dash/ResultRendererHorizontalTile.h (+2/-0) dash/ResultRendererTile.cpp (+18/-5) dash/ResultRendererTile.h (+4/-0) dash/ResultViewGrid.cpp (+11/-101) dash/ResultViewGrid.h (+1/-1) tests/CMakeLists.txt (+1/-0) tests/test_result_renderer.cpp (+124/-0) |
To merge this branch: | bzr merge lp:~nick-dedekind/unity/lp863412.dash-result-dnd-icon |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+138527@code.launchpad.net |
Commit message
Use the dash rendered icon as the source for the drag icon.
Description of the change
= Problem description =
Dash result drag icon is not the same as the icon rendered onto the dash.
https:/
= The fix =
Use the dash rendered icon as the source for the drag icon.
= Test coverage =
Cannot directly test the drag icon.
Added unit test harness for result renderer. Includes tests for result renderer construction and dnd icon return.
Brandon Schaefer (brandontschaefer) wrote : | # |
Nick Dedekind (nick-dedekind) wrote : | # |
> Looks good, just couple things:
>
> 60 + virtual ~RowAdaptorBase();
>
> Could we make this pure? Or just define it in the header, with a {}?
>
Pure virtual would require the derived classes to implement a destructor.
I don't see any benifit from inlining the destructor in a non-abstract class.
> 437 + , drag_index_(~0)
> 585 + drag_index_ = ~0;
>
> Why not just -1? As the bit complement of 0 is a bit less readable. (Though I
> like it :)
> Unless you change all the -1 usage to ~0, it should be consistent.
-1 is not an unsigned value.
I believe a comparison of "-1 == (unsigned)value" will cause an overflow error on 64bit systems.
There are a few instances of ~0 for unsigned values around the code
And they should all be changed, but I'm not going to go around and find them. :)
Brandon Schaefer (brandontschaefer) wrote : | # |
O I didn't notice it was an unsigned int...cool looks good then!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Francis Ginther (fginther) wrote : | # |
Re-approving. Autolanding failed due to a API change with compiz that was not yet reflected in unity. The API change has been resolved.
Preview Diff
1 | === modified file 'UnityCore/ModelRowAdaptor-inl.h' | |||
2 | --- UnityCore/ModelRowAdaptor-inl.h 2011-07-29 14:21:22 +0000 | |||
3 | +++ UnityCore/ModelRowAdaptor-inl.h 2012-12-06 18:02:23 +0000 | |||
4 | @@ -28,13 +28,13 @@ | |||
5 | 28 | template<typename T> | 28 | template<typename T> |
6 | 29 | void RowAdaptorBase::set_renderer(T renderer) | 29 | void RowAdaptorBase::set_renderer(T renderer) |
7 | 30 | { | 30 | { |
9 | 31 | dee_model_set_tag(model_, iter_, tag_, renderer); | 31 | set_model_tag(renderer); |
10 | 32 | } | 32 | } |
11 | 33 | 33 | ||
12 | 34 | template<typename T> | 34 | template<typename T> |
14 | 35 | T RowAdaptorBase::renderer() | 35 | T RowAdaptorBase::renderer() const |
15 | 36 | { | 36 | { |
17 | 37 | return static_cast<T>(dee_model_get_tag(model_, iter_, tag_)); | 37 | return static_cast<T>(get_model_tag()); |
18 | 38 | } | 38 | } |
19 | 39 | 39 | ||
20 | 40 | } | 40 | } |
21 | 41 | 41 | ||
22 | === modified file 'UnityCore/ModelRowAdaptor.cpp' | |||
23 | --- UnityCore/ModelRowAdaptor.cpp 2012-09-02 20:34:37 +0000 | |||
24 | +++ UnityCore/ModelRowAdaptor.cpp 2012-12-06 18:02:23 +0000 | |||
25 | @@ -36,6 +36,10 @@ | |||
26 | 36 | tag_ = other.tag_; | 36 | tag_ = other.tag_; |
27 | 37 | } | 37 | } |
28 | 38 | 38 | ||
29 | 39 | RowAdaptorBase::~RowAdaptorBase() | ||
30 | 40 | { | ||
31 | 41 | } | ||
32 | 42 | |||
33 | 39 | RowAdaptorBase& RowAdaptorBase::operator=(RowAdaptorBase const& other) | 43 | RowAdaptorBase& RowAdaptorBase::operator=(RowAdaptorBase const& other) |
34 | 40 | { | 44 | { |
35 | 41 | model_ = other.model_; | 45 | model_ = other.model_; |
36 | @@ -91,5 +95,15 @@ | |||
37 | 91 | return static_cast<float>(dee_model_get_double(model_, iter_, position)); | 95 | return static_cast<float>(dee_model_get_double(model_, iter_, position)); |
38 | 92 | } | 96 | } |
39 | 93 | 97 | ||
40 | 98 | void RowAdaptorBase::set_model_tag(gpointer value) | ||
41 | 99 | { | ||
42 | 100 | dee_model_set_tag(model_, iter_, tag_, value); | ||
43 | 101 | } | ||
44 | 102 | |||
45 | 103 | gpointer RowAdaptorBase::get_model_tag() const | ||
46 | 104 | { | ||
47 | 105 | return dee_model_get_tag(model_, iter_, tag_); | ||
48 | 106 | } | ||
49 | 107 | |||
50 | 94 | } | 108 | } |
51 | 95 | } | 109 | } |
52 | 96 | 110 | ||
53 | === modified file 'UnityCore/ModelRowAdaptor.h' | |||
54 | --- UnityCore/ModelRowAdaptor.h 2012-09-02 20:34:37 +0000 | |||
55 | +++ UnityCore/ModelRowAdaptor.h 2012-12-06 18:02:23 +0000 | |||
56 | @@ -50,13 +50,15 @@ | |||
57 | 50 | public: | 50 | public: |
58 | 51 | RowAdaptorBase(DeeModel* model=0, DeeModelIter* iter=0, DeeModelTag* tag=0); | 51 | RowAdaptorBase(DeeModel* model=0, DeeModelIter* iter=0, DeeModelTag* tag=0); |
59 | 52 | RowAdaptorBase(RowAdaptorBase const& other); | 52 | RowAdaptorBase(RowAdaptorBase const& other); |
60 | 53 | virtual ~RowAdaptorBase(); | ||
61 | 54 | |||
62 | 53 | RowAdaptorBase& operator=(RowAdaptorBase const& other); | 55 | RowAdaptorBase& operator=(RowAdaptorBase const& other); |
63 | 54 | 56 | ||
69 | 55 | std::string GetStringAt(int position) const; | 57 | virtual std::string GetStringAt(int position) const; |
70 | 56 | bool GetBoolAt(int position) const; | 58 | virtual bool GetBoolAt(int position) const; |
71 | 57 | int GetIntAt(int position) const; | 59 | virtual int GetIntAt(int position) const; |
72 | 58 | unsigned int GetUIntAt(int position) const; | 60 | virtual unsigned int GetUIntAt(int position) const; |
73 | 59 | float GetFloatAt(int position) const; | 61 | virtual float GetFloatAt(int position) const; |
74 | 60 | 62 | ||
75 | 61 | void SetTarget(DeeModel* model, DeeModelIter* iter, DeeModelTag* tag); | 63 | void SetTarget(DeeModel* model, DeeModelIter* iter, DeeModelTag* tag); |
76 | 62 | 64 | ||
77 | @@ -64,9 +66,12 @@ | |||
78 | 64 | void set_renderer(T renderer); | 66 | void set_renderer(T renderer); |
79 | 65 | 67 | ||
80 | 66 | template<typename T> | 68 | template<typename T> |
82 | 67 | T renderer(); | 69 | T renderer() const; |
83 | 68 | 70 | ||
84 | 69 | protected: | 71 | protected: |
85 | 72 | virtual void set_model_tag(gpointer value); | ||
86 | 73 | virtual gpointer get_model_tag() const; | ||
87 | 74 | |||
88 | 70 | DeeModel* model_; | 75 | DeeModel* model_; |
89 | 71 | DeeModelIter* iter_; | 76 | DeeModelIter* iter_; |
90 | 72 | DeeModelTag* tag_; | 77 | DeeModelTag* tag_; |
91 | 73 | 78 | ||
92 | === modified file 'UnityCore/Result.cpp' | |||
93 | --- UnityCore/Result.cpp 2011-09-13 22:35:13 +0000 | |||
94 | +++ UnityCore/Result.cpp 2012-12-06 18:02:23 +0000 | |||
95 | @@ -48,14 +48,22 @@ | |||
96 | 48 | 48 | ||
97 | 49 | void Result::SetupGetters() | 49 | void Result::SetupGetters() |
98 | 50 | { | 50 | { |
106 | 51 | uri.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 0)); | 51 | uri.SetGetterFunction(sigc::mem_fun(this, &Result::GetURI)); |
107 | 52 | icon_hint.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 1)); | 52 | icon_hint.SetGetterFunction(sigc::mem_fun(this, &Result::GetIconHint)); |
108 | 53 | category_index.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetUIntAt), 2)); | 53 | category_index.SetGetterFunction(sigc::mem_fun(this, &Result::GetCategoryIndex)); |
109 | 54 | mimetype.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 3)); | 54 | mimetype.SetGetterFunction(sigc::mem_fun(this, &Result::GetMimeType)); |
110 | 55 | name.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 4)); | 55 | name.SetGetterFunction(sigc::mem_fun(this, &Result::GetName)); |
111 | 56 | comment.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 5)); | 56 | comment.SetGetterFunction(sigc::mem_fun(this, &Result::GetComment)); |
112 | 57 | dnd_uri.SetGetterFunction(sigc::bind(sigc::mem_fun(this, &RowAdaptorBase::GetStringAt), 6)); | 57 | dnd_uri.SetGetterFunction(sigc::mem_fun(this, &Result::GetDndURI)); |
113 | 58 | } | 58 | } |
114 | 59 | |||
115 | 60 | std::string Result::GetURI() const { return GetStringAt(0); } | ||
116 | 61 | std::string Result::GetIconHint() const { return GetStringAt(1); } | ||
117 | 62 | std::size_t Result::GetCategoryIndex() const { return GetUIntAt(2); } | ||
118 | 63 | std::string Result::GetMimeType() const { return GetStringAt(3); } | ||
119 | 64 | std::string Result::GetName() const { return GetStringAt(4); } | ||
120 | 65 | std::string Result::GetComment() const { return GetStringAt(5); } | ||
121 | 66 | std::string Result::GetDndURI() const { return GetStringAt(6); } | ||
122 | 59 | 67 | ||
123 | 60 | } | 68 | } |
124 | 61 | } | 69 | } |
125 | 62 | 70 | ||
126 | === modified file 'UnityCore/Result.h' | |||
127 | --- UnityCore/Result.h 2011-09-13 22:35:13 +0000 | |||
128 | +++ UnityCore/Result.h 2012-12-06 18:02:23 +0000 | |||
129 | @@ -51,6 +51,15 @@ | |||
130 | 51 | nux::ROProperty<std::string> comment; | 51 | nux::ROProperty<std::string> comment; |
131 | 52 | nux::ROProperty<std::string> dnd_uri; | 52 | nux::ROProperty<std::string> dnd_uri; |
132 | 53 | 53 | ||
133 | 54 | protected: | ||
134 | 55 | virtual std::string GetURI() const; | ||
135 | 56 | virtual std::string GetIconHint() const; | ||
136 | 57 | virtual std::size_t GetCategoryIndex() const; | ||
137 | 58 | virtual std::string GetMimeType() const; | ||
138 | 59 | virtual std::string GetName() const; | ||
139 | 60 | virtual std::string GetComment() const; | ||
140 | 61 | virtual std::string GetDndURI() const; | ||
141 | 62 | |||
142 | 54 | private: | 63 | private: |
143 | 55 | void SetupGetters(); | 64 | void SetupGetters(); |
144 | 56 | }; | 65 | }; |
145 | 57 | 66 | ||
146 | === modified file 'dash/ResultRenderer.cpp' | |||
147 | --- dash/ResultRenderer.cpp 2012-10-22 12:04:55 +0000 | |||
148 | +++ dash/ResultRenderer.cpp 2012-12-06 18:02:23 +0000 | |||
149 | @@ -22,10 +22,99 @@ | |||
150 | 22 | 22 | ||
151 | 23 | #include "ResultRenderer.h" | 23 | #include "ResultRenderer.h" |
152 | 24 | 24 | ||
153 | 25 | #include <gtk/gtk.h> | ||
154 | 26 | #include <unity-protocol.h> | ||
155 | 27 | #include <NuxGraphics/GdkGraphics.h> | ||
156 | 28 | |||
157 | 25 | namespace unity | 29 | namespace unity |
158 | 26 | { | 30 | { |
159 | 27 | namespace dash | 31 | namespace dash |
160 | 28 | { | 32 | { |
161 | 33 | |||
162 | 34 | namespace | ||
163 | 35 | { | ||
164 | 36 | #define DEFAULT_GICON ". GThemedIcon text-x-preview" | ||
165 | 37 | |||
166 | 38 | GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size) | ||
167 | 39 | { | ||
168 | 40 | GdkPixbuf *pbuf; | ||
169 | 41 | GtkIconTheme *theme; | ||
170 | 42 | GtkIconInfo *info; | ||
171 | 43 | GError *error = NULL; | ||
172 | 44 | GIcon *icon; | ||
173 | 45 | if (icon_hint.empty()) | ||
174 | 46 | icon_hint = DEFAULT_GICON; | ||
175 | 47 | if (g_str_has_prefix(icon_hint.c_str(), "/")) | ||
176 | 48 | { | ||
177 | 49 | pbuf = gdk_pixbuf_new_from_file_at_scale (icon_hint.c_str(), | ||
178 | 50 | size, size, TRUE, &error); | ||
179 | 51 | if (error != NULL || !pbuf || !GDK_IS_PIXBUF (pbuf)) | ||
180 | 52 | { | ||
181 | 53 | icon_hint = "application-default-icon"; | ||
182 | 54 | g_error_free (error); | ||
183 | 55 | error = NULL; | ||
184 | 56 | } | ||
185 | 57 | else | ||
186 | 58 | return pbuf; | ||
187 | 59 | } | ||
188 | 60 | theme = gtk_icon_theme_get_default(); | ||
189 | 61 | icon = g_icon_new_for_string(icon_hint.c_str(), NULL); | ||
190 | 62 | |||
191 | 63 | if (G_IS_ICON(icon)) | ||
192 | 64 | { | ||
193 | 65 | if (UNITY_PROTOCOL_IS_ANNOTATED_ICON(icon)) | ||
194 | 66 | { | ||
195 | 67 | UnityProtocolAnnotatedIcon *anno; | ||
196 | 68 | anno = UNITY_PROTOCOL_ANNOTATED_ICON(icon); | ||
197 | 69 | |||
198 | 70 | GIcon *base_icon = unity_protocol_annotated_icon_get_icon(anno); | ||
199 | 71 | info = gtk_icon_theme_lookup_by_gicon(theme, base_icon, size, (GtkIconLookupFlags)0); | ||
200 | 72 | } | ||
201 | 73 | else | ||
202 | 74 | { | ||
203 | 75 | info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0); | ||
204 | 76 | } | ||
205 | 77 | g_object_unref(icon); | ||
206 | 78 | } | ||
207 | 79 | else | ||
208 | 80 | { | ||
209 | 81 | info = gtk_icon_theme_lookup_icon(theme, | ||
210 | 82 | icon_hint.c_str(), | ||
211 | 83 | size, | ||
212 | 84 | (GtkIconLookupFlags) 0); | ||
213 | 85 | } | ||
214 | 86 | |||
215 | 87 | if (!info) | ||
216 | 88 | { | ||
217 | 89 | info = gtk_icon_theme_lookup_icon(theme, | ||
218 | 90 | "application-default-icon", | ||
219 | 91 | size, | ||
220 | 92 | (GtkIconLookupFlags) 0); | ||
221 | 93 | } | ||
222 | 94 | |||
223 | 95 | if (gtk_icon_info_get_filename(info) == NULL) | ||
224 | 96 | { | ||
225 | 97 | gtk_icon_info_free(info); | ||
226 | 98 | info = gtk_icon_theme_lookup_icon(theme, | ||
227 | 99 | "application-default-icon", | ||
228 | 100 | size, | ||
229 | 101 | (GtkIconLookupFlags) 0); | ||
230 | 102 | } | ||
231 | 103 | |||
232 | 104 | pbuf = gtk_icon_info_load_icon(info, &error); | ||
233 | 105 | |||
234 | 106 | if (error != NULL) | ||
235 | 107 | { | ||
236 | 108 | g_error_free (error); | ||
237 | 109 | pbuf = NULL; | ||
238 | 110 | } | ||
239 | 111 | |||
240 | 112 | gtk_icon_info_free(info); | ||
241 | 113 | return pbuf; | ||
242 | 114 | } | ||
243 | 115 | |||
244 | 116 | } | ||
245 | 117 | |||
246 | 29 | NUX_IMPLEMENT_OBJECT_TYPE(ResultRenderer); | 118 | NUX_IMPLEMENT_OBJECT_TYPE(ResultRenderer); |
247 | 30 | 119 | ||
248 | 31 | ResultRenderer::ResultRenderer(NUX_FILE_LINE_DECL) | 120 | ResultRenderer::ResultRenderer(NUX_FILE_LINE_DECL) |
249 | @@ -52,6 +141,12 @@ | |||
250 | 52 | // unload any resources | 141 | // unload any resources |
251 | 53 | } | 142 | } |
252 | 54 | 143 | ||
253 | 144 | nux::NBitmapData* ResultRenderer::GetDndImage(Result const& row) const | ||
254 | 145 | { | ||
255 | 146 | nux::GdkGraphics graphics(_icon_hint_get_drag_pixbuf(row.icon_hint, 64)); | ||
256 | 147 | return graphics.GetBitmap(); | ||
257 | 148 | } | ||
258 | 149 | |||
259 | 55 | } | 150 | } |
260 | 56 | } | 151 | } |
261 | 57 | 152 | ||
262 | 58 | 153 | ||
263 | === modified file 'dash/ResultRenderer.h' | |||
264 | --- dash/ResultRenderer.h 2012-10-22 12:04:55 +0000 | |||
265 | +++ dash/ResultRenderer.h 2012-12-06 18:02:23 +0000 | |||
266 | @@ -62,6 +62,9 @@ | |||
267 | 62 | // unload any previous grabbed images | 62 | // unload any previous grabbed images |
268 | 63 | virtual void Unload(Result& row); | 63 | virtual void Unload(Result& row); |
269 | 64 | 64 | ||
270 | 65 | // get a image to drag | ||
271 | 66 | virtual nux::NBitmapData* GetDndImage(Result const& row) const; | ||
272 | 67 | |||
273 | 65 | nux::Property<int> width; | 68 | nux::Property<int> width; |
274 | 66 | nux::Property<int> height; | 69 | nux::Property<int> height; |
275 | 67 | 70 | ||
276 | 68 | 71 | ||
277 | === modified file 'dash/ResultRendererHorizontalTile.cpp' | |||
278 | --- dash/ResultRendererHorizontalTile.cpp 2012-10-22 12:04:55 +0000 | |||
279 | +++ dash/ResultRendererHorizontalTile.cpp 2012-12-06 18:02:23 +0000 | |||
280 | @@ -29,6 +29,7 @@ | |||
281 | 29 | 29 | ||
282 | 30 | #include "unity-shared/CairoTexture.h" | 30 | #include "unity-shared/CairoTexture.h" |
283 | 31 | #include "unity-shared/TextureCache.h" | 31 | #include "unity-shared/TextureCache.h" |
284 | 32 | #include <NuxGraphics/GdkGraphics.h> | ||
285 | 32 | 33 | ||
286 | 33 | 34 | ||
287 | 34 | namespace unity | 35 | namespace unity |
288 | @@ -42,7 +43,7 @@ | |||
289 | 42 | const int CARD_VIEW_HEIGHT = 74; // pixels | 43 | const int CARD_VIEW_HEIGHT = 74; // pixels |
290 | 43 | const int CARD_VIEW_HIGHLIGHT_CORNER_RADIUS = 2; // pixels | 44 | const int CARD_VIEW_HIGHLIGHT_CORNER_RADIUS = 2; // pixels |
291 | 44 | const int CARD_VIEW_ICON_OUTLINE_WIDTH = 1; // pixels | 45 | const int CARD_VIEW_ICON_OUTLINE_WIDTH = 1; // pixels |
293 | 45 | const int CARD_VIEW_TEXT_LINE_SPACING = 0; // points | 46 | const int CARD_VIEW_TEXT_LINE_SPACING = 0; // points |
294 | 46 | } | 47 | } |
295 | 47 | 48 | ||
296 | 48 | namespace dash | 49 | namespace dash |
297 | @@ -297,6 +298,25 @@ | |||
298 | 297 | container->text = texture_ptr_from_cairo_graphics(_cairoGraphics); | 298 | container->text = texture_ptr_from_cairo_graphics(_cairoGraphics); |
299 | 298 | } | 299 | } |
300 | 299 | 300 | ||
301 | 301 | nux::NBitmapData* ResultRendererHorizontalTile::GetDndImage(Result const& row) const | ||
302 | 302 | { | ||
303 | 303 | TextureContainer* container = row.renderer<TextureContainer*>(); | ||
304 | 304 | nux::NBitmapData* bitmap = nullptr; | ||
305 | 305 | |||
306 | 306 | if (container && container->drag_icon && container->drag_icon.IsType(GDK_TYPE_PIXBUF)) | ||
307 | 307 | { | ||
308 | 308 | int width = gdk_pixbuf_get_width(container->drag_icon); | ||
309 | 309 | int height = gdk_pixbuf_get_height(container->drag_icon); | ||
310 | 310 | |||
311 | 311 | if (width != CARD_VIEW_ICON_SIZE || height != CARD_VIEW_ICON_SIZE) | ||
312 | 312 | { | ||
313 | 313 | nux::GdkGraphics graphics(gdk_pixbuf_scale_simple(container->drag_icon, CARD_VIEW_ICON_SIZE, CARD_VIEW_ICON_SIZE, GDK_INTERP_BILINEAR)); | ||
314 | 314 | bitmap = graphics.GetBitmap(); | ||
315 | 315 | } | ||
316 | 316 | } | ||
317 | 317 | return bitmap ? bitmap : ResultRendererTile::GetDndImage(row); | ||
318 | 318 | } | ||
319 | 319 | |||
320 | 300 | 320 | ||
321 | 301 | } | 321 | } |
322 | 302 | } | 322 | } |
323 | 303 | 323 | ||
324 | === modified file 'dash/ResultRendererHorizontalTile.h' | |||
325 | --- dash/ResultRendererHorizontalTile.h 2012-10-22 12:04:55 +0000 | |||
326 | +++ dash/ResultRendererHorizontalTile.h 2012-12-06 18:02:23 +0000 | |||
327 | @@ -46,6 +46,8 @@ | |||
328 | 46 | nux::Geometry const& geometry, | 46 | nux::Geometry const& geometry, |
329 | 47 | int x_offset, int y_offset); | 47 | int x_offset, int y_offset); |
330 | 48 | 48 | ||
331 | 49 | virtual nux::NBitmapData* GetDndImage(Result const& row) const; | ||
332 | 50 | |||
333 | 49 | protected: | 51 | protected: |
334 | 50 | virtual void LoadText(Result& row); | 52 | virtual void LoadText(Result& row); |
335 | 51 | 53 | ||
336 | 52 | 54 | ||
337 | === modified file 'dash/ResultRendererTile.cpp' | |||
338 | --- dash/ResultRendererTile.cpp 2012-10-30 18:18:35 +0000 | |||
339 | +++ dash/ResultRendererTile.cpp 2012-12-06 18:02:23 +0000 | |||
340 | @@ -23,10 +23,10 @@ | |||
341 | 23 | #include "ResultRendererTile.h" | 23 | #include "ResultRendererTile.h" |
342 | 24 | 24 | ||
343 | 25 | #include <pango/pangocairo.h> | 25 | #include <pango/pangocairo.h> |
344 | 26 | #include <gtk/gtk.h> | ||
345 | 27 | 26 | ||
346 | 28 | #include <NuxCore/Logger.h> | 27 | #include <NuxCore/Logger.h> |
347 | 29 | #include <UnityCore/GLibWrapper.h> | 28 | #include <UnityCore/GLibWrapper.h> |
348 | 29 | #include <NuxGraphics/GdkGraphics.h> | ||
349 | 30 | 30 | ||
350 | 31 | #include "unity-shared/CairoTexture.h" | 31 | #include "unity-shared/CairoTexture.h" |
351 | 32 | #include "unity-shared/DashStyle.h" | 32 | #include "unity-shared/DashStyle.h" |
352 | @@ -34,7 +34,8 @@ | |||
353 | 34 | 34 | ||
354 | 35 | namespace | 35 | namespace |
355 | 36 | { | 36 | { |
357 | 37 | bool neko; | 37 | bool neko; |
358 | 38 | #define DEFAULT_GICON ". GThemedIcon text-x-preview" | ||
359 | 38 | } | 39 | } |
360 | 39 | 40 | ||
361 | 40 | namespace unity | 41 | namespace unity |
362 | @@ -180,11 +181,24 @@ | |||
363 | 180 | row.set_renderer<TextureContainer*>(nullptr); | 181 | row.set_renderer<TextureContainer*>(nullptr); |
364 | 181 | } | 182 | } |
365 | 182 | 183 | ||
366 | 184 | nux::NBitmapData* ResultRendererTile::GetDndImage(Result const& row) const | ||
367 | 185 | { | ||
368 | 186 | TextureContainer* container = row.renderer<TextureContainer*>(); | ||
369 | 187 | nux::NBitmapData* bitmap = nullptr; | ||
370 | 188 | |||
371 | 189 | if (container && container->drag_icon && container->drag_icon.IsType(GDK_TYPE_PIXBUF)) | ||
372 | 190 | { | ||
373 | 191 | // Need to ref the drag icon because GdkGraphics will unref it. | ||
374 | 192 | nux::GdkGraphics graphics(GDK_PIXBUF(g_object_ref(container->drag_icon))); | ||
375 | 193 | bitmap = graphics.GetBitmap(); | ||
376 | 194 | } | ||
377 | 195 | return bitmap ? bitmap : ResultRenderer::GetDndImage(row); | ||
378 | 196 | } | ||
379 | 197 | |||
380 | 183 | void ResultRendererTile::LoadIcon(Result& row) | 198 | void ResultRendererTile::LoadIcon(Result& row) |
381 | 184 | { | 199 | { |
382 | 185 | Style& style = Style::Instance(); | 200 | Style& style = Style::Instance(); |
383 | 186 | std::string icon_hint(row.icon_hint); | 201 | std::string icon_hint(row.icon_hint); |
384 | 187 | #define DEFAULT_GICON ". GThemedIcon text-x-preview" | ||
385 | 188 | std::string icon_name; | 202 | std::string icon_name; |
386 | 189 | if (G_UNLIKELY(neko)) | 203 | if (G_UNLIKELY(neko)) |
387 | 190 | { | 204 | { |
388 | @@ -289,10 +303,8 @@ | |||
389 | 289 | 303 | ||
390 | 290 | return texture_from_cairo_graphics(cairo_graphics); | 304 | return texture_from_cairo_graphics(cairo_graphics); |
391 | 291 | } | 305 | } |
392 | 292 | |||
393 | 293 | } | 306 | } |
394 | 294 | 307 | ||
395 | 295 | |||
396 | 296 | void ResultRendererTile::IconLoaded(std::string const& texid, | 308 | void ResultRendererTile::IconLoaded(std::string const& texid, |
397 | 297 | int max_width, | 309 | int max_width, |
398 | 298 | int max_height, | 310 | int max_height, |
399 | @@ -314,6 +326,7 @@ | |||
400 | 314 | 326 | ||
401 | 315 | container->icon = texture; | 327 | container->icon = texture; |
402 | 316 | container->prelight = texture_prelight; | 328 | container->prelight = texture_prelight; |
403 | 329 | container->drag_icon = pixbuf; | ||
404 | 317 | 330 | ||
405 | 318 | NeedsRedraw.emit(); | 331 | NeedsRedraw.emit(); |
406 | 319 | 332 | ||
407 | 320 | 333 | ||
408 | === modified file 'dash/ResultRendererTile.h' | |||
409 | --- dash/ResultRendererTile.h 2012-10-24 15:01:10 +0000 | |||
410 | +++ dash/ResultRendererTile.h 2012-12-06 18:02:23 +0000 | |||
411 | @@ -38,6 +38,8 @@ | |||
412 | 38 | BaseTexturePtr text; | 38 | BaseTexturePtr text; |
413 | 39 | BaseTexturePtr icon; | 39 | BaseTexturePtr icon; |
414 | 40 | BaseTexturePtr prelight; | 40 | BaseTexturePtr prelight; |
415 | 41 | glib::Object<GdkPixbuf> drag_icon; | ||
416 | 42 | |||
417 | 41 | int slot_handle; | 43 | int slot_handle; |
418 | 42 | 44 | ||
419 | 43 | TextureContainer() | 45 | TextureContainer() |
420 | @@ -67,6 +69,8 @@ | |||
421 | 67 | 69 | ||
422 | 68 | virtual void Preload(Result& row); | 70 | virtual void Preload(Result& row); |
423 | 69 | virtual void Unload(Result& row); | 71 | virtual void Unload(Result& row); |
424 | 72 | |||
425 | 73 | virtual nux::NBitmapData* GetDndImage(Result const& row) const; | ||
426 | 70 | 74 | ||
427 | 71 | int spacing; | 75 | int spacing; |
428 | 72 | int padding; | 76 | int padding; |
429 | 73 | 77 | ||
430 | === modified file 'dash/ResultViewGrid.cpp' | |||
431 | --- dash/ResultViewGrid.cpp 2012-12-04 17:23:39 +0000 | |||
432 | +++ dash/ResultViewGrid.cpp 2012-12-06 18:02:23 +0000 | |||
433 | @@ -56,6 +56,7 @@ | |||
434 | 56 | , last_lazy_loaded_result_(0) | 56 | , last_lazy_loaded_result_(0) |
435 | 57 | , last_mouse_down_x_(-1) | 57 | , last_mouse_down_x_(-1) |
436 | 58 | , last_mouse_down_y_(-1) | 58 | , last_mouse_down_y_(-1) |
437 | 59 | , drag_index_(~0) | ||
438 | 59 | , recorded_dash_width_(-1) | 60 | , recorded_dash_width_(-1) |
439 | 60 | , recorded_dash_height_(-1) | 61 | , recorded_dash_height_(-1) |
440 | 61 | , mouse_last_x_(-1) | 62 | , mouse_last_x_(-1) |
441 | @@ -778,27 +779,23 @@ | |||
442 | 778 | bool ResultViewGrid::DndSourceDragBegin() | 779 | bool ResultViewGrid::DndSourceDragBegin() |
443 | 779 | { | 780 | { |
444 | 780 | #ifdef USE_X11 | 781 | #ifdef USE_X11 |
447 | 781 | unsigned num_results = GetNumResults(); | 782 | drag_index_ = GetIndexAtPosition(last_mouse_down_x_, last_mouse_down_y_); |
446 | 782 | unsigned drag_index = GetIndexAtPosition(last_mouse_down_x_, last_mouse_down_y_); | ||
448 | 783 | 783 | ||
450 | 784 | if (drag_index >= num_results) | 784 | if (drag_index_ >= GetNumResults()) |
451 | 785 | return false; | 785 | return false; |
452 | 786 | 786 | ||
453 | 787 | Reference(); | 787 | Reference(); |
454 | 788 | 788 | ||
456 | 789 | ResultIterator iter(GetIteratorAtRow(drag_index)); | 789 | ResultIterator iter(GetIteratorAtRow(drag_index_)); |
457 | 790 | Result drag_result = *iter; | 790 | Result drag_result = *iter; |
458 | 791 | 791 | ||
459 | 792 | current_drag_uri_ = drag_result.dnd_uri; | 792 | current_drag_uri_ = drag_result.dnd_uri; |
460 | 793 | if (current_drag_uri_ == "") | 793 | if (current_drag_uri_ == "") |
461 | 794 | current_drag_uri_ = drag_result.uri().substr(drag_result.uri().find(":") + 1); | 794 | current_drag_uri_ = drag_result.uri().substr(drag_result.uri().find(":") + 1); |
462 | 795 | 795 | ||
463 | 796 | current_drag_icon_name_ = drag_result.icon_hint; | ||
464 | 797 | |||
465 | 798 | LOG_DEBUG (logger) << "Dnd begin at " << | 796 | LOG_DEBUG (logger) << "Dnd begin at " << |
466 | 799 | last_mouse_down_x_ << ", " << last_mouse_down_y_ << " - using; " | 797 | last_mouse_down_x_ << ", " << last_mouse_down_y_ << " - using; " |
469 | 800 | << current_drag_uri_ << " - " | 798 | << current_drag_uri_; |
468 | 801 | << current_drag_icon_name_; | ||
470 | 802 | 799 | ||
471 | 803 | return true; | 800 | return true; |
472 | 804 | #else | 801 | #else |
473 | @@ -806,101 +803,14 @@ | |||
474 | 806 | #endif | 803 | #endif |
475 | 807 | } | 804 | } |
476 | 808 | 805 | ||
477 | 809 | GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint) | ||
478 | 810 | { | ||
479 | 811 | GdkPixbuf *pbuf; | ||
480 | 812 | GtkIconTheme *theme; | ||
481 | 813 | GtkIconInfo *info; | ||
482 | 814 | GError *error = NULL; | ||
483 | 815 | GIcon *icon; | ||
484 | 816 | int size = 64; | ||
485 | 817 | if (icon_hint.empty()) | ||
486 | 818 | icon_hint = "application-default-icon"; | ||
487 | 819 | if (g_str_has_prefix(icon_hint.c_str(), "/")) | ||
488 | 820 | { | ||
489 | 821 | pbuf = gdk_pixbuf_new_from_file_at_scale (icon_hint.c_str(), | ||
490 | 822 | size, size, FALSE, &error); | ||
491 | 823 | if (error != NULL || !pbuf || !GDK_IS_PIXBUF (pbuf)) | ||
492 | 824 | { | ||
493 | 825 | icon_hint = "application-default-icon"; | ||
494 | 826 | g_error_free (error); | ||
495 | 827 | error = NULL; | ||
496 | 828 | } | ||
497 | 829 | else | ||
498 | 830 | return pbuf; | ||
499 | 831 | } | ||
500 | 832 | theme = gtk_icon_theme_get_default(); | ||
501 | 833 | icon = g_icon_new_for_string(icon_hint.c_str(), NULL); | ||
502 | 834 | |||
503 | 835 | if (G_IS_ICON(icon)) | ||
504 | 836 | { | ||
505 | 837 | if (UNITY_PROTOCOL_IS_ANNOTATED_ICON(icon)) | ||
506 | 838 | { | ||
507 | 839 | UnityProtocolAnnotatedIcon *anno; | ||
508 | 840 | anno = UNITY_PROTOCOL_ANNOTATED_ICON(icon); | ||
509 | 841 | |||
510 | 842 | GIcon *base_icon = unity_protocol_annotated_icon_get_icon(anno); | ||
511 | 843 | info = gtk_icon_theme_lookup_by_gicon(theme, base_icon, size, (GtkIconLookupFlags)0); | ||
512 | 844 | } | ||
513 | 845 | else | ||
514 | 846 | { | ||
515 | 847 | info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0); | ||
516 | 848 | } | ||
517 | 849 | g_object_unref(icon); | ||
518 | 850 | } | ||
519 | 851 | else | ||
520 | 852 | { | ||
521 | 853 | info = gtk_icon_theme_lookup_icon(theme, | ||
522 | 854 | icon_hint.c_str(), | ||
523 | 855 | size, | ||
524 | 856 | (GtkIconLookupFlags) 0); | ||
525 | 857 | } | ||
526 | 858 | |||
527 | 859 | if (!info) | ||
528 | 860 | { | ||
529 | 861 | info = gtk_icon_theme_lookup_icon(theme, | ||
530 | 862 | "application-default-icon", | ||
531 | 863 | size, | ||
532 | 864 | (GtkIconLookupFlags) 0); | ||
533 | 865 | } | ||
534 | 866 | |||
535 | 867 | if (gtk_icon_info_get_filename(info) == NULL) | ||
536 | 868 | { | ||
537 | 869 | gtk_icon_info_free(info); | ||
538 | 870 | info = gtk_icon_theme_lookup_icon(theme, | ||
539 | 871 | "application-default-icon", | ||
540 | 872 | size, | ||
541 | 873 | (GtkIconLookupFlags) 0); | ||
542 | 874 | } | ||
543 | 875 | |||
544 | 876 | pbuf = gtk_icon_info_load_icon(info, &error); | ||
545 | 877 | |||
546 | 878 | if (error != NULL) | ||
547 | 879 | { | ||
548 | 880 | LOG_WARN (logger) << "could not find a pixbuf for " << icon_hint; | ||
549 | 881 | g_error_free (error); | ||
550 | 882 | pbuf = NULL; | ||
551 | 883 | } | ||
552 | 884 | |||
553 | 885 | gtk_icon_info_free(info); | ||
554 | 886 | return pbuf; | ||
555 | 887 | } | ||
556 | 888 | |||
557 | 889 | nux::NBitmapData* | 806 | nux::NBitmapData* |
558 | 890 | ResultViewGrid::DndSourceGetDragImage() | 807 | ResultViewGrid::DndSourceGetDragImage() |
559 | 891 | { | 808 | { |
572 | 892 | nux::NBitmapData* result = 0; | 809 | if (drag_index_ >= GetNumResults()) |
573 | 893 | GdkPixbuf* pbuf; | 810 | return nullptr; |
574 | 894 | pbuf = _icon_hint_get_drag_pixbuf (current_drag_icon_name_); | 811 | |
575 | 895 | 812 | Result result(*GetIteratorAtRow(drag_index_)); | |
576 | 896 | if (pbuf && GDK_IS_PIXBUF(pbuf)) | 813 | return renderer_->GetDndImage(result); |
565 | 897 | { | ||
566 | 898 | // we don't free the pbuf as GdkGraphics will do it for us will do it for us | ||
567 | 899 | nux::GdkGraphics graphics(pbuf); | ||
568 | 900 | result = graphics.GetBitmap(); | ||
569 | 901 | } | ||
570 | 902 | |||
571 | 903 | return result; | ||
577 | 904 | } | 814 | } |
578 | 905 | 815 | ||
579 | 906 | std::list<const char*> | 816 | std::list<const char*> |
580 | @@ -934,7 +844,7 @@ | |||
581 | 934 | last_mouse_down_x_ = -1; | 844 | last_mouse_down_x_ = -1; |
582 | 935 | last_mouse_down_y_ = -1; | 845 | last_mouse_down_y_ = -1; |
583 | 936 | current_drag_uri_.clear(); | 846 | current_drag_uri_.clear(); |
585 | 937 | current_drag_icon_name_.clear(); | 847 | drag_index_ = ~0; |
586 | 938 | 848 | ||
587 | 939 | // We need this because the drag can start in a ResultViewGrid and can | 849 | // We need this because the drag can start in a ResultViewGrid and can |
588 | 940 | // end in another ResultViewGrid | 850 | // end in another ResultViewGrid |
589 | 941 | 851 | ||
590 | === modified file 'dash/ResultViewGrid.h' | |||
591 | --- dash/ResultViewGrid.h 2012-11-19 18:54:19 +0000 | |||
592 | +++ dash/ResultViewGrid.h 2012-12-06 18:02:23 +0000 | |||
593 | @@ -106,7 +106,7 @@ | |||
594 | 106 | int last_mouse_down_x_; | 106 | int last_mouse_down_x_; |
595 | 107 | int last_mouse_down_y_; | 107 | int last_mouse_down_y_; |
596 | 108 | std::string current_drag_uri_; | 108 | std::string current_drag_uri_; |
598 | 109 | std::string current_drag_icon_name_; | 109 | unsigned drag_index_; |
599 | 110 | 110 | ||
600 | 111 | int recorded_dash_width_; | 111 | int recorded_dash_width_; |
601 | 112 | int recorded_dash_height_; | 112 | int recorded_dash_height_; |
602 | 113 | 113 | ||
603 | === modified file 'tests/CMakeLists.txt' | |||
604 | --- tests/CMakeLists.txt 2012-12-05 09:10:04 +0000 | |||
605 | +++ tests/CMakeLists.txt 2012-12-06 18:02:23 +0000 | |||
606 | @@ -230,6 +230,7 @@ | |||
607 | 230 | test_overlay_scrollbar.cpp | 230 | test_overlay_scrollbar.cpp |
608 | 231 | test_quicklist_menu_item.cpp | 231 | test_quicklist_menu_item.cpp |
609 | 232 | test_quicklist_view.cpp | 232 | test_quicklist_view.cpp |
610 | 233 | test_result_renderer.cpp | ||
611 | 233 | test_resultviewgrid.cpp | 234 | test_resultviewgrid.cpp |
612 | 234 | test_shortcut_controller.cpp | 235 | test_shortcut_controller.cpp |
613 | 235 | test_single_monitor_launcher_icon.cpp | 236 | test_single_monitor_launcher_icon.cpp |
614 | 236 | 237 | ||
615 | === added file 'tests/test_result_renderer.cpp' | |||
616 | --- tests/test_result_renderer.cpp 1970-01-01 00:00:00 +0000 | |||
617 | +++ tests/test_result_renderer.cpp 2012-12-06 18:02:23 +0000 | |||
618 | @@ -0,0 +1,124 @@ | |||
619 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
620 | 2 | /* | ||
621 | 3 | * Copyright 2012 Canonical Ltd. | ||
622 | 4 | * | ||
623 | 5 | * This program is free software: you can redistribute it and/or modify it | ||
624 | 6 | * under the terms of the GNU Lesser General Public License version 3, as | ||
625 | 7 | * published by the Free Software Foundation. | ||
626 | 8 | * | ||
627 | 9 | * This program is distributed in the hope that it will be useful, but | ||
628 | 10 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
629 | 11 | * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
630 | 12 | * PURPOSE. See the applicable version of the GNU Lesser General Public | ||
631 | 13 | * License for more details. | ||
632 | 14 | * | ||
633 | 15 | * You should have received a copy of both the GNU Lesser General Public | ||
634 | 16 | * License version 3 along with this program. If not, see | ||
635 | 17 | * <http://www.gnu.org/licenses/> | ||
636 | 18 | * | ||
637 | 19 | * Authored by: Nick Dedekind <nick.dedekind@canonical.com> | ||
638 | 20 | * | ||
639 | 21 | */ | ||
640 | 22 | #include <gmock/gmock.h> | ||
641 | 23 | #include <glib-object.h> | ||
642 | 24 | |||
643 | 25 | #include "unity-shared/DashStyle.h" | ||
644 | 26 | #include "unity-shared/UnitySettings.h" | ||
645 | 27 | #include "UnityCore/Result.h" | ||
646 | 28 | #include "dash/ResultRendererTile.h" | ||
647 | 29 | |||
648 | 30 | #include "test_utils.h" | ||
649 | 31 | |||
650 | 32 | using namespace std; | ||
651 | 33 | using namespace unity; | ||
652 | 34 | using namespace testing; | ||
653 | 35 | |||
654 | 36 | namespace unity | ||
655 | 37 | { | ||
656 | 38 | |||
657 | 39 | namespace | ||
658 | 40 | { | ||
659 | 41 | |||
660 | 42 | #define DEFAULT_GICON ". GThemedIcon text-x-preview" | ||
661 | 43 | |||
662 | 44 | GdkPixbuf* GetIconData(std::string icon_hint, int size) | ||
663 | 45 | { | ||
664 | 46 | GdkPixbuf *pbuf; | ||
665 | 47 | GtkIconTheme *theme; | ||
666 | 48 | GError *error = NULL; | ||
667 | 49 | |||
668 | 50 | theme = gtk_icon_theme_get_default(); | ||
669 | 51 | glib::Object<GIcon> icon(g_icon_new_for_string(icon_hint.c_str(), NULL)); | ||
670 | 52 | |||
671 | 53 | if (icon.IsType(G_TYPE_ICON)) | ||
672 | 54 | { | ||
673 | 55 | GtkIconInfo *info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0); | ||
674 | 56 | pbuf = gtk_icon_info_load_icon(info, &error); | ||
675 | 57 | if (error != NULL) | ||
676 | 58 | { | ||
677 | 59 | g_error_free (error); | ||
678 | 60 | pbuf = NULL; | ||
679 | 61 | } | ||
680 | 62 | gtk_icon_info_free(info); | ||
681 | 63 | } | ||
682 | 64 | |||
683 | 65 | return pbuf; | ||
684 | 66 | } | ||
685 | 67 | |||
686 | 68 | } // namespace [anonymous] | ||
687 | 69 | |||
688 | 70 | class TestResultRenderer : public testing::Test | ||
689 | 71 | { | ||
690 | 72 | public: | ||
691 | 73 | TestResultRenderer() {} | ||
692 | 74 | |||
693 | 75 | unity::Settings settings; | ||
694 | 76 | dash::Style style; | ||
695 | 77 | }; | ||
696 | 78 | |||
697 | 79 | class MockResult : public dash::Result | ||
698 | 80 | { | ||
699 | 81 | public: | ||
700 | 82 | MockResult() | ||
701 | 83 | : Result(NULL, NULL, NULL) | ||
702 | 84 | , renderer_(new dash::TextureContainer()) | ||
703 | 85 | { | ||
704 | 86 | ON_CALL (*this, GetURI ()).WillByDefault (Return ("file:///result_render_test")); | ||
705 | 87 | ON_CALL (*this, GetIconHint()).WillByDefault (Return (DEFAULT_GICON)); | ||
706 | 88 | ON_CALL (*this, GetCategoryIndex ()).WillByDefault (Return (0)); | ||
707 | 89 | ON_CALL (*this, GetName ()).WillByDefault (Return ("Result Render Test")); | ||
708 | 90 | ON_CALL (*this, GetDndURI ()).WillByDefault (Return ("file:///result_render_test_dnd")); | ||
709 | 91 | } | ||
710 | 92 | |||
711 | 93 | MOCK_CONST_METHOD0(GetURI, std::string()); | ||
712 | 94 | MOCK_CONST_METHOD0(GetIconHint, std::string()); | ||
713 | 95 | MOCK_CONST_METHOD0(GetCategoryIndex, std::size_t()); | ||
714 | 96 | MOCK_CONST_METHOD0(GetMimeType, std::string()); | ||
715 | 97 | MOCK_CONST_METHOD0(GetName, std::string()); | ||
716 | 98 | MOCK_CONST_METHOD0(GetComment, std::string()); | ||
717 | 99 | MOCK_CONST_METHOD0(GetDndURI, std::string()); | ||
718 | 100 | |||
719 | 101 | virtual gpointer get_model_tag() const | ||
720 | 102 | { | ||
721 | 103 | return renderer_.get(); | ||
722 | 104 | } | ||
723 | 105 | |||
724 | 106 | private: | ||
725 | 107 | std::auto_ptr<dash::TextureContainer> renderer_; | ||
726 | 108 | }; | ||
727 | 109 | |||
728 | 110 | TEST_F(TestResultRenderer, TestConstruction) | ||
729 | 111 | { | ||
730 | 112 | dash::ResultRendererTile renderer; | ||
731 | 113 | } | ||
732 | 114 | |||
733 | 115 | TEST_F(TestResultRenderer, TestDndIcon) | ||
734 | 116 | { | ||
735 | 117 | dash::ResultRendererTile renderer; | ||
736 | 118 | NiceMock<MockResult> result; | ||
737 | 119 | |||
738 | 120 | nux::NBitmapData* bitmap = renderer.GetDndImage(result); | ||
739 | 121 | ASSERT_NE(bitmap, nullptr); | ||
740 | 122 | } | ||
741 | 123 | |||
742 | 124 | } |
Looks good, just couple things:
60 + virtual ~RowAdaptorBase();
Could we make this pure? Or just define it in the header, with a {}?
437 + , drag_index_(~0)
585 + drag_index_ = ~0;
Why not just -1? As the bit complement of 0 is a bit less readable. (Though I like it :)
Unless you change all the -1 usage to ~0, it should be consistent.