Merge lp:~unity-team/unity/unity-7.2.3-version-bump into lp:unity/7.2

Proposed by Christopher Townsend
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3803
Proposed branch: lp:~unity-team/unity/unity-7.2.3-version-bump
Merge into: lp:unity/7.2
Prerequisite: lp:~unity-team/unity/prepare-7.2.3-SRU
Diff against target: 11710 lines (+3401/-2380)
125 files modified
AUTHORS (+3/-0)
CMakeLists.txt (+1/-1)
ChangeLog (+120/-0)
UnityCore/GnomeSessionManager.cpp (+62/-14)
UnityCore/GnomeSessionManager.h (+2/-0)
UnityCore/GnomeSessionManagerImpl.h (+1/-0)
UnityCore/SessionManager.h (+3/-0)
dash/DashController.cpp (+2/-2)
dash/DashView.cpp (+55/-71)
dash/DashView.h (+3/-2)
dash/FilterBar.cpp (+8/-18)
dash/FilterBar.h (+0/-2)
dash/FilterBasicButton.cpp (+39/-46)
dash/FilterBasicButton.h (+6/-4)
dash/FilterExpanderLabel.cpp (+39/-41)
dash/FilterExpanderLabel.h (+2/-5)
dash/FilterGenreWidget.cpp (+33/-16)
dash/FilterGenreWidget.h (+1/-1)
dash/FilterMultiRangeButton.cpp (+22/-30)
dash/FilterMultiRangeButton.h (+3/-3)
dash/FilterMultiRangeWidget.cpp (+12/-1)
dash/FilterRatingsButton.cpp (+30/-223)
dash/FilterRatingsButton.h (+8/-21)
dash/FilterRatingsWidget.cpp (+22/-12)
dash/FilterRatingsWidget.h (+2/-1)
dash/PlacesGroup.cpp (+27/-29)
dash/ResultRendererHorizontalTile.cpp (+2/-2)
dash/ResultRendererTile.cpp (+18/-33)
dash/ScopeBar.cpp (+3/-1)
dash/ScopeBarIcon.cpp (+0/-1)
dash/ScopeView.cpp (+13/-14)
dash/StandaloneDash.cpp (+41/-27)
dash/previews/ActionButton.cpp (+43/-20)
dash/previews/ActionButton.h (+4/-0)
dash/previews/ActionLink.cpp (+13/-0)
dash/previews/ActionLink.h (+2/-2)
dash/previews/ApplicationPreview.cpp (+137/-48)
dash/previews/ApplicationPreview.h (+8/-0)
dash/previews/ErrorPreview.cpp (+53/-14)
dash/previews/ErrorPreview.h (+2/-0)
dash/previews/GenericPreview.cpp (+78/-28)
dash/previews/GenericPreview.h (+7/-0)
dash/previews/MoviePreview.cpp (+71/-21)
dash/previews/MoviePreview.h (+6/-1)
dash/previews/MusicPaymentPreview.cpp (+103/-29)
dash/previews/MusicPaymentPreview.h (+1/-0)
dash/previews/MusicPreview.cpp (+96/-37)
dash/previews/MusicPreview.h (+5/-0)
dash/previews/PaymentPreview.cpp (+59/-23)
dash/previews/PaymentPreview.h (+3/-0)
dash/previews/Preview.cpp (+39/-5)
dash/previews/Preview.h (+4/-0)
dash/previews/PreviewContainer.cpp (+62/-20)
dash/previews/PreviewContainer.h (+7/-2)
dash/previews/PreviewInfoHintWidget.cpp (+73/-77)
dash/previews/PreviewInfoHintWidget.h (+9/-8)
dash/previews/PreviewNavigator.cpp (+22/-5)
dash/previews/PreviewNavigator.h (+8/-4)
dash/previews/PreviewRatingsWidget.cpp (+31/-10)
dash/previews/PreviewRatingsWidget.h (+7/-2)
dash/previews/SocialPreview.cpp (+125/-50)
dash/previews/SocialPreview.h (+10/-0)
dash/previews/SocialPreviewComments.cpp (+16/-22)
dash/previews/SocialPreviewComments.h (+1/-5)
dash/previews/SocialPreviewContent.cpp (+33/-19)
dash/previews/SocialPreviewContent.h (+4/-1)
dash/previews/StandaloneApplicationPreview.cpp (+31/-12)
dash/previews/StandaloneErrorPreview.cpp (+18/-4)
dash/previews/StandaloneMoviePreview.cpp (+18/-3)
dash/previews/StandaloneMusicPaymentPreview.cpp (+17/-4)
dash/previews/StandaloneSocialPreview.cpp (+22/-8)
dash/previews/Track.cpp (+41/-18)
dash/previews/Track.h (+10/-3)
dash/previews/Tracks.cpp (+36/-5)
dash/previews/Tracks.h (+5/-0)
debian/changelog (+47/-1)
debian/patches/lp1349128.patch (+0/-164)
debian/patches/series (+0/-1)
hud/HudAbstractView.h (+3/-0)
hud/HudButton.cpp (+40/-28)
hud/HudButton.h (+5/-4)
hud/HudController.cpp (+15/-1)
hud/HudController.h (+4/-2)
hud/HudIcon.cpp (+1/-2)
hud/HudView.cpp (+52/-36)
hud/HudView.h (+2/-2)
hud/StandaloneHud.cpp (+28/-12)
lockscreen/LockScreenAcceleratorController.cpp (+46/-2)
lockscreen/LockScreenAcceleratorController.h (+2/-1)
lockscreen/LockScreenController.cpp (+12/-5)
lockscreen/UserPromptView.cpp (+0/-1)
plugins/unityshell/src/unityshell.cpp (+16/-12)
plugins/unityshell/src/unityshell.h (+1/-0)
resources/flow-view.svg (+0/-16)
resources/grid-view.svg (+0/-21)
resources/search_magnify.svg (+155/-0)
shutdown/SessionDBusManager.cpp (+23/-9)
shutdown/SessionView.cpp (+49/-30)
shutdown/SessionView.h (+6/-5)
shutdown/StandaloneSession.cpp (+2/-0)
tests/test_mock_session_manager.h (+2/-0)
tests/test_places_group.cpp (+34/-25)
tests/test_previews_payment.cpp (+1/-2)
tests/test_session_controller.cpp (+1/-0)
tests/test_session_view.cpp (+23/-2)
tools/unity.cmake (+14/-1)
unity-shared/CoverArt.cpp (+37/-28)
unity-shared/CoverArt.h (+7/-3)
unity-shared/DashStyle.cpp (+260/-302)
unity-shared/DashStyle.h (+88/-94)
unity-shared/DashStyleInterface.h (+13/-11)
unity-shared/IconTexture.cpp (+7/-17)
unity-shared/OverlayRenderer.cpp (+129/-89)
unity-shared/OverlayRenderer.h (+1/-0)
unity-shared/PreviewStyle.cpp (+155/-163)
unity-shared/PreviewStyle.h (+46/-45)
unity-shared/RatingsButton.cpp (+20/-20)
unity-shared/RatingsButton.h (+5/-4)
unity-shared/RawPixel.h (+1/-1)
unity-shared/SearchBar.cpp (+39/-32)
unity-shared/SearchBarSpinner.cpp (+48/-34)
unity-shared/SearchBarSpinner.h (+7/-4)
unity-shared/SpreadFilter.cpp (+2/-2)
unity-shared/TextureCache.cpp (+10/-3)
unity-shared/UnitySettings.cpp (+19/-12)
To merge this branch: bzr merge lp:~unity-team/unity/unity-7.2.3-version-bump
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+228325@code.launchpad.net

Commit message

