Merge lp:~3v1n0/unity/dash-scrollbars-scaling into lp:unity
- dash-scrollbars-scaling
- Merge into trunk
Proposed by
Marco Trevisan (Treviño)
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | no longer in the source branch. |
Merged at revision: | 3846 |
Proposed branch: | lp:~3v1n0/unity/dash-scrollbars-scaling |
Merge into: | lp:unity |
Prerequisite: | lp:~3v1n0/unity/hud-scaling |
Diff against target: |
1324 lines (+314/-240) 25 files modified
dash/ScopeView.cpp (+10/-9) dash/ScopeView.h (+0/-1) dash/previews/ApplicationPreview.cpp (+11/-14) dash/previews/ApplicationPreview.h (+2/-0) dash/previews/ErrorPreview.cpp (+0/-12) dash/previews/GenericPreview.cpp (+8/-14) dash/previews/GenericPreview.h (+3/-2) dash/previews/MoviePreview.cpp (+7/-13) dash/previews/MoviePreview.h (+2/-0) dash/previews/MusicPaymentPreview.cpp (+0/-12) dash/previews/MusicPreview.h (+1/-0) dash/previews/Preview.cpp (+3/-3) dash/previews/SocialPreview.cpp (+7/-13) dash/previews/SocialPreview.h (+2/-0) dash/previews/Tracks.cpp (+1/-3) dash/previews/Tracks.h (+2/-3) unity-shared/CMakeLists.txt (+1/-0) unity-shared/OverlayScrollView.cpp (+56/-0) unity-shared/OverlayScrollView.h (+43/-0) unity-shared/PlacesOverlayVScrollBar.cpp (+40/-27) unity-shared/PlacesOverlayVScrollBar.h (+4/-2) unity-shared/PlacesVScrollBar.cpp (+54/-53) unity-shared/PlacesVScrollBar.h (+6/-11) unity-shared/VScrollBarOverlayWindow.cpp (+48/-47) unity-shared/VScrollBarOverlayWindow.h (+3/-1) |
To merge this branch: | bzr merge lp:~3v1n0/unity/dash-scrollbars-scaling |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Brandon Schaefer (community) | Approve | ||
Review via email: mp+226551@code.launchpad.net |
Commit message
PlacesOverlayVS
Add a new ScrollView class to create ScrollViews with an OverlayScrollbar and with scaling support.
Using them in dash Scopes and Previews.
Description of the change
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:3914
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'dash/ScopeView.cpp' |
2 | --- dash/ScopeView.cpp 2014-07-11 22:58:11 +0000 |
3 | +++ dash/ScopeView.cpp 2014-07-11 22:58:11 +0000 |
4 | @@ -29,7 +29,7 @@ |
5 | #include "ResultRendererHorizontalTile.h" |
6 | #include "unity-shared/UBusMessages.h" |
7 | #include "unity-shared/UBusWrapper.h" |
8 | -#include "unity-shared/PlacesOverlayVScrollBar.h" |
9 | +#include "unity-shared/OverlayScrollView.h" |
10 | #include "unity-shared/GraphicsUtils.h" |
11 | |
12 | #include "config.h" |
13 | @@ -51,16 +51,14 @@ |
14 | } |
15 | |
16 | // This is so we can access some protected members in scrollview. |
17 | -class ScopeScrollView: public nux::ScrollView |
18 | +class ScopeScrollView: public dash::ScrollView |
19 | { |
20 | public: |
21 | - ScopeScrollView(nux::VScrollBar* scroll_bar, NUX_FILE_LINE_DECL) |
22 | - : nux::ScrollView(NUX_FILE_LINE_PARAM) |
23 | + ScopeScrollView(NUX_FILE_LINE_DECL) |
24 | + : ScrollView(NUX_FILE_LINE_PARAM) |
25 | , right_area_(nullptr) |
26 | , up_area_(nullptr) |
27 | { |
28 | - SetVScrollBar(scroll_bar); |
29 | - |
30 | OnVisibleChanged.connect([this] (nux::Area* /*area*/, bool visible) { |
31 | if (m_horizontal_scrollbar_enable) |
32 | _hscrollbar->SetVisible(visible); |
33 | @@ -236,8 +234,8 @@ |
34 | { |
35 | layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); |
36 | |
37 | - scroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), |
38 | - NUX_TRACKER_LOCATION); |
39 | + scroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION); |
40 | + scroll_view_->scale = scale(); |
41 | scroll_view_->EnableVerticalScrollBar(true); |
42 | scroll_view_->EnableHorizontalScrollBar(false); |
43 | layout_->AddView(scroll_view_); |
44 | @@ -252,7 +250,8 @@ |
45 | no_results_->SetScale(scale); |
46 | scroll_layout_->AddView(no_results_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); |
47 | |
48 | - fscroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), NUX_TRACKER_LOCATION); |
49 | + fscroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION); |
50 | + fscroll_view_->scale = scale(); |
51 | fscroll_view_->EnableVerticalScrollBar(true); |
52 | fscroll_view_->EnableHorizontalScrollBar(false); |
53 | fscroll_view_->SetVisible(false); |
54 | @@ -296,6 +295,8 @@ |
55 | for (auto& group : category_views_) |
56 | group->scale = scale; |
57 | |
58 | + scroll_view_->scale = scale; |
59 | + fscroll_view_->scale = scale; |
60 | filter_bar_->scale = scale; |
61 | no_results_->SetScale(scale); |
62 | } |
63 | |
64 | === modified file 'dash/ScopeView.h' |
65 | --- dash/ScopeView.h 2014-03-20 04:05:39 +0000 |
66 | +++ dash/ScopeView.h 2014-07-11 22:58:11 +0000 |
67 | @@ -36,7 +36,6 @@ |
68 | #include "PlacesGroup.h" |
69 | #include "ResultViewGrid.h" |
70 | #include "unity-shared/UBusWrapper.h" |
71 | -#include "unity-shared/PlacesVScrollBar.h" |
72 | |
73 | namespace unity |
74 | { |
75 | |
76 | === modified file 'dash/previews/ApplicationPreview.cpp' |
77 | --- dash/previews/ApplicationPreview.cpp 2014-07-11 22:58:11 +0000 |
78 | +++ dash/previews/ApplicationPreview.cpp 2014-07-11 22:58:11 +0000 |
79 | @@ -24,7 +24,6 @@ |
80 | #include "unity-shared/PreviewStyle.h" |
81 | #include "unity-shared/CoverArt.h" |
82 | #include "unity-shared/IconTexture.h" |
83 | -#include "unity-shared/PlacesOverlayVScrollBar.h" |
84 | #include <UnityCore/ApplicationPreview.h> |
85 | #include <NuxCore/Logger.h> |
86 | #include <Nux/HLayout.h> |
87 | @@ -58,17 +57,6 @@ |
88 | |
89 | DECLARE_LOGGER(logger, "unity.dash.preview.application"); |
90 | |
91 | -class DetailsScrollView : public nux::ScrollView |
92 | -{ |
93 | -public: |
94 | - DetailsScrollView(NUX_FILE_LINE_PROTO) |
95 | - : ScrollView(NUX_FILE_LINE_PARAM) |
96 | - { |
97 | - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); |
98 | - } |
99 | - |
100 | -}; |
101 | - |
102 | NUX_IMPLEMENT_OBJECT_TYPE(ApplicationPreview); |
103 | |
104 | ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model) |
105 | @@ -80,6 +68,7 @@ |
106 | , app_data_layout_(nullptr) |
107 | , app_updated_copywrite_layout_(nullptr) |
108 | , app_info_layout_(nullptr) |
109 | +, app_info_scroll_(nullptr) |
110 | , actions_layout_(nullptr) |
111 | { |
112 | SetupViews(); |
113 | @@ -172,7 +161,8 @@ |
114 | app_icon_->mouse_click.connect(on_mouse_down); |
115 | icon_layout_->AddView(app_icon_.GetPointer(), 0); |
116 | |
117 | - if (app_preview_model->rating >= 0) { |
118 | + if (app_preview_model->rating >= 0) |
119 | + { |
120 | app_rating_ = new PreviewRatingsWidget(); |
121 | AddChild(app_rating_.GetPointer()); |
122 | app_rating_->scale = scale(); |
123 | @@ -264,7 +254,9 @@ |
124 | |
125 | ///////////////////// |
126 | // Description |
127 | - nux::ScrollView* app_info = new DetailsScrollView(NUX_TRACKER_LOCATION); |
128 | + auto* app_info = new ScrollView(NUX_TRACKER_LOCATION); |
129 | + app_info_scroll_ = app_info; |
130 | + app_info->scale = scale(); |
131 | app_info->EnableHorizontalScrollBar(false); |
132 | app_info->mouse_click.connect(on_mouse_down); |
133 | |
134 | @@ -362,10 +354,15 @@ |
135 | app_icon_->ReLoadIcon(); |
136 | } |
137 | |
138 | + if (app_info_scroll_) |
139 | + app_info_scroll_->scale = scale; |
140 | + |
141 | if (license_) |
142 | license_->SetScale(scale); |
143 | + |
144 | if (last_update_) |
145 | last_update_->SetScale(scale); |
146 | + |
147 | if (copywrite_) |
148 | copywrite_->SetScale(scale); |
149 | |
150 | |
151 | === modified file 'dash/previews/ApplicationPreview.h' |
152 | --- dash/previews/ApplicationPreview.h 2014-06-16 09:16:53 +0000 |
153 | +++ dash/previews/ApplicationPreview.h 2014-07-11 22:58:11 +0000 |
154 | @@ -24,6 +24,7 @@ |
155 | #define APPLICATIONPREVIEW_H |
156 | |
157 | #include "Preview.h" |
158 | +#include "unity-shared/OverlayScrollView.h" |
159 | |
160 | namespace unity |
161 | { |
162 | @@ -64,6 +65,7 @@ |
163 | nux::VLayout* app_data_layout_; |
164 | nux::VLayout* app_updated_copywrite_layout_; |
165 | nux::VLayout* app_info_layout_; |
166 | + ScrollView* app_info_scroll_; |
167 | nux::Layout* actions_layout_; |
168 | |
169 | nux::ObjectPtr<IconTexture> app_icon_; |
170 | |
171 | === modified file 'dash/previews/ErrorPreview.cpp' |
172 | --- dash/previews/ErrorPreview.cpp 2014-06-17 11:13:42 +0000 |
173 | +++ dash/previews/ErrorPreview.cpp 2014-07-11 22:58:11 +0000 |
174 | @@ -26,7 +26,6 @@ |
175 | #include "unity-shared/PreviewStyle.h" |
176 | #include "unity-shared/CoverArt.h" |
177 | #include "unity-shared/StaticCairoText.h" |
178 | -#include "unity-shared/PlacesVScrollBar.h" |
179 | #include <NuxCore/Logger.h> |
180 | #include <Nux/VLayout.h> |
181 | #include <Nux/HLayout.h> |
182 | @@ -62,17 +61,6 @@ |
183 | const std::string ErrorPreview::CANCEL_ACTION = "cancel"; |
184 | const std::string ErrorPreview::GO_TO_U1_ACTION = "open_u1_link"; |
185 | |
186 | -class DetailsScrollView : public nux::ScrollView |
187 | -{ |
188 | -public: |
189 | - DetailsScrollView(NUX_FILE_LINE_PROTO) |
190 | - : ScrollView(NUX_FILE_LINE_PARAM) |
191 | - { |
192 | - SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION)); |
193 | - } |
194 | - |
195 | -}; |
196 | - |
197 | NUX_IMPLEMENT_OBJECT_TYPE(ErrorPreview) |
198 | |
199 | ErrorPreview::ErrorPreview(dash::Preview::Ptr preview_model) |
200 | |
201 | === modified file 'dash/previews/GenericPreview.cpp' |
202 | --- dash/previews/GenericPreview.cpp 2014-07-11 22:58:11 +0000 |
203 | +++ dash/previews/GenericPreview.cpp 2014-07-11 22:58:11 +0000 |
204 | @@ -23,7 +23,6 @@ |
205 | #include "unity-shared/IntrospectableWrappers.h" |
206 | #include "unity-shared/PreviewStyle.h" |
207 | #include "unity-shared/CoverArt.h" |
208 | -#include "unity-shared/PlacesOverlayVScrollBar.h" |
209 | #include <NuxCore/Logger.h> |
210 | #include <Nux/HLayout.h> |
211 | #include <Nux/VLayout.h> |
212 | @@ -49,23 +48,13 @@ |
213 | |
214 | DECLARE_LOGGER(logger, "unity.dash.preview.generic"); |
215 | |
216 | -class DetailsScrollView : public nux::ScrollView |
217 | -{ |
218 | -public: |
219 | - DetailsScrollView(NUX_FILE_LINE_PROTO) |
220 | - : ScrollView(NUX_FILE_LINE_PARAM) |
221 | - { |
222 | - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); |
223 | - } |
224 | - |
225 | -}; |
226 | - |
227 | NUX_IMPLEMENT_OBJECT_TYPE(GenericPreview); |
228 | |
229 | GenericPreview::GenericPreview(dash::Preview::Ptr preview_model) |
230 | : Preview(preview_model) |
231 | , image_data_layout_(nullptr) |
232 | , preview_info_layout_(nullptr) |
233 | +, preview_info_scroll_(nullptr) |
234 | , preview_data_layout_(nullptr) |
235 | , actions_layout_(nullptr) |
236 | { |
237 | @@ -85,7 +74,7 @@ |
238 | gfx_engine.PushClippingRectangle(base); |
239 | nux::GetPainter().PaintBackground(gfx_engine, base); |
240 | |
241 | - gfx_engine.PopClippingRectangle(); |
242 | + gfx_engine.PopClippingRectangle(); |
243 | } |
244 | |
245 | void GenericPreview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw) |
246 | @@ -169,7 +158,9 @@ |
247 | |
248 | ///////////////////// |
249 | // Description |
250 | - nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION); |
251 | + auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION); |
252 | + preview_info_scroll_ = preview_info; |
253 | + preview_info->scale = scale(); |
254 | preview_info->EnableHorizontalScrollBar(false); |
255 | preview_info->mouse_click.connect(on_mouse_down); |
256 | |
257 | @@ -255,6 +246,9 @@ |
258 | if (image_) |
259 | image_->scale = scale; |
260 | |
261 | + if (preview_info_scroll_) |
262 | + preview_info_scroll_->scale = scale; |
263 | + |
264 | if (preview_info_hints_) |
265 | preview_info_hints_->scale = scale; |
266 | |
267 | |
268 | === modified file 'dash/previews/GenericPreview.h' |
269 | --- dash/previews/GenericPreview.h 2014-06-16 17:10:45 +0000 |
270 | +++ dash/previews/GenericPreview.h 2014-07-11 22:58:11 +0000 |
271 | @@ -23,8 +23,9 @@ |
272 | #ifndef GENERICPREVIEW_H |
273 | #define GENERICPREVIEW_H |
274 | |
275 | +#include <UnityCore/GenericPreview.h> |
276 | #include "Preview.h" |
277 | -#include <UnityCore/GenericPreview.h> |
278 | +#include "unity-shared/OverlayScrollView.h" |
279 | |
280 | namespace unity |
281 | { |
282 | @@ -56,9 +57,9 @@ |
283 | |
284 | nux::HLayout* image_data_layout_; |
285 | nux::VLayout* preview_info_layout_; |
286 | + ScrollView* preview_info_scroll_; |
287 | nux::VLayout* preview_data_layout_; |
288 | nux::Layout* actions_layout_; |
289 | - |
290 | }; |
291 | |
292 | } |
293 | |
294 | === modified file 'dash/previews/MoviePreview.cpp' |
295 | --- dash/previews/MoviePreview.cpp 2014-07-11 22:58:11 +0000 |
296 | +++ dash/previews/MoviePreview.cpp 2014-07-11 22:58:11 +0000 |
297 | @@ -23,7 +23,6 @@ |
298 | #include "unity-shared/IntrospectableWrappers.h" |
299 | #include "unity-shared/PreviewStyle.h" |
300 | #include "unity-shared/CoverArt.h" |
301 | -#include "unity-shared/PlacesOverlayVScrollBar.h" |
302 | #include <UnityCore/MoviePreview.h> |
303 | #include <NuxCore/Logger.h> |
304 | #include <Nux/HLayout.h> |
305 | @@ -50,23 +49,13 @@ |
306 | |
307 | DECLARE_LOGGER(logger, "unity.dash.preview.movie"); |
308 | |
309 | -class DetailsScrollView : public nux::ScrollView |
310 | -{ |
311 | -public: |
312 | - DetailsScrollView(NUX_FILE_LINE_PROTO) |
313 | - : ScrollView(NUX_FILE_LINE_PARAM) |
314 | - { |
315 | - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); |
316 | - } |
317 | - |
318 | -}; |
319 | - |
320 | NUX_IMPLEMENT_OBJECT_TYPE(MoviePreview); |
321 | |
322 | MoviePreview::MoviePreview(dash::Preview::Ptr preview_model) |
323 | : Preview(preview_model) |
324 | , image_data_layout_(nullptr) |
325 | , preview_info_layout_(nullptr) |
326 | +, preview_info_scroll_(nullptr) |
327 | , actions_layout_(nullptr) |
328 | { |
329 | SetupViews(); |
330 | @@ -187,7 +176,9 @@ |
331 | |
332 | ///////////////////// |
333 | // Description |
334 | - nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION); |
335 | + auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION); |
336 | + preview_info_scroll_ = preview_info; |
337 | + preview_info->scale = scale(); |
338 | preview_info->EnableHorizontalScrollBar(false); |
339 | preview_info->mouse_click.connect(on_mouse_down); |
340 | |
341 | @@ -296,6 +287,9 @@ |
342 | rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale)); |
343 | } |
344 | |
345 | + if (preview_info_scroll_) |
346 | + preview_info_scroll_->scale = scale; |
347 | + |
348 | if (preview_info_layout_) |
349 | preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE); |
350 | |
351 | |
352 | === modified file 'dash/previews/MoviePreview.h' |
353 | --- dash/previews/MoviePreview.h 2014-06-17 16:55:33 +0000 |
354 | +++ dash/previews/MoviePreview.h 2014-07-11 22:58:11 +0000 |
355 | @@ -24,6 +24,7 @@ |
356 | #define MOVIEPREVIEW_H |
357 | |
358 | #include "Preview.h" |
359 | +#include "unity-shared/OverlayScrollView.h" |
360 | |
361 | namespace unity |
362 | { |
363 | @@ -62,6 +63,7 @@ |
364 | |
365 | nux::HLayout* image_data_layout_; |
366 | nux::VLayout* preview_info_layout_; |
367 | + ScrollView* preview_info_scroll_; |
368 | nux::Layout* actions_layout_; |
369 | }; |
370 | |
371 | |
372 | === modified file 'dash/previews/MusicPaymentPreview.cpp' |
373 | --- dash/previews/MusicPaymentPreview.cpp 2014-07-11 22:58:11 +0000 |
374 | +++ dash/previews/MusicPaymentPreview.cpp 2014-07-11 22:58:11 +0000 |
375 | @@ -24,7 +24,6 @@ |
376 | #include "unity-shared/PreviewStyle.h" |
377 | #include "unity-shared/CoverArt.h" |
378 | #include "unity-shared/StaticCairoText.h" |
379 | -#include "unity-shared/PlacesVScrollBar.h" |
380 | #include "config.h" |
381 | |
382 | #include <glib/gi18n-lib.h> |
383 | @@ -75,17 +74,6 @@ |
384 | const std::string MusicPaymentPreview::CANCEL_PURCHASE_ACTION = "cancel_purchase"; |
385 | const std::string MusicPaymentPreview::PURCHASE_ALBUM_ACTION = "purchase_album"; |
386 | |
387 | -class DetailsScrollView : public nux::ScrollView |
388 | -{ |
389 | -public: |
390 | - DetailsScrollView(NUX_FILE_LINE_PROTO) |
391 | - : ScrollView(NUX_FILE_LINE_PARAM) |
392 | - { |
393 | - SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION)); |
394 | - } |
395 | - |
396 | -}; |
397 | - |
398 | NUX_IMPLEMENT_OBJECT_TYPE(MusicPaymentPreview) |
399 | |
400 | MusicPaymentPreview::MusicPaymentPreview(dash::Preview::Ptr preview_model) |
401 | |
402 | === modified file 'dash/previews/MusicPreview.h' |
403 | --- dash/previews/MusicPreview.h 2014-07-11 22:58:11 +0000 |
404 | +++ dash/previews/MusicPreview.h 2014-07-11 22:58:11 +0000 |
405 | @@ -24,6 +24,7 @@ |
406 | #define MUSICPREVIEW_H |
407 | |
408 | #include "Preview.h" |
409 | +#include "unity-shared/OverlayScrollView.h" |
410 | #include "unity-shared/IconTexture.h" |
411 | |
412 | namespace unity |
413 | |
414 | === modified file 'dash/previews/Preview.cpp' |
415 | --- dash/previews/Preview.cpp 2014-07-11 22:58:11 +0000 |
416 | +++ dash/previews/Preview.cpp 2014-07-11 22:58:11 +0000 |
417 | @@ -313,6 +313,6 @@ |
418 | QueueDraw(); |
419 | } |
420 | |
421 | -} |
422 | -} |
423 | -} |
424 | +} // preview |
425 | +} // dash |
426 | +} // unity |
427 | |
428 | === modified file 'dash/previews/SocialPreview.cpp' |
429 | --- dash/previews/SocialPreview.cpp 2014-07-11 22:58:11 +0000 |
430 | +++ dash/previews/SocialPreview.cpp 2014-07-11 22:58:11 +0000 |
431 | @@ -24,7 +24,6 @@ |
432 | #include "unity-shared/PreviewStyle.h" |
433 | #include "unity-shared/CoverArt.h" |
434 | #include "unity-shared/IconTexture.h" |
435 | -#include "unity-shared/PlacesOverlayVScrollBar.h" |
436 | #include <UnityCore/SocialPreview.h> |
437 | #include <NuxCore/Logger.h> |
438 | #include <Nux/HLayout.h> |
439 | @@ -56,17 +55,6 @@ |
440 | const RawPixel SOCIAL_INFO_CHILDREN_SPACE = 12_em; |
441 | } |
442 | |
443 | -class DetailsScrollView : public nux::ScrollView |
444 | -{ |
445 | -public: |
446 | - DetailsScrollView(NUX_FILE_LINE_PROTO) |
447 | - : ScrollView(NUX_FILE_LINE_PARAM) |
448 | - { |
449 | - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); |
450 | - } |
451 | - |
452 | -}; |
453 | - |
454 | NUX_IMPLEMENT_OBJECT_TYPE(SocialPreview); |
455 | |
456 | SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) |
457 | @@ -77,6 +65,7 @@ |
458 | , social_content_layout_(nullptr) |
459 | , social_data_layout_(nullptr) |
460 | , social_info_layout_(nullptr) |
461 | +, social_info_scroll_(nullptr) |
462 | , icon_layout_(nullptr) |
463 | , actions_layout_(nullptr) |
464 | { |
465 | @@ -215,7 +204,9 @@ |
466 | |
467 | ///////////////////// |
468 | // Details |
469 | - nux::ScrollView* social_info = new DetailsScrollView(NUX_TRACKER_LOCATION); |
470 | + auto* social_info = new ScrollView(NUX_TRACKER_LOCATION); |
471 | + social_info_scroll_ = social_info; |
472 | + social_info->scale = scale(); |
473 | social_info->EnableHorizontalScrollBar(false); |
474 | social_info->mouse_click.connect(on_mouse_down); |
475 | |
476 | @@ -345,6 +336,9 @@ |
477 | if (social_info_layout_) |
478 | social_info_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); |
479 | |
480 | + if (social_info_scroll_) |
481 | + social_info_scroll_->scale = scale; |
482 | + |
483 | if (actions_layout_) |
484 | actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); |
485 | |
486 | |
487 | === modified file 'dash/previews/SocialPreview.h' |
488 | --- dash/previews/SocialPreview.h 2014-07-11 22:58:11 +0000 |
489 | +++ dash/previews/SocialPreview.h 2014-07-11 22:58:11 +0000 |
490 | @@ -24,6 +24,7 @@ |
491 | #define SOCIALPREVIEW_H |
492 | |
493 | #include "Preview.h" |
494 | +#include "unity-shared/OverlayScrollView.h" |
495 | |
496 | namespace unity |
497 | { |
498 | @@ -68,6 +69,7 @@ |
499 | nux::VLayout* social_content_layout_; |
500 | nux::VLayout* social_data_layout_; |
501 | nux::VLayout* social_info_layout_; |
502 | + ScrollView* social_info_scroll_; |
503 | nux::VLayout* icon_layout_; |
504 | nux::Layout* actions_layout_; |
505 | |
506 | |
507 | === modified file 'dash/previews/Tracks.cpp' |
508 | --- dash/previews/Tracks.cpp 2014-07-11 22:58:11 +0000 |
509 | +++ dash/previews/Tracks.cpp 2014-07-11 22:58:11 +0000 |
510 | @@ -24,7 +24,6 @@ |
511 | #include <NuxCore/Logger.h> |
512 | #include <Nux/VLayout.h> |
513 | #include "unity-shared/IntrospectableWrappers.h" |
514 | -#include "unity-shared/PlacesOverlayVScrollBar.h" |
515 | #include "unity-shared/PreviewStyle.h" |
516 | #include <UnityCore/Track.h> |
517 | |
518 | @@ -45,7 +44,6 @@ |
519 | |
520 | Tracks::Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_DECL) |
521 | : ScrollView(NUX_FILE_LINE_PARAM) |
522 | - , scale(1.0) |
523 | , tracks_(tracks) |
524 | { |
525 | SetupViews(); |
526 | @@ -60,6 +58,7 @@ |
527 | for (std::size_t i = 0; i < tracks_->count.Get(); ++i) |
528 | OnTrackAdded(tracks_->RowAtIndex(i)); |
529 | } |
530 | + |
531 | UpdateScale(scale); |
532 | scale.changed.connect(sigc::mem_fun(this, &Tracks::UpdateScale)); |
533 | } |
534 | @@ -77,7 +76,6 @@ |
535 | |
536 | void Tracks::SetupViews() |
537 | { |
538 | - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); |
539 | EnableHorizontalScrollBar(false); |
540 | layout_ = new nux::VLayout(); |
541 | layout_->SetPadding(0, previews::Style::Instance().GetDetailsRightMargin().CP(scale), 0, 0); |
542 | |
543 | === modified file 'dash/previews/Tracks.h' |
544 | --- dash/previews/Tracks.h 2014-07-11 22:58:11 +0000 |
545 | +++ dash/previews/Tracks.h 2014-07-11 22:58:11 +0000 |
546 | @@ -27,6 +27,7 @@ |
547 | #include <Nux/ScrollView.h> |
548 | #include <UnityCore/Tracks.h> |
549 | #include <UnityCore/ConnectionManager.h> |
550 | +#include "unity-shared/OverlayScrollView.h" |
551 | #include "unity-shared/Introspectable.h" |
552 | #include "Track.h" |
553 | |
554 | @@ -44,7 +45,7 @@ |
555 | namespace previews |
556 | { |
557 | |
558 | -class Tracks : public debug::Introspectable, public nux::ScrollView |
559 | +class Tracks : public debug::Introspectable, public dash::ScrollView |
560 | { |
561 | public: |
562 | typedef nux::ObjectPtr<Tracks> Ptr; |
563 | @@ -52,8 +53,6 @@ |
564 | |
565 | Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_PROTO); |
566 | |
567 | - nux::Property<double> scale; |
568 | - |
569 | protected: |
570 | virtual bool AcceptKeyNavFocus() { return false; } |
571 | |
572 | |
573 | === modified file 'unity-shared/CMakeLists.txt' |
574 | --- unity-shared/CMakeLists.txt 2014-03-20 16:11:21 +0000 |
575 | +++ unity-shared/CMakeLists.txt 2014-07-11 22:58:11 +0000 |
576 | @@ -44,6 +44,7 @@ |
577 | LineSeparator.cpp |
578 | MenuManager.cpp |
579 | OverlayRenderer.cpp |
580 | + OverlayScrollView.cpp |
581 | OverlayWindowButtons.cpp |
582 | PanelStyle.cpp |
583 | PlacesVScrollBar.cpp |
584 | |
585 | === added file 'unity-shared/OverlayScrollView.cpp' |
586 | --- unity-shared/OverlayScrollView.cpp 1970-01-01 00:00:00 +0000 |
587 | +++ unity-shared/OverlayScrollView.cpp 2014-07-11 22:58:11 +0000 |
588 | @@ -0,0 +1,56 @@ |
589 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
590 | +/* |
591 | + * Copyright (C) 2014 Canonical Ltd |
592 | + * |
593 | + * This program is free software: you can redistribute it and/or modify |
594 | + * it under the terms of the GNU General Public License version 3 as |
595 | + * published by the Free Software Foundation. |
596 | + * |
597 | + * This program is distributed in the hope that it will be useful, |
598 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
599 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
600 | + * GNU General Public License for more details. |
601 | + * |
602 | + * You should have received a copy of the GNU General Public License |
603 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
604 | + * |
605 | + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
606 | + */ |
607 | + |
608 | +#include "OverlayScrollView.h" |
609 | +#include "PlacesOverlayVScrollBar.h" |
610 | +#include "RawPixel.h" |
611 | + |
612 | +namespace unity |
613 | +{ |
614 | +namespace dash |
615 | +{ |
616 | +namespace |
617 | +{ |
618 | + const RawPixel MOUSE_WHEEL_SCROLL_SIZE = 32_em; |
619 | +} |
620 | + |
621 | +ScrollView::ScrollView(NUX_FILE_LINE_DECL) |
622 | + : nux::ScrollView(NUX_FILE_LINE_PARAM) |
623 | +{ |
624 | + auto* scrollbar = new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION); |
625 | + SetVScrollBar(scrollbar); |
626 | + |
627 | + scale.SetGetterFunction([scrollbar] { return scrollbar->scale(); }); |
628 | + scale.SetSetterFunction([scrollbar] (double scale) { |
629 | + if (scrollbar->scale() == scale) |
630 | + return false; |
631 | + |
632 | + scrollbar->scale = scale; |
633 | + return true; |
634 | + }); |
635 | + |
636 | + m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale); |
637 | + |
638 | + scale.changed.connect([this] (double scale) { |
639 | + m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale); |
640 | + }); |
641 | +} |
642 | + |
643 | +} // dash namespace |
644 | +} // unity namespace |
645 | \ No newline at end of file |
646 | |
647 | === added file 'unity-shared/OverlayScrollView.h' |
648 | --- unity-shared/OverlayScrollView.h 1970-01-01 00:00:00 +0000 |
649 | +++ unity-shared/OverlayScrollView.h 2014-07-11 22:58:11 +0000 |
650 | @@ -0,0 +1,43 @@ |
651 | +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
652 | +/* |
653 | + * Copyright (C) 2014 Canonical Ltd |
654 | + * |
655 | + * This program is free software: you can redistribute it and/or modify |
656 | + * it under the terms of the GNU General Public License version 3 as |
657 | + * published by the Free Software Foundation. |
658 | + * |
659 | + * This program is distributed in the hope that it will be useful, |
660 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
661 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
662 | + * GNU General Public License for more details. |
663 | + * |
664 | + * You should have received a copy of the GNU General Public License |
665 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
666 | + * |
667 | + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> |
668 | + */ |
669 | + |
670 | +#ifndef _UNITY_SCROLL_VIEW_H_ |
671 | +#define _UNITY_SCROLL_VIEW_H_ |
672 | + |
673 | +#include <Nux/Nux.h> |
674 | + |
675 | +namespace unity |
676 | +{ |
677 | +namespace dash |
678 | +{ |
679 | + |
680 | +class ScrollView : public nux::ScrollView |
681 | +{ |
682 | +public: |
683 | + ScrollView(NUX_FILE_LINE_PROTO); |
684 | + |
685 | + nux::RWProperty<double> scale; |
686 | + |
687 | + using nux::ScrollView::SetVScrollBar; |
688 | +}; |
689 | + |
690 | +} // dash namespace |
691 | +} // unity namespace |
692 | + |
693 | +#endif // _UNITY_SCROLL_VIEW_H_ |
694 | |
695 | === modified file 'unity-shared/PlacesOverlayVScrollBar.cpp' |
696 | --- unity-shared/PlacesOverlayVScrollBar.cpp 2014-03-20 03:24:26 +0000 |
697 | +++ unity-shared/PlacesOverlayVScrollBar.cpp 2014-07-11 22:58:11 +0000 |
698 | @@ -19,33 +19,46 @@ |
699 | |
700 | #include <Nux/Nux.h> |
701 | |
702 | +#include "CairoTexture.h" |
703 | #include "PlacesOverlayVScrollBar.h" |
704 | -#include "CairoTexture.h" |
705 | - |
706 | -namespace |
707 | -{ |
708 | - int const PROXIMITY = 7; |
709 | - int const SCROLL_ANIMATION = 400; |
710 | - int const MAX_CONNECTOR_ANIMATION = 200; |
711 | -} |
712 | +#include "RawPixel.h" |
713 | |
714 | namespace unity |
715 | { |
716 | namespace dash |
717 | { |
718 | +namespace |
719 | +{ |
720 | + const RawPixel PROXIMITY = 7_em; |
721 | + const int SCROLL_ANIMATION = 400; |
722 | + const int MAX_CONNECTOR_ANIMATION = 200; |
723 | + const nux::Color CONNECTOR_COLOR = nux::color::Gray; |
724 | +} |
725 | + |
726 | +class PlacesOverlayVScrollBar::ProximityArea : public nux::InputAreaProximity, public sigc::trackable |
727 | +{ |
728 | +public: |
729 | + ProximityArea(nux::InputArea* area, unsigned prox) |
730 | + : nux::InputAreaProximity(area, prox) |
731 | + , proximity([this] { return proximity_; }, [this] (unsigned px) { proximity_ = px; return false; }) |
732 | + {} |
733 | + |
734 | + nux::RWProperty<unsigned> proximity; |
735 | +}; |
736 | |
737 | PlacesOverlayVScrollBar::PlacesOverlayVScrollBar(NUX_FILE_LINE_DECL) |
738 | : PlacesVScrollBar(NUX_FILE_LINE_PARAM) |
739 | , overlay_window_(new VScrollBarOverlayWindow(_track->GetAbsoluteGeometry())) |
740 | - , area_prox_(this, PROXIMITY) |
741 | + , area_prox_(std::make_shared<ProximityArea>(this, PROXIMITY.CP(scale))) |
742 | , thumb_above_slider_(false) |
743 | , connector_height_(0) |
744 | , mouse_down_offset_(0) |
745 | , delta_update_(0) |
746 | { |
747 | - area_prox_.mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); |
748 | - area_prox_.mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); |
749 | + area_prox_->mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); |
750 | + area_prox_->mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); |
751 | |
752 | + overlay_window_->scale = scale(); |
753 | overlay_window_->mouse_enter.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseEnter)); |
754 | overlay_window_->mouse_leave.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseLeave)); |
755 | overlay_window_->mouse_down.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseDown)); |
756 | @@ -58,6 +71,11 @@ |
757 | _track->geometry_changed.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnTrackGeometryChanged)); |
758 | OnVisibleChanged.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnVisibilityChanged)); |
759 | OnSensitiveChanged.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnSensitivityChanged)); |
760 | + |
761 | + scale.changed.connect([this] (double scale) { |
762 | + area_prox_->proximity = PROXIMITY.CP(scale); |
763 | + overlay_window_->scale = scale; |
764 | + }); |
765 | } |
766 | |
767 | void PlacesOverlayVScrollBar::OnTrackGeometryChanged(nux::Area* /*area*/, nux::Geometry& /*geo*/) |
768 | @@ -410,30 +428,25 @@ |
769 | if (connector_height_ < 0) |
770 | return; |
771 | |
772 | - int width = 3; |
773 | + int width = _slider->GetWidth(); |
774 | int height = connector_height_; |
775 | - float const radius = 1.5f; |
776 | - float const aspect = 1.0f; |
777 | - |
778 | - cairo_t* cr = NULL; |
779 | - |
780 | - nux::color::RedGreenBlue const& connector_bg = nux::color::Gray; |
781 | + |
782 | + if (connector_texture_ && connector_texture_->GetWidth() == width && connector_texture_->GetHeight() == height) |
783 | + return; |
784 | |
785 | nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height); |
786 | - cr = cairoGraphics.GetInternalContext(); |
787 | - cairo_save(cr); |
788 | + cairo_t* cr = cairoGraphics.GetInternalContext(); |
789 | + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); |
790 | |
791 | cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); |
792 | cairo_paint(cr); |
793 | |
794 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
795 | - cairo_save(cr); |
796 | - |
797 | - cairo_set_source_rgba(cr, connector_bg.red, connector_bg.green, connector_bg.blue, 0.8); |
798 | - cairoGraphics.DrawRoundedRectangle(cr, aspect, 0.0f, 0.0f, radius, width, height); |
799 | - cairo_fill_preserve(cr); |
800 | - |
801 | - connector_texture_.Adopt(texture_from_cairo_graphics(cairoGraphics)); |
802 | + cairo_set_source_rgba(cr, CONNECTOR_COLOR.red, CONNECTOR_COLOR.green, CONNECTOR_COLOR.blue, 0.8); |
803 | + cairo_rectangle(cr, 0, 0, static_cast<double>(width)/scale(), static_cast<double>(height)/scale()); |
804 | + cairo_fill(cr); |
805 | + |
806 | + connector_texture_ = texture_ptr_from_cairo_graphics(cairoGraphics); |
807 | |
808 | QueueDraw(); |
809 | } |
810 | |
811 | === modified file 'unity-shared/PlacesOverlayVScrollBar.h' |
812 | --- unity-shared/PlacesOverlayVScrollBar.h 2013-11-06 11:21:43 +0000 |
813 | +++ unity-shared/PlacesOverlayVScrollBar.h 2014-07-11 22:58:11 +0000 |
814 | @@ -80,7 +80,7 @@ |
815 | |
816 | void UpdateConnectorPosition(); |
817 | void ResetConnector(); |
818 | - |
819 | + |
820 | void UpdateStepY(); |
821 | |
822 | void SetupAnimation(int start, int stop, int milliseconds); |
823 | @@ -93,7 +93,9 @@ |
824 | void UpdateConnectorTexture(); |
825 | |
826 | nux::ObjectPtr<VScrollBarOverlayWindow> overlay_window_; |
827 | - nux::InputAreaProximity area_prox_; |
828 | + |
829 | + class ProximityArea; |
830 | + std::shared_ptr<ProximityArea> area_prox_; |
831 | |
832 | nux::animation::AnimateValue<int> animation_; |
833 | connection::Wrapper tweening_connection_; |
834 | |
835 | === modified file 'unity-shared/PlacesVScrollBar.cpp' |
836 | --- unity-shared/PlacesVScrollBar.cpp 2012-11-27 23:16:06 +0000 |
837 | +++ unity-shared/PlacesVScrollBar.cpp 2014-07-11 22:58:11 +0000 |
838 | @@ -1,6 +1,6 @@ |
839 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- |
840 | /* |
841 | - * Copyright (C) 2011 Canonical Ltd |
842 | + * Copyright (C) 2011-2014 Canonical Ltd |
843 | * |
844 | * This program is free software: you can redistribute it and/or modify |
845 | * it under the terms of the GNU General Public License version 3 as |
846 | @@ -15,44 +15,53 @@ |
847 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
848 | * |
849 | * Authored by: Mirco Müller <mirco.mueller@canonical.com> |
850 | + * Marco Trevisan <marco.trevisan@canonical.com> |
851 | */ |
852 | |
853 | #include <Nux/Nux.h> |
854 | +#include <NuxGraphics/CairoGraphics.h> |
855 | |
856 | #include "unity-shared/CairoTexture.h" |
857 | +#include "unity-shared/RawPixel.h" |
858 | #include "PlacesVScrollBar.h" |
859 | |
860 | -using unity::texture_from_cairo_graphics; |
861 | - |
862 | namespace unity |
863 | { |
864 | namespace dash |
865 | { |
866 | +namespace |
867 | +{ |
868 | +const RawPixel BUTTONS_HEIGHT = 15_em; |
869 | +const RawPixel WIDTH = 3_em; |
870 | +} |
871 | |
872 | PlacesVScrollBar::PlacesVScrollBar(NUX_FILE_LINE_DECL) |
873 | - : VScrollBar(NUX_FILE_LINE_PARAM), |
874 | - _slider_texture(NULL) |
875 | -{ |
876 | - _scroll_up_button->SetMaximumHeight(15); |
877 | - _scroll_up_button->SetMinimumHeight(15); |
878 | - |
879 | - _scroll_down_button->SetMaximumHeight(15); |
880 | - _scroll_down_button->SetMinimumHeight(15); |
881 | - |
882 | - _slider->SetMinimumWidth(3); |
883 | - _slider->SetMaximumWidth(3); |
884 | - SetMinimumWidth(3); |
885 | - SetMaximumWidth(3); |
886 | -} |
887 | - |
888 | -PlacesVScrollBar::~PlacesVScrollBar() |
889 | -{ |
890 | - if (_slider_texture) |
891 | - _slider_texture->UnReference(); |
892 | -} |
893 | - |
894 | -void |
895 | -PlacesVScrollBar::PreLayoutManagement() |
896 | + : nux::VScrollBar(NUX_FILE_LINE_PARAM) |
897 | + , scale(1.0) |
898 | +{ |
899 | + UpdateSize(); |
900 | + scale.changed.connect([this] (double scale) { |
901 | + UpdateSize(); |
902 | + QueueRelayout(); |
903 | + QueueDraw(); |
904 | + }); |
905 | +} |
906 | + |
907 | +void PlacesVScrollBar::UpdateSize() |
908 | +{ |
909 | + _scroll_up_button->SetMaximumHeight(BUTTONS_HEIGHT.CP(scale)); |
910 | + _scroll_up_button->SetMinimumHeight(BUTTONS_HEIGHT.CP(scale)); |
911 | + |
912 | + _scroll_down_button->SetMaximumHeight(BUTTONS_HEIGHT.CP(scale)); |
913 | + _scroll_down_button->SetMinimumHeight(BUTTONS_HEIGHT.CP(scale)); |
914 | + |
915 | + _slider->SetMinimumWidth(WIDTH.CP(scale)); |
916 | + _slider->SetMaximumWidth(WIDTH.CP(scale)); |
917 | + SetMinimumWidth(WIDTH.CP(scale)); |
918 | + SetMaximumWidth(WIDTH.CP(scale)); |
919 | +} |
920 | + |
921 | +void PlacesVScrollBar::PreLayoutManagement() |
922 | { |
923 | nux::VScrollBar::PreLayoutManagement(); |
924 | } |
925 | @@ -69,8 +78,8 @@ |
926 | void |
927 | PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) |
928 | { |
929 | - if(!RedirectedAncestor()) |
930 | - { |
931 | + if (!RedirectedAncestor()) |
932 | + { |
933 | DrawScrollbar(graphics_engine); |
934 | } |
935 | } |
936 | @@ -78,15 +87,19 @@ |
937 | void |
938 | PlacesVScrollBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) |
939 | { |
940 | - if(RedirectedAncestor()) |
941 | - { |
942 | - DrawScrollbar(graphics_engine); |
943 | + if (RedirectedAncestor()) |
944 | + { |
945 | + DrawScrollbar(graphics_engine); |
946 | } |
947 | } |
948 | |
949 | void |
950 | PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) |
951 | { |
952 | + // check if textures have been computed... if they haven't, exit function |
953 | + if (!slider_texture_) |
954 | + return; |
955 | + |
956 | nux::Color color = nux::color::White; |
957 | nux::Geometry const& base = GetGeometry(); |
958 | nux::TexCoordXForm texxform; |
959 | @@ -95,9 +108,6 @@ |
960 | unsigned int alpha = 0, src = 0, dest = 0; |
961 | graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); |
962 | |
963 | - // check if textures have been computed... if they haven't, exit function |
964 | - if (!_slider_texture) |
965 | - return; |
966 | |
967 | texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD); |
968 | |
969 | @@ -112,7 +122,7 @@ |
970 | slider_geo.y, |
971 | slider_geo.width, |
972 | slider_geo.height, |
973 | - _slider_texture->GetDeviceTexture(), |
974 | + slider_texture_->GetDeviceTexture(), |
975 | texxform, |
976 | color); |
977 | } |
978 | @@ -123,35 +133,26 @@ |
979 | |
980 | void PlacesVScrollBar::UpdateTexture() |
981 | { |
982 | - nux::CairoGraphics* cairoGraphics = NULL; |
983 | - cairo_t* cr = NULL; |
984 | - |
985 | // update texture of slider |
986 | int width = _slider->GetBaseWidth(); |
987 | int height = _slider->GetBaseHeight(); |
988 | - cairoGraphics = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height); |
989 | - cr = cairoGraphics->GetContext(); |
990 | + |
991 | + if (slider_texture_ && slider_texture_->GetWidth() == width && slider_texture_->GetHeight() == height) |
992 | + return; |
993 | + |
994 | + nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height); |
995 | + auto* cr = cg.GetContext(); |
996 | + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); |
997 | |
998 | cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); |
999 | cairo_paint(cr); |
1000 | |
1001 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1002 | cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); |
1003 | - cairoGraphics->DrawRoundedRectangle(cr, |
1004 | - 1.0f, |
1005 | - 0.0, |
1006 | - 0.0, |
1007 | - 1.5, |
1008 | - 3.0, |
1009 | - (double) height - 3.0); |
1010 | + cg.DrawRoundedRectangle(cr, 1.0f, 0.0, 0.0, 1.5, 3.0, static_cast<double>(height)/scale() - 3.0); |
1011 | cairo_fill(cr); |
1012 | |
1013 | - if (_slider_texture) |
1014 | - _slider_texture->UnReference(); |
1015 | - _slider_texture = texture_from_cairo_graphics(*cairoGraphics); |
1016 | - |
1017 | - cairo_destroy(cr); |
1018 | - delete cairoGraphics; |
1019 | + slider_texture_ = texture_ptr_from_cairo_graphics(cg); |
1020 | } |
1021 | |
1022 | } // namespace dash |
1023 | |
1024 | === modified file 'unity-shared/PlacesVScrollBar.h' |
1025 | --- unity-shared/PlacesVScrollBar.h 2013-11-06 11:21:43 +0000 |
1026 | +++ unity-shared/PlacesVScrollBar.h 2014-07-11 22:58:11 +0000 |
1027 | @@ -20,12 +20,7 @@ |
1028 | #ifndef PLACES_VSCROLLBAR_H |
1029 | #define PLACES_VSCROLLBAR_H |
1030 | |
1031 | -#include <Nux/Nux.h> |
1032 | -#include <Nux/View.h> |
1033 | -#include <Nux/ScrollView.h> |
1034 | -#include <Nux/BaseWindow.h> |
1035 | #include <Nux/VScrollBar.h> |
1036 | -#include <NuxGraphics/CairoGraphics.h> |
1037 | |
1038 | namespace unity |
1039 | { |
1040 | @@ -36,23 +31,23 @@ |
1041 | { |
1042 | public: |
1043 | PlacesVScrollBar(NUX_FILE_LINE_PROTO); |
1044 | - virtual ~PlacesVScrollBar(); |
1045 | + |
1046 | + nux::Property<double> scale; |
1047 | |
1048 | protected: |
1049 | virtual void PreLayoutManagement(); |
1050 | virtual long PostLayoutManagement(long LayoutResult); |
1051 | |
1052 | - void Draw(nux::GraphicsEngine& gfxContext, |
1053 | - bool forceDraw); |
1054 | - void DrawContent(nux::GraphicsEngine& gfxContext, |
1055 | - bool forceDraw); |
1056 | + void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw); |
1057 | + void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw); |
1058 | |
1059 | private: |
1060 | + void UpdateSize(); |
1061 | void UpdateTexture(); |
1062 | void DrawScrollbar(nux::GraphicsEngine& graphics_engine); |
1063 | |
1064 | private: |
1065 | - nux::BaseTexture* _slider_texture; |
1066 | + nux::ObjectPtr<nux::BaseTexture> slider_texture_; |
1067 | }; |
1068 | |
1069 | } // namespace dash |
1070 | |
1071 | === modified file 'unity-shared/VScrollBarOverlayWindow.cpp' |
1072 | --- unity-shared/VScrollBarOverlayWindow.cpp 2014-02-25 03:35:17 +0000 |
1073 | +++ unity-shared/VScrollBarOverlayWindow.cpp 2014-07-11 22:58:11 +0000 |
1074 | @@ -31,15 +31,15 @@ |
1075 | |
1076 | namespace |
1077 | { |
1078 | - int const THUMB_WIDTH = 21; |
1079 | - int const THUMB_HEIGHT = 68; |
1080 | - int const THUMB_RADIUS = 3; |
1081 | - int const ANIMATION_DURATION = 90; |
1082 | + const RawPixel THUMB_WIDTH = 21_em; |
1083 | + const RawPixel THUMB_HEIGHT = 68_em; |
1084 | + const int THUMB_RADIUS = 3; |
1085 | + const int ANIMATION_DURATION = 90; |
1086 | } |
1087 | |
1088 | - |
1089 | VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo) |
1090 | : nux::BaseWindow("") |
1091 | + , scale(1.0) |
1092 | , content_size_(geo) |
1093 | , content_offset_x_(0) |
1094 | , mouse_offset_y_(0) |
1095 | @@ -47,7 +47,7 @@ |
1096 | , current_action_(ThumbAction::NONE) |
1097 | , show_animator_(ANIMATION_DURATION) |
1098 | { |
1099 | - Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH, content_size_.height); |
1100 | + Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height); |
1101 | SetBackgroundColor(nux::color::Transparent); |
1102 | |
1103 | show_animator_.updated.connect(sigc::mem_fun(this, &BaseWindow::SetOpacity)); |
1104 | @@ -58,6 +58,17 @@ |
1105 | |
1106 | SetOpacity(0.0f); |
1107 | UpdateTexture(); |
1108 | + |
1109 | + scale.changed.connect([this] (double scale) { |
1110 | + UpdateContentGeometry(); |
1111 | + UpdateTexture(); |
1112 | + }); |
1113 | +} |
1114 | + |
1115 | +void VScrollBarOverlayWindow::UpdateContentGeometry() |
1116 | +{ |
1117 | + UpdateMouseOffsetX(); |
1118 | + Area::SetGeometry(content_size_.x + content_offset_x_, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height); |
1119 | } |
1120 | |
1121 | void VScrollBarOverlayWindow::UpdateGeometry(nux::Geometry const& geo) |
1122 | @@ -67,9 +78,7 @@ |
1123 | content_size_.height != geo.height) |
1124 | { |
1125 | content_size_ = geo; |
1126 | - UpdateMouseOffsetX(); |
1127 | - |
1128 | - Area::SetGeometry(content_size_.x + content_offset_x_, content_size_.y, THUMB_WIDTH, content_size_.height); |
1129 | + UpdateContentGeometry(); |
1130 | } |
1131 | } |
1132 | |
1133 | @@ -91,8 +100,8 @@ |
1134 | { |
1135 | if (new_offset < 0) |
1136 | return 0; |
1137 | - else if (new_offset > content_size_.height - THUMB_HEIGHT) |
1138 | - return content_size_.height - THUMB_HEIGHT; |
1139 | + else if (new_offset > content_size_.height - THUMB_HEIGHT.CP(scale)) |
1140 | + return content_size_.height - THUMB_HEIGHT.CP(scale); |
1141 | |
1142 | return new_offset; |
1143 | } |
1144 | @@ -102,15 +111,15 @@ |
1145 | int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse(); |
1146 | nux::Geometry const& geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor); |
1147 | |
1148 | - if (content_size_.x + THUMB_WIDTH > geo.x + geo.width) |
1149 | - content_offset_x_ = geo.x + geo.width - (content_size_.x + THUMB_WIDTH); |
1150 | + if (content_size_.x + THUMB_WIDTH.CP(scale) > geo.x + geo.width) |
1151 | + content_offset_x_ = geo.x + geo.width - (content_size_.x + THUMB_WIDTH.CP(scale)); |
1152 | else |
1153 | content_offset_x_ = 0; |
1154 | } |
1155 | |
1156 | bool VScrollBarOverlayWindow::IsMouseInsideThumb(int y) const |
1157 | { |
1158 | - nux::Geometry const thumb(0, mouse_offset_y_, THUMB_WIDTH, THUMB_HEIGHT); |
1159 | + nux::Geometry const thumb(0, mouse_offset_y_, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); |
1160 | return thumb.IsPointInside(0,y); |
1161 | } |
1162 | |
1163 | @@ -121,7 +130,7 @@ |
1164 | |
1165 | int VScrollBarOverlayWindow::GetThumbHeight() const |
1166 | { |
1167 | - return THUMB_HEIGHT; |
1168 | + return THUMB_HEIGHT.CP(scale); |
1169 | } |
1170 | |
1171 | int VScrollBarOverlayWindow::GetThumbOffsetY() const |
1172 | @@ -133,7 +142,7 @@ |
1173 | { |
1174 | return nux::Geometry(content_size_.x + content_offset_x_, |
1175 | content_size_.y + mouse_offset_y_, |
1176 | - THUMB_WIDTH, THUMB_HEIGHT); |
1177 | + THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); |
1178 | } |
1179 | |
1180 | void VScrollBarOverlayWindow::MouseDown() |
1181 | @@ -267,7 +276,7 @@ |
1182 | if (!thumb_texture_) |
1183 | return; |
1184 | |
1185 | - nux::Geometry base(0, mouse_offset_y_, THUMB_WIDTH, THUMB_HEIGHT); |
1186 | + nux::Geometry base(0, mouse_offset_y_, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); |
1187 | nux::TexCoordXForm texxform; |
1188 | |
1189 | graphics_engine.QRP_1Tex(base.x, |
1190 | @@ -372,7 +381,7 @@ |
1191 | } |
1192 | |
1193 | |
1194 | -void DrawArrow (cairo_t* cr, nux::color::RedGreenBlue const& rgb, double x, double y, double width, double height) |
1195 | +void DrawArrow(cairo_t* cr, nux::color::RedGreenBlue const& rgb, double x, double y, double width, double height) |
1196 | { |
1197 | cairo_save (cr); |
1198 | |
1199 | @@ -417,37 +426,30 @@ |
1200 | { |
1201 | int width = THUMB_WIDTH; |
1202 | int height = THUMB_HEIGHT; |
1203 | - int radius = THUMB_RADIUS; |
1204 | |
1205 | float const aspect = 1.0f; |
1206 | float current_x = 0.0f; |
1207 | float current_y = 0.0f; |
1208 | |
1209 | - cairo_t* cr = NULL; |
1210 | - cairo_pattern_t* pat = NULL; |
1211 | - |
1212 | - nux::color::RedGreenBlue const& bg = nux::color::WhiteSmoke; |
1213 | - nux::color::RedGreenBlue const& bg_selected = nux::color::White; |
1214 | - nux::color::RedGreenBlue const& bg_active = nux::color::Gray; |
1215 | - nux::color::RedGreenBlue const& arrow_color = nux::color::DarkSlateGray; |
1216 | - |
1217 | - nux::color::RedGreenBlue const& bg_arrow_up = ProduceColorShade(bg, 0.86); |
1218 | - nux::color::RedGreenBlue const& bg_arrow_down = ProduceColorShade(bg, 1.1); |
1219 | - nux::color::RedGreenBlue const& bg_shadow = ProduceColorShade(bg, 0.2); |
1220 | - |
1221 | - nux::color::RedGreenBlue const& bg_dark_line = ProduceColorShade(bg, 0.4); |
1222 | - nux::color::RedGreenBlue const& bg_bright_line = ProduceColorShade(bg, 1.2); |
1223 | - |
1224 | - nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height); |
1225 | - cr = cairoGraphics.GetInternalContext(); |
1226 | - |
1227 | - cairo_save(cr); |
1228 | + auto const& bg = nux::color::WhiteSmoke; |
1229 | + auto const& bg_selected = nux::color::White; |
1230 | + auto const& bg_active = nux::color::Gray; |
1231 | + auto const& arrow_color = nux::color::DarkSlateGray; |
1232 | + |
1233 | + auto const& bg_arrow_up = ProduceColorShade(bg, 0.86); |
1234 | + auto const& bg_arrow_down = ProduceColorShade(bg, 1.1); |
1235 | + auto const& bg_shadow = ProduceColorShade(bg, 0.2); |
1236 | + |
1237 | + auto const& bg_dark_line = ProduceColorShade(bg, 0.4); |
1238 | + auto const& bg_bright_line = ProduceColorShade(bg, 1.2); |
1239 | + |
1240 | + nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); |
1241 | + cairo_t* cr = cairoGraphics.GetInternalContext(); |
1242 | + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); |
1243 | |
1244 | cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); |
1245 | cairo_paint(cr); |
1246 | |
1247 | - cairo_save(cr); |
1248 | - |
1249 | cairo_translate (cr, 0.5, 0.5); |
1250 | width--; |
1251 | height--; |
1252 | @@ -455,15 +457,14 @@ |
1253 | cairo_set_line_width (cr, 1.0); |
1254 | |
1255 | cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1256 | - cairo_save(cr); |
1257 | |
1258 | // Draw backgound |
1259 | SetSourceRGB(cr, bg, 1.0); |
1260 | - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius, width, height); |
1261 | + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS, width, height); |
1262 | cairo_fill_preserve(cr); |
1263 | |
1264 | // Draw shaded background |
1265 | - pat = cairo_pattern_create_linear(0, 0, 0, height); |
1266 | + cairo_pattern_t* pat = cairo_pattern_create_linear(0, 0, 0, height); |
1267 | |
1268 | PatternAddRGBStop(pat, bg_arrow_up, 0.0, 0.8); |
1269 | PatternAddRGBStop(pat, bg_arrow_down, 1.0, 0.8); |
1270 | @@ -502,7 +503,7 @@ |
1271 | |
1272 | current_x += 0.5; |
1273 | current_y += 0.5; |
1274 | - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 1, height - 1); |
1275 | + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS - 1, width - 1, height - 1); |
1276 | |
1277 | if (HasState(ThumbState::INSIDE_SLIDER)) |
1278 | SetSourceRGB(cr, bg_selected, 1.0); |
1279 | @@ -545,12 +546,12 @@ |
1280 | |
1281 | current_x += 0.5; |
1282 | current_y += 0.5; |
1283 | - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius, width- 2, height - 2); |
1284 | + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS, width- 2, height - 2); |
1285 | cairo_stroke(cr); |
1286 | |
1287 | current_x += 1.0; |
1288 | current_y += 1.0; |
1289 | - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 4, height- 4); |
1290 | + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS - 1, width - 4, height- 4); |
1291 | SetSourceRGB(cr, bg_bright_line, 0.6); |
1292 | cairo_stroke(cr); |
1293 | |
1294 | @@ -558,7 +559,7 @@ |
1295 | DrawLineSeperator(cr, bg_dark_line, bg_bright_line, width, height); |
1296 | DrawBothArrows(cr, arrow_color, width, height); |
1297 | |
1298 | - thumb_texture_.Adopt(unity::texture_from_cairo_graphics(cairoGraphics)); |
1299 | + thumb_texture_ = texture_ptr_from_cairo_graphics(cairoGraphics); |
1300 | |
1301 | QueueDraw(); |
1302 | } |
1303 | |
1304 | === modified file 'unity-shared/VScrollBarOverlayWindow.h' |
1305 | --- unity-shared/VScrollBarOverlayWindow.h 2013-11-06 11:21:43 +0000 |
1306 | +++ unity-shared/VScrollBarOverlayWindow.h 2014-07-11 22:58:11 +0000 |
1307 | @@ -32,7 +32,8 @@ |
1308 | { |
1309 | public: |
1310 | VScrollBarOverlayWindow(nux::Geometry const& geo); |
1311 | - virtual ~VScrollBarOverlayWindow() {} |
1312 | + |
1313 | + nux::Property<double> scale; |
1314 | |
1315 | void UpdateGeometry(nux::Geometry const& geo); |
1316 | void SetThumbOffsetY(int y); |
1317 | @@ -85,6 +86,7 @@ |
1318 | |
1319 | void MouseDragging(); |
1320 | void UpdateMouseOffsetX(); |
1321 | + void UpdateContentGeometry(); |
1322 | int GetValidOffsetYValue(int y) const; |
1323 | |
1324 | void ShouldShow(); |
LGTM