Release Unity 7.2.3.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AUTHORS'
2--- AUTHORS 2014-07-03 15:37:26 +0000
3+++ AUTHORS 2014-08-26 13:46:04 +0000
4@@ -49,6 +49,7 @@
5 Christopher Townsend <christopher.townsend@canonical.com>
6 Chris Townsend <christopher.townsend@canonical.com>
7 Chris Townsend <Christopher.Townsend@canonical.com>
8+ Chris Townsend <christopher.townsend@canonical.com>, Andrea Azzarone <azzaronea@gmail.com>
9 CI bot <ps-jenkins@lists.canonical.com>
10 Daniel d'Andrada <daniel.dandrada@canonical.com>
11 Daniel van Vugt <vanvugt@gmail.com>
12@@ -117,6 +118,7 @@
13 Marco Trevisan (Treviño) <mail@3v1n0.net>, Andrea Cimitan <andrea.cimitan@canonical.com>
14 Marco Trevisan (Treviño) <mail@3v1n0.net>, Brandon Schaefer <brandon.schaefer@canonical.com>
15 Marco Trevisan (Treviño) <mail@3v1n0.net>, Brandon Schaefer <brandontschaefer@gmail.com>, Tim Penhey <tim.penhey@canonical.com>
16+ Marco Trevisan (Treviño) <mail@3v1n0.net>, Eleni Maria Stea <elenimaria.stea@canonical.com>
17 Marco Trevisan (Treviño) <mail@3v1n0.net>, Lukas Vacek <lucas.vacek@gmail.com>
18 Marco Trevisan (Treviño) <mail@3v1n0.net>, Michal Hruby <michal.mhr@gmail.com>
19 Marco Trevisan (Treviño) <mail@3v1n0.net>, Sam Spilsbury <sam.spilsbury@canonical.com>
20@@ -187,6 +189,7 @@
21 smspillaz <sam.spilsbury@canonical.com>, Sam Spilsbury <sam.spilsbury@canonical.com>
22 Stephen M. Webb <stephen.webb@canonical.com>
23 Stephen M. Webb <stephen.webb@canonical.com>, Andrew McCarthy <me@andrewmccarthy.ie>
24+ Stephen M. Webb <stephen.webb@canonical.com>, Pawel Szubert
25 Steve Langasek <steve.langasek@canonical.com>
26 Sven Baars <svenb.linux@gmail.com>
27 Tarmac
28
29=== modified file 'CMakeLists.txt'
30--- CMakeLists.txt 2014-07-03 15:37:26 +0000
31+++ CMakeLists.txt 2014-08-26 13:46:04 +0000
32@@ -10,7 +10,7 @@
33 set (PROJECT_NAME "unity")
34 set (UNITY_MAJOR 7)
35 set (UNITY_MINOR 2)
36-set (UNITY_MICRO 2)
37+set (UNITY_MICRO 3)
38 set (UNITY_VERSION "${UNITY_MAJOR}.${UNITY_MINOR}.${UNITY_MICRO}")
39 set (UNITY_API_VERSION "6.0")
40 set (UNITY_COMPONENTS_VERSION "6")
41
42=== modified file 'ChangeLog'
43--- ChangeLog 2014-07-03 15:37:26 +0000
44+++ ChangeLog 2014-08-26 13:46:04 +0000
45@@ -1,3 +1,123 @@
46+2014-07-24 Chris Townsend <christopher.townsend@canonical.com>
47+
48+ Added changelog entry for lp:1340477.
49+
50+2014-07-24 Marco Trevisan (Treviño) <mail@3v1n0.net>
51+
52+ Hud: scale to match current DPI settings for monitor
53+
54+2014-07-24 Chris Townsend <christopher.townsend@canonical.com>
55+
56+ Added changelog entries for lp:1283415 and lp:1340394.
57+
58+2014-07-24 Marco Trevisan (Treviño) <mail@3v1n0.net>
59+
60+ OverlayRendering: correctly scale the overlays borders and edges to match settings
61+
62+ DashStyle has been modified to return smart pointers of textures that are loaded
63+ depending on the scale level. The cache will make sure that we don't duplicate
64+ the textures and that they get removed when not needed anymore.
65+
66+ Also thanks to this the SearchBarSpinner textures (and the other spinners as well)
67+ uses the SVGs scaled at the proper size (I desgined a new SVG for the magnifier,
68+ as we only had a PNG).
69+
70+2014-07-24 Chris Townsend <christopher.townsend@canonical.com>
71+
72+ Added changelog entry for lp:1340171.
73+
74+2014-07-24 Marco Trevisan (Treviño) <mail@3v1n0.net>
75+
76+ FilterWidgets: add support for scaling.
77+
78+2014-07-24 Chris Townsend <christopher.townsend@canonical.com>
79+
80+ Added changelog entries for lp:1339629.
81+
82+2014-07-24 Marco Trevisan (Treviño) <mail@3v1n0.net>
83+
84+ Previews: scale the dash preview contents to match current monitor scaling
85+
86+ Improved also the scaling of search-bar, spinner, categories and many other components.
87+
88+2014-07-23 Chris Townsend <christopher.townsend@canonical.com>
89+
90+ Added changelog entries for lp:1324114.
91+
92+2014-07-23 Stephen M. Webb <stephen.webb@canonical.com>
93+
94+ Reduce the scope of the kill command when restarting Compiz.
95+
96+2014-07-23 Chris Townsend <christopher.townsend@canonical.com>
97+
98+ Add changelog entries for lp:1306211, lp:1320051, and lp:1320071.
99+
100+2014-07-23 Marco Trevisan (Treviño) <mail@3v1n0.net>
101+
102+ LockScreenAcceleratorController: do ther configured action on power special keys press
103+
104+ We finally can suspend, shutdown, hibernate or start the screensaver when the screen is locked, using
105+ the Suspend, Sleep, Hibernate and PowerOff hardware keys.
106+
107+ Also the Shutdown dialog doesn't allow now to lock the session if it is not allowed by settings.
108+
109+2014-07-23 Chris Townsend <christopher.townsend@canonical.com>
110+
111+ Add changelog entry for lp:1292391.
112+
113+2014-07-23 Andrea Azzarone <azzaronea@gmail.com>
114+
115+ Manually emit nux::Area::geometry_changed beucase nux can fail to emit it.
116+
117+2014-07-23 Chris Townsend <christopher.townsend@canonical.com>
118+
119+ Add changelog entry for lp:1312107.
120+
121+2014-07-23 Andrea Azzarone <andrea.azzarone@canonical.com>
122+
123+ Remove cross fade effect during lock/unlocking. A simple fading works just fine.
124+
125+2014-07-14 CI bot <ps-jenkins@lists.canonical.com>
126+
127+ Releasing 7.2.2+14.04.20140714-0ubuntu1
128+
129+2014-07-14 Chris Townsend <christopher.townsend@canonical.com>
130+
131+ Release Unity 7.2.2.
132+ Approved by: Stephen M. Webb
133+
134+2014-07-03 Chris Townsend <christopher.townsend@canonical.com>
135+
136+ Bump upstream release to 7.2.2.
137+
138+2014-07-14 Chris Townsend <christopher.townsend@canonical.com>
139+
140+ Prepare for upstream micro-release 7.2.2 that includes fixes for the following bugs:
141+ Bug #607796: Launcher, Window management - Dragging and holding a selection over an entry in the Launcher should spread out windows belonging to that application
142+ Bug #727902: Launcher icon highlighting should not switch off as soon the cursor moves after the app spread appears.
143+ Bug #741869: Unity/compiz intercepts Super and Alt keypresses from grabbed windows like VMs.
144+ Bug #754580: Cannot move tabs between multiple Firefox or Chromium windows while using Unity unless windows are both unmaximized, unminimized, and visible.
145+ Bug #839728: Launcher - dragging a item on top of a launcher tile that is a valid drop receptacle in the Launcher should cause that launcher tile to glow
146+ Bug #924840: Keyboard shortcuts overlay text too long
147+ Bug #1281058: [UIFe] The system shutdowns when multiple accounts are open
148+ Bug #1283775: Launcher: icon pips are not always updated properly
149+ Bug #1304882: [Regression] Launcher doesn't reappear fully after hiding from DND
150+ Bug #1305586: Lock screen is unusable when some windows have a keyboard/mouse grab
151+ Bug #1307738: Lockscreen caps lock icon drawn under text entry, should be a white icon.
152+ Bug #1308288: Lockscreen warning icon has no tooltip
153+ Bug #1308323: Shutdown/reboot/login/logout dialogs not scaled after toggling UI scale Edit
154+ Bug #1308911: Clipboard contents are accessible within lockscreen
155+ Bug #1309739: Unity launcher icon edge illumination is offset
156+ Bug #1310200: Indicators disappear at the panel (clementine, dropbox, skype etc)
157+ Bug #1313280: Fullscreen window set to "Always on Top" in single-monitor will hide the lockscreen
158+ Bug #1316005: Panel shadow appears over full screen applications w/ locally integrated menus enabled
159+ Bug #1317348: Switcher (Alt-Tab) does not respect monitor-defined scaling factor
160+ Bug #1317356: Shortcut hint does not respect monitor scaling factor
161+ Bug #1317869: Keyboard shortcuts overlay does not show up when workspaces are enabled at 1366x768
162+ Bug #1320438: Unity launcher auto hide fails on screen unlock using "Super+L"
163+ Bug #1321043: [regression] lock screen bypass with touchpad Fixes: 607796, 727902, 741869, 754580, 839728, 924840, 1281058, 1283775, 1304882, 1305586, 1307738, 1308288, 1308323, 1308911, 1309739, 1310200, 1313280, 1316005, 1317348, 1317356, 1317869, 1320438, 1321043
164+ Approved by: Marco Trevisan (Treviño)
165+
166 2014-07-01 Chris Townsend <christopher.townsend@canonical.com>
167
168 Add changelog entry for lp:1281058.
169
170=== modified file 'UnityCore/GnomeSessionManager.cpp'
171--- UnityCore/GnomeSessionManager.cpp 2014-07-01 15:24:59 +0000
172+++ UnityCore/GnomeSessionManager.cpp 2014-08-26 13:46:04 +0000
173@@ -91,6 +91,11 @@
174 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);
175 shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::OnShellMethodCall));
176
177+ manager_->is_locked = false;
178+ manager_->is_locked.changed.connect([this] (bool locked) {
179+ locked ? manager_->locked.emit() : manager_->unlocked.emit();
180+ });
181+
182 {
183 const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID");
184
185@@ -421,21 +426,13 @@
186 {
187 EnsureCancelPendingAction();
188
189+ if (!manager_->CanLock())
190+ {
191+ manager_->ScreenSaverActivate();
192+ return;
193+ }
194+
195 // FIXME (andy) we should ask gnome-session to emit the logind signal
196- glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
197-
198- if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()))
199- {
200- manager_->ScreenSaverActivate();
201- return;
202- }
203- else if (manager_->UserName().find("guest-") == 0)
204- {
205- LOG_INFO(logger) << "Impossible to lock a guest session";
206- manager_->ScreenSaverActivate();
207- return;
208- }
209-
210 prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit();
211 }
212
213@@ -454,6 +451,39 @@
214 });
215 }
216
217+bool GnomeManager::Impl::HasInhibitors()
218+{
219+ glib::Error error;
220+ glib::Object<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error));
221+
222+ if (error)
223+ {
224+ LOG_ERROR(logger) << "Impossible to get the session bus, to fetch the inhibitors: " << error;
225+ return false;
226+ }
227+
228+ enum class Inhibited : unsigned
229+ {
230+ LOGOUT = 1,
231+ USER_SWITCH = 2,
232+ SUSPEND = 4,
233+ IDLE_SET = 8
234+ };
235+
236+ glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager",
237+ "/org/gnome/SessionManager", "org.gnome.SessionManager",
238+ "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr,
239+ G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error));
240+
241+ if (error)
242+ {
243+ LOG_ERROR(logger) << "Impossible to get the inhibitors: " << error;
244+ return false;
245+ }
246+
247+ return inhibitors.GetBool();
248+}
249+
250 // Public implementation
251
252 GnomeManager::GnomeManager()
253@@ -617,6 +647,19 @@
254 });
255 }
256
257+bool GnomeManager::CanLock() const
258+{
259+ glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
260+
261+ if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()) ||
262+ UserName().find("guest-") == 0 || is_locked())
263+ {
264+ return false;
265+ }
266+
267+ return true;
268+}
269+
270 bool GnomeManager::CanShutdown() const
271 {
272 return impl_->can_shutdown_;
273@@ -632,6 +675,11 @@
274 return impl_->can_hibernate_;
275 }
276
277+bool GnomeManager::HasInhibitors() const
278+{
279+ return impl_->HasInhibitors();
280+}
281+
282 void GnomeManager::CancelAction()
283 {
284 impl_->CancelAction();
285
286=== modified file 'UnityCore/GnomeSessionManager.h'
287--- UnityCore/GnomeSessionManager.h 2014-04-10 04:47:58 +0000
288+++ UnityCore/GnomeSessionManager.h 2014-08-26 13:46:04 +0000
289@@ -47,9 +47,11 @@
290 void Suspend();
291 void Hibernate();
292
293+ bool CanLock() const;
294 bool CanShutdown() const;
295 bool CanSuspend() const;
296 bool CanHibernate() const;
297+ bool HasInhibitors() const;
298
299 void CancelAction();
300
301
302=== modified file 'UnityCore/GnomeSessionManagerImpl.h'
303--- UnityCore/GnomeSessionManagerImpl.h 2014-07-01 15:24:59 +0000
304+++ UnityCore/GnomeSessionManagerImpl.h 2014-08-26 13:46:04 +0000
305@@ -51,6 +51,7 @@
306 void ConfirmShutdown();
307 void CancelAction();
308 void ClosedDialog();
309+ bool HasInhibitors();
310 void EnsureCancelPendingAction();
311 void LockScreen(bool prompt);
312
313
314=== modified file 'UnityCore/SessionManager.h'
315--- UnityCore/SessionManager.h 2014-07-01 15:24:59 +0000
316+++ UnityCore/SessionManager.h 2014-08-26 13:46:04 +0000
317@@ -39,6 +39,7 @@
318 virtual ~Manager() = default;
319
320 nux::ROProperty<bool> have_other_open_sessions;
321+ nux::Property<bool> is_locked;
322
323 virtual std::string RealName() const = 0;
324 virtual std::string UserName() const = 0;
325@@ -54,9 +55,11 @@
326 virtual void Suspend() = 0;
327 virtual void Hibernate() = 0;
328
329+ virtual bool CanLock() const = 0;
330 virtual bool CanShutdown() const = 0;
331 virtual bool CanSuspend() const = 0;
332 virtual bool CanHibernate() const = 0;
333+ virtual bool HasInhibitors() const = 0;
334
335 virtual void CancelAction() = 0;
336
337
338=== modified file 'dash/DashController.cpp'
339--- dash/DashController.cpp 2014-06-23 19:42:24 +0000
340+++ dash/DashController.cpp 2014-08-26 13:46:04 +0000
341@@ -468,8 +468,8 @@
342 nux::Geometry const& view_content_geo(view_->GetContentGeometry());
343
344 nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height);
345- geo.width += style.GetDashRightTileWidth();
346- geo.height += style.GetDashBottomTileHeight();
347+ geo.width += style.GetDashRightTileWidth().CP(view_->scale());
348+ geo.height += style.GetDashBottomTileHeight().CP(view_->scale());
349 return geo;
350 }
351
352
353=== modified file 'dash/DashView.cpp'
354--- dash/DashView.cpp 2014-04-25 02:42:01 +0000
355+++ dash/DashView.cpp 2014-08-26 13:46:04 +0000
356@@ -36,7 +36,6 @@
357 #include "unity-shared/DashStyle.h"
358 #include "unity-shared/KeyboardUtil.h"
359 #include "unity-shared/PreviewStyle.h"
360-#include "unity-shared/RawPixel.h"
361 #include "unity-shared/UBusMessages.h"
362 #include "unity-shared/UnitySettings.h"
363 #include "unity-shared/WindowManager.h"
364@@ -57,6 +56,8 @@
365
366 const RawPixel DASH_RESULT_RIGHT_PAD = 35_em;
367 const RawPixel PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10_em;
368+const RawPixel PREVIEW_CONTAINER_TRIANGLE_WIDTH = 14_em;
369+const RawPixel PREVIEW_CONTAINER_TRIANGLE_HEIGHT = 12_em;
370
371 const int MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT = 1000;
372 }
373@@ -112,6 +113,7 @@
374
375 DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter)
376 : nux::View(NUX_TRACKER_LOCATION)
377+ , scale(Settings::Instance().em()->DPIScale())
378 , scopes_(scopes)
379 , application_starter_(application_starter)
380 , preview_container_(nullptr)
381@@ -129,7 +131,6 @@
382 , animate_preview_container_value_(0.0)
383 , animate_preview_value_(0.0)
384 , overlay_window_buttons_(new OverlayWindowButtons())
385- , cv_(Settings::Instance().em())
386 , monitor_(0)
387 {
388 renderer_.SetOwner(this);
389@@ -144,7 +145,6 @@
390
391 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
392 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
393- Relayout();
394
395 if (scopes_)
396 {
397@@ -159,6 +159,8 @@
398 });
399
400 unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &DashView::OnDPIChanged));
401+ scale.changed.connect(sigc::mem_fun(this, &DashView::UpdateScale));
402+ UpdateScale(scale());
403 }
404
405 DashView::~DashView()
406@@ -232,13 +234,13 @@
407
408 if (!preview_container_)
409 {
410- preview_container_ = previews::PreviewContainer::Ptr(new previews::PreviewContainer());
411+ preview_container_ = new previews::PreviewContainer();
412 preview_container_->SetRedirectRenderingToTexture(true);
413 AddChild(preview_container_.GetPointer());
414 preview_container_->SetParentObject(this);
415 }
416 preview_container_->Preview(model, previews::Navigation::NONE); // no swipe left or right
417-
418+ preview_container_->scale = scale();
419 preview_container_->SetGeometry(scopes_layout_->GetGeometry());
420 preview_displaying_ = true;
421
422@@ -265,6 +267,7 @@
423 {
424 // got a new preview whilst already displaying, we probably clicked a navigation button.
425 preview_container_->Preview(model, preview_navigation_mode_); // TODO
426+ preview_container_->scale = scale();
427 }
428
429 if (G_LIKELY(preview_state_machine_.left_results() > 0 && preview_state_machine_.right_results() > 0))
430@@ -466,10 +469,7 @@
431 if (monitor_ != monitor)
432 {
433 monitor_ = monitor;
434- cv_ = Settings::Instance().em(monitor_);
435-
436- OnDPIChanged();
437- Relayout();
438+ scale = Settings::Instance().em(monitor_)->DPIScale();
439 }
440
441 /* Give the scopes a chance to prep data before we map them */
442@@ -492,6 +492,7 @@
443
444 overlay_window_buttons_->Show();
445
446+ renderer_.scale = scale();
447 renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false);
448 renderer_.AboutToShow();
449 }
450@@ -499,7 +500,7 @@
451 void DashView::AboutToHide()
452 {
453 if (BackgroundEffectHelper::blur_type == BLUR_STATIC)
454- {
455+ {
456 content_geo_ = {0, 0, 0, 0};
457 renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false);
458 }
459@@ -547,7 +548,7 @@
460 content_layout_->AddLayout(search_bar_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
461
462 search_bar_ = new SearchBar(true);
463- search_bar_->scale = cv_->DPIScale();
464+ search_bar_->scale = scale();
465 AddChild(search_bar_);
466 search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated));
467 search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged));
468@@ -576,8 +577,11 @@
469
470 void DashView::OnDPIChanged()
471 {
472- double scale = cv_->DPIScale();
473+ scale = Settings::Instance().em(monitor_)->DPIScale();
474+}
475
476+void DashView::UpdateScale(double scale)
477+{
478 UpdateDashViewSize();
479
480 for (auto& scope : scope_views_)
481@@ -585,27 +589,23 @@
482
483 search_bar_->scale = scale;
484 scope_bar_->scale = scale;
485+ renderer_.scale = scale;
486+
487+ if (preview_container_)
488+ preview_container_->scale = scale;
489+
490+ Relayout();
491 }
492
493 void DashView::UpdateDashViewSize()
494 {
495 dash::Style const& style = dash::Style::Instance();
496
497- RawPixel const v_separator_size = style.GetVSeparatorSize();
498- RawPixel const h_separator_size = style.GetHSeparatorSize();
499- RawPixel const view_top_padding = style.GetDashViewTopPadding();
500-
501- RawPixel const search_bar_left_padding = style.GetSearchBarLeftPadding();
502- RawPixel const search_bar_height = style.GetSearchBarHeight();
503-
504- layout_->SetLeftAndRightPadding(v_separator_size.CP(cv_), 0);
505- layout_->SetTopAndBottomPadding(h_separator_size.CP(cv_), 0);
506-
507- content_layout_->SetTopAndBottomPadding(view_top_padding.CP(cv_), 0);
508-
509- search_bar_layout_->SetLeftAndRightPadding(search_bar_left_padding.CP(cv_), 0);
510- search_bar_->SetMinimumHeight(search_bar_height.CP(cv_));
511- search_bar_->SetMaximumHeight(search_bar_height.CP(cv_));
512+ layout_->SetLeftAndRightPadding(style.GetVSeparatorSize().CP(scale), 0);
513+ layout_->SetTopAndBottomPadding(style.GetHSeparatorSize().CP(scale), 0);
514+
515+ content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding().CP(scale), 0);
516+ search_bar_layout_->SetLeftAndRightPadding(style.GetSearchBarLeftPadding().CP(scale), 0);
517 }
518
519 void DashView::SetupUBusConnections()
520@@ -626,7 +626,7 @@
521 content_geo_ = GetBestFitGeometry(geo);
522 dash::Style& style = dash::Style::Instance();
523
524- RawPixel const top_padding = style.GetDashViewTopPadding();
525+ int top_padding = style.GetDashViewTopPadding().CP(scale);
526
527 // kinda hacky, but it makes sure the content isn't so big that it throws
528 // the bottom of the dash off the screen
529@@ -634,18 +634,17 @@
530 scopes_layout_->SetMaximumHeight (std::max(0, content_geo_.height -
531 search_bar_->GetGeometry().height -
532 scope_bar_->GetGeometry().height -
533- top_padding.CP(cv_)));
534+ top_padding));
535
536 scopes_layout_->SetMinimumHeight (std::max(0, content_geo_.height -
537 search_bar_->GetGeometry().height -
538 scope_bar_->GetGeometry().height -
539- top_padding.CP(cv_)));
540+ top_padding));
541
542 layout_->SetMinMaxSize(content_geo_.width, content_geo_.y + content_geo_.height);
543
544 // Minus the padding that gets added to the left
545- RawPixel const tile_width = style.GetTileWidth();
546- style.SetDefaultNColumns(floorf((content_geo_.width - cv_->CP(32)) / tile_width.CP(cv_)));
547+ style.columns_number = floorf((content_geo_.width - (32_em).CP(scale)) / style.GetTileWidth().CP(scale));
548
549 ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height));
550
551@@ -666,33 +665,24 @@
552 int panel_height = renderer_.y_offset;
553
554 int width = 0, height = 0;
555- RawPixel const tile_width = style.GetTileWidth();
556- RawPixel const tile_height = style.GetTileHeight();
557- RawPixel const group_top_space = style.GetPlacesGroupTopSpace();
558- RawPixel const category_icon_size = style.GetCategoryIconSize();
559- RawPixel const group_top_padding = style.GetPlacesGroupResultTopPadding();
560+ int tile_width = style.GetTileWidth().CP(scale);
561
562- int category_height = (group_top_space.CP(cv_) + category_icon_size.CP(cv_) +
563- group_top_padding.CP(cv_) + tile_height.CP(cv_));
564+ int category_height = (style.GetPlacesGroupTopSpace().CP(scale) +
565+ style.GetCategoryIconSize().CP(scale) +
566+ style.GetPlacesGroupResultTopPadding().CP(scale) +
567+ style.GetTileHeight().CP(scale));
568
569 int half = for_geo.width / 2;
570
571 // if default dash size is bigger than half a screens worth of items, go for that.
572- while ((width += tile_width.CP(cv_)) < half)
573- ;
574-
575- RawPixel const v_separator_size = style.GetVSeparatorSize();
576- RawPixel const group_left_padding = style.GetPlacesGroupResultLeftPadding();
577-
578- width = std::max(width, tile_width.CP(cv_) * DASH_TILE_HORIZONTAL_COUNT);
579- width += v_separator_size.CP(cv_);
580- width += group_left_padding.CP(cv_) + DASH_RESULT_RIGHT_PAD.CP(cv_);
581-
582- RawPixel const h_separator_size = style.GetHSeparatorSize();
583- RawPixel const top_padding = style.GetDashViewTopPadding();
584-
585- height = h_separator_size.CP(cv_);
586- height += top_padding.CP(cv_);
587+ while ((width += tile_width) < half);
588+
589+ width = std::max(width, tile_width * DASH_TILE_HORIZONTAL_COUNT);
590+ width += style.GetVSeparatorSize().CP(scale);
591+ width += style.GetPlacesGroupResultLeftPadding().CP(scale) + DASH_RESULT_RIGHT_PAD.CP(scale);
592+
593+ height = style.GetHSeparatorSize().CP(scale);
594+ height += style.GetDashViewTopPadding().CP(scale);
595 height += search_bar_->GetGeometry().height;
596 height += category_height * DASH_DEFAULT_CATEGORY_COUNT; // adding three categories
597 height += scope_bar_->GetGeometry().height;
598@@ -806,7 +796,7 @@
599 texxform.voffset = (scope_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
600
601 int start_y = scope_bar_->GetY();
602- int final_y = geo_layout.y + geo_layout.height + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);
603+ int final_y = geo_layout.y + geo_layout.height + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
604
605 int scope_y = (1.0f - animate_split_value_) * start_y + (animate_split_value_ * final_y);
606
607@@ -830,7 +820,7 @@
608 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
609
610 start_y = search_bar_->GetY();
611- final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);
612+ final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
613
614 graphics_engine.QRP_1Tex
615 (
616@@ -848,7 +838,7 @@
617 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
618
619 int start_x = active_scope_view_->filter_bar()->GetX();
620- int final_x = content_view_->GetX() + content_view_->GetWidth() + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);
621+ int final_x = content_view_->GetX() + content_view_->GetWidth() + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
622
623 int filter_x = (1.0f - animate_split_value_) * start_x + (animate_split_value_ * final_x);
624
625@@ -872,7 +862,7 @@
626 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
627
628 int start_y = search_bar_->GetY();
629- int final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);
630+ int final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
631
632 graphics_engine.QRP_1Tex
633 (
634@@ -906,8 +896,8 @@
635 // Triangle pointed at preview item
636 if (opening_column_x_ != -1)
637 {
638- int final_width = cv_->CP(14);
639- int final_height = cv_->CP(12);
640+ int final_width = PREVIEW_CONTAINER_TRIANGLE_WIDTH.CP(scale);
641+ int final_height = PREVIEW_CONTAINER_TRIANGLE_HEIGHT.CP(scale);
642
643 int x_center = geo_content.x + (opening_column_x_ - geo_abs.x) + opening_column_width_ / 2;
644 int start_y = geo_abs_preview.y - geo_abs.y;
645@@ -1136,11 +1126,8 @@
646 if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
647 {
648 dash::Style& style = dash::Style::Instance();
649- RawPixel const right_title_width = style.GetDashRightTileWidth();
650- RawPixel const bottom_title_width = style.GetDashBottomTileHeight();
651-
652- geo.width += right_title_width.CP(cv_);
653- geo.height += bottom_title_width.CP(cv_);
654+ geo.width += style.GetDashRightTileWidth().CP(scale);
655+ geo.height += style.GetDashBottomTileHeight().CP(scale);
656 }
657 }
658
659@@ -1282,7 +1269,7 @@
660
661 nux::ObjectPtr<ScopeView> view(new ScopeView(scope, search_bar_->show_filters()));
662 AddChild(view.GetPointer());
663- view->scale = cv_->DPIScale();
664+ view->scale = scale();
665 view->SetVisible(false);
666 view->result_activated.connect(sigc::mem_fun(this, &DashView::OnResultActivated));
667
668@@ -1500,9 +1487,6 @@
669 int num_rows = 1; // The search bar
670 std::vector<bool> button_on_monitor;
671
672- RawPixel const right_title_width = style.GetDashRightTileWidth();
673- RawPixel const bottom_title_width = style.GetDashBottomTileHeight();
674-
675 if (active_scope_view_.IsValid())
676 num_rows += active_scope_view_->GetNumRows();
677
678@@ -1521,8 +1505,8 @@
679 introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height))
680 .add("num_rows", num_rows)
681 .add("form_factor", form_factor)
682- .add("right-border-width", right_title_width.CP(cv_))
683- .add("bottom-border-height", bottom_title_width.CP(cv_))
684+ .add("right-border-width", style.GetDashRightTileWidth().CP(scale))
685+ .add("bottom-border-height", style.GetDashBottomTileHeight().CP(scale))
686 .add("preview_displaying", preview_displaying_)
687 .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_)
688 .add("dash_maximized", style.always_maximised())
689
690=== modified file 'dash/DashView.h'
691--- dash/DashView.h 2014-03-01 22:51:41 +0000
692+++ dash/DashView.h 2014-08-26 13:46:04 +0000
693@@ -37,7 +37,6 @@
694
695 #include "unity-shared/BackgroundEffectHelper.h"
696 #include "unity-shared/BGHash.h"
697-#include "unity-shared/EMConverter.h"
698 #include "unity-shared/Introspectable.h"
699 #include "unity-shared/OverlayRenderer.h"
700 #include "unity-shared/SearchBar.h"
701@@ -63,6 +62,8 @@
702 DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter);
703 ~DashView();
704
705+ nux::Property<double> scale;
706+
707 void AboutToShow(int monitor);
708 void AboutToHide();
709 void Relayout();
710@@ -131,6 +132,7 @@
711 nux::Geometry GetRenderAbsoluteGeometry() const;
712
713 void UpdateDashViewSize();
714+ void UpdateScale(double scale);
715 void OnDPIChanged();
716
717 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
718@@ -195,7 +197,6 @@
719
720 nux::ObjectPtr<OverlayWindowButtons> overlay_window_buttons_;
721
722- EMConverter::Ptr cv_;
723 int monitor_;
724
725 friend class TestDashView;
726
727=== modified file 'dash/FilterBar.cpp'
728--- dash/FilterBar.cpp 2014-03-20 04:05:39 +0000
729+++ dash/FilterBar.cpp 2014-08-26 13:46:04 +0000
730@@ -47,28 +47,20 @@
731 : View(NUX_FILE_LINE_PARAM)
732 , scale(DEFAULT_SCALE)
733 {
734- Init();
735-}
736-
737-FilterBar::~FilterBar()
738-{
739-}
740-
741-void FilterBar::Init()
742-{
743- dash::Style& style = dash::Style::Instance();
744-
745- nux::LinearLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
746- layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding());
747- layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding());
748+ SetLayout(new nux::VLayout(NUX_TRACKER_LOCATION));
749 scale.changed.connect(sigc::mem_fun(this, &FilterBar::UpdateScale));
750- SetLayout(layout);
751+ UpdateScale(scale);
752 }
753
754 void FilterBar::UpdateScale(double scale)
755 {
756 for (auto& filters : filter_map_)
757 filters.second->scale = scale;
758+
759+ auto& style = dash::Style::Instance();
760+ auto* layout = static_cast<nux::VLayout*>(GetLayout());
761+ layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding().CP(scale) - style.GetFilterHighlightPadding().CP(scale));
762+ layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale));
763 }
764
765 void FilterBar::SetFilters(Filters::Ptr const& filters)
766@@ -118,9 +110,7 @@
767 }
768
769 void FilterBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
770-{
771-
772-}
773+{}
774
775 void FilterBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
776 {
777
778=== modified file 'dash/FilterBar.h'
779--- dash/FilterBar.h 2014-03-20 04:05:39 +0000
780+++ dash/FilterBar.h 2014-08-26 13:46:04 +0000
781@@ -42,7 +42,6 @@
782 NUX_DECLARE_OBJECT_TYPE(FilterBar, nux::View);
783 public:
784 FilterBar(NUX_FILE_LINE_PROTO);
785- ~FilterBar();
786
787 nux::Property<double> scale;
788
789@@ -62,7 +61,6 @@
790 virtual void AddProperties(debug::IntrospectionData&);
791
792 private:
793- void Init();
794 void UpdateScale(double scale);
795
796 FilterFactory factory_;
797
798=== modified file 'dash/FilterBasicButton.cpp'
799--- dash/FilterBasicButton.cpp 2013-11-14 03:00:29 +0000
800+++ dash/FilterBasicButton.cpp 2014-08-26 13:46:04 +0000
801@@ -22,53 +22,36 @@
802 #include "unity-shared/DashStyle.h"
803 #include "FilterBasicButton.h"
804
805-namespace
806-{
807-const int kMinButtonHeight = 30;
808-const int kMinButtonWidth = 48;
809-const int kFontSizePx = 15; // 15px == 11pt
810-}
811-
812 namespace unity
813 {
814 namespace dash
815 {
816-
817+namespace
818+{
819+const RawPixel BUTTON_HEIGHT = 30_em;
820+const RawPixel MIN_BUTTON_WIDTH = 48_em;
821+const int FONT_SIZE_PX = 15; // 15px == 11pt
822+}
823+
824 NUX_IMPLEMENT_OBJECT_TYPE(FilterBasicButton);
825
826 FilterBasicButton::FilterBasicButton(nux::TextureArea* image, NUX_FILE_LINE_DECL)
827- : nux::ToggleButton(image, NUX_FILE_LINE_PARAM)
828-{
829- Init();
830-}
831+ : FilterBasicButton(std::string(), image, NUX_FILE_LINE_PARAM)
832+{}
833+
834+FilterBasicButton::FilterBasicButton(NUX_FILE_LINE_DECL)
835+ : FilterBasicButton(std::string(), NUX_FILE_LINE_PARAM)
836+{}
837
838 FilterBasicButton::FilterBasicButton(std::string const& label, NUX_FILE_LINE_DECL)
839- : nux::ToggleButton(NUX_FILE_LINE_PARAM)
840- , label_(label)
841-{
842- Init();
843-}
844+ : FilterBasicButton(label, nullptr, NUX_FILE_LINE_PARAM)
845+{}
846
847 FilterBasicButton::FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_DECL)
848 : nux::ToggleButton(image, NUX_FILE_LINE_PARAM)
849+ , scale(1.0)
850 , label_(label)
851 {
852- Init();
853-}
854-
855-FilterBasicButton::FilterBasicButton(NUX_FILE_LINE_DECL)
856- : nux::ToggleButton(NUX_FILE_LINE_PARAM)
857-{
858- Init();
859-}
860-
861-FilterBasicButton::~FilterBasicButton()
862-{
863-}
864-
865-void FilterBasicButton::Init()
866-{
867-
868 InitTheme();
869 SetAcceptKeyNavFocusOnMouseDown(false);
870 SetAcceptKeyNavFocusOnMouseEnter(true);
871@@ -85,34 +68,44 @@
872 if (GetInputEventSensitivity())
873 Active() ? Deactivate() : Activate();
874 });
875+
876+ scale.changed.connect(sigc::mem_fun(this, &FilterBasicButton::UpdateScale));
877 }
878
879 void FilterBasicButton::InitTheme()
880 {
881- if (!active_)
882- {
883- nux::Geometry const& geo = GetGeometry();
884-
885- prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
886- active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
887- normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
888- focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay)));
889- }
890-
891- SetMinimumHeight(kMinButtonHeight);
892- SetMinimumWidth(kMinButtonWidth);
893+ nux::Geometry const& geo = GetGeometry();
894+
895+ prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
896+ active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
897+ normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
898+ focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay)));
899+
900+ SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale));
901+ ApplyMinWidth();
902+
903+ SetMinimumHeight(BUTTON_HEIGHT.CP(scale));
904+ SetMaximumHeight(BUTTON_HEIGHT.CP(scale));
905 }
906
907 void FilterBasicButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)
908 {
909- Style::Instance().Button(cr, faked_state, label_, kFontSizePx, Alignment::CENTER, true);
910+ cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
911+ Style::Instance().Button(cr, faked_state, label_, FONT_SIZE_PX, Alignment::CENTER, true);
912 }
913
914 void FilterBasicButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr)
915 {
916+ cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
917 Style::Instance().ButtonFocusOverlay(cr);
918 }
919
920+void FilterBasicButton::UpdateScale(double scale)
921+{
922+ InitTheme();
923+ QueueDraw();
924+}
925+
926 long FilterBasicButton::ComputeContentSize()
927 {
928 long ret = nux::Button::ComputeContentSize();
929
930=== modified file 'dash/FilterBasicButton.h'
931--- dash/FilterBasicButton.h 2012-12-13 09:19:34 +0000
932+++ dash/FilterBasicButton.h 2014-08-26 13:46:04 +0000
933@@ -39,15 +39,15 @@
934 FilterBasicButton(std::string const& label, NUX_FILE_LINE_PROTO);
935 FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_PROTO);
936 FilterBasicButton(NUX_FILE_LINE_PROTO);
937- virtual ~FilterBasicButton();
938-
939- void SetClearBeforeDraw(bool clear_before_draw);
940+
941+ nux::Property<double> scale;
942+
943 protected:
944 virtual long ComputeContentSize();
945 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
946
947- void Init();
948 void InitTheme();
949+ void SetClearBeforeDraw(bool clear_before_draw);
950 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
951 void RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr);
952
953@@ -61,6 +61,8 @@
954 nux::Geometry cached_geometry_;
955
956 private:
957+ void UpdateScale(double);
958+
959 std::string label_;
960 bool clear_before_draw_;
961 };
962
963=== modified file 'dash/FilterExpanderLabel.cpp'
964--- dash/FilterExpanderLabel.cpp 2014-03-20 04:05:39 +0000
965+++ dash/FilterExpanderLabel.cpp 2014-08-26 13:46:04 +0000
966@@ -22,16 +22,20 @@
967
968 #include "unity-shared/DashStyle.h"
969 #include "unity-shared/GraphicsUtils.h"
970-#include "unity-shared/RawPixel.h"
971 #include "FilterExpanderLabel.h"
972
973+namespace unity
974+{
975+namespace dash
976+{
977 namespace
978 {
979-
980+const double DEFAULT_SCALE = 1.0;
981 const float EXPAND_DEFAULT_ICON_OPACITY = 1.0f;
982-
983-// expander_layout_
984-const int EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8;
985+const RawPixel EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8_em;
986+const RawPixel ARROW_HORIZONTAL_PADDING = 2_em;
987+const RawPixel ARROW_TOP_PADDING = 11_em;
988+const RawPixel ARROW_BOTTOM_PADDING = 9_em;
989
990 // font
991 const char* const FONT_EXPANDER_LABEL = "Ubuntu 13"; // 17px = 13
992@@ -72,16 +76,6 @@
993
994 }
995
996-namespace unity
997-{
998-namespace dash
999-{
1000-
1001-namespace
1002-{
1003- double const DEFAULT_SCALE = 1.0;
1004-}
1005-
1006 NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);
1007
1008 FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL)
1009@@ -94,8 +88,6 @@
1010 , expander_layout_(nullptr)
1011 , right_hand_contents_(nullptr)
1012 , cairo_label_(nullptr)
1013- , raw_label_(label)
1014- , label_("label")
1015 {
1016 scale.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::UpdateScale));
1017 expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
1018@@ -104,14 +96,13 @@
1019
1020 void FilterExpanderLabel::SetLabel(std::string const& label)
1021 {
1022- raw_label_ = label;
1023-
1024- cairo_label_->SetText(label.c_str());
1025+ cairo_label_->SetText(label);
1026 }
1027
1028 void FilterExpanderLabel::UpdateScale(double scale)
1029 {
1030 cairo_label_->SetScale(scale);
1031+ UpdateLayoutSizes();
1032 }
1033
1034 void FilterExpanderLabel::SetRightHandView(nux::View* view)
1035@@ -143,40 +134,27 @@
1036
1037 void FilterExpanderLabel::BuildLayout()
1038 {
1039- dash::Style& style = dash::Style::Instance();
1040-
1041 layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
1042- layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding(), style.GetFilterBarRightPadding());
1043-
1044 top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
1045- top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding());
1046-
1047 expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
1048- expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN);
1049
1050 expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
1051 expander_view_->SetLayout(expander_layout_);
1052 top_bar_layout_->AddView(expander_view_, 1);
1053
1054- cairo_label_ = new StaticCairoText(label_.c_str(), NUX_TRACKER_LOCATION);
1055+ cairo_label_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
1056 cairo_label_->SetFont(FONT_EXPANDER_LABEL);
1057+ cairo_label_->SetScale(scale);
1058 cairo_label_->SetTextColor(nux::color::White);
1059 cairo_label_->SetAcceptKeyboardEvent(false);
1060
1061- nux::BaseTexture* arrow;
1062- arrow = dash::Style::Instance().GetGroupUnexpandIcon();
1063- expand_icon_ = new IconTexture(arrow,
1064- arrow->GetWidth(),
1065- arrow->GetHeight());
1066+ expand_icon_ = new IconTexture(Style::Instance().GetGroupUnexpandIcon());
1067 expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY);
1068- expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());
1069+ expand_icon_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
1070 expand_icon_->SetVisible(true);
1071+
1072 arrow_layout_ = new nux::VLayout();
1073- arrow_top_space_ = new nux::SpaceLayout(2, 2, 11, 11);
1074- arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 9, 9);
1075- arrow_layout_->AddView(arrow_top_space_, 0, nux::MINOR_POSITION_CENTER);
1076 arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER);
1077- arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER);
1078
1079 expander_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1080 expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);
1081@@ -209,8 +187,25 @@
1082 cairo_label_->mouse_click.connect(mouse_expand);
1083 expand_icon_->mouse_click.connect(mouse_expand);
1084
1085+ UpdateLayoutSizes();
1086+}
1087+
1088+void FilterExpanderLabel::UpdateLayoutSizes()
1089+{
1090+ auto& style = dash::Style::Instance();
1091+
1092+ layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding().CP(scale), style.GetFilterBarRightPadding().CP(scale));
1093+ top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding().CP(scale));
1094+ expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN.CP(scale));
1095+
1096+ auto const& tex = expand_icon_->texture();
1097+ expand_icon_->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale));
1098+
1099+ arrow_layout_->SetLeftAndRightPadding(ARROW_HORIZONTAL_PADDING.CP(scale));
1100+ arrow_layout_->SetTopAndBottomPadding(ARROW_TOP_PADDING.CP(scale), ARROW_BOTTOM_PADDING.CP(scale));
1101+
1102 QueueRelayout();
1103- NeedRedraw();
1104+ QueueDraw();
1105 }
1106
1107 void FilterExpanderLabel::DoExpandChange(bool change)
1108@@ -221,6 +216,9 @@
1109 else
1110 expand_icon_->SetTexture(style.GetGroupExpandIcon());
1111
1112+ auto const& tex = expand_icon_->texture();
1113+ expand_icon_->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale));
1114+
1115 if (change and contents_ and !contents_->IsChildOf(layout_))
1116 {
1117 layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition(1));
1118@@ -278,7 +276,7 @@
1119 graphics::ClearGeometry(right_hand_contents_->GetGeometry());
1120
1121 if (expanded())
1122- ClearRedirectedRenderChildArea();
1123+ ClearRedirectedRenderChildArea();
1124 }
1125
1126 if (focus_layer_ && ShouldBeHighlighted())
1127@@ -296,7 +294,7 @@
1128
1129 if (IsFullRedraw())
1130 {
1131- nux::GetPainter().PopPaintLayerStack();
1132+ nux::GetPainter().PopPaintLayerStack();
1133 }
1134 else if (pushed_paint_layers > 0)
1135 {
1136
1137=== modified file 'dash/FilterExpanderLabel.h'
1138--- dash/FilterExpanderLabel.h 2014-03-20 04:05:39 +0000
1139+++ dash/FilterExpanderLabel.h 2014-08-26 13:46:04 +0000
1140@@ -80,21 +80,18 @@
1141
1142 private:
1143 void BuildLayout();
1144+ void UpdateLayoutSizes();
1145 void DoExpandChange(bool change);
1146 bool ShouldBeHighlighted();
1147 void UpdateScale(double scale);
1148
1149- nux::LinearLayout* layout_;
1150+ nux::VLayout* layout_;
1151 nux::LinearLayout* top_bar_layout_;
1152 nux::View* expander_view_;
1153 nux::LinearLayout* expander_layout_;
1154 nux::View* right_hand_contents_;
1155 StaticCairoText* cairo_label_;
1156- std::string raw_label_;
1157- std::string label_;
1158 nux::VLayout* arrow_layout_;
1159- nux::SpaceLayout* arrow_top_space_;
1160- nux::SpaceLayout* arrow_bottom_space_;
1161 IconTexture* expand_icon_;
1162
1163 nux::ObjectPtr<nux::Layout> contents_;
1164
1165=== modified file 'dash/FilterGenreWidget.cpp'
1166--- dash/FilterGenreWidget.cpp 2013-04-18 12:13:21 +0000
1167+++ dash/FilterGenreWidget.cpp 2014-08-26 13:46:04 +0000
1168@@ -35,6 +35,11 @@
1169 {
1170 namespace dash
1171 {
1172+namespace
1173+{
1174+const RawPixel CHILDREN_SPACE = 12_em;
1175+const RawPixel CHILDREN_SPACE_SMALLER = 10_em;
1176+}
1177
1178 NUX_IMPLEMENT_OBJECT_TYPE(FilterGenre);
1179
1180@@ -42,33 +47,41 @@
1181 : FilterExpanderLabel(_("Categories"), NUX_FILE_LINE_PARAM)
1182 , all_button_(nullptr)
1183 {
1184- dash::Style& style = dash::Style::Instance();
1185-
1186 InitTheme();
1187
1188-
1189 genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);
1190 genre_layout_->ForceChildrenSize(true);
1191 genre_layout_->MatchContentSize(true);
1192- genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding(), style.GetFilterHighlightPadding());
1193 genre_layout_->EnablePartialVisibility(false);
1194
1195+ UpdateSize(columns);
1196+ SetContents(genre_layout_);
1197+
1198+ scale.changed.connect([this, columns] (double scale) {
1199+ if (all_button_) all_button_->scale = scale;
1200+
1201+ for (auto* button : buttons_)
1202+ button->scale = scale;
1203+
1204+ UpdateSize(columns);
1205+ });
1206+}
1207+
1208+void FilterGenre::UpdateSize(int columns)
1209+{
1210+ auto& style = dash::Style::Instance();
1211+ genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale), style.GetFilterHighlightPadding().CP(scale));
1212+
1213 if (columns == 3)
1214 {
1215- genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 12 * 2) / 3, style.GetFilterButtonHeight());
1216- genre_layout_->SetSpaceBetweenChildren (12, 12);
1217+ genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE.CP(scale) * 2) / 3, style.GetFilterButtonHeight().CP(scale));
1218+ genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale), CHILDREN_SPACE.CP(scale));
1219 }
1220 else
1221 {
1222- genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 10 ) / 2, style.GetFilterButtonHeight());
1223- genre_layout_->SetSpaceBetweenChildren (10, 12);
1224+ genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE_SMALLER.CP(scale)) / 2, style.GetFilterButtonHeight().CP(scale));
1225+ genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE_SMALLER.CP(scale), CHILDREN_SPACE.CP(scale));
1226 }
1227-
1228- SetContents(genre_layout_);
1229-}
1230-
1231-FilterGenre::~FilterGenre()
1232-{
1233 }
1234
1235 void FilterGenre::SetFilter(Filter::Ptr const& filter)
1236@@ -81,11 +94,14 @@
1237 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
1238 SetRightHandView(all_button_);
1239 if (all_button_)
1240+ {
1241+ all_button_->scale = scale();
1242 all_button_->SetFilter(filter_);
1243+ }
1244 };
1245 show_button_func(filter_->show_all_button);
1246 filter_->show_all_button.changed.connect(show_button_func);
1247-
1248+
1249 expanded = !filter_->collapsed();
1250
1251 filter_->option_added.connect(sigc::mem_fun(this, &FilterGenre::OnOptionAdded));
1252@@ -106,6 +122,7 @@
1253 std::string label(escape.Value());
1254
1255 FilterGenreButton* button = new FilterGenreButton(label, NUX_TRACKER_LOCATION);
1256+ button->scale = scale();
1257 button->SetFilter(new_filter);
1258 genre_layout_->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
1259 buttons_.push_back(button);
1260@@ -121,7 +138,7 @@
1261 {
1262 genre_layout_->RemoveChildObject(*it);
1263 buttons_.erase(it);
1264-
1265+
1266 QueueRelayout();
1267 break;
1268 }
1269
1270=== modified file 'dash/FilterGenreWidget.h'
1271--- dash/FilterGenreWidget.h 2012-11-27 23:16:06 +0000
1272+++ dash/FilterGenreWidget.h 2014-08-26 13:46:04 +0000
1273@@ -46,7 +46,6 @@
1274 NUX_DECLARE_OBJECT_TYPE(FilterGenre, FilterExpanderLabel);
1275 public:
1276 FilterGenre(int columns, NUX_FILE_LINE_PROTO);
1277- virtual ~FilterGenre();
1278
1279 void SetFilter(Filter::Ptr const& filter);
1280 std::string GetFilterType();
1281@@ -59,6 +58,7 @@
1282 private:
1283 void OnOptionAdded(FilterOption::Ptr const& new_filter);
1284 void OnOptionRemoved(FilterOption::Ptr const& removed_filter);
1285+ void UpdateSize(int columns);
1286
1287 nux::GridHLayout* genre_layout_;
1288 FilterAllButton* all_button_;
1289
1290=== modified file 'dash/FilterMultiRangeButton.cpp'
1291--- dash/FilterMultiRangeButton.cpp 2013-11-14 03:00:29 +0000
1292+++ dash/FilterMultiRangeButton.cpp 2014-08-26 13:46:04 +0000
1293@@ -33,29 +33,18 @@
1294
1295 namespace
1296 {
1297-const int kFontSizePx = 10;
1298-
1299-const int kLayoutPadLeftRight = 4;
1300-const int kLayoutPadtopBottom = 2;
1301+const int FONT_SIZE_PX = 10;
1302 }
1303
1304 NUX_IMPLEMENT_OBJECT_TYPE(FilterMultiRangeButton);
1305
1306 FilterMultiRangeButton::FilterMultiRangeButton(NUX_FILE_LINE_DECL)
1307 : nux::ToggleButton(NUX_FILE_LINE_PARAM)
1308+ , scale(1.0)
1309 , theme_init_(false)
1310 , has_arrow_(MultiRangeArrow::NONE)
1311 , side_(MultiRangeSide::CENTER)
1312 {
1313- Init();
1314-}
1315-
1316-FilterMultiRangeButton::~FilterMultiRangeButton()
1317-{
1318-}
1319-
1320-void FilterMultiRangeButton::Init()
1321-{
1322 InitTheme();
1323 // Controlled by parent widget
1324 SetAcceptKeyNavFocusOnMouseDown(false);
1325@@ -64,6 +53,8 @@
1326 state_change.connect(sigc::mem_fun(this, &FilterMultiRangeButton::OnActivated));
1327 key_nav_focus_change.connect([this](nux::Area*, bool, nux::KeyNavDirection) { QueueDraw(); });
1328 key_nav_focus_activate.connect([this](nux::Area* area) { Active() ? Deactivate() : Activate(); });
1329+
1330+ scale.changed.connect(sigc::hide(sigc::mem_fun(this, &FilterMultiRangeButton::InitTheme)));
1331 }
1332
1333 void FilterMultiRangeButton::OnActivated(nux::Area* area)
1334@@ -133,27 +124,26 @@
1335
1336 void FilterMultiRangeButton::InitTheme()
1337 {
1338- if (!active_[MapKey(MultiRangeArrow::LEFT, MultiRangeSide::LEFT)])
1339+ nux::Geometry const& geo = GetGeometry();
1340+
1341+ std::vector<MultiRangeSide> sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER};
1342+ std::vector<MultiRangeArrow> arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE};
1343+
1344+ for (auto arrow : arrows)
1345 {
1346- nux::Geometry const& geo = GetGeometry();
1347-
1348- std::vector<MultiRangeSide> sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER};
1349- std::vector<MultiRangeArrow> arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE};
1350-
1351- for (auto arrow : arrows)
1352+ for (auto side : sides)
1353 {
1354- for (auto side : sides)
1355- {
1356- active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side)));
1357- normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side)));
1358- prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side)));
1359- focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side)));
1360- }
1361+ active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side)));
1362+ normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side)));
1363+ prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side)));
1364+ focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side)));
1365 }
1366 }
1367
1368- SetMinimumHeight(dash::Style::Instance().GetFilterButtonHeight() + 3);
1369+ SetMinimumHeight(Style::Instance().GetFilterButtonHeight().CP(scale) + (3_em).CP(scale));
1370 theme_init_ = true;
1371+
1372+ QueueDraw();
1373 }
1374
1375 void FilterMultiRangeButton::RedrawTheme(nux::Geometry const& geom,
1376@@ -187,8 +177,9 @@
1377 else
1378 segment = Segment::RIGHT;
1379
1380- Style::Instance().MultiRangeSegment(cr, faked_state, name, kFontSizePx, arrow, segment);
1381- NeedRedraw();
1382+ cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
1383+ Style::Instance().MultiRangeSegment(cr, faked_state, name, FONT_SIZE_PX, arrow, segment);
1384+ QueueDraw();
1385 }
1386
1387 void FilterMultiRangeButton::RedrawFocusOverlay(nux::Geometry const& geom,
1388@@ -214,6 +205,7 @@
1389 else
1390 segment = Segment::RIGHT;
1391
1392+ cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
1393 Style::Instance().MultiRangeFocusOverlay(cr, arrow, segment);
1394 QueueDraw();
1395 }
1396
1397=== modified file 'dash/FilterMultiRangeButton.h'
1398--- dash/FilterMultiRangeButton.h 2013-11-08 15:05:51 +0000
1399+++ dash/FilterMultiRangeButton.h 2014-08-26 13:46:04 +0000
1400@@ -54,8 +54,9 @@
1401 {
1402 NUX_DECLARE_OBJECT_TYPE(FilterMultiRangeButton, nux::ToggleButton);
1403 public:
1404- FilterMultiRangeButton (NUX_FILE_LINE_PROTO);
1405- virtual ~FilterMultiRangeButton();
1406+ FilterMultiRangeButton(NUX_FILE_LINE_PROTO);
1407+
1408+ nux::Property<double> scale;
1409
1410 void SetFilter(FilterOption::Ptr const& filter);
1411 FilterOption::Ptr GetFilter();
1412@@ -69,7 +70,6 @@
1413
1414 private:
1415 void InitTheme();
1416- void Init();
1417
1418 void RedrawTheme(nux::Geometry const& geom,
1419 cairo_t* cr,
1420
1421=== modified file 'dash/FilterMultiRangeWidget.cpp'
1422--- dash/FilterMultiRangeWidget.cpp 2013-04-17 15:10:39 +0000
1423+++ dash/FilterMultiRangeWidget.cpp 2014-08-26 13:46:04 +0000
1424@@ -64,6 +64,13 @@
1425 mouse_up.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseUp));
1426
1427 mouse_drag.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseDrag));
1428+
1429+ scale.changed.connect([this] (double scale) {
1430+ if (all_button_) all_button_->scale = scale;
1431+
1432+ for (auto const& button : buttons_)
1433+ button->scale = scale;
1434+ });
1435 }
1436
1437 void FilterMultiRangeWidget::SetFilter(Filter::Ptr const& filter)
1438@@ -83,11 +90,14 @@
1439 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
1440 SetRightHandView(all_button_);
1441 if (all_button_)
1442+ {
1443+ all_button_->scale = scale();
1444 all_button_->SetFilter(filter_);
1445+ }
1446 };
1447 show_button_func(filter_->show_all_button);
1448 filter_->show_all_button.changed.connect(show_button_func);
1449-
1450+
1451 expanded = !filter_->collapsed();
1452
1453 filter_->option_added.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::OnOptionAdded));
1454@@ -151,6 +161,7 @@
1455 void FilterMultiRangeWidget::OnOptionAdded(FilterOption::Ptr const& new_filter)
1456 {
1457 FilterMultiRangeButtonPtr button(new FilterMultiRangeButton(NUX_TRACKER_LOCATION));
1458+ button->scale = scale();
1459 button->SetFilter(new_filter);
1460 layout_->AddView(button.GetPointer());
1461 buttons_.push_back(button);
1462
1463=== modified file 'dash/FilterRatingsButton.cpp'
1464--- dash/FilterRatingsButton.cpp 2013-11-14 03:00:29 +0000
1465+++ dash/FilterRatingsButton.cpp 2014-08-26 13:46:04 +0000
1466@@ -1,5 +1,5 @@
1467 /*
1468- * Copyright 2011 Canonical Ltd.
1469+ * Copyright 2014 Canonical Ltd.
1470 *
1471 * This program is free software: you can redistribute it and/or modify it
1472 * under the terms of the GNU Lesser General Public License version 3, as
1473@@ -15,66 +15,39 @@
1474 * License version 3 along with this program. If not, see
1475 * <http://www.gnu.org/licenses/>
1476 *
1477- * Authored by: Gordon Allott <gord.allott@canonical.com>
1478+ * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
1479 *
1480 */
1481
1482-#include <math.h>
1483-
1484-#include <Nux/Nux.h>
1485-#include <NuxCore/Logger.h>
1486-
1487-#include "unity-shared/DashStyle.h"
1488 #include "FilterRatingsButton.h"
1489
1490 namespace
1491 {
1492-const int star_size = 28;
1493-const int star_gap = 10;
1494-const int num_stars = 5;
1495+const int STAR_SIZE = 28;
1496+const int STAR_GAP = 10;
1497 }
1498
1499 namespace unity
1500 {
1501 namespace dash
1502 {
1503-
1504+
1505 NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsButton);
1506
1507 FilterRatingsButton::FilterRatingsButton(NUX_FILE_LINE_DECL)
1508- : nux::ToggleButton(NUX_FILE_LINE_PARAM)
1509- , focused_star_(-1)
1510-{
1511- SetAcceptKeyNavFocusOnMouseDown(false);
1512- SetAcceptKeyNavFocusOnMouseEnter(true);
1513-
1514- mouse_up.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseUp));
1515- mouse_move.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseMove));
1516- mouse_drag.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseDrag));
1517-
1518- key_nav_focus_change.connect([this](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
1519- {
1520- if (has_focus)
1521- focused_star_ = 0;
1522- else if (!has_focus)
1523- focused_star_ = -1;
1524-
1525- QueueDraw();
1526- });
1527-
1528- key_nav_focus_activate.connect([this](nux::Area*) { filter_->rating = static_cast<float>(focused_star_+1)/num_stars; });
1529- key_down.connect(sigc::mem_fun(this, &FilterRatingsButton::OnKeyDown));
1530-}
1531-
1532-FilterRatingsButton::~FilterRatingsButton()
1533-{
1534-}
1535+ : RatingsButton(STAR_SIZE, STAR_GAP, NUX_FILE_LINE_PARAM)
1536+{}
1537
1538 void FilterRatingsButton::SetFilter(Filter::Ptr const& filter)
1539 {
1540 filter_ = std::static_pointer_cast<RatingsFilter>(filter);
1541- filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::OnRatingsChanged));
1542- NeedRedraw();
1543+ filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::SetRating));
1544+ QueueDraw();
1545+}
1546+
1547+RatingsFilter::Ptr FilterRatingsButton::GetFilter() const
1548+{
1549+ return filter_;
1550 }
1551
1552 std::string FilterRatingsButton::GetFilterType()
1553@@ -82,188 +55,22 @@
1554 return "FilterRatingsButton";
1555 }
1556
1557-void FilterRatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
1558-{
1559- int rating = 0;
1560- if (filter_ && filter_->filtering)
1561- rating = static_cast<int>(filter_->rating * num_stars);
1562- // FIXME: 9/26/2011
1563- // We should probably support an API for saying whether the ratings
1564- // should or shouldn't support half stars...but our only consumer at
1565- // the moment is the applications scope which according to design
1566- // (Bug #839759) shouldn't. So for now just force rounding.
1567- // int total_half_stars = rating % 2;
1568- // int total_full_stars = rating / 2;
1569- int total_full_stars = rating;
1570-
1571- nux::Geometry const& geo = GetGeometry();
1572- nux::Geometry geo_star(geo);
1573- geo_star.width = star_size;
1574-
1575- gPainter.PaintBackground(GfxContext, geo);
1576- // set up our texture mode
1577- nux::TexCoordXForm texxform;
1578- texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
1579- texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
1580-
1581- // clear what is behind us
1582- unsigned int alpha = 0, src = 0, dest = 0;
1583-
1584- GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
1585- GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
1586-
1587- nux::Color col = nux::color::Black;
1588- col.alpha = 0;
1589- GfxContext.QRP_Color(geo.x,
1590- geo.y,
1591- geo.width,
1592- geo.height,
1593- col);
1594-
1595- for (int index = 0; index < num_stars; ++index)
1596- {
1597- Style& style = Style::Instance();
1598- nux::BaseTexture* texture = style.GetStarSelectedIcon();
1599- if (index < total_full_stars)
1600- {
1601- if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
1602- texture = style.GetStarSelectedIcon();
1603- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
1604- texture = style.GetStarSelectedIcon();
1605- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
1606- texture = style.GetStarSelectedIcon();
1607- }
1608- else
1609- {
1610- if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
1611- texture = style.GetStarDeselectedIcon();
1612- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
1613- texture = style.GetStarDeselectedIcon();
1614- else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
1615- texture = style.GetStarDeselectedIcon();
1616- }
1617-
1618- GfxContext.QRP_1Tex(geo_star.x,
1619- geo_star.y,
1620- geo_star.width,
1621- geo_star.height,
1622- texture->GetDeviceTexture(),
1623- texxform,
1624- nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
1625-
1626- if (focused_star_ == index)
1627- {
1628- GfxContext.QRP_1Tex(geo_star.x,
1629- geo_star.y,
1630- geo_star.width,
1631- geo_star.height,
1632- style.GetStarHighlightIcon()->GetDeviceTexture(),
1633- texxform,
1634- nux::Color(1.0f, 1.0f, 1.0f, 0.5f));
1635- }
1636-
1637- geo_star.x += geo_star.width + star_gap;
1638-
1639- }
1640-
1641- GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
1642-
1643-}
1644-
1645-static void _UpdateRatingToMouse(RatingsFilter::Ptr filter, int x)
1646-{
1647- int width = 180;
1648- float new_rating = (static_cast<float>(x) / width);
1649-
1650- // FIXME: change to * 2 once we decide to support also half-stars
1651- new_rating = ceil((num_stars * 1) * new_rating) / (num_stars * 1);
1652- new_rating = (new_rating > 1) ? 1 : ((new_rating < 0) ? 0 : new_rating);
1653-
1654- if (filter)
1655- filter->rating = new_rating;
1656-}
1657-
1658-void FilterRatingsButton::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
1659-{
1660- _UpdateRatingToMouse(filter_, x);
1661-}
1662-
1663-void FilterRatingsButton::RecvMouseDrag(int x, int y, int dx, int dy,
1664- unsigned long button_flags,
1665- unsigned long key_flags)
1666-{
1667- _UpdateRatingToMouse(filter_, x);
1668-}
1669-
1670-void FilterRatingsButton::OnRatingsChanged(int rating)
1671-{
1672- NeedRedraw();
1673-}
1674-
1675-void FilterRatingsButton::RecvMouseMove(int x, int y, int dx, int dy,
1676- unsigned long button_flags,
1677- unsigned long key_flags)
1678-{
1679- int width = 180;
1680- focused_star_ = std::max(0, std::min(static_cast<int>(ceil((static_cast<float>(x) / width) * num_stars) - 1), num_stars - 1));
1681-
1682- if (!HasKeyFocus())
1683- nux::GetWindowCompositor().SetKeyFocusArea(this);
1684-
1685- QueueDraw();
1686-}
1687-
1688-
1689-bool FilterRatingsButton::InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character)
1690-{
1691- nux::KeyNavDirection direction = nux::KEY_NAV_NONE;
1692-
1693- switch (keysym)
1694- {
1695- case NUX_VK_LEFT:
1696- direction = nux::KeyNavDirection::KEY_NAV_LEFT;
1697- break;
1698- case NUX_VK_RIGHT:
1699- direction = nux::KeyNavDirection::KEY_NAV_RIGHT;
1700- break;
1701- default:
1702- direction = nux::KeyNavDirection::KEY_NAV_NONE;
1703- break;
1704- }
1705-
1706- if (direction == nux::KeyNavDirection::KEY_NAV_NONE)
1707- return false;
1708- else if (direction == nux::KEY_NAV_LEFT && (focused_star_ <= 0))
1709- return false;
1710- else if (direction == nux::KEY_NAV_RIGHT && (focused_star_ >= num_stars - 1))
1711- return false;
1712- else
1713- return true;
1714-}
1715-
1716-
1717-void FilterRatingsButton::OnKeyDown(unsigned long event_type, unsigned long event_keysym,
1718- unsigned long event_state, const TCHAR* character,
1719- unsigned short key_repeat_count)
1720-{
1721- switch (event_keysym)
1722- {
1723- case NUX_VK_LEFT:
1724- --focused_star_;
1725- break;
1726- case NUX_VK_RIGHT:
1727- ++focused_star_;
1728- break;
1729- default:
1730- return;
1731- }
1732-
1733- QueueDraw();
1734-}
1735-
1736-bool FilterRatingsButton::AcceptKeyNavFocus()
1737-{
1738- return true;
1739+std::string FilterRatingsButton::GetName() const
1740+{
1741+ return "FilterRatingsButton";
1742+}
1743+
1744+void FilterRatingsButton::SetRating(float rating)
1745+{
1746+ if (filter_)
1747+ filter_->rating = rating;
1748+
1749+ QueueDraw();
1750+}
1751+
1752+float FilterRatingsButton::GetRating() const
1753+{
1754+ return (filter_ && filter_->filtering) ? filter_->rating : 0;
1755 }
1756
1757 } // namespace dash
1758
1759=== modified file 'dash/FilterRatingsButton.h'
1760--- dash/FilterRatingsButton.h 2012-12-13 09:19:34 +0000
1761+++ dash/FilterRatingsButton.h 2014-08-26 13:46:04 +0000
1762@@ -25,46 +25,33 @@
1763 #include <memory>
1764
1765 #include <Nux/Nux.h>
1766-#include <Nux/ToggleButton.h>
1767-#include <Nux/CairoWrapper.h>
1768 #include <UnityCore/RatingsFilter.h>
1769+#include "unity-shared/RatingsButton.h"
1770
1771 namespace unity
1772 {
1773 namespace dash
1774 {
1775
1776-class FilterRatingsButton : public nux::ToggleButton
1777+class FilterRatingsButton : public RatingsButton
1778 {
1779- NUX_DECLARE_OBJECT_TYPE(FilterRatingsButton, nux::ToggleButton);
1780+ NUX_DECLARE_OBJECT_TYPE(FilterRatingsButton, RatingsButton);
1781 public:
1782 FilterRatingsButton(NUX_FILE_LINE_PROTO);
1783- virtual ~FilterRatingsButton();
1784
1785 void SetFilter(Filter::Ptr const& filter);
1786- RatingsFilter::Ptr GetFilter();
1787+ RatingsFilter::Ptr GetFilter() const;
1788 std::string GetFilterType();
1789
1790 protected:
1791- virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
1792+ // Introspectable methods
1793+ std::string GetName() const;
1794
1795- // Key-nav
1796- virtual bool AcceptKeyNavFocus();
1797- virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
1798+ void SetRating(float rating) override;
1799+ float GetRating() const override;
1800
1801 private:
1802- void OnKeyDown(unsigned long event_type, unsigned long event_keysym,
1803- unsigned long event_state, const TCHAR* character,
1804- unsigned short key_repeat_count);
1805-
1806- void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
1807- void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
1808- void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
1809- void OnRatingsChanged(int rating);
1810-
1811 dash::RatingsFilter::Ptr filter_;
1812- int focused_star_;
1813-
1814 };
1815
1816 } // namespace dash
1817
1818=== modified file 'dash/FilterRatingsWidget.cpp'
1819--- dash/FilterRatingsWidget.cpp 2013-03-19 18:22:11 +0000
1820+++ dash/FilterRatingsWidget.cpp 2014-08-26 13:46:04 +0000
1821@@ -33,15 +33,14 @@
1822 #include "FilterRatingsButton.h"
1823 #include "FilterRatingsWidget.h"
1824
1825-namespace
1826-{
1827-const int star_size = 28;
1828-}
1829-
1830 namespace unity
1831 {
1832 namespace dash
1833 {
1834+namespace
1835+{
1836+const RawPixel STAR_SIZE = 28_em;
1837+}
1838
1839 NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsWidget);
1840
1841@@ -49,22 +48,30 @@
1842 : FilterExpanderLabel(_("Rating"), NUX_FILE_LINE_PARAM)
1843 , all_button_(nullptr)
1844 {
1845- dash::Style& style = dash::Style::Instance();
1846- const int top_padding = style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding() - 1; // -1 (PNGs have an 1px top padding)
1847- const int bottom_padding = style.GetFilterHighlightPadding();
1848-
1849 nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
1850- layout->SetTopAndBottomPadding(top_padding, bottom_padding);
1851 ratings_ = new FilterRatingsButton(NUX_TRACKER_LOCATION);
1852- ratings_->SetMinimumHeight(star_size);
1853
1854 layout->AddView(ratings_);
1855
1856+ UpdateSize();
1857 SetContents(layout);
1858+
1859+ scale.changed.connect([this] (double scale) {
1860+ if (all_button_) all_button_->scale = scale;
1861+ UpdateSize();
1862+ });
1863 }
1864
1865-FilterRatingsWidget::~FilterRatingsWidget()
1866+void FilterRatingsWidget::UpdateSize()
1867 {
1868+ dash::Style& style = dash::Style::Instance();
1869+ int top_padding = style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale) - (1_em).CP(scale); // -1 (PNGs have an 1px top padding)
1870+ int bottom_padding = style.GetFilterHighlightPadding().CP(scale);
1871+ static_cast<nux::VLayout*>(GetLayout())->SetTopAndBottomPadding(top_padding, bottom_padding);
1872+
1873+ ratings_->scale = scale();
1874+ ratings_->SetMinimumHeight(STAR_SIZE.CP(scale));
1875+ ratings_->ApplyMinHeight();
1876 }
1877
1878 void FilterRatingsWidget::SetFilter(Filter::Ptr const& filter)
1879@@ -77,7 +84,10 @@
1880 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
1881 SetRightHandView(all_button_);
1882 if (all_button_)
1883+ {
1884+ all_button_->scale = scale();
1885 all_button_->SetFilter(filter_);
1886+ }
1887 };
1888 show_button_func(filter_->show_all_button);
1889 filter_->show_all_button.changed.connect(show_button_func);
1890
1891=== modified file 'dash/FilterRatingsWidget.h'
1892--- dash/FilterRatingsWidget.h 2012-11-27 23:16:06 +0000
1893+++ dash/FilterRatingsWidget.h 2014-08-26 13:46:04 +0000
1894@@ -45,7 +45,6 @@
1895 NUX_DECLARE_OBJECT_TYPE(FilterRatingsWidget, FilterExpanderLabel);
1896 public:
1897 FilterRatingsWidget(NUX_FILE_LINE_PROTO);
1898- virtual ~FilterRatingsWidget();
1899
1900 void SetFilter(Filter::Ptr const& filter);
1901 std::string GetFilterType();
1902@@ -54,6 +53,8 @@
1903 void ClearRedirectedRenderChildArea();
1904
1905 private:
1906+ void UpdateSize();
1907+
1908 FilterAllButton* all_button_;
1909 FilterRatingsButton* ratings_;
1910 RatingsFilter::Ptr filter_;
1911
1912=== modified file 'dash/PlacesGroup.cpp'
1913--- dash/PlacesGroup.cpp 2014-03-20 04:05:39 +0000
1914+++ dash/PlacesGroup.cpp 2014-08-26 13:46:04 +0000
1915@@ -33,7 +33,6 @@
1916 #include "unity-shared/UBusWrapper.h"
1917 #include "unity-shared/UBusMessages.h"
1918 #include "unity-shared/GraphicsUtils.h"
1919-#include "unity-shared/RawPixel.h"
1920
1921 #include "ResultView.h"
1922 #include "ResultViewGrid.h"
1923@@ -133,10 +132,8 @@
1924 SetAcceptKeyNavFocusOnMouseEnter(false);
1925 scale.changed.connect(sigc::mem_fun(this, &PlacesGroup::UpdateScale));
1926
1927- nux::BaseTexture* arrow = _style.GetGroupExpandIcon();
1928-
1929- _background = _style.GetCategoryBackground();
1930- _background_nofilters = _style.GetCategoryBackgroundNoFilters();
1931+ _background = _style.GetCategoryBackground().GetPointer();
1932+ _background_nofilters = _style.GetCategoryBackgroundNoFilters().GetPointer();
1933
1934 nux::ROPConfig rop;
1935 rop.Blend = true;
1936@@ -144,8 +141,8 @@
1937 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
1938
1939 nux::TexCoordXForm texxform;
1940- _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(),
1941- texxform,
1942+ _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(),
1943+ texxform,
1944 nux::color::White,
1945 false,
1946 rop));
1947@@ -160,11 +157,10 @@
1948 _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
1949
1950 _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
1951- _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding(), 0);
1952+ _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding().CP(scale), 0);
1953 _header_view->SetLayout(_header_layout);
1954
1955- RawPixel const icon_size = _style.GetCategoryIconSize();
1956- _icon = new IconTexture("", icon_size.CP(scale()));
1957+ _icon = new IconTexture("", _style.GetCategoryIconSize().CP(scale));
1958 _header_layout->AddView(_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
1959
1960 _text_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
1961@@ -172,6 +168,7 @@
1962
1963 _name = new StaticCairoText("", NUX_TRACKER_LOCATION);
1964 _name->SetFont(NAME_LABEL_FONT);
1965+ _name->SetLines(-1);
1966 _name->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);
1967 _name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
1968 _text_layout->AddView(_name, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
1969@@ -184,16 +181,17 @@
1970
1971 _expand_label = new StaticCairoText("", NUX_TRACKER_LOCATION);
1972 _expand_label->SetFont(EXPANDER_LABEL_FONT);
1973+ _expand_label->SetLines(-1);
1974 _expand_label->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);
1975 _expand_label->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
1976 _expand_label->SetTextColor(kExpandDefaultTextColor);
1977 _expand_label_layout->AddView(_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
1978
1979- _expand_icon = new IconTexture(arrow, arrow->GetWidth(), arrow->GetHeight());
1980+ _expand_icon = new IconTexture(_style.GetGroupExpandIcon());
1981+ _expand_icon->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
1982 _expand_icon->SetOpacity(kExpandDefaultIconOpacity);
1983- _expand_icon->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());
1984 _expand_icon->SetVisible(false);
1985- _expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
1986+ _expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
1987
1988 SetLayout(_group_layout);
1989
1990@@ -223,16 +221,16 @@
1991 void
1992 PlacesGroup::UpdatePlacesGroupSize()
1993 {
1994- RawPixel const icon_size = _style.GetCategoryIconSize();
1995- RawPixel const group_top = _style.GetPlacesGroupTopSpace();
1996+ int icon_size = _style.GetCategoryIconSize().CP(scale);
1997+ int top_space = _style.GetPlacesGroupTopSpace().CP(scale);
1998
1999- int top_space = group_top.CP(scale());
2000 _space_layout->SetMinimumSize(top_space, top_space);
2001 _space_layout->SetMaximumSize(top_space, top_space);
2002
2003 _header_layout->SetSpaceBetweenChildren(SPACE_BETWEEN_CHILDREN.CP(scale()));
2004+ _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding().CP(scale), 0);
2005
2006- _icon->SetMinMaxSize(icon_size.CP(scale()), icon_size.CP(scale()));
2007+ _icon->SetMinMaxSize(icon_size, icon_size);
2008
2009 _text_layout->SetHorizontalInternalMargin(TEXT_INTERNAL_MARGIN.CP(scale()));
2010 _expand_layout->SetHorizontalInternalMargin(EXPAND_INTERNAL_MARGIN.CP(scale()));
2011@@ -241,15 +239,16 @@
2012 void
2013 PlacesGroup::UpdateScale(double scale)
2014 {
2015- RawPixel const icon_size = _style.GetCategoryIconSize();
2016-
2017+ _name->SetMinimumSize(nux::AREA_MIN_WIDTH, nux::AREA_MIN_HEIGHT);
2018+ _name->SetMaximumSize(nux::AREA_MAX_WIDTH, nux::AREA_MAX_HEIGHT);
2019 _name->SetScale(scale);
2020 _expand_label->SetScale(scale);
2021
2022- _icon->SetSize(icon_size.CP(scale));
2023+ _icon->SetSize(_style.GetCategoryIconSize().CP(scale));
2024 _icon->ReLoadIcon();
2025
2026- // FIXME _expand_icon, needs some work here. Not as easy as _icon
2027+ auto const& arrow = _expand_icon->texture();
2028+ _expand_icon->SetMinMaxSize(RawPixel(arrow->GetWidth()).CP(scale), RawPixel(arrow->GetHeight()).CP(scale));
2029
2030 if (_child_view)
2031 _child_view->scale = scale;
2032@@ -279,7 +278,6 @@
2033
2034 void
2035
2036-// FIXME _expand_icon, needs some work here. Not as easy as _icon
2037 PlacesGroup::SetName(std::string const& name)
2038 {
2039 if (_cached_name != name)
2040@@ -310,7 +308,7 @@
2041 void
2042 PlacesGroup::SetIcon(std::string const& path_to_emblem)
2043 {
2044- _icon->SetByIconName(path_to_emblem, _style.GetCategoryIconSize());
2045+ _icon->SetByIconName(path_to_emblem, _style.GetCategoryIconSize().CP(scale));
2046 }
2047
2048 void
2049@@ -318,11 +316,8 @@
2050 {
2051 if (_child_layout)
2052 {
2053- RawPixel const result_top_padding = _style.GetPlacesGroupResultTopPadding();
2054- RawPixel const result_left_padding = _style.GetPlacesGroupResultLeftPadding();
2055-
2056- _child_layout->SetTopAndBottomPadding(result_top_padding.CP(scale()), 0);
2057- _child_layout->SetLeftAndRightPadding(result_left_padding.CP(scale()), 0);
2058+ _child_layout->SetTopAndBottomPadding(_style.GetPlacesGroupResultTopPadding().CP(scale), 0);
2059+ _child_layout->SetLeftAndRightPadding(_style.GetPlacesGroupResultLeftPadding().CP(scale), 0);
2060 }
2061 }
2062
2063@@ -462,7 +457,7 @@
2064 // only the width matters
2065 if (_cached_geometry.GetWidth() != geo.GetWidth())
2066 {
2067- _focus_layer.reset(_style.FocusOverlay(geo.width -
2068+ _focus_layer.reset(_style.FocusOverlay(geo.width -
2069 kHighlightLeftPadding.CP(scale()) -
2070 kHighlightRightPadding.CP(scale()),
2071 kHighlightHeight.CP(scale())));
2072@@ -595,6 +590,9 @@
2073 else
2074 _expand_icon->SetTexture(_style.GetGroupExpandIcon());
2075
2076+ auto const& tex = _expand_icon->texture();
2077+ _expand_icon->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale));
2078+
2079 expanded.emit(this);
2080 }
2081
2082
2083=== modified file 'dash/ResultRendererHorizontalTile.cpp'
2084--- dash/ResultRendererHorizontalTile.cpp 2014-03-20 05:05:21 +0000
2085+++ dash/ResultRendererHorizontalTile.cpp 2014-08-26 13:46:04 +0000
2086@@ -247,8 +247,8 @@
2087 0.0f,
2088 0.0f,
2089 CARD_VIEW_HIGHLIGHT_CORNER_RADIUS,
2090- width,
2091- height,
2092+ width/scale(),
2093+ height/scale(),
2094 false);
2095 cairo_fill(cr);
2096
2097
2098=== modified file 'dash/ResultRendererTile.cpp'
2099--- dash/ResultRendererTile.cpp 2014-05-03 17:57:47 +0000
2100+++ dash/ResultRendererTile.cpp 2014-08-26 13:46:04 +0000
2101@@ -31,7 +31,6 @@
2102 #include "unity-shared/CairoTexture.h"
2103 #include "unity-shared/DashStyle.h"
2104 #include "unity-shared/TextureCache.h"
2105-#include "unity-shared/RawPixel.h"
2106 #include "unity-shared/UnitySettings.h"
2107
2108 namespace unity
2109@@ -120,13 +119,7 @@
2110 return;
2111
2112 dash::Style const& style = dash::Style::Instance();
2113- RawPixel const tile_size = style.GetTileImageSize();
2114- RawPixel const tile_width = style.GetTileWidth();
2115- RawPixel const tile_height = style.GetTileHeight();
2116- RawPixel const tile_highlight_width = style.GetTileIconHightlightWidth();
2117- RawPixel const tile_highlight_height = style.GetTileIconHightlightHeight();
2118-
2119- int tile_icon_size = tile_size.CP(scale());
2120+ int tile_icon_size = style.GetTileImageSize().CP(scale);
2121
2122 // set up our texture mode
2123 nux::TexCoordXForm texxform;
2124@@ -148,8 +141,8 @@
2125 // render highlight if its needed
2126 if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL)
2127 {
2128- int highlight_x = (geometry.x + geometry.width/2) - tile_highlight_width.CP(scale())/2;
2129- int highlight_y = (geometry.y + PADDING.CP(scale()) + tile_icon_size / 2) - tile_highlight_height.CP(scale())/2;
2130+ int highlight_x = (geometry.x + geometry.width/2) - style.GetTileIconHightlightWidth().CP(scale)/2;
2131+ int highlight_y = (geometry.y + PADDING.CP(scale) + tile_icon_size / 2) - style.GetTileIconHightlightHeight().CP(scale)/2;
2132
2133 RenderTexture(GfxContext,
2134 highlight_x,
2135@@ -179,10 +172,10 @@
2136 if (container->text)
2137 {
2138 RenderTexture(GfxContext,
2139- geometry.x + PADDING.CP(scale()),
2140- geometry.y + tile_icon_size + SPACING.CP(scale()),
2141- tile_width.CP(scale()) - (PADDING.CP(scale()) * 2),
2142- tile_height.CP(scale()) - tile_icon_size - SPACING.CP(scale()),
2143+ geometry.x + PADDING.CP(scale),
2144+ geometry.y + tile_icon_size + SPACING.CP(scale),
2145+ style.GetTileWidth().CP(scale) - (PADDING.CP(scale) * 2),
2146+ style.GetTileHeight().CP(scale) - tile_icon_size - SPACING.CP(scale),
2147 container->text->GetDeviceTexture(),
2148 texxform,
2149 color,
2150@@ -273,10 +266,8 @@
2151 void ResultRendererTile::LoadIcon(Result const& row)
2152 {
2153 Style const& style = Style::Instance();
2154- RawPixel const tile_size = style.GetTileImageSize();
2155- RawPixel const tile_gsize = style.GetTileGIconSize();
2156- RawPixel const tile_highlight_width = style.GetTileIconHightlightWidth();
2157- RawPixel const tile_highlight_height = style.GetTileIconHightlightHeight();
2158+ int tile_size = style.GetTileImageSize().CP(scale);
2159+ int tile_gsize = style.GetTileGIconSize().CP(scale);
2160
2161 std::string const& icon_hint = row.icon_hint;
2162 std::string const& icon_name = !icon_hint.empty() ? icon_hint : DEFAULT_GICON;
2163@@ -288,8 +279,8 @@
2164 {
2165 TextureCache& cache = TextureCache::GetDefault();
2166 BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight",
2167- tile_highlight_width.CP(scale()),
2168- tile_highlight_height.CP(scale()),
2169+ style.GetTileIconHightlightWidth().CP(scale),
2170+ style.GetTileIconHightlightHeight().CP(scale),
2171 sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));
2172 container->prelight = texture_prelight;
2173 }
2174@@ -300,13 +291,13 @@
2175 {
2176 bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON);
2177 container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name,
2178- tile_size.CP(scale()),
2179+ tile_size,
2180 use_large_icon ?
2181- tile_size.CP(scale()) : tile_gsize.CP(scale()), slot);
2182+ tile_size : tile_gsize, slot);
2183 }
2184 else
2185 {
2186- container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, tile_gsize.CP(scale()), slot);
2187+ container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, tile_gsize, slot);
2188 }
2189 }
2190
2191@@ -333,15 +324,12 @@
2192 }
2193 else
2194 {
2195- Style const& style = Style::Instance();
2196- RawPixel const tile_size = style.GetTileImageSize();
2197-
2198 // slow path for non square icons that must be resized to fit in the square
2199 // texture
2200 float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
2201 if (aspect < 1.0f)
2202 {
2203- pixbuf_width = tile_size.CP(scale());
2204+ pixbuf_width = Style::Instance().GetTileImageSize().CP(scale);
2205 pixbuf_height = pixbuf_width * aspect;
2206
2207 if (pixbuf_height > height)
2208@@ -470,13 +458,10 @@
2209 void ResultRendererTile::LoadText(Result const& row)
2210 {
2211 Style const& style = Style::Instance();
2212- RawPixel const tile_size = style.GetTileImageSize();
2213- RawPixel const tile_width = style.GetTileWidth();
2214- RawPixel const tile_height = style.GetTileHeight();
2215
2216 nux::CairoGraphics _cairoGraphics(CAIRO_FORMAT_ARGB32,
2217- tile_width.CP(scale()) - (PADDING.CP(scale()) * 2),
2218- tile_height.CP(scale()) - tile_size.CP(scale()) - SPACING.CP(scale()));
2219+ style.GetTileWidth().CP(scale()) - (PADDING.CP(scale()) * 2),
2220+ style.GetTileHeight().CP(scale()) - style.GetTileImageSize().CP(scale()) - SPACING.CP(scale()));
2221 cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale(), scale());
2222
2223 cairo_t* cr = _cairoGraphics.GetInternalContext();
2224@@ -499,7 +484,7 @@
2225
2226 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
2227 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START);
2228- pango_layout_set_width(layout, (tile_width - (PADDING * 2))* PANGO_SCALE);
2229+ pango_layout_set_width(layout, (style.GetTileWidth() - (PADDING * 2))* PANGO_SCALE);
2230 pango_layout_set_height(layout, -2);
2231
2232 // FIXME bug #1239381
2233
2234=== modified file 'dash/ScopeBar.cpp'
2235--- dash/ScopeBar.cpp 2014-03-20 04:05:39 +0000
2236+++ dash/ScopeBar.cpp 2014-08-26 13:46:04 +0000
2237@@ -27,7 +27,6 @@
2238 #include "unity-shared/StaticCairoText.h"
2239 #include "unity-shared/CairoTexture.h"
2240 #include "unity-shared/GraphicsUtils.h"
2241-#include "unity-shared/RawPixel.h"
2242 #include "unity-shared/UBusMessages.h"
2243
2244 namespace unity
2245@@ -71,6 +70,9 @@
2246
2247 for (auto icon : icons_)
2248 icon->scale = scale;
2249+
2250+ QueueDraw();
2251+ QueueRelayout();
2252 }
2253
2254 void ScopeBar::SetupLayout()
2255
2256=== modified file 'dash/ScopeBarIcon.cpp'
2257--- dash/ScopeBarIcon.cpp 2014-03-20 21:43:02 +0000
2258+++ dash/ScopeBarIcon.cpp 2014-08-26 13:46:04 +0000
2259@@ -17,7 +17,6 @@
2260 */
2261
2262 #include "unity-shared/DashStyle.h"
2263-#include "unity-shared/RawPixel.h"
2264 #include "ScopeBarIcon.h"
2265
2266 #include "config.h"
2267
2268=== modified file 'dash/ScopeView.cpp'
2269--- dash/ScopeView.cpp 2014-03-20 04:05:39 +0000
2270+++ dash/ScopeView.cpp 2014-08-26 13:46:04 +0000
2271@@ -31,7 +31,6 @@
2272 #include "unity-shared/UBusWrapper.h"
2273 #include "unity-shared/PlacesOverlayVScrollBar.h"
2274 #include "unity-shared/GraphicsUtils.h"
2275-#include "unity-shared/RawPixel.h"
2276
2277 #include "config.h"
2278 #include <glib/gi18n-lib.h>
2279@@ -250,6 +249,7 @@
2280 no_results_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
2281 no_results_->SetTextColor(nux::color::White);
2282 no_results_->SetVisible(false);
2283+ no_results_->SetScale(scale);
2284 scroll_layout_->AddView(no_results_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
2285
2286 fscroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), NUX_TRACKER_LOCATION);
2287@@ -276,19 +276,17 @@
2288 {
2289 dash::Style const& style = dash::Style::Instance();
2290
2291- RawPixel const scope_filter_space = style.GetSpaceBetweenScopeAndFilters();
2292- RawPixel const right_padding = style.GetFilterViewRightPadding();
2293- RawPixel const filter_width = style.GetFilterBarWidth() +
2294- style.GetFilterBarLeftPadding() +
2295- style.GetFilterBarRightPadding();
2296-
2297- double scale = this->scale();
2298- layout_->SetSpaceBetweenChildren(scope_filter_space.CP(scale));
2299-
2300- fscroll_view_->SetMinimumWidth(filter_width.CP(scale) + right_padding.CP(scale));
2301- fscroll_view_->SetMaximumWidth(filter_width.CP(scale) + right_padding.CP(scale));
2302- filter_bar_->SetMinimumWidth(filter_width.CP(scale));
2303- filter_bar_->SetMaximumWidth(filter_width.CP(scale));
2304+ int right_padding = style.GetFilterViewRightPadding().CP(scale);
2305+ int filter_width = style.GetFilterBarWidth().CP(scale) +
2306+ style.GetFilterBarLeftPadding().CP(scale) +
2307+ style.GetFilterBarRightPadding().CP(scale);
2308+
2309+ layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenScopeAndFilters().CP(scale));
2310+
2311+ fscroll_view_->SetMinimumWidth(filter_width + right_padding);
2312+ fscroll_view_->SetMaximumWidth(filter_width + right_padding);
2313+ filter_bar_->SetMinimumWidth(filter_width);
2314+ filter_bar_->SetMaximumWidth(filter_width);
2315 }
2316
2317 void ScopeView::UpdateScale(double scale)
2318@@ -299,6 +297,7 @@
2319 group->scale = scale;
2320
2321 filter_bar_->scale = scale;
2322+ no_results_->SetScale(scale);
2323 }
2324
2325 void ScopeView::SetupCategories(Categories::Ptr const& categories)
2326
2327=== modified file 'dash/StandaloneDash.cpp'
2328--- dash/StandaloneDash.cpp 2014-02-28 23:32:05 +0000
2329+++ dash/StandaloneDash.cpp 2014-08-26 13:46:04 +0000
2330@@ -36,47 +36,50 @@
2331 #include "unity-shared/DashStyle.h"
2332 #include "unity-shared/PanelStyle.h"
2333 #include "unity-shared/ThumbnailGenerator.h"
2334-#include "UnityCore/GSettingsScopes.h"
2335+#include "unity-shared/UBusMessages.h"
2336+#include "unity-shared/UBusServer.h"
2337+#include <UnityCore/GSettingsScopes.h>
2338+#include <UnityCore/ScopeProxyInterface.h>
2339
2340-#define WIDTH 1024
2341-#define HEIGHT 768
2342+const unity::RawPixel WIDTH(1024);
2343+const unity::RawPixel HEIGHT(768);
2344
2345 using namespace unity::dash;
2346
2347 class TestRunner
2348 {
2349 public:
2350- TestRunner ();
2351- ~TestRunner ();
2352+ TestRunner(std::string const& scope, double scale)
2353+ : scope_(scope)
2354+ , scale_(scale)
2355+ {}
2356
2357 static void InitWindowThread (nux::NThread* thread, void* InitData);
2358 void Init ();
2359+ std::string scope_;
2360+ double scale_;
2361 nux::Layout *layout;
2362 };
2363
2364-TestRunner::TestRunner ()
2365-{
2366-}
2367-
2368-TestRunner::~TestRunner ()
2369-{
2370-}
2371-
2372 void TestRunner::Init ()
2373 {
2374 layout = new nux::HLayout(NUX_TRACKER_LOCATION);
2375
2376- DashView* view = new DashView(std::make_shared<unity::dash::GSettingsScopes>(),
2377+ DashView* view = new DashView(std::make_shared<unity::dash::GSettingsScopes>(),
2378 std::make_shared<unity::ApplicationStarterImp>());
2379+ view->scale = scale_;
2380 view->DisableBlur();
2381- view->SetMinMaxSize(WIDTH, HEIGHT);
2382+ view->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));
2383 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
2384- layout->SetMinMaxSize(WIDTH, HEIGHT);
2385+ layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));
2386
2387 view->AboutToShow(0);
2388
2389 nux::GetWindowThread()->SetLayout (layout);
2390 nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());
2391+
2392+ unity::UBusServer().SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
2393+ g_variant_new("(sus)", scope_.c_str(), GOTO_DASH_URI, ""));
2394 }
2395
2396 void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
2397@@ -87,8 +90,6 @@
2398
2399 int main(int argc, char **argv)
2400 {
2401- nux::WindowThread* wt = NULL;
2402-
2403 gtk_init (&argc, &argv);
2404
2405 unity::BGHash bghash;
2406@@ -102,17 +103,30 @@
2407 unity::dash::Style dash_style;
2408 unity::panel::Style panel_style;
2409
2410- TestRunner *test_runner = new TestRunner ();
2411- wt = nux::CreateGUIThread(TEXT("Unity Dash"),
2412- WIDTH, HEIGHT,
2413- 0,
2414- &TestRunner::InitWindowThread,
2415- test_runner);
2416+ double scale = 1.0;
2417+ unity::glib::String scope;
2418+ unity::glib::Error err;
2419+
2420+ GOptionEntry args_parsed[] =
2421+ {
2422+ { "scope", 's', 0, G_OPTION_ARG_STRING, &scope, "The default scope ", "S" },
2423+ { "scaling-factor", 'f', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" },
2424+ { NULL }
2425+ };
2426+
2427+ std::shared_ptr<GOptionContext> ctx(g_option_context_new("Standalone Dash"), g_option_context_free);
2428+ g_option_context_add_main_entries(ctx.get(), args_parsed, NULL);
2429+ if (!g_option_context_parse(ctx.get(), &argc, &argv, &err))
2430+ std::cerr << "Got error when parsing arguments: " << err << std::endl;
2431+
2432+ TestRunner *test_runner = new TestRunner(scope.Str(), scale);
2433+ std::unique_ptr<nux::WindowThread> wt(nux::CreateGUIThread(TEXT("Unity Dash"),
2434+ WIDTH.CP(scale), HEIGHT.CP(scale),
2435+ 0, &TestRunner::InitWindowThread, test_runner));
2436
2437 nux::NuxTimerTickSource tick_source;
2438 nux::animation::AnimationController animation_controller(tick_source);
2439+ wt->Run(nullptr);
2440
2441- wt->Run (NULL);
2442- delete wt;
2443- return 0;
2444+ return EXIT_SUCCESS;
2445 }
2446
2447=== modified file 'dash/previews/ActionButton.cpp'
2448--- dash/previews/ActionButton.cpp 2013-11-19 18:48:35 +0000
2449+++ dash/previews/ActionButton.cpp 2014-08-26 13:46:04 +0000
2450@@ -26,22 +26,23 @@
2451 #include "unity-shared/IconTexture.h"
2452 #include "unity-shared/StaticCairoText.h"
2453
2454+namespace unity
2455+{
2456 namespace
2457 {
2458-const int kMinButtonHeight = 34;
2459-const int kMinButtonWidth = 48;
2460+const RawPixel MIN_BUTTON_HEIGHT = 34_em;
2461+const RawPixel MIN_BUTTON_WIDTH = 48_em;
2462
2463-const int icon_size = 24;
2464+const RawPixel icon_size = 24_em;
2465 }
2466
2467-namespace unity
2468-{
2469 namespace dash
2470 {
2471 DECLARE_LOGGER(logger, "unity.dash.preview.action");
2472
2473 ActionButton::ActionButton(std::string const& action_hint, std::string const& label, std::string const& icon_hint, NUX_FILE_LINE_DECL)
2474 : nux::AbstractButton(NUX_FILE_LINE_PARAM)
2475+ , scale(1.0)
2476 , action_hint_(action_hint)
2477 , image_(nullptr)
2478 {
2479@@ -49,6 +50,7 @@
2480 SetAcceptKeyNavFocusOnMouseEnter(true);
2481 Init();
2482 BuildLayout(label, icon_hint, "");
2483+ scale.changed.connect(sigc::mem_fun(this, &ActionButton::UpdateScale));
2484 }
2485
2486 ActionButton::~ActionButton()
2487@@ -84,22 +86,19 @@
2488
2489 void ActionButton::InitTheme()
2490 {
2491- if (!cr_active_)
2492- {
2493- nux::Geometry const& geo = GetGeometry();
2494-
2495- cr_prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
2496- cr_active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
2497- cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
2498- cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay)));
2499- }
2500-
2501- SetMinimumHeight(kMinButtonHeight);
2502- SetMinimumWidth(kMinButtonWidth);
2503+ nux::Geometry const& geo = GetGeometry();
2504+
2505+ cr_prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
2506+ cr_active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
2507+ cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
2508+ cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay)));
2509+
2510+ SetMinimumHeight(MIN_BUTTON_HEIGHT.CP(scale));
2511+ SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale));
2512 }
2513
2514 void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint)
2515-{
2516+{
2517 extra_font_hint_= font_hint;
2518 if (extra_text_)
2519 {
2520@@ -123,13 +122,13 @@
2521
2522 if (!icon_hint_.empty())
2523 {
2524- image_ = new IconTexture(icon_hint, icon_size);
2525+ image_ = new IconTexture(icon_hint, icon_size.CP(scale));
2526 image_->texture_updated.connect([this](nux::ObjectPtr<nux::BaseTexture> const&)
2527 {
2528 BuildLayout(label_, icon_hint_, extra_hint_);
2529 });
2530 image_->SetInputEventSensitivity(false);
2531- image_->SetMinMaxSize(icon_size, icon_size);
2532+ image_->SetMinMaxSize(icon_size.CP(scale), icon_size.CP(scale));
2533 }
2534 }
2535
2536@@ -192,11 +191,13 @@
2537
2538 void ActionButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)
2539 {
2540+ cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
2541 Style::Instance().Button(cr, faked_state, "", -1, Alignment::CENTER, true);
2542 }
2543
2544 void ActionButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr)
2545 {
2546+ cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
2547 Style::Instance().ButtonFocusOverlay(cr, 0.20f);
2548 }
2549
2550@@ -311,5 +312,27 @@
2551 return extra_hint_;
2552 }
2553
2554+void ActionButton::UpdateScale(double scale)
2555+{
2556+ InitTheme();
2557+
2558+ if (image_)
2559+ {
2560+ image_->SetSize(icon_size.CP(scale));
2561+ image_->SetMinMaxSize(icon_size.CP(scale), icon_size.CP(scale));
2562+ image_->ReLoadIcon();
2563+ }
2564+
2565+ if (static_text_)
2566+ static_text_->SetScale(scale);
2567+
2568+ if (extra_text_)
2569+ extra_text_->SetScale(scale);
2570+
2571+ QueueRelayout();
2572+ QueueDraw();
2573+}
2574+
2575+
2576 } // namespace dash
2577 } // namespace unity
2578
2579=== modified file 'dash/previews/ActionButton.h'
2580--- dash/previews/ActionButton.h 2013-09-19 16:44:03 +0000
2581+++ dash/previews/ActionButton.h 2014-08-26 13:46:04 +0000
2582@@ -59,6 +59,8 @@
2583 std::string GetLabel() const;
2584 std::string GetExtraText() const;
2585
2586+ nux::Property<double> scale;
2587+
2588 protected:
2589 virtual long ComputeContentSize();
2590 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
2591@@ -95,6 +97,8 @@
2592 nux::ObjectPtr<IconTexture> image_;
2593 nux::ObjectPtr<unity::StaticCairoText> static_text_;
2594 nux::ObjectPtr<unity::StaticCairoText> extra_text_;
2595+
2596+ void UpdateScale(double scale);
2597 };
2598
2599 } // namespace dash
2600
2601=== modified file 'dash/previews/ActionLink.cpp'
2602--- dash/previews/ActionLink.cpp 2013-11-19 18:48:35 +0000
2603+++ dash/previews/ActionLink.cpp 2014-08-26 13:46:04 +0000
2604@@ -40,12 +40,15 @@
2605
2606 ActionLink::ActionLink(std::string const& action_hint, std::string const& label, NUX_FILE_LINE_DECL)
2607 : nux::AbstractButton(NUX_FILE_LINE_PARAM)
2608+ , scale(1.0)
2609 , action_hint_(action_hint)
2610 , aligment_(StaticCairoText::NUX_ALIGN_CENTRE)
2611 , underline_(StaticCairoText::NUX_UNDERLINE_SINGLE)
2612 {
2613 Init();
2614 BuildLayout(label);
2615+ UpdateScale(scale);
2616+ scale.changed.connect(sigc::mem_fun(this, &ActionLink::UpdateScale));
2617 }
2618
2619 std::string ActionLink::GetName() const
2620@@ -109,6 +112,7 @@
2621 static_text_ = new StaticCairoText(label_, true, NUX_TRACKER_LOCATION);
2622 if (!font_hint_.empty())
2623 static_text_->SetFont(font_hint_);
2624+ static_text_->SetScale(scale);
2625 static_text_->SetInputEventSensitivity(false);
2626 static_text_->SetTextAlignment(aligment_);
2627 static_text_->SetUnderline(underline_);
2628@@ -243,5 +247,14 @@
2629 return label_;
2630 }
2631
2632+void ActionLink::UpdateScale(double scale)
2633+{
2634+ if (static_text_)
2635+ static_text_->SetScale(scale);
2636+
2637+ QueueRelayout();
2638+ QueueDraw();
2639+}
2640+
2641 } // namespace dash
2642 } // namespace unity
2643
2644=== modified file 'dash/previews/ActionLink.h'
2645--- dash/previews/ActionLink.h 2013-09-19 16:44:03 +0000
2646+++ dash/previews/ActionLink.h 2014-08-26 13:46:04 +0000
2647@@ -47,6 +47,7 @@
2648 nux::RWProperty<StaticCairoText::AlignState> text_aligment;
2649 nux::RWProperty<StaticCairoText::UnderlineState> underline_state;
2650 nux::RWProperty<std::string> font_hint;
2651+ nux::Property<double> scale;
2652
2653 void Activate() {}
2654 void Deactivate() {}
2655@@ -90,8 +91,7 @@
2656 StaticCairoText::UnderlineState underline_;
2657 private:
2658 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
2659-
2660-
2661+ void UpdateScale(double scale);
2662 };
2663
2664 } // namespace dash
2665
2666=== modified file 'dash/previews/ApplicationPreview.cpp'
2667--- dash/previews/ApplicationPreview.cpp 2013-11-19 18:48:35 +0000
2668+++ dash/previews/ApplicationPreview.cpp 2014-08-26 13:46:04 +0000
2669@@ -46,6 +46,16 @@
2670 {
2671 namespace previews
2672 {
2673+
2674+namespace
2675+{
2676+ const RawPixel ICON_SPACE_CHILDREN = 3_em;
2677+ const RawPixel DATA_SPACE_CHILDREN = 16_em;
2678+ const RawPixel INFO_SPACE_CHILDREN = 12_em;
2679+ const RawPixel COPYRIGHT_SPACE_CHILDREN = 8_em;
2680+ const RawPixel ICON_SIZE = 72_em;
2681+}
2682+
2683 DECLARE_LOGGER(logger, "unity.dash.preview.application");
2684
2685 class DetailsScrollView : public nux::ScrollView
2686@@ -63,6 +73,14 @@
2687
2688 ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model)
2689 : Preview(preview_model)
2690+, title_subtitle_layout_(nullptr)
2691+, image_data_layout_(nullptr)
2692+, main_app_info_(nullptr)
2693+, icon_layout_(nullptr)
2694+, app_data_layout_(nullptr)
2695+, app_updated_copywrite_layout_(nullptr)
2696+, app_info_layout_(nullptr)
2697+, actions_layout_(nullptr)
2698 {
2699 SetupViews();
2700 }
2701@@ -121,12 +139,13 @@
2702
2703 auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
2704
2705- nux::HLayout* image_data_layout = new nux::HLayout();
2706- image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
2707+ image_data_layout_ = new nux::HLayout();
2708+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
2709
2710 /////////////////////
2711 // Image
2712 image_ = new CoverArt();
2713+ image_->scale = scale();
2714 AddChild(image_.GetPointer());
2715 UpdateCoverArtImage(image_.GetPointer());
2716 /////////////////////
2717@@ -134,34 +153,35 @@
2718 /////////////////////
2719 // App Data Panel
2720 full_data_layout_ = new nux::VLayout();
2721- full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());
2722- full_data_layout_->SetSpaceBetweenChildren(16);
2723+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
2724+ full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
2725
2726 /////////////////////
2727 // Main App Info
2728- nux::HLayout* main_app_info = new nux::HLayout();
2729- main_app_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails());
2730+ main_app_info_ = new nux::HLayout();
2731+ main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale));
2732
2733 /////////////////////
2734 // Icon Layout
2735- nux::VLayout* icon_layout = new nux::VLayout();
2736- icon_layout->SetSpaceBetweenChildren(3);
2737- app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", 72);
2738+ icon_layout_ = new nux::VLayout();
2739+ icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale));
2740+ app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", ICON_SIZE.CP(scale));
2741 AddChild(app_icon_.GetPointer());
2742- app_icon_->SetMinimumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());
2743- app_icon_->SetMaximumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());
2744+ app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
2745+ app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
2746 app_icon_->mouse_click.connect(on_mouse_down);
2747- icon_layout->AddView(app_icon_.GetPointer(), 0);
2748+ icon_layout_->AddView(app_icon_.GetPointer(), 0);
2749
2750 if (app_preview_model->rating >= 0) {
2751 app_rating_ = new PreviewRatingsWidget();
2752 AddChild(app_rating_.GetPointer());
2753- app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
2754- app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
2755+ app_rating_->scale = scale();
2756+ app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
2757+ app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
2758 app_rating_->SetRating(app_preview_model->rating);
2759 app_rating_->SetReviews(app_preview_model->num_ratings);
2760 app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
2761- icon_layout->AddView(app_rating_.GetPointer(), 0);
2762+ icon_layout_->AddView(app_rating_.GetPointer(), 0);
2763 }
2764
2765 /////////////////////
2766@@ -169,15 +189,16 @@
2767 /////////////////////
2768 // Data
2769
2770- nux::VLayout* app_data_layout = new nux::VLayout();
2771- app_data_layout->SetSpaceBetweenChildren(16);
2772+ app_data_layout_ = new nux::VLayout();
2773+ app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
2774
2775 title_subtitle_layout_ = new nux::VLayout();
2776- title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
2777+ title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
2778
2779 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
2780 AddChild(title_.GetPointer());
2781 title_->SetLines(-1);
2782+ title_->SetScale(scale);
2783 title_->SetFont(style.title_font().c_str());
2784 title_->mouse_click.connect(on_mouse_down);
2785 title_subtitle_layout_->AddView(title_.GetPointer(), 1);
2786@@ -188,12 +209,13 @@
2787 AddChild(subtitle_.GetPointer());
2788 subtitle_->SetFont(style.subtitle_size_font().c_str());
2789 subtitle_->SetLines(-1);
2790+ subtitle_->SetScale(scale);
2791 subtitle_->mouse_click.connect(on_mouse_down);
2792 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);
2793 }
2794
2795- nux::VLayout* app_updated_copywrite_layout = new nux::VLayout();
2796- app_updated_copywrite_layout->SetSpaceBetweenChildren(8);
2797+ app_updated_copywrite_layout_ = new nux::VLayout();
2798+ app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale));
2799
2800 if (!app_preview_model->license.Get().empty())
2801 {
2802@@ -201,8 +223,9 @@
2803 AddChild(license_.GetPointer());
2804 license_->SetFont(style.app_license_font().c_str());
2805 license_->SetLines(-1);
2806+ license_->SetScale(scale);
2807 license_->mouse_click.connect(on_mouse_down);
2808- app_updated_copywrite_layout->AddView(license_.GetPointer(), 1);
2809+ app_updated_copywrite_layout_->AddView(license_.GetPointer(), 1);
2810 }
2811
2812 if (!app_preview_model->last_update.Get().empty())
2813@@ -213,8 +236,9 @@
2814 last_update_ = new StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION);
2815 AddChild(last_update_.GetPointer());
2816 last_update_->SetFont(style.app_last_update_font().c_str());
2817+ last_update_->SetScale(scale);
2818 last_update_->mouse_click.connect(on_mouse_down);
2819- app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1);
2820+ app_updated_copywrite_layout_->AddView(last_update_.GetPointer(), 1);
2821 }
2822
2823 if (!app_preview_model->copyright.Get().empty())
2824@@ -223,18 +247,19 @@
2825 AddChild(copywrite_.GetPointer());
2826 copywrite_->SetFont(style.app_copywrite_font().c_str());
2827 copywrite_->SetLines(-1);
2828+ copywrite_->SetScale(scale);
2829 copywrite_->mouse_click.connect(on_mouse_down);
2830- app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1);
2831+ app_updated_copywrite_layout_->AddView(copywrite_.GetPointer(), 1);
2832 }
2833
2834- app_data_layout->AddLayout(title_subtitle_layout_);
2835- app_data_layout->AddLayout(app_updated_copywrite_layout);
2836+ app_data_layout_->AddLayout(title_subtitle_layout_);
2837+ app_data_layout_->AddLayout(app_updated_copywrite_layout_);
2838
2839 // buffer space
2840 /////////////////////
2841
2842- main_app_info->AddLayout(icon_layout, 0);
2843- main_app_info->AddLayout(app_data_layout, 1);
2844+ main_app_info_->AddLayout(icon_layout_, 0);
2845+ main_app_info_->AddLayout(app_data_layout_, 1);
2846 /////////////////////
2847
2848 /////////////////////
2849@@ -243,9 +268,9 @@
2850 app_info->EnableHorizontalScrollBar(false);
2851 app_info->mouse_click.connect(on_mouse_down);
2852
2853- nux::VLayout* app_info_layout = new nux::VLayout();
2854- app_info_layout->SetSpaceBetweenChildren(12);
2855- app_info->SetLayout(app_info_layout);
2856+ app_info_layout_ = new nux::VLayout();
2857+ app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale));
2858+ app_info->SetLayout(app_info_layout_);
2859
2860 if (!preview_model_->description.Get().empty())
2861 {
2862@@ -256,36 +281,36 @@
2863 description_->SetLines(-style.GetDescriptionLineCount());
2864 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
2865 description_->mouse_click.connect(on_mouse_down);
2866- app_info_layout->AddView(description_.GetPointer());
2867+ app_info_layout_->AddView(description_.GetPointer());
2868 }
2869
2870 if (!preview_model_->GetInfoHints().empty())
2871 {
2872- preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
2873+ preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
2874 AddChild(preview_info_hints_.GetPointer());
2875 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
2876- app_info_layout->AddView(preview_info_hints_.GetPointer());
2877+ app_info_layout_->AddView(preview_info_hints_.GetPointer());
2878 }
2879 /////////////////////
2880
2881 /////////////////////
2882 // Actions
2883 action_buttons_.clear();
2884- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
2885- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
2886+ actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
2887+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
2888 ///////////////////
2889
2890- full_data_layout_->AddLayout(main_app_info, 0);
2891+ full_data_layout_->AddLayout(main_app_info_, 0);
2892 full_data_layout_->AddView(app_info, 1);
2893- full_data_layout_->AddLayout(actions_layout, 0);
2894+ full_data_layout_->AddLayout(actions_layout_, 0);
2895 /////////////////////
2896-
2897- image_data_layout->AddView(image_.GetPointer(), 0);
2898- image_data_layout->AddLayout(full_data_layout_, 1);
2899+
2900+ image_data_layout_->AddView(image_.GetPointer(), 0);
2901+ image_data_layout_->AddLayout(full_data_layout_, 1);
2902
2903 mouse_click.connect(on_mouse_down);
2904
2905- SetLayout(image_data_layout);
2906+ SetLayout(image_data_layout_);
2907 }
2908
2909 void ApplicationPreview::PreLayoutManagement()
2910@@ -296,12 +321,16 @@
2911
2912 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
2913
2914- if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
2915- geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
2916+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale)
2917+ - style.GetDetailsLeftMargin().CP(scale)
2918+ - style.GetDetailsRightMargin().CP(scale);
2919+ if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
2920+ geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
2921+
2922 image_->SetMinMaxSize(geo_art.width, geo_art.height);
2923
2924- int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
2925- int top_app_info_max_width = MAX(0, details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails());
2926+ int details_width = std::max(0, content_width - geo_art.width);
2927+ int top_app_info_max_width = std::max(0, details_width - style.GetAppIconAreaWidth().CP(scale) - style.GetSpaceBetweenIconAndDetails().CP(scale));
2928
2929 if (title_) { title_->SetMaximumWidth(top_app_info_max_width); }
2930 if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); }
2931@@ -310,14 +339,74 @@
2932 if (copywrite_) { copywrite_->SetMaximumWidth(top_app_info_max_width); }
2933 if (description_) { description_->SetMaximumWidth(details_width); }
2934
2935+ int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
2936+ int button_h = style.GetActionButtonHeight().CP(scale);
2937+
2938 for (nux::AbstractButton* button : action_buttons_)
2939- {
2940- button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
2941- }
2942+ button->SetMinMaxSize(button_w, button_h);
2943
2944 Preview::PreLayoutManagement();
2945 }
2946
2947+void ApplicationPreview::UpdateScale(double scale)
2948+{
2949+ Preview::UpdateScale(scale);
2950+
2951+ previews::Style& style = dash::previews::Style::Instance();
2952+
2953+ if (app_icon_)
2954+ {
2955+ app_icon_->SetSize(ICON_SIZE.CP(scale));
2956+ app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
2957+ app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
2958+ app_icon_->ReLoadIcon();
2959+ }
2960+
2961+ if (license_)
2962+ license_->SetScale(scale);
2963+ if (last_update_)
2964+ last_update_->SetScale(scale);
2965+ if (copywrite_)
2966+ copywrite_->SetScale(scale);
2967+
2968+ if (app_rating_)
2969+ {
2970+ app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
2971+ app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
2972+ app_rating_->scale = scale;
2973+ }
2974+
2975+ if (image_data_layout_)
2976+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
2977+
2978+ if (full_data_layout_)
2979+ {
2980+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
2981+ full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
2982+ }
2983+
2984+ if (main_app_info_)
2985+ main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale));
2986+
2987+ if (icon_layout_)
2988+ icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale));
2989+
2990+ if (app_data_layout_)
2991+ app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
2992+
2993+ if (title_subtitle_layout_)
2994+ title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
2995+
2996+ if (app_info_layout_)
2997+ app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale));
2998+
2999+ if (actions_layout_)
3000+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
3001+
3002+ if (app_updated_copywrite_layout_)
3003+ app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale));
3004+}
3005+
3006 } // namespace previews
3007 } // namespace dash
3008 } // namepsace unity
3009
3010=== modified file 'dash/previews/ApplicationPreview.h'
3011--- dash/previews/ApplicationPreview.h 2013-09-19 16:44:03 +0000
3012+++ dash/previews/ApplicationPreview.h 2014-08-26 13:46:04 +0000
3013@@ -54,9 +54,17 @@
3014 virtual void PreLayoutManagement();
3015
3016 virtual void SetupViews();
3017+ void UpdateScale(double scale) override;
3018
3019 protected:
3020 nux::VLayout* title_subtitle_layout_;
3021+ nux::HLayout* image_data_layout_;
3022+ nux::HLayout* main_app_info_;
3023+ nux::VLayout* icon_layout_;
3024+ nux::VLayout* app_data_layout_;
3025+ nux::VLayout* app_updated_copywrite_layout_;
3026+ nux::VLayout* app_info_layout_;
3027+ nux::Layout* actions_layout_;
3028
3029 nux::ObjectPtr<IconTexture> app_icon_;
3030 nux::ObjectPtr<PreviewRatingsWidget> app_rating_;
3031
3032=== modified file 'dash/previews/ErrorPreview.cpp'
3033--- dash/previews/ErrorPreview.cpp 2013-09-19 16:44:03 +0000
3034+++ dash/previews/ErrorPreview.cpp 2014-08-26 13:46:04 +0000
3035@@ -50,6 +50,13 @@
3036 {
3037 nux::logging::Logger logger("unity.dash.previews.ErrorPreview");
3038
3039+const RawPixel TITLE_DATA_MAX_SIZE = 76_em;
3040+const RawPixel TITLE_DATA_CHILDREN_SPACE = 10_em;
3041+const RawPixel LINE_SPACING = 10_em;
3042+const RawPixel TITLE_MAX_WIDTH = 480_em;
3043+const RawPixel CHILDREN_SPACE = 5_em;
3044+const RawPixel BUTTONS_DATA_SPACE = 20_em;
3045+const RawPixel INTRO_SPACE = 110_em;
3046 }
3047
3048 const std::string ErrorPreview::CANCEL_ACTION = "cancel";
3049@@ -73,6 +80,9 @@
3050 {
3051 PaymentPreview::SetupBackground();
3052 SetupViews();
3053+
3054+ UpdateScale(scale);
3055+ scale.changed.connect(sigc::mem_fun(this, &ErrorPreview::UpdateScale));
3056 }
3057
3058 ErrorPreview::~ErrorPreview()
3059@@ -114,6 +124,7 @@
3060 for (dash::Preview::ActionPtr action : preview_model_->GetActions())
3061 {
3062 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);
3063+ button->scale = scale();
3064 button->activate.connect(sigc::mem_fun(this, &ErrorPreview::OnActionActivated));
3065 buttons_map_.insert(std::make_pair(action->id, button));
3066 }
3067@@ -123,8 +134,8 @@
3068 {
3069 previews::Style& style = dash::previews::Style::Instance();
3070 nux::VLayout* title_data_layout = new nux::VLayout();
3071- title_data_layout->SetMaximumHeight(76);
3072- title_data_layout->SetSpaceBetweenChildren(10);
3073+ title_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale));
3074+ title_data_layout->SetSpaceBetweenChildren(TITLE_DATA_CHILDREN_SPACE.CP(scale));
3075
3076 title_ = new StaticCairoText(
3077 preview_model_->title.Get(), true,
3078@@ -133,7 +144,7 @@
3079 title_->SetFont(style.payment_title_font());
3080 title_->SetLines(-1);
3081 title_->SetFont(style.title_font());
3082- title_->SetMaximumWidth(480);
3083+ title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
3084 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
3085 title_data_layout->AddView(title_.GetPointer(), 1);
3086
3087@@ -151,9 +162,9 @@
3088 {
3089 previews::Style& style = dash::previews::Style::Instance();
3090 nux::VLayout *prize_data_layout = new nux::VLayout();
3091- prize_data_layout->SetMaximumHeight(76);
3092- prize_data_layout->SetSpaceBetweenChildren(5);
3093- prize_data_layout->SetPadding(0, 10, 0, 0);
3094+ prize_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale));
3095+ prize_data_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
3096+ prize_data_layout->SetPadding(0, TITLE_DATA_CHILDREN_SPACE.CP(scale), 0, 0);
3097
3098 purchase_prize_ = new StaticCairoText(
3099 error_preview_model_->purchase_prize.Get(), true,
3100@@ -188,16 +199,17 @@
3101 nux::HLayout *intro_layout = new nux::HLayout();
3102 nux::VLayout *icon_layout = new nux::VLayout();
3103
3104- icon_layout->SetPadding(78, 10, 90, 43);
3105- intro_layout->SetPadding(75, 20, 0, 0);
3106- intro_layout->SetSpaceBetweenChildren(5);
3107+ icon_layout->SetPadding((78_em).CP(scale), (10_em).CP(scale), (90_em).CP(scale), (43_em).CP(scale));
3108+ intro_layout->SetPadding((75_em).CP(scale), (20_em).CP(scale), 0, 0);
3109+ intro_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
3110
3111 intro_ = new StaticCairoText(
3112 error_preview_model_->header.Get(), true,
3113 NUX_TRACKER_LOCATION);
3114 intro_->SetFont(style.payment_intro_font().c_str());
3115+ intro_->SetScale(scale);
3116 intro_->SetLines(-3);
3117- intro_->SetLineSpacing(10);
3118+ intro_->SetLineSpacing(LINE_SPACING.CP(scale));
3119 intro_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
3120
3121 intro_layout->AddView(intro_.GetPointer());//, 0, nux::MINOR_POSITION_CENTER);
3122@@ -220,9 +232,9 @@
3123 actions_buffer_h->AddSpace(0, 1);
3124
3125 nux::HLayout* buttons_data_layout = new TabIteratorHLayout(tab_iterator_);
3126- buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());
3127+ buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
3128
3129- buttons_data_layout->AddSpace(20, 1);
3130+ buttons_data_layout->AddSpace(BUTTONS_DATA_SPACE.CP(scale), 1);
3131 if(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer()){
3132 ActionButton* button = (ActionButton*)buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer();
3133 buttons_data_layout->AddView(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer(),
3134@@ -249,11 +261,11 @@
3135
3136 previews::Style& style = dash::previews::Style::Instance();
3137
3138- int width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
3139+ int width = std::max(0, geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
3140
3141 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }
3142 if(header_layout_) { header_layout_->SetMaximumWidth(width); }
3143- if(intro_) { intro_->SetMaximumWidth(width - 110); }
3144+ if(intro_) { intro_->SetMaximumWidth(width - INTRO_SPACE.CP(scale)); }
3145 if(footer_layout_) { footer_layout_->SetMaximumWidth(width); }
3146
3147 Preview::PreLayoutManagement();
3148@@ -274,6 +286,33 @@
3149 PaymentPreview::SetupViews();
3150 }
3151
3152+void ErrorPreview::UpdateScale(double scale)
3153+{
3154+ if (intro_)
3155+ intro_->SetScale(scale);
3156+
3157+ if (purchase_hint_)
3158+ purchase_hint_->SetScale(scale);
3159+ if (purchase_prize_)
3160+ purchase_prize_->SetScale(scale);
3161+ if (purchase_type_)
3162+ purchase_type_->SetScale(scale);
3163+
3164+ if (warning_texture_)
3165+ {
3166+ previews::Style& style = dash::previews::Style::Instance();
3167+ RawPixel width(style.GetWarningIcon()->GetWidth());
3168+ RawPixel height(style.GetWarningIcon()->GetHeight());
3169+
3170+ warning_texture_->SetSize(std::max(width, height).CP(scale));
3171+ warning_texture_->ReLoadIcon();
3172+ }
3173+
3174+ if (title_)
3175+ title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
3176+
3177+ Preview::UpdateScale(scale);
3178+}
3179
3180 }
3181 }
3182
3183=== modified file 'dash/previews/ErrorPreview.h'
3184--- dash/previews/ErrorPreview.h 2013-09-19 16:44:03 +0000
3185+++ dash/previews/ErrorPreview.h 2014-08-26 13:46:04 +0000
3186@@ -94,6 +94,8 @@
3187 void PreLayoutManagement();
3188
3189 virtual void SetupViews();
3190+ virtual void UpdateScale(double scale);
3191+
3192 // content elements
3193 nux::ObjectPtr<CoverArt> image_;
3194 nux::ObjectPtr<StaticCairoText> intro_;
3195
3196=== modified file 'dash/previews/GenericPreview.cpp'
3197--- dash/previews/GenericPreview.cpp 2013-11-19 18:48:35 +0000
3198+++ dash/previews/GenericPreview.cpp 2014-08-26 13:46:04 +0000
3199@@ -40,6 +40,13 @@
3200 {
3201 namespace previews
3202 {
3203+
3204+namespace
3205+{
3206+ const RawPixel CHILDREN_SPACE = 12_em;
3207+ const RawPixel FULL_CHILDREN_SPACE = 16_em;
3208+}
3209+
3210 DECLARE_LOGGER(logger, "unity.dash.preview.generic");
3211
3212 class DetailsScrollView : public nux::ScrollView
3213@@ -57,8 +64,14 @@
3214
3215 GenericPreview::GenericPreview(dash::Preview::Ptr preview_model)
3216 : Preview(preview_model)
3217+, image_data_layout_(nullptr)
3218+, preview_info_layout_(nullptr)
3219+, preview_data_layout_(nullptr)
3220+, actions_layout_(nullptr)
3221 {
3222 SetupViews();
3223+ UpdateScale(scale);
3224+ scale.changed.connect(sigc::mem_fun(this, &GenericPreview::UpdateScale));
3225 }
3226
3227 GenericPreview::~GenericPreview()
3228@@ -113,8 +126,8 @@
3229
3230 auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
3231
3232- nux::HLayout* image_data_layout = new nux::HLayout();
3233- image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
3234+ image_data_layout_ = new nux::HLayout();
3235+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
3236
3237 /////////////////////
3238 // Image
3239@@ -126,21 +139,22 @@
3240 /////////////////////
3241 // Data Panel
3242 full_data_layout_ = new nux::VLayout();
3243- full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());
3244- full_data_layout_->SetSpaceBetweenChildren(16);
3245+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0,
3246+ style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
3247+ full_data_layout_->SetSpaceBetweenChildren(FULL_CHILDREN_SPACE.CP(scale));
3248
3249 /////////////////////
3250 // Data
3251
3252- nux::VLayout* preview_data_layout = new nux::VLayout();
3253- preview_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
3254+ preview_data_layout_ = new nux::VLayout();
3255+ preview_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
3256
3257 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
3258 AddChild(title_.GetPointer());
3259 title_->SetLines(-1);
3260 title_->SetFont(style.title_font().c_str());
3261 title_->mouse_click.connect(on_mouse_down);
3262- preview_data_layout->AddView(title_.GetPointer(), 1);
3263+ preview_data_layout_->AddView(title_.GetPointer(), 1);
3264
3265 if (!preview_model_->subtitle.Get().empty())
3266 {
3267@@ -149,7 +163,7 @@
3268 subtitle_->SetLines(-1);
3269 subtitle_->SetFont(style.subtitle_size_font().c_str());
3270 subtitle_->mouse_click.connect(on_mouse_down);
3271- preview_data_layout->AddView(subtitle_.GetPointer(), 1);
3272+ preview_data_layout_->AddView(subtitle_.GetPointer(), 1);
3273 }
3274 /////////////////////
3275
3276@@ -159,9 +173,9 @@
3277 preview_info->EnableHorizontalScrollBar(false);
3278 preview_info->mouse_click.connect(on_mouse_down);
3279
3280- nux::VLayout* preview_info_layout = new nux::VLayout();
3281- preview_info_layout->SetSpaceBetweenChildren(12);
3282- preview_info->SetLayout(preview_info_layout);
3283+ preview_info_layout_ = new nux::VLayout();
3284+ preview_info_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
3285+ preview_info->SetLayout(preview_info_layout_);
3286
3287 if (!preview_model_->description.Get().empty())
3288 {
3289@@ -172,37 +186,37 @@
3290 description_->SetLines(-style.GetDescriptionLineCount());
3291 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
3292 description_->mouse_click.connect(on_mouse_down);
3293- preview_info_layout->AddView(description_.GetPointer());
3294+ preview_info_layout_->AddView(description_.GetPointer());
3295 }
3296
3297 if (!preview_model_->GetInfoHints().empty())
3298 {
3299- preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
3300+ preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
3301 AddChild(preview_info_hints_.GetPointer());
3302 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
3303- preview_info_layout->AddView(preview_info_hints_.GetPointer());
3304+ preview_info_layout_->AddView(preview_info_hints_.GetPointer());
3305 }
3306 /////////////////////
3307
3308 /////////////////////
3309 // Actions
3310 action_buttons_.clear();
3311- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
3312- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
3313+ actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
3314+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
3315 ///////////////////
3316
3317- full_data_layout_->AddLayout(preview_data_layout, 0);
3318+ full_data_layout_->AddLayout(preview_data_layout_, 0);
3319 full_data_layout_->AddView(preview_info, 1);
3320- full_data_layout_->AddView(actions_layout, 0);
3321+ full_data_layout_->AddView(actions_layout_, 0);
3322 /////////////////////
3323
3324- image_data_layout->AddView(image_.GetPointer(), 0);
3325+ image_data_layout_->AddView(image_.GetPointer(), 0);
3326
3327- image_data_layout->AddLayout(full_data_layout_, 1);
3328+ image_data_layout_->AddLayout(full_data_layout_, 1);
3329
3330 mouse_click.connect(on_mouse_down);
3331
3332- SetLayout(image_data_layout);
3333+ SetLayout(image_data_layout_);
3334 }
3335
3336 void GenericPreview::PreLayoutManagement()
3337@@ -213,24 +227,60 @@
3338
3339 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
3340
3341- if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
3342- geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
3343+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale)
3344+ - style.GetDetailsLeftMargin().CP(scale)
3345+ - style.GetDetailsRightMargin().CP(scale);
3346+
3347+ if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
3348+ geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
3349+
3350 image_->SetMinMaxSize(geo_art.width, geo_art.height);
3351-
3352- int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
3353+ int details_width = std::max(0, content_width - geo_art.width);
3354
3355 if (title_) { title_->SetMaximumWidth(details_width); }
3356 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
3357 if (description_) { description_->SetMaximumWidth(details_width); }
3358
3359+ int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
3360+ int button_h = style.GetActionButtonHeight().CP(scale);
3361+
3362 for (nux::AbstractButton* button : action_buttons_)
3363- {
3364- button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
3365- }
3366+ button->SetMinMaxSize(button_w, button_h);
3367
3368 Preview::PreLayoutManagement();
3369 }
3370
3371+void GenericPreview::UpdateScale(double scale)
3372+{
3373+ if (image_)
3374+ image_->scale = scale;
3375+
3376+ if (preview_info_hints_)
3377+ preview_info_hints_->scale = scale;
3378+
3379+ previews::Style& style = dash::previews::Style::Instance();
3380+
3381+ if (full_data_layout_)
3382+ {
3383+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
3384+ full_data_layout_->SetSpaceBetweenChildren(FULL_CHILDREN_SPACE.CP(scale));
3385+ }
3386+
3387+ if (image_data_layout_)
3388+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
3389+
3390+ if (preview_info_layout_)
3391+ preview_info_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
3392+
3393+ if (preview_data_layout_)
3394+ preview_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
3395+
3396+ if (actions_layout_)
3397+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
3398+
3399+ Preview::UpdateScale(scale);
3400+}
3401+
3402
3403 }
3404 }
3405
3406=== modified file 'dash/previews/GenericPreview.h'
3407--- dash/previews/GenericPreview.h 2013-09-19 16:44:03 +0000
3408+++ dash/previews/GenericPreview.h 2014-08-26 13:46:04 +0000
3409@@ -52,6 +52,13 @@
3410 virtual void PreLayoutManagement();
3411
3412 virtual void SetupViews();
3413+ virtual void UpdateScale(double scale);
3414+
3415+ nux::HLayout* image_data_layout_;
3416+ nux::VLayout* preview_info_layout_;
3417+ nux::VLayout* preview_data_layout_;
3418+ nux::Layout* actions_layout_;
3419+
3420 };
3421
3422 }
3423
3424=== modified file 'dash/previews/MoviePreview.cpp'
3425--- dash/previews/MoviePreview.cpp 2013-11-19 18:48:35 +0000
3426+++ dash/previews/MoviePreview.cpp 2014-08-26 13:46:04 +0000
3427@@ -41,6 +41,13 @@
3428 {
3429 namespace previews
3430 {
3431+
3432+namespace
3433+{
3434+ const RawPixel CHILDREN_SPACE = 16_em;
3435+ const RawPixel PREVIEW_INFO_CHILDREN_SPACE = 12_em;
3436+}
3437+
3438 DECLARE_LOGGER(logger, "unity.dash.preview.movie");
3439
3440 class DetailsScrollView : public nux::ScrollView
3441@@ -58,6 +65,9 @@
3442
3443 MoviePreview::MoviePreview(dash::Preview::Ptr preview_model)
3444 : Preview(preview_model)
3445+, image_data_layout_(nullptr)
3446+, preview_info_layout_(nullptr)
3447+, actions_layout_(nullptr)
3448 {
3449 SetupViews();
3450 }
3451@@ -123,8 +133,8 @@
3452
3453 auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
3454
3455- nux::HLayout* image_data_layout = new nux::HLayout();
3456- image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
3457+ image_data_layout_ = new nux::HLayout();
3458+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
3459
3460 /////////////////////
3461 // Image
3462@@ -136,8 +146,8 @@
3463 /////////////////////
3464 // Data Panel
3465 full_data_layout_ = new nux::VLayout();
3466- full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());
3467- full_data_layout_->SetSpaceBetweenChildren(16);
3468+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
3469+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
3470
3471 /////////////////////
3472 // Data
3473@@ -148,6 +158,7 @@
3474 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
3475 AddChild(title_.GetPointer());
3476 title_->SetLines(-1);
3477+ title_->SetScale(scale);
3478 title_->SetFont(style.title_font().c_str());
3479 title_->mouse_click.connect(on_mouse_down);
3480 app_data_layout->AddView(title_.GetPointer(), 1);
3481@@ -157,6 +168,7 @@
3482 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
3483 AddChild(subtitle_.GetPointer());
3484 subtitle_->SetLines(-1);
3485+ subtitle_->SetScale(scale);
3486 subtitle_->SetFont(style.subtitle_size_font().c_str());
3487 subtitle_->mouse_click.connect(on_mouse_down);
3488 app_data_layout->AddView(subtitle_.GetPointer(), 1);
3489@@ -166,8 +178,8 @@
3490 if (movie_preview_model->rating >= 0) {
3491 rating_ = new PreviewRatingsWidget();
3492 AddChild(rating_.GetPointer());
3493- rating_->SetMaximumHeight(style.GetRatingWidgetHeight());
3494- rating_->SetMinimumHeight(style.GetRatingWidgetHeight());
3495+ rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
3496+ rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
3497 rating_->SetRating(movie_preview_model->rating);
3498 rating_->SetReviews(movie_preview_model->num_ratings);
3499 rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
3500@@ -179,16 +191,17 @@
3501 preview_info->EnableHorizontalScrollBar(false);
3502 preview_info->mouse_click.connect(on_mouse_down);
3503
3504- nux::VLayout* preview_info_layout = new nux::VLayout();
3505- preview_info_layout->SetSpaceBetweenChildren(12);
3506- preview_info->SetLayout(preview_info_layout);
3507+ preview_info_layout_ = new nux::VLayout();
3508+ preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE.CP(scale));
3509+ preview_info->SetLayout(preview_info_layout_);
3510
3511 if (!preview_model_->GetInfoHints().empty())
3512 {
3513 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
3514+ preview_info_hints_->scale = scale();
3515 AddChild(preview_info_hints_.GetPointer());
3516 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
3517- preview_info_layout->AddView(preview_info_hints_.GetPointer(), 0);
3518+ preview_info_layout_->AddView(preview_info_hints_.GetPointer(), 0);
3519 }
3520
3521 if (!preview_model_->description.Get().empty())
3522@@ -196,34 +209,35 @@
3523 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
3524 AddChild(description_.GetPointer());
3525 description_->SetFont(style.description_font().c_str());
3526+ description_->SetScale(scale);
3527 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
3528 description_->SetLines(-style.GetDescriptionLineCount());
3529 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
3530 description_->mouse_click.connect(on_mouse_down);
3531- preview_info_layout->AddView(description_.GetPointer());
3532+ preview_info_layout_->AddView(description_.GetPointer());
3533 }
3534 /////////////////////
3535
3536 /////////////////////
3537 // Actions
3538 action_buttons_.clear();
3539- nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
3540- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
3541+ actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
3542+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
3543 ///////////////////
3544
3545 full_data_layout_->AddLayout(app_data_layout, 0);
3546 if (rating_ != NULL)
3547 full_data_layout_->AddView(rating_.GetPointer(), 0);
3548 full_data_layout_->AddView(preview_info, 1);
3549- full_data_layout_->AddView(actions_layout, 0);
3550+ full_data_layout_->AddView(actions_layout_, 0);
3551 /////////////////////
3552
3553- image_data_layout->AddView(image_.GetPointer(), 0);
3554- image_data_layout->AddLayout(full_data_layout_, 1);
3555+ image_data_layout_->AddView(image_.GetPointer(), 0);
3556+ image_data_layout_->AddLayout(full_data_layout_, 1);
3557
3558 mouse_click.connect(on_mouse_down);
3559
3560- SetLayout(image_data_layout);
3561+ SetLayout(image_data_layout_);
3562 }
3563
3564
3565@@ -235,11 +249,13 @@
3566
3567 nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height);
3568
3569- if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
3570- geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
3571+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
3572+ if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
3573+ geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
3574+
3575 image_->SetMinMaxSize(geo_art.width, geo_art.height);
3576
3577- int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
3578+ int details_width = std::max(0, geo.width - geo_art.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
3579
3580 if (title_) { title_->SetMaximumWidth(details_width); }
3581 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
3582@@ -247,12 +263,46 @@
3583
3584 for (nux::AbstractButton* button : action_buttons_)
3585 {
3586- button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
3587+ button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale));
3588 }
3589
3590 Preview::PreLayoutManagement();
3591 }
3592
3593+void MoviePreview::UpdateScale(double scale)
3594+{
3595+ Preview::UpdateScale(scale);
3596+
3597+ if (image_)
3598+ image_->scale = scale;
3599+
3600+ if (preview_info_hints_)
3601+ preview_info_hints_->scale = scale;
3602+
3603+ previews::Style& style = dash::previews::Style::Instance();
3604+
3605+ if (full_data_layout_)
3606+ {
3607+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
3608+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
3609+ }
3610+
3611+ if (image_data_layout_)
3612+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
3613+
3614+ if (rating_)
3615+ {
3616+ rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
3617+ rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
3618+ }
3619+
3620+ if (preview_info_layout_)
3621+ preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE);
3622+
3623+ if (actions_layout_)
3624+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
3625+}
3626+
3627 } // namespace previews
3628 } // namespace dash
3629 } // namespace unity
3630
3631=== modified file 'dash/previews/MoviePreview.h'
3632--- dash/previews/MoviePreview.h 2013-09-19 16:44:03 +0000
3633+++ dash/previews/MoviePreview.h 2014-08-26 13:46:04 +0000
3634@@ -55,9 +55,14 @@
3635 virtual void OnNavigateInComplete();
3636
3637 virtual void SetupViews();
3638-
3639+ virtual void UpdateScale(double scale);
3640+
3641 protected:
3642 nux::ObjectPtr<PreviewRatingsWidget> rating_;
3643+
3644+ nux::HLayout* image_data_layout_;
3645+ nux::VLayout* preview_info_layout_;
3646+ nux::Layout* actions_layout_;
3647 };
3648
3649 }
3650
3651=== modified file 'dash/previews/MusicPaymentPreview.cpp'
3652--- dash/previews/MusicPaymentPreview.cpp 2013-09-19 16:44:03 +0000
3653+++ dash/previews/MusicPaymentPreview.cpp 2014-08-26 13:46:04 +0000
3654@@ -49,6 +49,22 @@
3655 {
3656 nux::logging::Logger logger("unity.dash.previews.payment.preview.music");
3657
3658+const RawPixel DATA_MAX_HEIGHT = 76_em;
3659+const RawPixel TITLE_CHILDREN_SPACE = 10_em;
3660+const RawPixel PRIZE_CHILDREN_SPACE = 5_em;
3661+const RawPixel TITLE_MAX_WIDTH = 480_em;
3662+const RawPixel INTRO_MIN_HEIGHT = 50_em;
3663+const RawPixel FORM_MIN_HEIGHT = 107_em;
3664+const RawPixel FORM_PADDING = 20_em;
3665+const RawPixel LABELS_CHILDREN_SPACE = 18_em;
3666+const RawPixel PASSWORD_MIN_HEIGHT = 40_em;
3667+const RawPixel PASSWORD_MIN_WIDTH = 240_em;
3668+const RawPixel ACTIONS_CHILDREN_SPACE_MAX = 16_em;
3669+const RawPixel ACTIONS_CHILDREN_SPACE_MIN = 8_em;
3670+const RawPixel BUTTONS_SPACE = 20_em;
3671+const RawPixel HEADER_CHILDREN_SPACE = 10_em;
3672+const RawPixel HEADER_MAX_SIZE = 76_em;
3673+const RawPixel BODY_CHILDREN_SPACE = 20_em;
3674 }
3675
3676 // static string definitions
3677@@ -77,6 +93,7 @@
3678 {
3679 SetupViews();
3680 PaymentPreview::SetupBackground();
3681+ UpdateScale(scale);
3682 }
3683
3684 std::string MusicPaymentPreview::GetName() const
3685@@ -127,6 +144,7 @@
3686 || MusicPaymentPreview::FORGOT_PASSWORD_ACTION == action_id)
3687 {
3688 nux::ObjectPtr<ActionLink> link = this->CreateLink(action);
3689+ link->scale = scale();
3690 link->activate.connect(sigc::mem_fun(this,
3691 &MusicPaymentPreview::OnActionLinkActivated));
3692
3693@@ -137,6 +155,7 @@
3694 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);
3695 button->activate.connect(sigc::mem_fun(this,
3696 &MusicPaymentPreview::OnActionActivated));
3697+ button->scale = scale();
3698
3699 buttons_map_.insert(std::make_pair(action->id, button));
3700 }
3701@@ -148,8 +167,8 @@
3702 {
3703 previews::Style& style = dash::previews::Style::Instance();
3704 nux::VLayout* title_data_layout = new nux::VLayout();
3705- title_data_layout->SetMaximumHeight(76);
3706- title_data_layout->SetSpaceBetweenChildren(10);
3707+ title_data_layout->SetMaximumHeight(DATA_MAX_HEIGHT.CP(scale));
3708+ title_data_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
3709
3710 title_ = new StaticCairoText(
3711 preview_model_->title.Get(), true,
3712@@ -157,8 +176,9 @@
3713
3714 title_->SetFont(style.payment_title_font());
3715 title_->SetLines(-1);
3716+ title_->SetScale(scale);
3717 title_->SetFont(style.title_font());
3718- title_->SetMaximumWidth(480);
3719+ title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
3720 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
3721 title_data_layout->AddView(title_.GetPointer(), 1);
3722
3723@@ -166,6 +186,7 @@
3724 preview_model_->subtitle.Get(), true,
3725 NUX_TRACKER_LOCATION);
3726 subtitle_->SetLines(-1);
3727+ subtitle_->SetScale(scale);
3728 subtitle_->SetFont(style.payment_subtitle_font());
3729 title_data_layout->AddView(subtitle_.GetPointer(), 1);
3730 title_data_layout->AddSpace(1, 1);
3731@@ -176,14 +197,15 @@
3732 {
3733 previews::Style& style = dash::previews::Style::Instance();
3734 nux::VLayout *prize_data_layout = new nux::VLayout();
3735- prize_data_layout->SetMaximumHeight(76);
3736- prize_data_layout->SetSpaceBetweenChildren(5);
3737- prize_data_layout->SetPadding(0, 10, 0, 0);
3738+ prize_data_layout->SetMaximumHeight(DATA_MAX_HEIGHT.CP(scale));
3739+ prize_data_layout->SetSpaceBetweenChildren(PRIZE_CHILDREN_SPACE.CP(scale));
3740+ prize_data_layout->SetPadding(0, TITLE_CHILDREN_SPACE.CP(scale), 0, 0);
3741
3742 purchase_prize_ = new StaticCairoText(
3743 payment_preview_model_->purchase_prize.Get(), true,
3744 NUX_TRACKER_LOCATION);
3745 purchase_prize_->SetLines(-1);
3746+ purchase_prize_->SetScale(scale);
3747 purchase_prize_->SetFont(style.payment_prize_title_font());
3748 prize_data_layout->AddView(purchase_prize_.GetPointer(), 1,
3749 nux::MINOR_POSITION_END);
3750@@ -192,6 +214,7 @@
3751 _("Ubuntu One best offer"),
3752 true, NUX_TRACKER_LOCATION);
3753 purchase_hint_->SetLines(-1);
3754+ purchase_hint_->SetScale(scale);
3755 purchase_hint_->SetFont(style.payment_prize_subtitle_font());
3756 prize_data_layout->AddView(purchase_hint_.GetPointer(), 1,
3757 nux::MINOR_POSITION_END);
3758@@ -200,6 +223,7 @@
3759 payment_preview_model_->purchase_type.Get(), true,
3760 NUX_TRACKER_LOCATION);
3761 purchase_type_->SetLines(-1);
3762+ purchase_type_->SetScale(scale);
3763 purchase_type_->SetFont(style.payment_prize_subtitle_font());
3764 prize_data_layout->AddView(purchase_type_.GetPointer(), 1,
3765 nux::MINOR_POSITION_END);
3766@@ -210,31 +234,30 @@
3767 {
3768 previews::Style& style = dash::previews::Style::Instance();
3769 nux::VLayout *body_layout = new nux::VLayout();
3770- body_layout->SetSpaceBetweenChildren(20);
3771+ body_layout->SetSpaceBetweenChildren(BODY_CHILDREN_SPACE.CP(scale));
3772
3773 intro_ = new StaticCairoText(
3774 payment_preview_model_->header.Get(), true,
3775 NUX_TRACKER_LOCATION);
3776 intro_->SetFont(style.payment_intro_font());
3777- intro_->SetLineSpacing(10);
3778+ intro_->SetScale(scale);
3779+ intro_->SetLineSpacing(TITLE_CHILDREN_SPACE.CP(scale));
3780 intro_->SetLines(-style.GetDescriptionLineCount());
3781- intro_->SetMinimumHeight(50);
3782+ intro_->SetMinimumHeight(INTRO_MIN_HEIGHT.CP(scale));
3783
3784 form_layout_ = new nux::HLayout();
3785- form_layout_->SetSpaceBetweenChildren(10);
3786- form_layout_->SetMinimumHeight(107);
3787- form_layout_->SetLeftAndRightPadding(20);
3788- form_layout_->SetTopAndBottomPadding(10);
3789+ form_layout_->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
3790+ form_layout_->SetMinimumHeight(FORM_MIN_HEIGHT.CP(scale));
3791+ form_layout_->SetLeftAndRightPadding(FORM_PADDING.CP(scale));
3792+ form_layout_->SetTopAndBottomPadding(TITLE_CHILDREN_SPACE.CP(scale));
3793
3794 form_layout_->AddLayout(GetFormLabels(), 1, nux::MINOR_POSITION_END);
3795 form_layout_->AddLayout(GetFormFields(), 1, nux::MINOR_POSITION_END);
3796 form_layout_->AddLayout(GetFormActions(), 1, nux::MINOR_POSITION_END);
3797
3798-
3799 body_layout->AddView(intro_.GetPointer(), 1);
3800 body_layout->AddLayout(form_layout_.GetPointer(), 1);
3801
3802-
3803 return body_layout;
3804 }
3805
3806@@ -244,17 +267,18 @@
3807 nux::VLayout *labels_layout = new nux::VLayout();
3808 if (error_message_.empty())
3809 {
3810- labels_layout->SetSpaceBetweenChildren(18);
3811+ labels_layout->SetSpaceBetweenChildren(LABELS_CHILDREN_SPACE.CP(scale));
3812 }
3813 else
3814 {
3815- labels_layout->SetSpaceBetweenChildren(10);
3816+ labels_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
3817 }
3818
3819 email_label_ = new StaticCairoText(
3820 _("Ubuntu One email:"), true,
3821 NUX_TRACKER_LOCATION);
3822 email_label_->SetLines(-1);
3823+ email_label_->SetScale(scale);
3824 email_label_->SetFont(style.payment_form_labels_font());
3825 labels_layout->AddView(email_label_.GetPointer(), 0, nux::MINOR_POSITION_END);
3826
3827@@ -262,6 +286,7 @@
3828 _("Payment method:"), true,
3829 NUX_TRACKER_LOCATION);
3830 payment_label_->SetLines(-1);
3831+ payment_label_->SetScale(scale);
3832 payment_label_->SetFont(style.payment_form_labels_font());
3833 labels_layout->AddView(payment_label_.GetPointer(), 0, nux::MINOR_POSITION_END);
3834
3835@@ -269,8 +294,9 @@
3836 _("Ubuntu One password:"), true,
3837 NUX_TRACKER_LOCATION);
3838 password_label_->SetLines(-1);
3839+ password_label_->SetScale(scale);
3840 password_label_->SetFont(style.payment_form_labels_font());
3841- password_label_->SetMinimumHeight(40);
3842+ password_label_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale));
3843 labels_layout->AddView(password_label_.GetPointer(), 0, nux::MINOR_POSITION_END);
3844
3845 return labels_layout;
3846@@ -282,17 +308,18 @@
3847 nux::VLayout *fields_layout = new nux::VLayout();
3848 if (error_message_.empty())
3849 {
3850- fields_layout->SetSpaceBetweenChildren(18);
3851+ fields_layout->SetSpaceBetweenChildren(LABELS_CHILDREN_SPACE.CP(scale));
3852 }
3853 else
3854 {
3855- fields_layout->SetSpaceBetweenChildren(10);
3856+ fields_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
3857 }
3858
3859 email_ = new StaticCairoText(
3860 payment_preview_model_->email.Get(), true,
3861 NUX_TRACKER_LOCATION);
3862 email_->SetLines(-1);
3863+ email_->SetScale(scale);
3864 email_->SetFont(style.payment_form_data_font());
3865 fields_layout->AddView(email_.GetPointer(), 1,
3866 nux::MINOR_POSITION_START);
3867@@ -301,13 +328,14 @@
3868 payment_preview_model_->payment_method.Get(), true,
3869 NUX_TRACKER_LOCATION);
3870 payment_->SetLines(-1);
3871+ payment_->SetScale(scale);
3872 payment_->SetFont(style.payment_form_data_font());
3873 fields_layout->AddView(payment_.GetPointer(), 1,
3874 nux::MINOR_POSITION_START);
3875
3876 password_entry_ = new TextInput();
3877- password_entry_->SetMinimumHeight(40);
3878- password_entry_->SetMinimumWidth(240);
3879+ password_entry_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale));
3880+ password_entry_->SetMinimumWidth(PASSWORD_MIN_WIDTH.CP(scale));
3881 password_entry_->input_hint = _("Password");
3882
3883 fields_layout->AddView(password_entry_.GetPointer(),
3884@@ -322,6 +350,7 @@
3885 StaticCairoText* error = new StaticCairoText(
3886 _("Wrong password"), true, NUX_TRACKER_LOCATION);
3887 error->SetLines(-1);
3888+ error->SetScale(scale);
3889 error->SetFont(style.payment_form_data_font());
3890 // ensure it is an error using red
3891 error->SetTextColor(style.payment_error_color());
3892@@ -337,11 +366,11 @@
3893 nux::VLayout *actions_layout = new nux::VLayout();
3894 if (error_message_.empty())
3895 {
3896- actions_layout->SetSpaceBetweenChildren(16);
3897+ actions_layout->SetSpaceBetweenChildren(ACTIONS_CHILDREN_SPACE_MAX.CP(scale));
3898 }
3899 else
3900 {
3901- actions_layout->SetSpaceBetweenChildren(8);
3902+ actions_layout->SetSpaceBetweenChildren(ACTIONS_CHILDREN_SPACE_MIN.CP(scale));
3903 }
3904
3905 nux::ObjectPtr<StaticCairoText> empty_;
3906@@ -349,6 +378,7 @@
3907 "", true,
3908 NUX_TRACKER_LOCATION);
3909 empty_->SetLines(-1);
3910+ empty_->SetScale(scale);
3911 empty_->SetFont(style.payment_form_labels_font());
3912 actions_layout->AddView(empty_.GetPointer(), 1,
3913 nux::MINOR_POSITION_START);
3914@@ -374,14 +404,14 @@
3915 actions_buffer_h->AddSpace(0, 1);
3916
3917 nux::HLayout* buttons_data_layout = new nux::HLayout();
3918- buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());
3919+ buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
3920
3921- lock_texture_ = new IconTexture(style.GetLockIcon(), style.GetPaymentLockWidth(),
3922- style.GetPaymentLockHeight());
3923+ lock_texture_ = new IconTexture(style.GetLockIcon(), style.GetPaymentLockWidth().CP(scale),
3924+ style.GetPaymentLockHeight().CP(scale));
3925 buttons_data_layout->AddView(lock_texture_.GetPointer(), 0, nux::MINOR_POSITION_CENTER,
3926 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
3927
3928- buttons_data_layout->AddSpace(20, 1);
3929+ buttons_data_layout->AddSpace(BUTTONS_SPACE.CP(scale), 1);
3930 if(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer())
3931 buttons_data_layout->AddView(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer(),
3932 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f,
3933@@ -413,7 +443,8 @@
3934
3935 previews::Style& style = dash::previews::Style::Instance();
3936
3937- int width = std::max<int>(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
3938+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
3939+ int width = std::max<int>(0, content_width);
3940
3941 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }
3942 if(header_layout_) { header_layout_->SetMaximumWidth(width); }
3943@@ -460,6 +491,49 @@
3944 PaymentPreview::SetupViews();
3945 }
3946
3947+void MusicPaymentPreview::UpdateScale(double scale)
3948+{
3949+ PaymentPreview::UpdateScale(scale);
3950+
3951+ if (intro_)
3952+ intro_->SetScale(scale);
3953+ if (email_label_)
3954+ email_label_->SetScale(scale);
3955+ if (payment_label_)
3956+ payment_label_->SetScale(scale);
3957+ if (payment_)
3958+ payment_->SetScale(scale);
3959+ if (password_label_)
3960+ password_label_->SetScale(scale);
3961+ if (purchase_hint_)
3962+ purchase_hint_->SetScale(scale);
3963+ if (purchase_prize_)
3964+ purchase_prize_->SetScale(scale);
3965+ if (purchase_type_)
3966+ purchase_type_->SetScale(scale);
3967+ if (change_payment_)
3968+ change_payment_->SetScale(scale);
3969+ if (error_label_)
3970+ error_label_->SetScale(scale);
3971+
3972+ previews::Style& style = dash::previews::Style::Instance();
3973+ if (lock_texture_)
3974+ lock_texture_->SetSize(std::max(style.GetPaymentLockWidth().CP(scale), style.GetPaymentLockHeight().CP(scale)));
3975+
3976+ if (password_entry_)
3977+ {
3978+ password_entry_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale));
3979+ password_entry_->SetMinimumWidth(PASSWORD_MIN_WIDTH.CP(scale));
3980+ }
3981+
3982+ if (form_layout_)
3983+ {
3984+ form_layout_->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
3985+ form_layout_->SetMinimumHeight(FORM_MIN_HEIGHT.CP(scale));
3986+ form_layout_->SetLeftAndRightPadding(FORM_PADDING.CP(scale));
3987+ form_layout_->SetTopAndBottomPadding(TITLE_CHILDREN_SPACE.CP(scale));
3988+ }
3989+}
3990
3991 }
3992 }
3993
3994=== modified file 'dash/previews/MusicPaymentPreview.h'
3995--- dash/previews/MusicPaymentPreview.h 2013-09-19 16:44:03 +0000
3996+++ dash/previews/MusicPaymentPreview.h 2014-08-26 13:46:04 +0000
3997@@ -90,6 +90,7 @@
3998 void OnActionLinkActivated(ActionLink* link, std::string const& id);
3999
4000 virtual void SetupViews();
4001+ virtual void UpdateScale(double scale) override;
4002
4003 void PreLayoutManagement();
4004
4005
4006=== modified file 'dash/previews/MusicPreview.cpp'
4007--- dash/previews/MusicPreview.cpp 2013-11-19 18:48:35 +0000
4008+++ dash/previews/MusicPreview.cpp 2014-08-26 13:46:04 +0000
4009@@ -42,14 +42,27 @@
4010 {
4011 namespace previews
4012 {
4013+
4014+namespace
4015+{
4016+ const RawPixel CHILDREN_SPACE = 16_em;
4017+ const RawPixel ICON_LEFT_RIGHT_PADDING = 10_em;
4018+ const RawPixel WARNING_MIN_HEIGHT = 50_em;
4019+ const RawPixel WARNING_MAX_WIDTH = 300_em;
4020+}
4021+
4022 DECLARE_LOGGER(logger, "unity.dash.preview.music");
4023
4024 NUX_IMPLEMENT_OBJECT_TYPE(MusicPreview);
4025
4026 MusicPreview::MusicPreview(dash::Preview::Ptr preview_model)
4027 : Preview(preview_model)
4028+, actions_layout_(nullptr)
4029+, image_data_layout_(nullptr)
4030+, icon_layout_(nullptr)
4031 {
4032 SetupViews();
4033+ UpdateScale(scale);
4034 }
4035
4036 MusicPreview::~MusicPreview()
4037@@ -130,13 +143,13 @@
4038
4039 auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); };
4040
4041- nux::HLayout* image_data_layout = new nux::HLayout();
4042- image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());
4043+ image_data_layout_ = new nux::HLayout();
4044+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
4045
4046 /////////////////////
4047 // Image
4048 image_ = new CoverArt();
4049-
4050+ image_->scale = scale();
4051 AddChild(image_.GetPointer());
4052 UpdateCoverArtImage(image_.GetPointer());
4053 /////////////////////
4054@@ -144,20 +157,21 @@
4055 /////////////////////
4056 // App Data Panel
4057 full_data_layout_ = new nux::VLayout();
4058- full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());
4059- full_data_layout_->SetSpaceBetweenChildren(16);
4060+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
4061+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
4062
4063 /////////////////////
4064 // Music Info
4065- nux::VLayout* album_data_layout = new nux::VLayout();
4066- album_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
4067+ album_data_layout_ = new nux::VLayout();
4068+ album_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
4069
4070 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
4071 AddChild(title_.GetPointer());
4072 title_->SetFont(style.title_font().c_str());
4073 title_->SetLines(-1);
4074+ title_->SetScale(scale);
4075 title_->mouse_click.connect(on_mouse_down);
4076- album_data_layout->AddView(title_.GetPointer(), 1);
4077+ album_data_layout_->AddView(title_.GetPointer(), 1);
4078
4079 if (!preview_model_->subtitle.Get().empty())
4080 {
4081@@ -165,8 +179,9 @@
4082 AddChild(subtitle_.GetPointer());
4083 subtitle_->SetFont(style.subtitle_size_font().c_str());
4084 subtitle_->SetLines(-1);
4085+ subtitle_->SetScale(scale);
4086 subtitle_->mouse_click.connect(on_mouse_down);
4087- album_data_layout->AddView(subtitle_.GetPointer(), 1);
4088+ album_data_layout_->AddView(subtitle_.GetPointer(), 1);
4089 }
4090
4091 /////////////////////
4092@@ -177,6 +192,7 @@
4093 if (tracks_model)
4094 {
4095 tracks_ = new previews::Tracks(tracks_model, NUX_TRACKER_LOCATION);
4096+ tracks_->scale = scale();
4097 AddChild(tracks_.GetPointer());
4098 tracks_->mouse_click.connect(on_mouse_down);
4099 }
4100@@ -187,7 +203,7 @@
4101 /////////////////////
4102 // Hints && Actions
4103 nux::VLayout* hints_layout = NULL;
4104- nux::Layout* actions_layout = NULL;
4105+ actions_layout_ = NULL;
4106 bool has_u1_creds = HasUbuntuOneCredentials();
4107
4108 if (has_u1_creds)
4109@@ -197,70 +213,72 @@
4110 hints_layout = new nux::VLayout();
4111 hints_layout->SetSpaceBetweenChildren(0);
4112 hints_layout->AddSpace(0, 1);
4113- preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
4114+ preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
4115+ preview_info_hints_->scale = scale();
4116 AddChild(preview_info_hints_.GetPointer());
4117 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
4118 hints_layout->AddView(preview_info_hints_.GetPointer(), 0);
4119
4120 // If there are actions, we use a vertical layout
4121 action_buttons_.clear();
4122- actions_layout = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);
4123- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
4124+ actions_layout_ = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);
4125+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
4126 }
4127 else // otherwise we add a grid layout.
4128 {
4129 action_buttons_.clear();
4130- actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
4131+ actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
4132 if (action_buttons_.size() < 2)
4133 hint_actions_layout->AddSpace(0, 1);
4134- actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());
4135+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
4136 }
4137 }
4138 else
4139 {
4140 // let the user know he needs to connect
4141 previews::Style& style = dash::previews::Style::Instance();
4142- actions_layout = new nux::HLayout();
4143- nux::VLayout* icon_layout = new nux::VLayout();
4144- icon_layout->SetLeftAndRightPadding(10);
4145+ nux::HLayout* actions_layout = new nux::HLayout();
4146+ icon_layout_ = new nux::VLayout();
4147+ icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
4148
4149 warning_texture_ = new IconTexture(style.GetWarningIcon());
4150- icon_layout->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START,
4151+ icon_layout_->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START,
4152 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
4153- actions_layout->AddLayout(icon_layout, 0, nux::MINOR_POSITION_CENTER);
4154+ actions_layout->AddLayout(icon_layout_, 0, nux::MINOR_POSITION_CENTER);
4155
4156 warning_msg_ = new StaticCairoText(
4157 no_credentials_message_, true,
4158 NUX_TRACKER_LOCATION);
4159- AddChild(warning_msg_.GetPointer());
4160+ AddChild(warning_msg_.GetPointer());
4161 warning_msg_->SetFont(style.u1_warning_font().c_str());
4162 warning_msg_->SetLines(-2);
4163- warning_msg_->SetMinimumHeight(50);
4164- warning_msg_->SetMaximumWidth(300);
4165+ warning_msg_->SetScale(scale);
4166+ warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale));
4167+ warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale));
4168
4169 actions_layout->AddView(warning_msg_.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
4170
4171 }
4172-
4173+
4174 /////////////////////
4175
4176 if (hints_layout) hint_actions_layout->AddView(hints_layout, 1);
4177- hint_actions_layout->AddView(actions_layout, 0);
4178+ hint_actions_layout->AddView(actions_layout_, 0);
4179
4180- full_data_layout_->AddLayout(album_data_layout, 0);
4181+ full_data_layout_->AddLayout(album_data_layout_, 0);
4182 if (tracks_)
4183 {
4184 full_data_layout_->AddView(tracks_.GetPointer(), 1);
4185 }
4186 full_data_layout_->AddLayout(hint_actions_layout, 0);
4187 /////////////////////
4188-
4189- image_data_layout->AddView(image_.GetPointer(), 0);
4190- image_data_layout->AddLayout(full_data_layout_, 1);
4191+
4192+ image_data_layout_->AddView(image_.GetPointer(), 0);
4193+ image_data_layout_->AddLayout(full_data_layout_, 1);
4194
4195 mouse_click.connect(on_mouse_down);
4196
4197- SetLayout(image_data_layout);
4198+ SetLayout(image_data_layout_);
4199 }
4200
4201 void MusicPreview::PreLayoutManagement()
4202@@ -272,23 +290,23 @@
4203
4204 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
4205
4206- if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())
4207- geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());
4208+ int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
4209+ if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
4210+ geo_art.width = MAX(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
4211 image_->SetMinMaxSize(geo_art.width, geo_art.height);
4212
4213- int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
4214+ int details_width = MAX(0, content_width - geo_art.width);
4215
4216 if (title_) { title_->SetMaximumWidth(details_width); }
4217 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
4218
4219 for (nux::AbstractButton* button : action_buttons_)
4220 {
4221- int action_width = CLAMP((details_width - style.GetSpaceBetweenActions()) /
4222- 2, 0, style.GetActionButtonMaximumWidth());
4223+ int action_width = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
4224 // do not use SetMinMax because width has to be able to grow
4225 button->SetMinimumWidth(action_width);
4226- button->SetMinimumHeight(style.GetActionButtonHeight());
4227- button->SetMaximumHeight(style.GetActionButtonHeight());
4228+ button->SetMinimumHeight(style.GetActionButtonHeight().CP(scale));
4229+ button->SetMaximumHeight(style.GetActionButtonHeight().CP(scale));
4230 }
4231
4232 Preview::PreLayoutManagement();
4233@@ -300,6 +318,47 @@
4234 player.Stop();
4235 }
4236
4237+void MusicPreview::UpdateScale(double scale)
4238+{
4239+ Preview::UpdateScale(scale);
4240+
4241+ if (tracks_)
4242+ tracks_->scale = scale;
4243+
4244+ if (preview_info_hints_)
4245+ preview_info_hints_->scale = scale;
4246+
4247+ if (icon_layout_)
4248+ icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
4249+
4250+ if (warning_msg_)
4251+ {
4252+ warning_msg_->SetScale(scale);
4253+ warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale));
4254+ warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale));
4255+ }
4256+
4257+ previews::Style& style = dash::previews::Style::Instance();
4258+
4259+ if (image_data_layout_)
4260+ image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
4261+
4262+ if (full_data_layout_)
4263+ {
4264+ full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
4265+ full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
4266+ }
4267+
4268+ if (album_data_layout_)
4269+ album_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
4270+
4271+ if (actions_layout_)
4272+ actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
4273+
4274+ if (icon_layout_)
4275+ icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
4276+}
4277+
4278 } // namespace previews
4279 } // namespace dash
4280 } // namespace unity
4281
4282=== modified file 'dash/previews/MusicPreview.h'
4283--- dash/previews/MusicPreview.h 2013-09-19 16:44:03 +0000
4284+++ dash/previews/MusicPreview.h 2014-08-26 13:46:04 +0000
4285@@ -53,6 +53,7 @@
4286 virtual void PreLayoutManagement();
4287
4288 virtual void SetupViews();
4289+ virtual void UpdateScale(double scale);
4290
4291 virtual void OnNavigateOut();
4292
4293@@ -64,6 +65,10 @@
4294 nux::ObjectPtr<IconTexture> warning_texture_;
4295 std::string no_credentials_message_;
4296
4297+ nux::Layout* actions_layout_;
4298+ nux::HLayout* image_data_layout_;
4299+ nux::VLayout* icon_layout_;
4300+ nux::VLayout* album_data_layout_;
4301 };
4302
4303 }
4304
4305=== modified file 'dash/previews/PaymentPreview.cpp'
4306--- dash/previews/PaymentPreview.cpp 2013-09-19 16:44:03 +0000
4307+++ dash/previews/PaymentPreview.cpp 2014-08-26 13:46:04 +0000
4308@@ -23,6 +23,7 @@
4309 #include <NuxCore/Logger.h>
4310 #include "PaymentPreview.h"
4311 #include "unity-shared/CoverArt.h"
4312+#include "unity-shared/DashStyle.h"
4313 #include "unity-shared/PreviewStyle.h"
4314
4315 namespace unity
4316@@ -39,6 +40,15 @@
4317
4318 nux::logging::Logger logger("unity.dash.previews.payment.preview");
4319
4320+const RawPixel CONTENT_DATA_CHILDREN_SPACE = 5_em;
4321+const RawPixel CONTENT_DATA_PADDING = 10_em;
4322+const RawPixel OVERLAY_LAYOUT_SPACE = 20_em;
4323+const RawPixel HEADER_CHILDREN_SPACE = 10_em;
4324+const RawPixel HEADER_MAX_SIZE = 76_em;
4325+const RawPixel IMAGE_MIN_MAX_SIZE = 64_em;
4326+const RawPixel HEADER_SPACE = 10_em;
4327+const RawPixel LINK_MIN_WIDTH = 178_em;
4328+const RawPixel LINK_MAX_HEIGHT = 34_em;
4329 }
4330
4331 class OverlaySpinner : public unity::debug::Introspectable, public nux::View
4332@@ -47,6 +57,8 @@
4333 public:
4334 OverlaySpinner();
4335
4336+ nux::Property<double> scale;
4337+
4338 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
4339 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
4340
4341@@ -61,7 +73,7 @@
4342 private:
4343 bool OnFrameTimeout();
4344
4345- nux::BaseTexture* spin_;
4346+ nux::ObjectPtr<nux::BaseTexture> spin_;
4347
4348 glib::Source::UniquePtr frame_timeout_;
4349
4350@@ -72,15 +84,19 @@
4351 NUX_IMPLEMENT_OBJECT_TYPE(OverlaySpinner);
4352
4353 OverlaySpinner::OverlaySpinner()
4354- : nux::View(NUX_TRACKER_LOCATION),
4355- rotation_(0.0f)
4356+ : nux::View(NUX_TRACKER_LOCATION)
4357+ , scale(1.0)
4358+ , rotation_(0.0f)
4359 {
4360- previews::Style& style = dash::previews::Style::Instance();
4361-
4362- spin_ = style.GetSearchSpinIcon();
4363+ spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
4364
4365 rotate_.Identity();
4366 rotate_.Rotate_z(0.0);
4367+
4368+ scale.changed.connect([this] (double scale) {
4369+ spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
4370+ QueueDraw();
4371+ });
4372 }
4373
4374 void OverlaySpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
4375@@ -183,8 +199,12 @@
4376 : Preview(preview_model)
4377 , data_(nullptr)
4378 , full_data_layout_(nullptr)
4379-{
4380-}
4381+, content_data_layout_(nullptr)
4382+, overlay_layout_(nullptr)
4383+, header_layout_(nullptr)
4384+, body_layout_(nullptr)
4385+, footer_layout_(nullptr)
4386+{}
4387
4388 std::string PaymentPreview::GetName() const
4389 {
4390@@ -199,18 +219,18 @@
4391 nux::Layout* PaymentPreview::GetHeader()
4392 {
4393 nux::HLayout* header_data_layout = new nux::HLayout();
4394- header_data_layout->SetSpaceBetweenChildren(10);
4395- header_data_layout->SetMaximumHeight(76);
4396- header_data_layout->SetMinimumHeight(76);
4397+ header_data_layout->SetSpaceBetweenChildren(HEADER_CHILDREN_SPACE.CP(scale));
4398+ header_data_layout->SetMaximumHeight(HEADER_MAX_SIZE.CP(scale));
4399+ header_data_layout->SetMinimumHeight(HEADER_MAX_SIZE.CP(scale));
4400
4401 image_ = new CoverArt();
4402- image_->SetMinMaxSize(64, 64);
4403+ image_->SetMinMaxSize(IMAGE_MIN_MAX_SIZE.CP(scale), IMAGE_MIN_MAX_SIZE.CP(scale));
4404 AddChild(image_.GetPointer());
4405 UpdateCoverArtImage(image_.GetPointer());
4406
4407 header_data_layout->AddView(image_.GetPointer(), 0);
4408 header_data_layout->AddLayout(GetTitle(), 0);
4409- header_data_layout->AddSpace(10, 1);
4410+ header_data_layout->AddSpace(HEADER_SPACE.CP(scale), 1);
4411 header_data_layout->AddLayout(GetPrice(), 0);
4412 return header_data_layout;
4413 }
4414@@ -223,8 +243,8 @@
4415 link = new ActionLink(action->id,
4416 action->display_name, NUX_TRACKER_LOCATION);
4417 link->font_hint.Set(style.payment_form_labels_font().c_str());
4418- link->SetMinimumWidth(178);
4419- link->SetMaximumHeight(34);
4420+ link->SetMinimumWidth(LINK_MIN_WIDTH.CP(scale));
4421+ link->SetMaximumHeight(LINK_MAX_HEIGHT.CP(scale));
4422 return link;
4423 }
4424
4425@@ -239,8 +259,8 @@
4426 NUX_TRACKER_LOCATION);
4427 button->SetFont(style.action_font());
4428 button->SetExtraHint(action->extra_text, style.action_extra_font());
4429- button->SetMinimumWidth(178);
4430- button->SetMaximumHeight(34);
4431+ button->SetMinimumWidth(LINK_MIN_WIDTH.CP(scale));
4432+ button->SetMaximumHeight(LINK_MAX_HEIGHT.CP(scale));
4433 return button;
4434 }
4435
4436@@ -327,8 +347,8 @@
4437
4438 // layout to be used to show the info
4439 content_data_layout_ = new nux::VLayout();
4440- content_data_layout_->SetSpaceBetweenChildren(5);
4441- content_data_layout_->SetPadding(10, 10, 0, 10);
4442+ content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale));
4443+ content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale));
4444
4445 header_layout_ = GetHeader();
4446
4447@@ -344,21 +364,37 @@
4448
4449 // layout to draw an overlay
4450 overlay_layout_ = new nux::VLayout();
4451- StaticCairoText* calculating = new StaticCairoText(
4452+ calculating_ = new StaticCairoText(
4453 "Performing purchase", true,
4454 NUX_TRACKER_LOCATION);
4455
4456 OverlaySpinner* spinner_ = new OverlaySpinner();
4457- overlay_layout_->AddSpace(20, 1);
4458- overlay_layout_->AddView(calculating, 0, nux::MINOR_POSITION_CENTER);
4459+ overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1);
4460+ overlay_layout_->AddView(calculating_, 0, nux::MINOR_POSITION_CENTER);
4461 overlay_layout_->AddView(spinner_, 1, nux::MINOR_POSITION_CENTER);
4462- overlay_layout_->AddSpace(20, 1);
4463+ overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1);
4464+ scale.changed.connect([this, spinner_] (double scale) { spinner_->scale = scale; });
4465
4466 full_data_layout_->AddLayout(overlay_layout_.GetPointer());
4467
4468+ UpdateScale(scale);
4469 SetLayout(full_data_layout_.GetPointer());
4470 }
4471
4472+void PaymentPreview::UpdateScale(double scale)
4473+{
4474+ Preview::UpdateScale(scale);
4475+
4476+ if (calculating_)
4477+ calculating_->SetScale(scale);
4478+
4479+ if (content_data_layout_)
4480+ {
4481+ content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale));
4482+ content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale));
4483+ }
4484+}
4485+
4486 }
4487
4488 }
4489
4490=== modified file 'dash/previews/PaymentPreview.h'
4491--- dash/previews/PaymentPreview.h 2013-09-19 16:44:03 +0000
4492+++ dash/previews/PaymentPreview.h 2014-08-26 13:46:04 +0000
4493@@ -106,6 +106,7 @@
4494
4495 virtual void LoadActions() = 0;
4496 virtual void SetupViews();
4497+ virtual void UpdateScale(double scale) override;
4498 virtual void SetupBackground();
4499
4500 nux::ObjectPtr<nux::LayeredLayout> full_data_layout_;
4501@@ -115,6 +116,8 @@
4502 nux::ObjectPtr<nux::Layout> body_layout_;
4503 nux::ObjectPtr<nux::Layout> footer_layout_;
4504
4505+ StaticCairoText* calculating_;
4506+
4507 // content elements
4508 nux::ObjectPtr<CoverArt> image_;
4509
4510
4511=== modified file 'dash/previews/Preview.cpp'
4512--- dash/previews/Preview.cpp 2013-11-19 18:48:35 +0000
4513+++ dash/previews/Preview.cpp 2014-08-26 13:46:04 +0000
4514@@ -38,6 +38,7 @@
4515 #include "MusicPaymentPreview.h"
4516 #include "SocialPreview.h"
4517 #include "PreviewInfoHintWidget.h"
4518+#include "ActionButton.h"
4519
4520 namespace unity
4521 {
4522@@ -100,14 +101,16 @@
4523
4524 Preview::Preview(dash::Preview::Ptr preview_model)
4525 : View(NUX_TRACKER_LOCATION)
4526+ , scale(1.0f)
4527 , preview_model_(preview_model)
4528 , tab_iterator_(new TabIterator())
4529 , full_data_layout_(nullptr)
4530 , image_(nullptr)
4531 , title_(nullptr)
4532 , subtitle_(nullptr)
4533+ , preview_container_(new PreviewContainer)
4534 {
4535- preview_container_ = new PreviewContainer;
4536+ scale.changed.connect(sigc::mem_fun(this, &Preview::UpdateScale));
4537 }
4538
4539 Preview::~Preview()
4540@@ -138,13 +141,13 @@
4541 previews::Style& style = dash::previews::Style::Instance();
4542
4543 nux::VLayout* actions_layout_v = new nux::VLayout();
4544- actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());
4545+ actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
4546 uint rows = actions.size() / 2 + ((actions.size() % 2 > 0) ? 1 : 0);
4547 uint action_iter = 0;
4548 for (uint i = 0; i < rows; i++)
4549 {
4550 nux::HLayout* actions_layout_h = new TabIteratorHLayout(tab_iterator_);
4551- actions_layout_h->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());
4552+ actions_layout_h->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
4553
4554 for (uint j = 0; j < 2 && action_iter < actions.size(); j++, action_iter++)
4555 {
4556@@ -172,7 +175,7 @@
4557 previews::Style& style = dash::previews::Style::Instance();
4558
4559 nux::VLayout* actions_layout_v = new TabIteratorVLayout(tab_iterator_);
4560- actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());
4561+ actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
4562
4563 uint action_iter = 0;
4564 for (uint i = 0; i < actions.size(); i++)
4565@@ -215,7 +218,7 @@
4566 else
4567 cover_art->SetNoImageAvailable();
4568 cover_art->SetFont(style.no_preview_image_font());
4569-
4570+
4571 cover_art->mouse_click.connect(on_mouse_down);
4572 }
4573
4574@@ -279,6 +282,37 @@
4575 return preview_container_->request_close;
4576 }
4577
4578+void Preview::UpdateScale(double scale)
4579+{
4580+ if (image_)
4581+ image_->scale = scale;
4582+
4583+ if (title_)
4584+ title_->SetScale(scale);
4585+ if (subtitle_)
4586+ subtitle_->SetScale(scale);
4587+ if (description_)
4588+ description_->SetScale(scale);
4589+
4590+ if (preview_container_)
4591+ preview_container_->scale = scale;
4592+
4593+ if (preview_info_hints_)
4594+ preview_info_hints_->scale = scale;
4595+
4596+ for (nux::AbstractButton* button : action_buttons_)
4597+ {
4598+ if (ActionButton* bn = dynamic_cast<ActionButton*>(button))
4599+ bn->scale = scale;
4600+
4601+ if (ActionLink* link = dynamic_cast<ActionLink*>(button))
4602+ link->scale = scale;
4603+ }
4604+
4605+ QueueRelayout();
4606+ QueueDraw();
4607+}
4608+
4609 }
4610 }
4611 }
4612
4613=== modified file 'dash/previews/Preview.h'
4614--- dash/previews/Preview.h 2013-09-19 16:44:03 +0000
4615+++ dash/previews/Preview.h 2014-08-26 13:46:04 +0000
4616@@ -74,6 +74,8 @@
4617 unsigned long special_keys_state);
4618 virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
4619
4620+ nux::Property<double> scale;
4621+
4622 protected:
4623 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {}
4624 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}
4625@@ -88,6 +90,8 @@
4626
4627 virtual void SetupViews() = 0;
4628
4629+ virtual void UpdateScale(double scale);
4630+
4631 nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
4632 nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
4633
4634
4635=== modified file 'dash/previews/PreviewContainer.cpp'
4636--- dash/previews/PreviewContainer.cpp 2013-11-19 18:48:35 +0000
4637+++ dash/previews/PreviewContainer.cpp 2014-08-26 13:46:04 +0000
4638@@ -23,11 +23,11 @@
4639 #include "PreviewContainer.h"
4640 #include <NuxCore/Logger.h>
4641 #include <Nux/HLayout.h>
4642-#include <Nux/VLayout.h>
4643
4644 #include "unity-shared/IntrospectableWrappers.h"
4645 #include "unity-shared/TimeUtil.h"
4646 #include "unity-shared/PreviewStyle.h"
4647+#include "unity-shared/DashStyle.h"
4648 #include "unity-shared/GraphicsUtils.h"
4649 #include "PreviewNavigator.h"
4650 #include <boost/math/constants/constants.hpp>
4651@@ -52,13 +52,15 @@
4652 const int PREVIEW_SPINNER_WAIT = 2000;
4653
4654 const std::string ANIMATION_IDLE = "animation-idle";
4655+const RawPixel CHILDREN_SPACE = 6_em;
4656 }
4657
4658 class PreviewContent : public nux::Layout, public debug::Introspectable
4659 {
4660 public:
4661 PreviewContent(PreviewContainer*const parent)
4662- : parent_(parent)
4663+ : scale(1.0)
4664+ , parent_(parent)
4665 , progress_(0.0)
4666 , curve_progress_(0.0)
4667 , animating_(false)
4668@@ -73,9 +75,19 @@
4669 // Need to update the preview geometries when updating the container geo.
4670 UpdateAnimationProgress(progress_, curve_progress_);
4671 });
4672- Style& style = previews::Style::Instance();
4673-
4674- spin_= style.GetSearchSpinIcon(32);
4675+
4676+ spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
4677+ scale.changed.connect(sigc::mem_fun(this, &PreviewContent::UpdateScale));
4678+ }
4679+
4680+ void UpdateScale(double scale)
4681+ {
4682+ spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
4683+
4684+ for (auto* area : GetChildren())
4685+ static_cast<previews::Preview*>(area)->scale = scale;
4686+
4687+ QueueDraw();
4688 }
4689
4690 // From debug::Introspectable
4691@@ -107,6 +119,7 @@
4692 AddChild(preview.GetPointer());
4693 AddView(preview.GetPointer());
4694 preview->SetVisible(false);
4695+ preview->scale = scale();
4696 }
4697 else
4698 {
4699@@ -355,6 +368,7 @@
4700 sigc::signal<void> start_navigation;
4701 sigc::signal<void> continue_navigation;
4702 sigc::signal<void> end_navigation;
4703+ nux::Property<double> scale;
4704
4705 private:
4706 PreviewContainer*const parent_;
4707@@ -394,6 +408,7 @@
4708
4709 PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL)
4710 : View(NUX_FILE_LINE_PARAM)
4711+ , scale(1.0)
4712 , preview_layout_(nullptr)
4713 , nav_disabled_(Navigation::NONE)
4714 , navigation_progress_speed_(0.0)
4715@@ -408,6 +423,7 @@
4716
4717 key_down.connect(sigc::mem_fun(this, &PreviewContainer::OnKeyDown));
4718 mouse_click.connect(sigc::mem_fun(this, &PreviewContainer::OnMouseDown));
4719+ scale.changed.connect(sigc::mem_fun(this, &PreviewContainer::UpdateScale));
4720 }
4721
4722 PreviewContainer::~PreviewContainer()
4723@@ -417,13 +433,12 @@
4724 void PreviewContainer::Preview(dash::Preview::Ptr preview_model, Navigation direction)
4725 {
4726 previews::Preview::Ptr preview_view = preview_model ? previews::Preview::PreviewForModel(preview_model) : previews::Preview::Ptr();
4727-
4728+
4729 if (preview_view)
4730 {
4731 preview_view->request_close().connect([this]() { request_close.emit(); });
4732+ preview_layout_->PushPreview(preview_view, direction);
4733 }
4734-
4735- preview_layout_->PushPreview(preview_view, direction);
4736 }
4737
4738 void PreviewContainer::DisableNavButton(Navigation button)
4739@@ -458,29 +473,32 @@
4740
4741 nux::VLayout* layout = new nux::VLayout();
4742 SetLayout(layout);
4743- layout->AddLayout(new nux::SpaceLayout(0,0,style.GetPreviewTopPadding(),style.GetPreviewTopPadding()));
4744+
4745+ layout->SetTopAndBottomPadding(style.GetPreviewTopPadding().CP(scale), 0);
4746
4747 layout_content_ = new nux::HLayout();
4748- layout_content_->SetSpaceBetweenChildren(6);
4749+ layout_content_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
4750 layout->AddLayout(layout_content_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
4751
4752 layout_content_->AddSpace(0, 1);
4753 nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
4754 AddChild(nav_left_);
4755- nav_left_->SetMinimumWidth(style.GetNavigatorWidth());
4756- nav_left_->SetMaximumWidth(style.GetNavigatorWidth());
4757+ nav_left_->scale = scale();
4758+ nav_left_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
4759+ nav_left_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
4760 nav_left_->activated.connect([this]() { navigate_left.emit(); });
4761 layout_content_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
4762
4763 preview_layout_ = new PreviewContent(this);
4764- preview_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight());
4765+ preview_layout_->SetMinMaxSize(style.GetPreviewWidth().CP(scale), style.GetPreviewHeight().CP(scale));
4766 AddChild(preview_layout_);
4767 layout_content_->AddLayout(preview_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
4768
4769 nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
4770 AddChild(nav_right_);
4771- nav_right_->SetMinimumWidth(style.GetNavigatorWidth());
4772- nav_right_->SetMaximumWidth(style.GetNavigatorWidth());
4773+ nav_right_->scale = scale();
4774+ nav_right_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
4775+ nav_right_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
4776 nav_right_->activated.connect([this]() { navigate_right.emit(); });
4777 layout_content_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
4778 layout_content_->AddSpace(0, 1);
4779@@ -492,7 +510,7 @@
4780 // reset animation clock.
4781 if (navigation_count_ == 0)
4782 clock_gettime(CLOCK_MONOTONIC, &last_progress_time_);
4783-
4784+
4785 float navigation_progress_remaining = CLAMP((1.0 - preview_layout_->GetAnimationProgress()) + navigation_count_, 1.0f, 10.0f);
4786 navigation_count_++;
4787
4788@@ -534,7 +552,7 @@
4789 gfx_engine.GetRenderStates().SetBlend(false);
4790 gfx_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
4791 }
4792-
4793+
4794 // rely on the compiz event loop to come back to us in a nice throttling
4795 if (AnimationInProgress())
4796 {
4797@@ -595,11 +613,12 @@
4798 bool PreviewContainer::QueueAnimation()
4799 {
4800 animation_timer_.reset();
4801-
4802+
4803 timespec current;
4804 clock_gettime(CLOCK_MONOTONIC, &current);
4805 float progress = GetSwipeAnimationProgress(current);
4806- preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out.
4807+ if (preview_layout_)
4808+ preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out.
4809 last_progress_time_ = current;
4810
4811 QueueDraw();
4812@@ -691,7 +710,30 @@
4813
4814 nux::Geometry PreviewContainer::GetLayoutGeometry() const
4815 {
4816- return layout_content_->GetAbsoluteGeometry();
4817+ return layout_content_->GetAbsoluteGeometry();
4818+}
4819+
4820+void PreviewContainer::UpdateScale(double scale)
4821+{
4822+ previews::Style& style = previews::Style::Instance();
4823+
4824+ GetLayout()->SetTopAndBottomPadding(style.GetPreviewTopPadding().CP(scale), 0);
4825+
4826+ preview_layout_->SetMinMaxSize(style.GetPreviewWidth().CP(scale), style.GetPreviewHeight().CP(scale));
4827+ preview_layout_->scale = scale;
4828+
4829+ layout_content_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
4830+
4831+ nav_left_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
4832+ nav_left_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
4833+ nav_left_->scale = scale;
4834+
4835+ nav_right_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
4836+ nav_right_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
4837+ nav_right_->scale = scale;
4838+
4839+ QueueRelayout();
4840+ QueueDraw();
4841 }
4842
4843 } // namespace previews
4844
4845=== modified file 'dash/previews/PreviewContainer.h'
4846--- dash/previews/PreviewContainer.h 2013-09-19 16:44:03 +0000
4847+++ dash/previews/PreviewContainer.h 2014-08-26 13:46:04 +0000
4848@@ -25,6 +25,7 @@
4849
4850 #include <Nux/Nux.h>
4851 #include <Nux/View.h>
4852+#include <Nux/VLayout.h>
4853 #include <UnityCore/Preview.h>
4854 #include "Preview.h"
4855 #include "unity-shared/Introspectable.h"
4856@@ -74,6 +75,8 @@
4857 sigc::signal<void> navigate_right;
4858 sigc::signal<void> request_close;
4859
4860+ nux::Property<double> scale;
4861+
4862 bool AcceptKeyNavFocus();
4863
4864 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
4865@@ -91,7 +94,7 @@
4866
4867 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
4868 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
4869-
4870+
4871 private:
4872 void SetupViews();
4873
4874@@ -101,6 +104,8 @@
4875 bool QueueAnimation();
4876
4877 private:
4878+ void UpdateScale(double scale);
4879+
4880 // View related
4881 nux::HLayout* layout_content_;
4882 PreviewNavigator* nav_left_;
4883@@ -112,7 +117,7 @@
4884 struct timespec last_progress_time_;
4885 float navigation_progress_speed_;
4886 int navigation_count_;
4887-
4888+
4889 glib::Source::UniquePtr animation_timer_;
4890 friend class PreviewContent;
4891 };
4892
4893=== modified file 'dash/previews/PreviewInfoHintWidget.cpp'
4894--- dash/previews/PreviewInfoHintWidget.cpp 2013-11-19 18:48:35 +0000
4895+++ dash/previews/PreviewInfoHintWidget.cpp 2014-08-26 13:46:04 +0000
4896@@ -17,6 +17,7 @@
4897 * <http://www.gnu.org/licenses/>
4898 *
4899 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
4900+ * Marco Trevisan <marco.trevisan@canonical.com>
4901 *
4902 */
4903
4904@@ -41,21 +42,23 @@
4905 DECLARE_LOGGER(logger, "unity.dash.preview.infohintwidget");
4906 namespace
4907 {
4908-const int layout_spacing = 12;
4909+const RawPixel LAYOUT_SPACING = 12_em;
4910+const RawPixel HINTS_SPACING = 6_em;
4911 }
4912
4913 NUX_IMPLEMENT_OBJECT_TYPE(PreviewInfoHintWidget);
4914
4915 PreviewInfoHintWidget::PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size)
4916 : View(NUX_TRACKER_LOCATION)
4917+, scale(1.0)
4918 , icon_size_(icon_size)
4919+, layout_(nullptr)
4920+, info_names_layout_(nullptr)
4921+, info_values_layout_(nullptr)
4922 , preview_model_(preview_model)
4923 {
4924 SetupViews();
4925-}
4926-
4927-PreviewInfoHintWidget::~PreviewInfoHintWidget()
4928-{
4929+ scale.changed.connect(sigc::mem_fun(this, &PreviewInfoHintWidget::UpdateScale));
4930 }
4931
4932 void PreviewInfoHintWidget::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw)
4933@@ -96,7 +99,7 @@
4934 {
4935 std::stringstream ss;
4936 const GVariantType* info_hint_type = g_variant_get_type(variant);
4937-
4938+
4939 if (g_variant_type_equal(info_hint_type, G_VARIANT_TYPE_BOOLEAN))
4940 {
4941 ss << g_variant_get_int16(variant);
4942@@ -144,98 +147,91 @@
4943 void PreviewInfoHintWidget::SetupViews()
4944 {
4945 RemoveLayout();
4946- info_hints_.clear();
4947-
4948- previews::Style& style = previews::Style::Instance();
4949+ auto& style = previews::Style::Instance();
4950
4951 auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); };
4952
4953- nux::VLayout* layout = new nux::VLayout();
4954- layout->SetSpaceBetweenChildren(6);
4955-
4956- for (dash::Preview::InfoHintPtr info_hint : preview_model_->GetInfoHints())
4957+ layout_ = new nux::HLayout();
4958+ layout_->SetSpaceBetweenChildren(LAYOUT_SPACING.CP(scale));
4959+
4960+ auto *hint_vlayout = new nux::VLayout();
4961+ hint_vlayout->SetSpaceBetweenChildren(HINTS_SPACING.CP(scale));
4962+ layout_->AddLayout(hint_vlayout);
4963+ info_names_layout_ = hint_vlayout;
4964+
4965+ hint_vlayout = new nux::VLayout();
4966+ hint_vlayout->SetSpaceBetweenChildren(HINTS_SPACING.CP(scale));
4967+ layout_->AddLayout(hint_vlayout);
4968+ info_values_layout_ = hint_vlayout;
4969+
4970+ for (dash::Preview::InfoHintPtr const& info_hint : preview_model_->GetInfoHints())
4971 {
4972- nux::HLayout* hint_layout = new nux::HLayout();
4973- hint_layout->SetSpaceBetweenChildren(layout_spacing);
4974-
4975- StaticCairoTextPtr info_name;
4976- if (!info_hint->display_name.empty())
4977- {
4978- // The "%s" is used in the dash preview to display the "<hint>: <value>" infos
4979- std::string tmp_display_name = glib::String(g_strdup_printf (_("%s:"), info_hint->display_name.c_str())).Str();
4980-
4981- info_name = new StaticCairoText(tmp_display_name, true, NUX_TRACKER_LOCATION);
4982- info_name->SetFont(style.info_hint_bold_font());
4983- info_name->SetLines(-1);
4984- info_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT);
4985- info_name->mouse_click.connect(on_mouse_down);
4986- hint_layout->AddView(info_name.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
4987- }
4988-
4989- StaticCairoTextPtr info_value(new StaticCairoText(StringFromVariant(info_hint->value), true, NUX_TRACKER_LOCATION));
4990+ // The "%s" is used in the dash preview to display the "<hint>: <value>" infos
4991+ auto const& name = glib::String(g_strdup_printf (_("%s:"), info_hint->display_name.c_str())).Str();
4992+ auto* info_name = new StaticCairoText(name == ":" ? "" : name, true, NUX_TRACKER_LOCATION);
4993+ info_name->SetFont(style.info_hint_bold_font());
4994+ info_name->SetLines(-1);
4995+ info_name->SetScale(scale);
4996+ info_name->SetTextAlignment(StaticCairoText::NUX_ALIGN_RIGHT);
4997+ info_name->SetMinimumWidth(style.GetInfoHintNameMinimumWidth().CP(scale));
4998+ info_name->SetMaximumWidth(style.GetInfoHintNameMaximumWidth().CP(scale));
4999+ info_name->mouse_click.connect(on_mouse_down);
5000+ info_names_layout_->AddView(info_name, 1, nux::MINOR_POSITION_RIGHT);
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: