Merge lp:~unity-team/unity/prepare-7.2.3-SRU 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: 3802
Proposed branch: lp:~unity-team/unity/prepare-7.2.3-SRU
Merge into: lp:unity/7.2
Diff against target: 13027 lines (+3701/-2676)
142 files modified
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 (+23/-23)
dash/ScopeView.h (+0/-1)
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 (+148/-62)
dash/previews/ApplicationPreview.h (+10/-0)
dash/previews/ErrorPreview.cpp (+53/-26)
dash/previews/ErrorPreview.h (+2/-0)
dash/previews/GenericPreview.cpp (+86/-42)
dash/previews/GenericPreview.h (+9/-1)
dash/previews/MoviePreview.cpp (+78/-34)
dash/previews/MoviePreview.h (+8/-1)
dash/previews/MusicPaymentPreview.cpp (+103/-41)
dash/previews/MusicPaymentPreview.h (+1/-0)
dash/previews/MusicPreview.cpp (+96/-37)
dash/previews/MusicPreview.h (+6/-0)
dash/previews/PaymentPreview.cpp (+59/-23)
dash/previews/PaymentPreview.h (+3/-0)
dash/previews/Preview.cpp (+42/-8)
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 (+130/-61)
dash/previews/SocialPreview.h (+12/-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/-7)
dash/previews/Tracks.h (+5/-1)
debian/changelog (+62/-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)
launcher/Launcher.cpp (+1/-1)
launcher/SwitcherView.cpp (+11/-2)
launcher/SwitcherView.h (+1/-0)
lockscreen/LockScreenAcceleratorController.cpp (+46/-2)
lockscreen/LockScreenAcceleratorController.h (+2/-1)
lockscreen/LockScreenController.cpp (+13/-6)
lockscreen/LockScreenShield.cpp (+35/-22)
lockscreen/LockScreenShield.h (+3/-0)
lockscreen/UserPromptView.cpp (+0/-1)
plugins/unityshell/src/unityshell.cpp (+17/-13)
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)
services/panel-service.c (+27/-5)
shutdown/SessionDBusManager.cpp (+23/-9)
shutdown/SessionView.cpp (+49/-30)
shutdown/SessionView.h (+6/-5)
shutdown/StandaloneSession.cpp (+2/-0)
tests/autopilot/unity/emulators/switcher.py (+4/-4)
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/CMakeLists.txt (+1/-0)
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/OverlayScrollView.cpp (+56/-0)
unity-shared/OverlayScrollView.h (+43/-0)
unity-shared/PlacesOverlayVScrollBar.cpp (+47/-27)
unity-shared/PlacesOverlayVScrollBar.h (+6/-4)
unity-shared/PlacesVScrollBar.cpp (+54/-53)
unity-shared/PlacesVScrollBar.h (+6/-11)
unity-shared/PluginAdapter.cpp (+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/TextInput.cpp (+6/-24)
unity-shared/TextInput.h (+0/-1)
unity-shared/TextureCache.cpp (+10/-3)
unity-shared/UnitySettings.cpp (+19/-12)
unity-shared/VScrollBarOverlayWindow.cpp (+49/-47)
unity-shared/VScrollBarOverlayWindow.h (+3/-1)
To merge this branch: bzr merge lp:~unity-team/unity/prepare-7.2.3-SRU
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+228324@code.launchpad.net

Commit message

Prepare fixes for upstream micro-release 7.2.3.

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

I think it would be nice to include in this revision also the other hidpi branches that have been approved recently or that are about to be finished, so that we can just make one trusty landing with all the HiDPI fixes at once.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'UnityCore/GnomeSessionManager.cpp'
--- UnityCore/GnomeSessionManager.cpp 2014-07-01 15:24:59 +0000
+++ UnityCore/GnomeSessionManager.cpp 2014-08-06 16:03:19 +0000
@@ -91,6 +91,11 @@
91 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);91 shell_object_ = shell_server_.GetObject(shell::DBUS_INTERFACE);
92 shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::OnShellMethodCall));92 shell_object_->SetMethodsCallsHandler(sigc::mem_fun(this, &Impl::OnShellMethodCall));
9393
94 manager_->is_locked = false;
95 manager_->is_locked.changed.connect([this] (bool locked) {
96 locked ? manager_->locked.emit() : manager_->unlocked.emit();
97 });
98
94 {99 {
95 const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID");100 const char* session_id = test_mode_ ? "id0" : g_getenv("XDG_SESSION_ID");
96101
@@ -421,21 +426,13 @@
421{426{
422 EnsureCancelPendingAction();427 EnsureCancelPendingAction();
423428
429 if (!manager_->CanLock())
430 {
431 manager_->ScreenSaverActivate();
432 return;
433 }
434
424 // FIXME (andy) we should ask gnome-session to emit the logind signal435 // FIXME (andy) we should ask gnome-session to emit the logind signal
425 glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
426
427 if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()))
428 {
429 manager_->ScreenSaverActivate();
430 return;
431 }
432 else if (manager_->UserName().find("guest-") == 0)
433 {
434 LOG_INFO(logger) << "Impossible to lock a guest session";
435 manager_->ScreenSaverActivate();
436 return;
437 }
438
439 prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit();436 prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit();
440}437}
441438
@@ -454,6 +451,39 @@
454 });451 });
455}452}
456453
454bool GnomeManager::Impl::HasInhibitors()
455{
456 glib::Error error;
457 glib::Object<GDBusConnection> bus(g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error));
458
459 if (error)
460 {
461 LOG_ERROR(logger) << "Impossible to get the session bus, to fetch the inhibitors: " << error;
462 return false;
463 }
464
465 enum class Inhibited : unsigned
466 {
467 LOGOUT = 1,
468 USER_SWITCH = 2,
469 SUSPEND = 4,
470 IDLE_SET = 8
471 };
472
473 glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager",
474 "/org/gnome/SessionManager", "org.gnome.SessionManager",
475 "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr,
476 G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error));
477
478 if (error)
479 {
480 LOG_ERROR(logger) << "Impossible to get the inhibitors: " << error;
481 return false;
482 }
483
484 return inhibitors.GetBool();
485}
486
457// Public implementation487// Public implementation
458488
459GnomeManager::GnomeManager()489GnomeManager::GnomeManager()
@@ -617,6 +647,19 @@
617 });647 });
618}648}
619649
650bool GnomeManager::CanLock() const
651{
652 glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
653
654 if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()) ||
655 UserName().find("guest-") == 0 || is_locked())
656 {
657 return false;
658 }
659
660 return true;
661}
662
620bool GnomeManager::CanShutdown() const663bool GnomeManager::CanShutdown() const
621{664{
622 return impl_->can_shutdown_;665 return impl_->can_shutdown_;
@@ -632,6 +675,11 @@
632 return impl_->can_hibernate_;675 return impl_->can_hibernate_;
633}676}
634677
678bool GnomeManager::HasInhibitors() const
679{
680 return impl_->HasInhibitors();
681}
682
635void GnomeManager::CancelAction()683void GnomeManager::CancelAction()
636{684{
637 impl_->CancelAction();685 impl_->CancelAction();
638686
=== modified file 'UnityCore/GnomeSessionManager.h'
--- UnityCore/GnomeSessionManager.h 2014-04-10 04:47:58 +0000
+++ UnityCore/GnomeSessionManager.h 2014-08-06 16:03:19 +0000
@@ -47,9 +47,11 @@
47 void Suspend();47 void Suspend();
48 void Hibernate();48 void Hibernate();
4949
50 bool CanLock() const;
50 bool CanShutdown() const;51 bool CanShutdown() const;
51 bool CanSuspend() const;52 bool CanSuspend() const;
52 bool CanHibernate() const;53 bool CanHibernate() const;
54 bool HasInhibitors() const;
5355
54 void CancelAction();56 void CancelAction();
5557
5658
=== modified file 'UnityCore/GnomeSessionManagerImpl.h'
--- UnityCore/GnomeSessionManagerImpl.h 2014-07-01 15:24:59 +0000
+++ UnityCore/GnomeSessionManagerImpl.h 2014-08-06 16:03:19 +0000
@@ -51,6 +51,7 @@
51 void ConfirmShutdown();51 void ConfirmShutdown();
52 void CancelAction();52 void CancelAction();
53 void ClosedDialog();53 void ClosedDialog();
54 bool HasInhibitors();
54 void EnsureCancelPendingAction();55 void EnsureCancelPendingAction();
55 void LockScreen(bool prompt);56 void LockScreen(bool prompt);
5657
5758
=== modified file 'UnityCore/SessionManager.h'
--- UnityCore/SessionManager.h 2014-07-01 15:24:59 +0000
+++ UnityCore/SessionManager.h 2014-08-06 16:03:19 +0000
@@ -39,6 +39,7 @@
39 virtual ~Manager() = default;39 virtual ~Manager() = default;
4040
41 nux::ROProperty<bool> have_other_open_sessions;41 nux::ROProperty<bool> have_other_open_sessions;
42 nux::Property<bool> is_locked;
4243
43 virtual std::string RealName() const = 0;44 virtual std::string RealName() const = 0;
44 virtual std::string UserName() const = 0;45 virtual std::string UserName() const = 0;
@@ -54,9 +55,11 @@
54 virtual void Suspend() = 0;55 virtual void Suspend() = 0;
55 virtual void Hibernate() = 0;56 virtual void Hibernate() = 0;
5657
58 virtual bool CanLock() const = 0;
57 virtual bool CanShutdown() const = 0;59 virtual bool CanShutdown() const = 0;
58 virtual bool CanSuspend() const = 0;60 virtual bool CanSuspend() const = 0;
59 virtual bool CanHibernate() const = 0;61 virtual bool CanHibernate() const = 0;
62 virtual bool HasInhibitors() const = 0;
6063
61 virtual void CancelAction() = 0;64 virtual void CancelAction() = 0;
6265
6366
=== modified file 'dash/DashController.cpp'
--- dash/DashController.cpp 2014-06-23 19:42:24 +0000
+++ dash/DashController.cpp 2014-08-06 16:03:19 +0000
@@ -468,8 +468,8 @@
468 nux::Geometry const& view_content_geo(view_->GetContentGeometry());468 nux::Geometry const& view_content_geo(view_->GetContentGeometry());
469469
470 nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height);470 nux::Geometry geo(window_geo.x, window_geo.y, view_content_geo.width, view_content_geo.height);
471 geo.width += style.GetDashRightTileWidth();471 geo.width += style.GetDashRightTileWidth().CP(view_->scale());
472 geo.height += style.GetDashBottomTileHeight();472 geo.height += style.GetDashBottomTileHeight().CP(view_->scale());
473 return geo;473 return geo;
474}474}
475475
476476
=== modified file 'dash/DashView.cpp'
--- dash/DashView.cpp 2014-04-25 02:42:01 +0000
+++ dash/DashView.cpp 2014-08-06 16:03:19 +0000
@@ -36,7 +36,6 @@
36#include "unity-shared/DashStyle.h"36#include "unity-shared/DashStyle.h"
37#include "unity-shared/KeyboardUtil.h"37#include "unity-shared/KeyboardUtil.h"
38#include "unity-shared/PreviewStyle.h"38#include "unity-shared/PreviewStyle.h"
39#include "unity-shared/RawPixel.h"
40#include "unity-shared/UBusMessages.h"39#include "unity-shared/UBusMessages.h"
41#include "unity-shared/UnitySettings.h"40#include "unity-shared/UnitySettings.h"
42#include "unity-shared/WindowManager.h"41#include "unity-shared/WindowManager.h"
@@ -57,6 +56,8 @@
5756
58const RawPixel DASH_RESULT_RIGHT_PAD = 35_em;57const RawPixel DASH_RESULT_RIGHT_PAD = 35_em;
59const RawPixel PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10_em;58const RawPixel PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET = 10_em;
59const RawPixel PREVIEW_CONTAINER_TRIANGLE_WIDTH = 14_em;
60const RawPixel PREVIEW_CONTAINER_TRIANGLE_HEIGHT = 12_em;
6061
61const int MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT = 1000;62const int MAX_ENTRY_ACTIVATE_WAIT_TIMEOUT = 1000;
62}63}
@@ -112,6 +113,7 @@
112113
113DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter)114DashView::DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter)
114 : nux::View(NUX_TRACKER_LOCATION)115 : nux::View(NUX_TRACKER_LOCATION)
116 , scale(Settings::Instance().em()->DPIScale())
115 , scopes_(scopes)117 , scopes_(scopes)
116 , application_starter_(application_starter)118 , application_starter_(application_starter)
117 , preview_container_(nullptr)119 , preview_container_(nullptr)
@@ -129,7 +131,6 @@
129 , animate_preview_container_value_(0.0)131 , animate_preview_container_value_(0.0)
130 , animate_preview_value_(0.0)132 , animate_preview_value_(0.0)
131 , overlay_window_buttons_(new OverlayWindowButtons())133 , overlay_window_buttons_(new OverlayWindowButtons())
132 , cv_(Settings::Instance().em())
133 , monitor_(0)134 , monitor_(0)
134{135{
135 renderer_.SetOwner(this);136 renderer_.SetOwner(this);
@@ -144,7 +145,6 @@
144145
145 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));146 mouse_down.connect(sigc::mem_fun(this, &DashView::OnMouseButtonDown));
146 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));147 preview_state_machine_.PreviewActivated.connect(sigc::mem_fun(this, &DashView::BuildPreview));
147 Relayout();
148148
149 if (scopes_)149 if (scopes_)
150 {150 {
@@ -159,6 +159,8 @@
159 });159 });
160160
161 unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &DashView::OnDPIChanged));161 unity::Settings::Instance().dpi_changed.connect(sigc::mem_fun(this, &DashView::OnDPIChanged));
162 scale.changed.connect(sigc::mem_fun(this, &DashView::UpdateScale));
163 UpdateScale(scale());
162}164}
163165
164DashView::~DashView()166DashView::~DashView()
@@ -232,13 +234,13 @@
232234
233 if (!preview_container_)235 if (!preview_container_)
234 {236 {
235 preview_container_ = previews::PreviewContainer::Ptr(new previews::PreviewContainer());237 preview_container_ = new previews::PreviewContainer();
236 preview_container_->SetRedirectRenderingToTexture(true);238 preview_container_->SetRedirectRenderingToTexture(true);
237 AddChild(preview_container_.GetPointer());239 AddChild(preview_container_.GetPointer());
238 preview_container_->SetParentObject(this);240 preview_container_->SetParentObject(this);
239 }241 }
240 preview_container_->Preview(model, previews::Navigation::NONE); // no swipe left or right242 preview_container_->Preview(model, previews::Navigation::NONE); // no swipe left or right
241243 preview_container_->scale = scale();
242 preview_container_->SetGeometry(scopes_layout_->GetGeometry());244 preview_container_->SetGeometry(scopes_layout_->GetGeometry());
243 preview_displaying_ = true;245 preview_displaying_ = true;
244246
@@ -265,6 +267,7 @@
265 {267 {
266 // got a new preview whilst already displaying, we probably clicked a navigation button.268 // got a new preview whilst already displaying, we probably clicked a navigation button.
267 preview_container_->Preview(model, preview_navigation_mode_); // TODO269 preview_container_->Preview(model, preview_navigation_mode_); // TODO
270 preview_container_->scale = scale();
268 }271 }
269272
270 if (G_LIKELY(preview_state_machine_.left_results() > 0 && preview_state_machine_.right_results() > 0))273 if (G_LIKELY(preview_state_machine_.left_results() > 0 && preview_state_machine_.right_results() > 0))
@@ -466,10 +469,7 @@
466 if (monitor_ != monitor)469 if (monitor_ != monitor)
467 {470 {
468 monitor_ = monitor;471 monitor_ = monitor;
469 cv_ = Settings::Instance().em(monitor_);472 scale = Settings::Instance().em(monitor_)->DPIScale();
470
471 OnDPIChanged();
472 Relayout();
473 }473 }
474474
475 /* Give the scopes a chance to prep data before we map them */475 /* Give the scopes a chance to prep data before we map them */
@@ -492,6 +492,7 @@
492492
493 overlay_window_buttons_->Show();493 overlay_window_buttons_->Show();
494494
495 renderer_.scale = scale();
495 renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false);496 renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false);
496 renderer_.AboutToShow();497 renderer_.AboutToShow();
497}498}
@@ -499,7 +500,7 @@
499void DashView::AboutToHide()500void DashView::AboutToHide()
500{501{
501 if (BackgroundEffectHelper::blur_type == BLUR_STATIC)502 if (BackgroundEffectHelper::blur_type == BLUR_STATIC)
502 { 503 {
503 content_geo_ = {0, 0, 0, 0};504 content_geo_ = {0, 0, 0, 0};
504 renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false);505 renderer_.UpdateBlurBackgroundSize(content_geo_, GetRenderAbsoluteGeometry(), false);
505 }506 }
@@ -547,7 +548,7 @@
547 content_layout_->AddLayout(search_bar_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);548 content_layout_->AddLayout(search_bar_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
548549
549 search_bar_ = new SearchBar(true);550 search_bar_ = new SearchBar(true);
550 search_bar_->scale = cv_->DPIScale();551 search_bar_->scale = scale();
551 AddChild(search_bar_);552 AddChild(search_bar_);
552 search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated));553 search_bar_->activated.connect(sigc::mem_fun(this, &DashView::OnEntryActivated));
553 search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged));554 search_bar_->search_changed.connect(sigc::mem_fun(this, &DashView::OnSearchChanged));
@@ -576,8 +577,11 @@
576577
577void DashView::OnDPIChanged()578void DashView::OnDPIChanged()
578{579{
579 double scale = cv_->DPIScale();580 scale = Settings::Instance().em(monitor_)->DPIScale();
581}
580582
583void DashView::UpdateScale(double scale)
584{
581 UpdateDashViewSize();585 UpdateDashViewSize();
582586
583 for (auto& scope : scope_views_)587 for (auto& scope : scope_views_)
@@ -585,27 +589,23 @@
585589
586 search_bar_->scale = scale;590 search_bar_->scale = scale;
587 scope_bar_->scale = scale;591 scope_bar_->scale = scale;
592 renderer_.scale = scale;
593
594 if (preview_container_)
595 preview_container_->scale = scale;
596
597 Relayout();
588}598}
589599
590void DashView::UpdateDashViewSize()600void DashView::UpdateDashViewSize()
591{601{
592 dash::Style const& style = dash::Style::Instance();602 dash::Style const& style = dash::Style::Instance();
593603
594 RawPixel const v_separator_size = style.GetVSeparatorSize();604 layout_->SetLeftAndRightPadding(style.GetVSeparatorSize().CP(scale), 0);
595 RawPixel const h_separator_size = style.GetHSeparatorSize();605 layout_->SetTopAndBottomPadding(style.GetHSeparatorSize().CP(scale), 0);
596 RawPixel const view_top_padding = style.GetDashViewTopPadding();606
597607 content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding().CP(scale), 0);
598 RawPixel const search_bar_left_padding = style.GetSearchBarLeftPadding();608 search_bar_layout_->SetLeftAndRightPadding(style.GetSearchBarLeftPadding().CP(scale), 0);
599 RawPixel const search_bar_height = style.GetSearchBarHeight();
600
601 layout_->SetLeftAndRightPadding(v_separator_size.CP(cv_), 0);
602 layout_->SetTopAndBottomPadding(h_separator_size.CP(cv_), 0);
603
604 content_layout_->SetTopAndBottomPadding(view_top_padding.CP(cv_), 0);
605
606 search_bar_layout_->SetLeftAndRightPadding(search_bar_left_padding.CP(cv_), 0);
607 search_bar_->SetMinimumHeight(search_bar_height.CP(cv_));
608 search_bar_->SetMaximumHeight(search_bar_height.CP(cv_));
609}609}
610610
611void DashView::SetupUBusConnections()611void DashView::SetupUBusConnections()
@@ -626,7 +626,7 @@
626 content_geo_ = GetBestFitGeometry(geo);626 content_geo_ = GetBestFitGeometry(geo);
627 dash::Style& style = dash::Style::Instance();627 dash::Style& style = dash::Style::Instance();
628628
629 RawPixel const top_padding = style.GetDashViewTopPadding();629 int top_padding = style.GetDashViewTopPadding().CP(scale);
630630
631 // kinda hacky, but it makes sure the content isn't so big that it throws631 // kinda hacky, but it makes sure the content isn't so big that it throws
632 // the bottom of the dash off the screen632 // the bottom of the dash off the screen
@@ -634,18 +634,17 @@
634 scopes_layout_->SetMaximumHeight (std::max(0, content_geo_.height -634 scopes_layout_->SetMaximumHeight (std::max(0, content_geo_.height -
635 search_bar_->GetGeometry().height -635 search_bar_->GetGeometry().height -
636 scope_bar_->GetGeometry().height -636 scope_bar_->GetGeometry().height -
637 top_padding.CP(cv_)));637 top_padding));
638638
639 scopes_layout_->SetMinimumHeight (std::max(0, content_geo_.height -639 scopes_layout_->SetMinimumHeight (std::max(0, content_geo_.height -
640 search_bar_->GetGeometry().height -640 search_bar_->GetGeometry().height -
641 scope_bar_->GetGeometry().height -641 scope_bar_->GetGeometry().height -
642 top_padding.CP(cv_)));642 top_padding));
643643
644 layout_->SetMinMaxSize(content_geo_.width, content_geo_.y + content_geo_.height);644 layout_->SetMinMaxSize(content_geo_.width, content_geo_.y + content_geo_.height);
645645
646 // Minus the padding that gets added to the left646 // Minus the padding that gets added to the left
647 RawPixel const tile_width = style.GetTileWidth();647 style.columns_number = floorf((content_geo_.width - (32_em).CP(scale)) / style.GetTileWidth().CP(scale));
648 style.SetDefaultNColumns(floorf((content_geo_.width - cv_->CP(32)) / tile_width.CP(cv_)));
649648
650 ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height));649 ubus_manager_.SendMessage(UBUS_DASH_SIZE_CHANGED, g_variant_new("(ii)", content_geo_.width, content_geo_.height));
651650
@@ -666,33 +665,24 @@
666 int panel_height = renderer_.y_offset;665 int panel_height = renderer_.y_offset;
667666
668 int width = 0, height = 0;667 int width = 0, height = 0;
669 RawPixel const tile_width = style.GetTileWidth();668 int tile_width = style.GetTileWidth().CP(scale);
670 RawPixel const tile_height = style.GetTileHeight();
671 RawPixel const group_top_space = style.GetPlacesGroupTopSpace();
672 RawPixel const category_icon_size = style.GetCategoryIconSize();
673 RawPixel const group_top_padding = style.GetPlacesGroupResultTopPadding();
674669
675 int category_height = (group_top_space.CP(cv_) + category_icon_size.CP(cv_) +670 int category_height = (style.GetPlacesGroupTopSpace().CP(scale) +
676 group_top_padding.CP(cv_) + tile_height.CP(cv_));671 style.GetCategoryIconSize().CP(scale) +
672 style.GetPlacesGroupResultTopPadding().CP(scale) +
673 style.GetTileHeight().CP(scale));
677674
678 int half = for_geo.width / 2;675 int half = for_geo.width / 2;
679676
680 // if default dash size is bigger than half a screens worth of items, go for that.677 // if default dash size is bigger than half a screens worth of items, go for that.
681 while ((width += tile_width.CP(cv_)) < half)678 while ((width += tile_width) < half);
682 ;679
683680 width = std::max(width, tile_width * DASH_TILE_HORIZONTAL_COUNT);
684 RawPixel const v_separator_size = style.GetVSeparatorSize();681 width += style.GetVSeparatorSize().CP(scale);
685 RawPixel const group_left_padding = style.GetPlacesGroupResultLeftPadding();682 width += style.GetPlacesGroupResultLeftPadding().CP(scale) + DASH_RESULT_RIGHT_PAD.CP(scale);
686683
687 width = std::max(width, tile_width.CP(cv_) * DASH_TILE_HORIZONTAL_COUNT);684 height = style.GetHSeparatorSize().CP(scale);
688 width += v_separator_size.CP(cv_);685 height += style.GetDashViewTopPadding().CP(scale);
689 width += group_left_padding.CP(cv_) + DASH_RESULT_RIGHT_PAD.CP(cv_);
690
691 RawPixel const h_separator_size = style.GetHSeparatorSize();
692 RawPixel const top_padding = style.GetDashViewTopPadding();
693
694 height = h_separator_size.CP(cv_);
695 height += top_padding.CP(cv_);
696 height += search_bar_->GetGeometry().height;686 height += search_bar_->GetGeometry().height;
697 height += category_height * DASH_DEFAULT_CATEGORY_COUNT; // adding three categories687 height += category_height * DASH_DEFAULT_CATEGORY_COUNT; // adding three categories
698 height += scope_bar_->GetGeometry().height;688 height += scope_bar_->GetGeometry().height;
@@ -806,7 +796,7 @@
806 texxform.voffset = (scope_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();796 texxform.voffset = (scope_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
807797
808 int start_y = scope_bar_->GetY();798 int start_y = scope_bar_->GetY();
809 int final_y = geo_layout.y + geo_layout.height + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);799 int final_y = geo_layout.y + geo_layout.height + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
810800
811 int scope_y = (1.0f - animate_split_value_) * start_y + (animate_split_value_ * final_y);801 int scope_y = (1.0f - animate_split_value_) * start_y + (animate_split_value_ * final_y);
812802
@@ -830,7 +820,7 @@
830 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();820 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
831821
832 start_y = search_bar_->GetY();822 start_y = search_bar_->GetY();
833 final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);823 final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
834824
835 graphics_engine.QRP_1Tex825 graphics_engine.QRP_1Tex
836 (826 (
@@ -848,7 +838,7 @@
848 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();838 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
849839
850 int start_x = active_scope_view_->filter_bar()->GetX();840 int start_x = active_scope_view_->filter_bar()->GetX();
851 int final_x = content_view_->GetX() + content_view_->GetWidth() + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);841 int final_x = content_view_->GetX() + content_view_->GetWidth() + PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
852842
853 int filter_x = (1.0f - animate_split_value_) * start_x + (animate_split_value_ * final_x);843 int filter_x = (1.0f - animate_split_value_) * start_x + (animate_split_value_ * final_x);
854844
@@ -872,7 +862,7 @@
872 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();862 texxform.voffset = (search_bar_->GetY() - content_view_->GetY())/(float)content_view_->GetHeight();
873863
874 int start_y = search_bar_->GetY();864 int start_y = search_bar_->GetY();
875 int final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(cv_);865 int final_y = geo_layout.y - search_bar_->GetHeight() - PREVIEW_ICON_SPLIT_OFFSCREEN_OFFSET.CP(scale);
876866
877 graphics_engine.QRP_1Tex867 graphics_engine.QRP_1Tex
878 (868 (
@@ -906,8 +896,8 @@
906 // Triangle pointed at preview item896 // Triangle pointed at preview item
907 if (opening_column_x_ != -1)897 if (opening_column_x_ != -1)
908 {898 {
909 int final_width = cv_->CP(14);899 int final_width = PREVIEW_CONTAINER_TRIANGLE_WIDTH.CP(scale);
910 int final_height = cv_->CP(12);900 int final_height = PREVIEW_CONTAINER_TRIANGLE_HEIGHT.CP(scale);
911901
912 int x_center = geo_content.x + (opening_column_x_ - geo_abs.x) + opening_column_width_ / 2;902 int x_center = geo_content.x + (opening_column_x_ - geo_abs.x) + opening_column_width_ / 2;
913 int start_y = geo_abs_preview.y - geo_abs.y;903 int start_y = geo_abs_preview.y - geo_abs.y;
@@ -1136,11 +1126,8 @@
1136 if (Settings::Instance().form_factor() == FormFactor::DESKTOP)1126 if (Settings::Instance().form_factor() == FormFactor::DESKTOP)
1137 {1127 {
1138 dash::Style& style = dash::Style::Instance();1128 dash::Style& style = dash::Style::Instance();
1139 RawPixel const right_title_width = style.GetDashRightTileWidth();1129 geo.width += style.GetDashRightTileWidth().CP(scale);
1140 RawPixel const bottom_title_width = style.GetDashBottomTileHeight();1130 geo.height += style.GetDashBottomTileHeight().CP(scale);
1141
1142 geo.width += right_title_width.CP(cv_);
1143 geo.height += bottom_title_width.CP(cv_);
1144 }1131 }
1145}1132}
11461133
@@ -1282,7 +1269,7 @@
12821269
1283 nux::ObjectPtr<ScopeView> view(new ScopeView(scope, search_bar_->show_filters()));1270 nux::ObjectPtr<ScopeView> view(new ScopeView(scope, search_bar_->show_filters()));
1284 AddChild(view.GetPointer());1271 AddChild(view.GetPointer());
1285 view->scale = cv_->DPIScale();1272 view->scale = scale();
1286 view->SetVisible(false);1273 view->SetVisible(false);
1287 view->result_activated.connect(sigc::mem_fun(this, &DashView::OnResultActivated));1274 view->result_activated.connect(sigc::mem_fun(this, &DashView::OnResultActivated));
12881275
@@ -1500,9 +1487,6 @@
1500 int num_rows = 1; // The search bar1487 int num_rows = 1; // The search bar
1501 std::vector<bool> button_on_monitor;1488 std::vector<bool> button_on_monitor;
15021489
1503 RawPixel const right_title_width = style.GetDashRightTileWidth();
1504 RawPixel const bottom_title_width = style.GetDashBottomTileHeight();
1505
1506 if (active_scope_view_.IsValid())1490 if (active_scope_view_.IsValid())
1507 num_rows += active_scope_view_->GetNumRows();1491 num_rows += active_scope_view_->GetNumRows();
15081492
@@ -1521,8 +1505,8 @@
1521 introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height))1505 introspection.add(nux::Geometry(GetAbsoluteX(), GetAbsoluteY(), content_geo_.width, content_geo_.height))
1522 .add("num_rows", num_rows)1506 .add("num_rows", num_rows)
1523 .add("form_factor", form_factor)1507 .add("form_factor", form_factor)
1524 .add("right-border-width", right_title_width.CP(cv_))1508 .add("right-border-width", style.GetDashRightTileWidth().CP(scale))
1525 .add("bottom-border-height", bottom_title_width.CP(cv_))1509 .add("bottom-border-height", style.GetDashBottomTileHeight().CP(scale))
1526 .add("preview_displaying", preview_displaying_)1510 .add("preview_displaying", preview_displaying_)
1527 .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_)1511 .add("preview_animation", animate_split_value_ * animate_preview_container_value_ * animate_preview_value_)
1528 .add("dash_maximized", style.always_maximised())1512 .add("dash_maximized", style.always_maximised())
15291513
=== modified file 'dash/DashView.h'
--- dash/DashView.h 2014-03-01 22:51:41 +0000
+++ dash/DashView.h 2014-08-06 16:03:19 +0000
@@ -37,7 +37,6 @@
3737
38#include "unity-shared/BackgroundEffectHelper.h"38#include "unity-shared/BackgroundEffectHelper.h"
39#include "unity-shared/BGHash.h"39#include "unity-shared/BGHash.h"
40#include "unity-shared/EMConverter.h"
41#include "unity-shared/Introspectable.h"40#include "unity-shared/Introspectable.h"
42#include "unity-shared/OverlayRenderer.h"41#include "unity-shared/OverlayRenderer.h"
43#include "unity-shared/SearchBar.h"42#include "unity-shared/SearchBar.h"
@@ -63,6 +62,8 @@
63 DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter);62 DashView(Scopes::Ptr const& scopes, ApplicationStarter::Ptr const& application_starter);
64 ~DashView();63 ~DashView();
6564
65 nux::Property<double> scale;
66
66 void AboutToShow(int monitor);67 void AboutToShow(int monitor);
67 void AboutToHide();68 void AboutToHide();
68 void Relayout();69 void Relayout();
@@ -131,6 +132,7 @@
131 nux::Geometry GetRenderAbsoluteGeometry() const;132 nux::Geometry GetRenderAbsoluteGeometry() const;
132133
133 void UpdateDashViewSize();134 void UpdateDashViewSize();
135 void UpdateScale(double scale);
134 void OnDPIChanged();136 void OnDPIChanged();
135137
136 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);138 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
@@ -195,7 +197,6 @@
195197
196 nux::ObjectPtr<OverlayWindowButtons> overlay_window_buttons_;198 nux::ObjectPtr<OverlayWindowButtons> overlay_window_buttons_;
197199
198 EMConverter::Ptr cv_;
199 int monitor_;200 int monitor_;
200201
201 friend class TestDashView;202 friend class TestDashView;
202203
=== modified file 'dash/FilterBar.cpp'
--- dash/FilterBar.cpp 2014-03-20 04:05:39 +0000
+++ dash/FilterBar.cpp 2014-08-06 16:03:19 +0000
@@ -47,28 +47,20 @@
47 : View(NUX_FILE_LINE_PARAM)47 : View(NUX_FILE_LINE_PARAM)
48 , scale(DEFAULT_SCALE)48 , scale(DEFAULT_SCALE)
49{49{
50 Init();50 SetLayout(new nux::VLayout(NUX_TRACKER_LOCATION));
51}
52
53FilterBar::~FilterBar()
54{
55}
56
57void FilterBar::Init()
58{
59 dash::Style& style = dash::Style::Instance();
60
61 nux::LinearLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
62 layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding() - style.GetFilterHighlightPadding());
63 layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding());
64 scale.changed.connect(sigc::mem_fun(this, &FilterBar::UpdateScale));51 scale.changed.connect(sigc::mem_fun(this, &FilterBar::UpdateScale));
65 SetLayout(layout);52 UpdateScale(scale);
66}53}
6754
68void FilterBar::UpdateScale(double scale)55void FilterBar::UpdateScale(double scale)
69{56{
70 for (auto& filters : filter_map_)57 for (auto& filters : filter_map_)
71 filters.second->scale = scale;58 filters.second->scale = scale;
59
60 auto& style = dash::Style::Instance();
61 auto* layout = static_cast<nux::VLayout*>(GetLayout());
62 layout->SetTopAndBottomPadding(style.GetFilterBarTopPadding().CP(scale) - style.GetFilterHighlightPadding().CP(scale));
63 layout->SetSpaceBetweenChildren(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale));
72}64}
7365
74void FilterBar::SetFilters(Filters::Ptr const& filters)66void FilterBar::SetFilters(Filters::Ptr const& filters)
@@ -118,9 +110,7 @@
118}110}
119111
120void FilterBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)112void FilterBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
121{113{}
122
123}
124114
125void FilterBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)115void FilterBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
126{116{
127117
=== modified file 'dash/FilterBar.h'
--- dash/FilterBar.h 2014-03-20 04:05:39 +0000
+++ dash/FilterBar.h 2014-08-06 16:03:19 +0000
@@ -42,7 +42,6 @@
42 NUX_DECLARE_OBJECT_TYPE(FilterBar, nux::View);42 NUX_DECLARE_OBJECT_TYPE(FilterBar, nux::View);
43public:43public:
44 FilterBar(NUX_FILE_LINE_PROTO);44 FilterBar(NUX_FILE_LINE_PROTO);
45 ~FilterBar();
4645
47 nux::Property<double> scale;46 nux::Property<double> scale;
4847
@@ -62,7 +61,6 @@
62 virtual void AddProperties(debug::IntrospectionData&);61 virtual void AddProperties(debug::IntrospectionData&);
6362
64private:63private:
65 void Init();
66 void UpdateScale(double scale);64 void UpdateScale(double scale);
6765
68 FilterFactory factory_;66 FilterFactory factory_;
6967
=== modified file 'dash/FilterBasicButton.cpp'
--- dash/FilterBasicButton.cpp 2013-11-14 03:00:29 +0000
+++ dash/FilterBasicButton.cpp 2014-08-06 16:03:19 +0000
@@ -22,53 +22,36 @@
22#include "unity-shared/DashStyle.h"22#include "unity-shared/DashStyle.h"
23#include "FilterBasicButton.h"23#include "FilterBasicButton.h"
2424
25namespace
26{
27const int kMinButtonHeight = 30;
28const int kMinButtonWidth = 48;
29const int kFontSizePx = 15; // 15px == 11pt
30}
31
32namespace unity25namespace unity
33{26{
34namespace dash27namespace dash
35{28{
36 29namespace
30{
31const RawPixel BUTTON_HEIGHT = 30_em;
32const RawPixel MIN_BUTTON_WIDTH = 48_em;
33const int FONT_SIZE_PX = 15; // 15px == 11pt
34}
35
37NUX_IMPLEMENT_OBJECT_TYPE(FilterBasicButton);36NUX_IMPLEMENT_OBJECT_TYPE(FilterBasicButton);
3837
39FilterBasicButton::FilterBasicButton(nux::TextureArea* image, NUX_FILE_LINE_DECL)38FilterBasicButton::FilterBasicButton(nux::TextureArea* image, NUX_FILE_LINE_DECL)
40 : nux::ToggleButton(image, NUX_FILE_LINE_PARAM)39 : FilterBasicButton(std::string(), image, NUX_FILE_LINE_PARAM)
41{40{}
42 Init();41
43}42FilterBasicButton::FilterBasicButton(NUX_FILE_LINE_DECL)
43 : FilterBasicButton(std::string(), NUX_FILE_LINE_PARAM)
44{}
4445
45FilterBasicButton::FilterBasicButton(std::string const& label, NUX_FILE_LINE_DECL)46FilterBasicButton::FilterBasicButton(std::string const& label, NUX_FILE_LINE_DECL)
46 : nux::ToggleButton(NUX_FILE_LINE_PARAM)47 : FilterBasicButton(label, nullptr, NUX_FILE_LINE_PARAM)
47 , label_(label)48{}
48{
49 Init();
50}
5149
52FilterBasicButton::FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_DECL)50FilterBasicButton::FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_DECL)
53 : nux::ToggleButton(image, NUX_FILE_LINE_PARAM)51 : nux::ToggleButton(image, NUX_FILE_LINE_PARAM)
52 , scale(1.0)
54 , label_(label)53 , label_(label)
55{54{
56 Init();
57}
58
59FilterBasicButton::FilterBasicButton(NUX_FILE_LINE_DECL)
60 : nux::ToggleButton(NUX_FILE_LINE_PARAM)
61{
62 Init();
63}
64
65FilterBasicButton::~FilterBasicButton()
66{
67}
68
69void FilterBasicButton::Init()
70{
71
72 InitTheme();55 InitTheme();
73 SetAcceptKeyNavFocusOnMouseDown(false);56 SetAcceptKeyNavFocusOnMouseDown(false);
74 SetAcceptKeyNavFocusOnMouseEnter(true);57 SetAcceptKeyNavFocusOnMouseEnter(true);
@@ -85,34 +68,44 @@
85 if (GetInputEventSensitivity())68 if (GetInputEventSensitivity())
86 Active() ? Deactivate() : Activate();69 Active() ? Deactivate() : Activate();
87 });70 });
71
72 scale.changed.connect(sigc::mem_fun(this, &FilterBasicButton::UpdateScale));
88}73}
8974
90void FilterBasicButton::InitTheme()75void FilterBasicButton::InitTheme()
91{76{
92 if (!active_)77 nux::Geometry const& geo = GetGeometry();
93 {78
94 nux::Geometry const& geo = GetGeometry();79 prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
9580 active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
96 prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));81 normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
97 active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));82 focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay)));
98 normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));83
99 focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay)));84 SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale));
100 }85 ApplyMinWidth();
10186
102 SetMinimumHeight(kMinButtonHeight);87 SetMinimumHeight(BUTTON_HEIGHT.CP(scale));
103 SetMinimumWidth(kMinButtonWidth);88 SetMaximumHeight(BUTTON_HEIGHT.CP(scale));
104}89}
10590
106void FilterBasicButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)91void FilterBasicButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)
107{92{
108 Style::Instance().Button(cr, faked_state, label_, kFontSizePx, Alignment::CENTER, true);93 cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
94 Style::Instance().Button(cr, faked_state, label_, FONT_SIZE_PX, Alignment::CENTER, true);
109}95}
11096
111void FilterBasicButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr)97void FilterBasicButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr)
112{98{
99 cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
113 Style::Instance().ButtonFocusOverlay(cr);100 Style::Instance().ButtonFocusOverlay(cr);
114}101}
115102
103void FilterBasicButton::UpdateScale(double scale)
104{
105 InitTheme();
106 QueueDraw();
107}
108
116long FilterBasicButton::ComputeContentSize()109long FilterBasicButton::ComputeContentSize()
117{110{
118 long ret = nux::Button::ComputeContentSize();111 long ret = nux::Button::ComputeContentSize();
119112
=== modified file 'dash/FilterBasicButton.h'
--- dash/FilterBasicButton.h 2012-12-13 09:19:34 +0000
+++ dash/FilterBasicButton.h 2014-08-06 16:03:19 +0000
@@ -39,15 +39,15 @@
39 FilterBasicButton(std::string const& label, NUX_FILE_LINE_PROTO);39 FilterBasicButton(std::string const& label, NUX_FILE_LINE_PROTO);
40 FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_PROTO);40 FilterBasicButton(std::string const& label, nux::TextureArea* image, NUX_FILE_LINE_PROTO);
41 FilterBasicButton(NUX_FILE_LINE_PROTO);41 FilterBasicButton(NUX_FILE_LINE_PROTO);
42 virtual ~FilterBasicButton();42
4343 nux::Property<double> scale;
44 void SetClearBeforeDraw(bool clear_before_draw);44
45protected:45protected:
46 virtual long ComputeContentSize();46 virtual long ComputeContentSize();
47 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);47 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
4848
49 void Init();
50 void InitTheme();49 void InitTheme();
50 void SetClearBeforeDraw(bool clear_before_draw);
51 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);51 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
52 void RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr);52 void RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr);
5353
@@ -61,6 +61,8 @@
61 nux::Geometry cached_geometry_;61 nux::Geometry cached_geometry_;
6262
63private:63private:
64 void UpdateScale(double);
65
64 std::string label_;66 std::string label_;
65 bool clear_before_draw_;67 bool clear_before_draw_;
66};68};
6769
=== modified file 'dash/FilterExpanderLabel.cpp'
--- dash/FilterExpanderLabel.cpp 2014-03-20 04:05:39 +0000
+++ dash/FilterExpanderLabel.cpp 2014-08-06 16:03:19 +0000
@@ -22,16 +22,20 @@
2222
23#include "unity-shared/DashStyle.h"23#include "unity-shared/DashStyle.h"
24#include "unity-shared/GraphicsUtils.h"24#include "unity-shared/GraphicsUtils.h"
25#include "unity-shared/RawPixel.h"
26#include "FilterExpanderLabel.h"25#include "FilterExpanderLabel.h"
2726
27namespace unity
28{
29namespace dash
30{
28namespace31namespace
29{32{
3033const double DEFAULT_SCALE = 1.0;
31const float EXPAND_DEFAULT_ICON_OPACITY = 1.0f;34const float EXPAND_DEFAULT_ICON_OPACITY = 1.0f;
3235const RawPixel EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8_em;
33// expander_layout_36const RawPixel ARROW_HORIZONTAL_PADDING = 2_em;
34const int EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN = 8;37const RawPixel ARROW_TOP_PADDING = 11_em;
38const RawPixel ARROW_BOTTOM_PADDING = 9_em;
3539
36// font40// font
37const char* const FONT_EXPANDER_LABEL = "Ubuntu 13"; // 17px = 1341const char* const FONT_EXPANDER_LABEL = "Ubuntu 13"; // 17px = 13
@@ -72,16 +76,6 @@
7276
73}77}
7478
75namespace unity
76{
77namespace dash
78{
79
80namespace
81{
82 double const DEFAULT_SCALE = 1.0;
83}
84
85NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);79NUX_IMPLEMENT_OBJECT_TYPE(FilterExpanderLabel);
8680
87FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL)81FilterExpanderLabel::FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_DECL)
@@ -94,8 +88,6 @@
94 , expander_layout_(nullptr)88 , expander_layout_(nullptr)
95 , right_hand_contents_(nullptr)89 , right_hand_contents_(nullptr)
96 , cairo_label_(nullptr)90 , cairo_label_(nullptr)
97 , raw_label_(label)
98 , label_("label")
99{91{
100 scale.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::UpdateScale));92 scale.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::UpdateScale));
101 expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));93 expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
@@ -104,14 +96,13 @@
10496
105void FilterExpanderLabel::SetLabel(std::string const& label)97void FilterExpanderLabel::SetLabel(std::string const& label)
106{98{
107 raw_label_ = label;99 cairo_label_->SetText(label);
108
109 cairo_label_->SetText(label.c_str());
110}100}
111101
112void FilterExpanderLabel::UpdateScale(double scale)102void FilterExpanderLabel::UpdateScale(double scale)
113{103{
114 cairo_label_->SetScale(scale);104 cairo_label_->SetScale(scale);
105 UpdateLayoutSizes();
115}106}
116107
117void FilterExpanderLabel::SetRightHandView(nux::View* view)108void FilterExpanderLabel::SetRightHandView(nux::View* view)
@@ -143,40 +134,27 @@
143134
144void FilterExpanderLabel::BuildLayout()135void FilterExpanderLabel::BuildLayout()
145{136{
146 dash::Style& style = dash::Style::Instance();
147
148 layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);137 layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
149 layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding(), style.GetFilterBarRightPadding());
150
151 top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);138 top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
152 top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding());
153
154 expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);139 expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
155 expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN);
156140
157 expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);141 expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
158 expander_view_->SetLayout(expander_layout_);142 expander_view_->SetLayout(expander_layout_);
159 top_bar_layout_->AddView(expander_view_, 1);143 top_bar_layout_->AddView(expander_view_, 1);
160144
161 cairo_label_ = new StaticCairoText(label_.c_str(), NUX_TRACKER_LOCATION);145 cairo_label_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
162 cairo_label_->SetFont(FONT_EXPANDER_LABEL);146 cairo_label_->SetFont(FONT_EXPANDER_LABEL);
147 cairo_label_->SetScale(scale);
163 cairo_label_->SetTextColor(nux::color::White);148 cairo_label_->SetTextColor(nux::color::White);
164 cairo_label_->SetAcceptKeyboardEvent(false);149 cairo_label_->SetAcceptKeyboardEvent(false);
165150
166 nux::BaseTexture* arrow;151 expand_icon_ = new IconTexture(Style::Instance().GetGroupUnexpandIcon());
167 arrow = dash::Style::Instance().GetGroupUnexpandIcon();
168 expand_icon_ = new IconTexture(arrow,
169 arrow->GetWidth(),
170 arrow->GetHeight());
171 expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY);152 expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY);
172 expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());153 expand_icon_->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
173 expand_icon_->SetVisible(true);154 expand_icon_->SetVisible(true);
155
174 arrow_layout_ = new nux::VLayout();156 arrow_layout_ = new nux::VLayout();
175 arrow_top_space_ = new nux::SpaceLayout(2, 2, 11, 11);
176 arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 9, 9);
177 arrow_layout_->AddView(arrow_top_space_, 0, nux::MINOR_POSITION_CENTER);
178 arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER);157 arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER);
179 arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER);
180158
181 expander_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);159 expander_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
182 expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);160 expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);
@@ -209,8 +187,25 @@
209 cairo_label_->mouse_click.connect(mouse_expand);187 cairo_label_->mouse_click.connect(mouse_expand);
210 expand_icon_->mouse_click.connect(mouse_expand);188 expand_icon_->mouse_click.connect(mouse_expand);
211189
190 UpdateLayoutSizes();
191}
192
193void FilterExpanderLabel::UpdateLayoutSizes()
194{
195 auto& style = dash::Style::Instance();
196
197 layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding().CP(scale), style.GetFilterBarRightPadding().CP(scale));
198 top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding().CP(scale));
199 expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN.CP(scale));
200
201 auto const& tex = expand_icon_->texture();
202 expand_icon_->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale));
203
204 arrow_layout_->SetLeftAndRightPadding(ARROW_HORIZONTAL_PADDING.CP(scale));
205 arrow_layout_->SetTopAndBottomPadding(ARROW_TOP_PADDING.CP(scale), ARROW_BOTTOM_PADDING.CP(scale));
206
212 QueueRelayout();207 QueueRelayout();
213 NeedRedraw();208 QueueDraw();
214}209}
215210
216void FilterExpanderLabel::DoExpandChange(bool change)211void FilterExpanderLabel::DoExpandChange(bool change)
@@ -221,6 +216,9 @@
221 else216 else
222 expand_icon_->SetTexture(style.GetGroupExpandIcon());217 expand_icon_->SetTexture(style.GetGroupExpandIcon());
223218
219 auto const& tex = expand_icon_->texture();
220 expand_icon_->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale));
221
224 if (change and contents_ and !contents_->IsChildOf(layout_))222 if (change and contents_ and !contents_->IsChildOf(layout_))
225 {223 {
226 layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition(1));224 layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition(1));
@@ -278,7 +276,7 @@
278 graphics::ClearGeometry(right_hand_contents_->GetGeometry());276 graphics::ClearGeometry(right_hand_contents_->GetGeometry());
279277
280 if (expanded())278 if (expanded())
281 ClearRedirectedRenderChildArea(); 279 ClearRedirectedRenderChildArea();
282 }280 }
283281
284 if (focus_layer_ && ShouldBeHighlighted())282 if (focus_layer_ && ShouldBeHighlighted())
@@ -296,7 +294,7 @@
296294
297 if (IsFullRedraw())295 if (IsFullRedraw())
298 {296 {
299 nux::GetPainter().PopPaintLayerStack(); 297 nux::GetPainter().PopPaintLayerStack();
300 }298 }
301 else if (pushed_paint_layers > 0)299 else if (pushed_paint_layers > 0)
302 {300 {
303301
=== modified file 'dash/FilterExpanderLabel.h'
--- dash/FilterExpanderLabel.h 2014-03-20 04:05:39 +0000
+++ dash/FilterExpanderLabel.h 2014-08-06 16:03:19 +0000
@@ -80,21 +80,18 @@
8080
81private:81private:
82 void BuildLayout();82 void BuildLayout();
83 void UpdateLayoutSizes();
83 void DoExpandChange(bool change);84 void DoExpandChange(bool change);
84 bool ShouldBeHighlighted();85 bool ShouldBeHighlighted();
85 void UpdateScale(double scale);86 void UpdateScale(double scale);
8687
87 nux::LinearLayout* layout_;88 nux::VLayout* layout_;
88 nux::LinearLayout* top_bar_layout_;89 nux::LinearLayout* top_bar_layout_;
89 nux::View* expander_view_;90 nux::View* expander_view_;
90 nux::LinearLayout* expander_layout_;91 nux::LinearLayout* expander_layout_;
91 nux::View* right_hand_contents_;92 nux::View* right_hand_contents_;
92 StaticCairoText* cairo_label_;93 StaticCairoText* cairo_label_;
93 std::string raw_label_;
94 std::string label_;
95 nux::VLayout* arrow_layout_;94 nux::VLayout* arrow_layout_;
96 nux::SpaceLayout* arrow_top_space_;
97 nux::SpaceLayout* arrow_bottom_space_;
98 IconTexture* expand_icon_;95 IconTexture* expand_icon_;
9996
100 nux::ObjectPtr<nux::Layout> contents_;97 nux::ObjectPtr<nux::Layout> contents_;
10198
=== modified file 'dash/FilterGenreWidget.cpp'
--- dash/FilterGenreWidget.cpp 2013-04-18 12:13:21 +0000
+++ dash/FilterGenreWidget.cpp 2014-08-06 16:03:19 +0000
@@ -35,6 +35,11 @@
35{35{
36namespace dash36namespace dash
37{37{
38namespace
39{
40const RawPixel CHILDREN_SPACE = 12_em;
41const RawPixel CHILDREN_SPACE_SMALLER = 10_em;
42}
3843
39NUX_IMPLEMENT_OBJECT_TYPE(FilterGenre);44NUX_IMPLEMENT_OBJECT_TYPE(FilterGenre);
4045
@@ -42,33 +47,41 @@
42: FilterExpanderLabel(_("Categories"), NUX_FILE_LINE_PARAM)47: FilterExpanderLabel(_("Categories"), NUX_FILE_LINE_PARAM)
43, all_button_(nullptr)48, all_button_(nullptr)
44{49{
45 dash::Style& style = dash::Style::Instance();
46
47 InitTheme();50 InitTheme();
4851
49
50 genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);52 genre_layout_ = new nux::GridHLayout(NUX_TRACKER_LOCATION);
51 genre_layout_->ForceChildrenSize(true);53 genre_layout_->ForceChildrenSize(true);
52 genre_layout_->MatchContentSize(true);54 genre_layout_->MatchContentSize(true);
53 genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding(), style.GetFilterHighlightPadding());
54 genre_layout_->EnablePartialVisibility(false);55 genre_layout_->EnablePartialVisibility(false);
5556
57 UpdateSize(columns);
58 SetContents(genre_layout_);
59
60 scale.changed.connect([this, columns] (double scale) {
61 if (all_button_) all_button_->scale = scale;
62
63 for (auto* button : buttons_)
64 button->scale = scale;
65
66 UpdateSize(columns);
67 });
68}
69
70void FilterGenre::UpdateSize(int columns)
71{
72 auto& style = dash::Style::Instance();
73 genre_layout_->SetTopAndBottomPadding(style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale), style.GetFilterHighlightPadding().CP(scale));
74
56 if (columns == 3)75 if (columns == 3)
57 {76 {
58 genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 12 * 2) / 3, style.GetFilterButtonHeight());77 genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE.CP(scale) * 2) / 3, style.GetFilterButtonHeight().CP(scale));
59 genre_layout_->SetSpaceBetweenChildren (12, 12);78 genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale), CHILDREN_SPACE.CP(scale));
60 }79 }
61 else80 else
62 {81 {
63 genre_layout_->SetChildrenSize((style.GetFilterBarWidth() - 10 ) / 2, style.GetFilterButtonHeight());82 genre_layout_->SetChildrenSize((style.GetFilterBarWidth().CP(scale) - CHILDREN_SPACE_SMALLER.CP(scale)) / 2, style.GetFilterButtonHeight().CP(scale));
64 genre_layout_->SetSpaceBetweenChildren (10, 12);83 genre_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE_SMALLER.CP(scale), CHILDREN_SPACE.CP(scale));
65 }84 }
66
67 SetContents(genre_layout_);
68}
69
70FilterGenre::~FilterGenre()
71{
72}85}
7386
74void FilterGenre::SetFilter(Filter::Ptr const& filter)87void FilterGenre::SetFilter(Filter::Ptr const& filter)
@@ -81,11 +94,14 @@
81 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;94 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
82 SetRightHandView(all_button_);95 SetRightHandView(all_button_);
83 if (all_button_)96 if (all_button_)
97 {
98 all_button_->scale = scale();
84 all_button_->SetFilter(filter_);99 all_button_->SetFilter(filter_);
100 }
85 };101 };
86 show_button_func(filter_->show_all_button);102 show_button_func(filter_->show_all_button);
87 filter_->show_all_button.changed.connect(show_button_func);103 filter_->show_all_button.changed.connect(show_button_func);
88 104
89 expanded = !filter_->collapsed();105 expanded = !filter_->collapsed();
90106
91 filter_->option_added.connect(sigc::mem_fun(this, &FilterGenre::OnOptionAdded));107 filter_->option_added.connect(sigc::mem_fun(this, &FilterGenre::OnOptionAdded));
@@ -106,6 +122,7 @@
106 std::string label(escape.Value());122 std::string label(escape.Value());
107123
108 FilterGenreButton* button = new FilterGenreButton(label, NUX_TRACKER_LOCATION);124 FilterGenreButton* button = new FilterGenreButton(label, NUX_TRACKER_LOCATION);
125 button->scale = scale();
109 button->SetFilter(new_filter);126 button->SetFilter(new_filter);
110 genre_layout_->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);127 genre_layout_->AddView(button, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
111 buttons_.push_back(button);128 buttons_.push_back(button);
@@ -121,7 +138,7 @@
121 {138 {
122 genre_layout_->RemoveChildObject(*it);139 genre_layout_->RemoveChildObject(*it);
123 buttons_.erase(it);140 buttons_.erase(it);
124 141
125 QueueRelayout();142 QueueRelayout();
126 break;143 break;
127 }144 }
128145
=== modified file 'dash/FilterGenreWidget.h'
--- dash/FilterGenreWidget.h 2012-11-27 23:16:06 +0000
+++ dash/FilterGenreWidget.h 2014-08-06 16:03:19 +0000
@@ -46,7 +46,6 @@
46 NUX_DECLARE_OBJECT_TYPE(FilterGenre, FilterExpanderLabel);46 NUX_DECLARE_OBJECT_TYPE(FilterGenre, FilterExpanderLabel);
47public:47public:
48 FilterGenre(int columns, NUX_FILE_LINE_PROTO);48 FilterGenre(int columns, NUX_FILE_LINE_PROTO);
49 virtual ~FilterGenre();
5049
51 void SetFilter(Filter::Ptr const& filter);50 void SetFilter(Filter::Ptr const& filter);
52 std::string GetFilterType();51 std::string GetFilterType();
@@ -59,6 +58,7 @@
59private:58private:
60 void OnOptionAdded(FilterOption::Ptr const& new_filter);59 void OnOptionAdded(FilterOption::Ptr const& new_filter);
61 void OnOptionRemoved(FilterOption::Ptr const& removed_filter);60 void OnOptionRemoved(FilterOption::Ptr const& removed_filter);
61 void UpdateSize(int columns);
6262
63 nux::GridHLayout* genre_layout_;63 nux::GridHLayout* genre_layout_;
64 FilterAllButton* all_button_;64 FilterAllButton* all_button_;
6565
=== modified file 'dash/FilterMultiRangeButton.cpp'
--- dash/FilterMultiRangeButton.cpp 2013-11-14 03:00:29 +0000
+++ dash/FilterMultiRangeButton.cpp 2014-08-06 16:03:19 +0000
@@ -33,29 +33,18 @@
3333
34namespace34namespace
35{35{
36const int kFontSizePx = 10;36const int FONT_SIZE_PX = 10;
37
38const int kLayoutPadLeftRight = 4;
39const int kLayoutPadtopBottom = 2;
40}37}
4138
42NUX_IMPLEMENT_OBJECT_TYPE(FilterMultiRangeButton);39NUX_IMPLEMENT_OBJECT_TYPE(FilterMultiRangeButton);
4340
44FilterMultiRangeButton::FilterMultiRangeButton(NUX_FILE_LINE_DECL)41FilterMultiRangeButton::FilterMultiRangeButton(NUX_FILE_LINE_DECL)
45 : nux::ToggleButton(NUX_FILE_LINE_PARAM)42 : nux::ToggleButton(NUX_FILE_LINE_PARAM)
43 , scale(1.0)
46 , theme_init_(false)44 , theme_init_(false)
47 , has_arrow_(MultiRangeArrow::NONE)45 , has_arrow_(MultiRangeArrow::NONE)
48 , side_(MultiRangeSide::CENTER)46 , side_(MultiRangeSide::CENTER)
49{47{
50 Init();
51}
52
53FilterMultiRangeButton::~FilterMultiRangeButton()
54{
55}
56
57void FilterMultiRangeButton::Init()
58{
59 InitTheme();48 InitTheme();
60 // Controlled by parent widget49 // Controlled by parent widget
61 SetAcceptKeyNavFocusOnMouseDown(false);50 SetAcceptKeyNavFocusOnMouseDown(false);
@@ -64,6 +53,8 @@
64 state_change.connect(sigc::mem_fun(this, &FilterMultiRangeButton::OnActivated));53 state_change.connect(sigc::mem_fun(this, &FilterMultiRangeButton::OnActivated));
65 key_nav_focus_change.connect([this](nux::Area*, bool, nux::KeyNavDirection) { QueueDraw(); });54 key_nav_focus_change.connect([this](nux::Area*, bool, nux::KeyNavDirection) { QueueDraw(); });
66 key_nav_focus_activate.connect([this](nux::Area* area) { Active() ? Deactivate() : Activate(); });55 key_nav_focus_activate.connect([this](nux::Area* area) { Active() ? Deactivate() : Activate(); });
56
57 scale.changed.connect(sigc::hide(sigc::mem_fun(this, &FilterMultiRangeButton::InitTheme)));
67}58}
6859
69void FilterMultiRangeButton::OnActivated(nux::Area* area)60void FilterMultiRangeButton::OnActivated(nux::Area* area)
@@ -133,27 +124,26 @@
133124
134void FilterMultiRangeButton::InitTheme()125void FilterMultiRangeButton::InitTheme()
135{126{
136 if (!active_[MapKey(MultiRangeArrow::LEFT, MultiRangeSide::LEFT)])127 nux::Geometry const& geo = GetGeometry();
128
129 std::vector<MultiRangeSide> sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER};
130 std::vector<MultiRangeArrow> arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE};
131
132 for (auto arrow : arrows)
137 {133 {
138 nux::Geometry const& geo = GetGeometry();134 for (auto side : sides)
139
140 std::vector<MultiRangeSide> sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER};
141 std::vector<MultiRangeArrow> arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE};
142
143 for (auto arrow : arrows)
144 {135 {
145 for (auto side : sides)136 active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side)));
146 {137 normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side)));
147 active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side)));138 prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side)));
148 normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side)));139 focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side)));
149 prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side)));
150 focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side)));
151 }
152 }140 }
153 }141 }
154142
155 SetMinimumHeight(dash::Style::Instance().GetFilterButtonHeight() + 3);143 SetMinimumHeight(Style::Instance().GetFilterButtonHeight().CP(scale) + (3_em).CP(scale));
156 theme_init_ = true;144 theme_init_ = true;
145
146 QueueDraw();
157}147}
158148
159void FilterMultiRangeButton::RedrawTheme(nux::Geometry const& geom,149void FilterMultiRangeButton::RedrawTheme(nux::Geometry const& geom,
@@ -187,8 +177,9 @@
187 else177 else
188 segment = Segment::RIGHT;178 segment = Segment::RIGHT;
189179
190 Style::Instance().MultiRangeSegment(cr, faked_state, name, kFontSizePx, arrow, segment);180 cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
191 NeedRedraw();181 Style::Instance().MultiRangeSegment(cr, faked_state, name, FONT_SIZE_PX, arrow, segment);
182 QueueDraw();
192}183}
193184
194void FilterMultiRangeButton::RedrawFocusOverlay(nux::Geometry const& geom,185void FilterMultiRangeButton::RedrawFocusOverlay(nux::Geometry const& geom,
@@ -214,6 +205,7 @@
214 else205 else
215 segment = Segment::RIGHT;206 segment = Segment::RIGHT;
216207
208 cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
217 Style::Instance().MultiRangeFocusOverlay(cr, arrow, segment);209 Style::Instance().MultiRangeFocusOverlay(cr, arrow, segment);
218 QueueDraw();210 QueueDraw();
219}211}
220212
=== modified file 'dash/FilterMultiRangeButton.h'
--- dash/FilterMultiRangeButton.h 2013-11-08 15:05:51 +0000
+++ dash/FilterMultiRangeButton.h 2014-08-06 16:03:19 +0000
@@ -54,8 +54,9 @@
54{54{
55 NUX_DECLARE_OBJECT_TYPE(FilterMultiRangeButton, nux::ToggleButton);55 NUX_DECLARE_OBJECT_TYPE(FilterMultiRangeButton, nux::ToggleButton);
56public:56public:
57 FilterMultiRangeButton (NUX_FILE_LINE_PROTO);57 FilterMultiRangeButton(NUX_FILE_LINE_PROTO);
58 virtual ~FilterMultiRangeButton();58
59 nux::Property<double> scale;
5960
60 void SetFilter(FilterOption::Ptr const& filter);61 void SetFilter(FilterOption::Ptr const& filter);
61 FilterOption::Ptr GetFilter();62 FilterOption::Ptr GetFilter();
@@ -69,7 +70,6 @@
6970
70private:71private:
71 void InitTheme();72 void InitTheme();
72 void Init();
7373
74 void RedrawTheme(nux::Geometry const& geom,74 void RedrawTheme(nux::Geometry const& geom,
75 cairo_t* cr,75 cairo_t* cr,
7676
=== modified file 'dash/FilterMultiRangeWidget.cpp'
--- dash/FilterMultiRangeWidget.cpp 2013-04-17 15:10:39 +0000
+++ dash/FilterMultiRangeWidget.cpp 2014-08-06 16:03:19 +0000
@@ -64,6 +64,13 @@
64 mouse_up.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseUp));64 mouse_up.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseUp));
6565
66 mouse_drag.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseDrag));66 mouse_drag.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::RecvMouseDrag));
67
68 scale.changed.connect([this] (double scale) {
69 if (all_button_) all_button_->scale = scale;
70
71 for (auto const& button : buttons_)
72 button->scale = scale;
73 });
67}74}
6875
69void FilterMultiRangeWidget::SetFilter(Filter::Ptr const& filter)76void FilterMultiRangeWidget::SetFilter(Filter::Ptr const& filter)
@@ -83,11 +90,14 @@
83 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;90 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
84 SetRightHandView(all_button_);91 SetRightHandView(all_button_);
85 if (all_button_)92 if (all_button_)
93 {
94 all_button_->scale = scale();
86 all_button_->SetFilter(filter_);95 all_button_->SetFilter(filter_);
96 }
87 };97 };
88 show_button_func(filter_->show_all_button);98 show_button_func(filter_->show_all_button);
89 filter_->show_all_button.changed.connect(show_button_func);99 filter_->show_all_button.changed.connect(show_button_func);
90 100
91 expanded = !filter_->collapsed();101 expanded = !filter_->collapsed();
92102
93 filter_->option_added.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::OnOptionAdded));103 filter_->option_added.connect(sigc::mem_fun(this, &FilterMultiRangeWidget::OnOptionAdded));
@@ -151,6 +161,7 @@
151void FilterMultiRangeWidget::OnOptionAdded(FilterOption::Ptr const& new_filter)161void FilterMultiRangeWidget::OnOptionAdded(FilterOption::Ptr const& new_filter)
152{162{
153 FilterMultiRangeButtonPtr button(new FilterMultiRangeButton(NUX_TRACKER_LOCATION));163 FilterMultiRangeButtonPtr button(new FilterMultiRangeButton(NUX_TRACKER_LOCATION));
164 button->scale = scale();
154 button->SetFilter(new_filter);165 button->SetFilter(new_filter);
155 layout_->AddView(button.GetPointer());166 layout_->AddView(button.GetPointer());
156 buttons_.push_back(button);167 buttons_.push_back(button);
157168
=== modified file 'dash/FilterRatingsButton.cpp'
--- dash/FilterRatingsButton.cpp 2013-11-14 03:00:29 +0000
+++ dash/FilterRatingsButton.cpp 2014-08-06 16:03:19 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2011 Canonical Ltd.2 * Copyright 2014 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3, as5 * under the terms of the GNU Lesser General Public License version 3, as
@@ -15,66 +15,39 @@
15 * License version 3 along with this program. If not, see15 * License version 3 along with this program. If not, see
16 * <http://www.gnu.org/licenses/>16 * <http://www.gnu.org/licenses/>
17 *17 *
18 * Authored by: Gordon Allott <gord.allott@canonical.com>18 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
19 *19 *
20 */20 */
2121
22#include <math.h>
23
24#include <Nux/Nux.h>
25#include <NuxCore/Logger.h>
26
27#include "unity-shared/DashStyle.h"
28#include "FilterRatingsButton.h"22#include "FilterRatingsButton.h"
2923
30namespace24namespace
31{25{
32const int star_size = 28;26const int STAR_SIZE = 28;
33const int star_gap = 10;27const int STAR_GAP = 10;
34const int num_stars = 5;
35}28}
3629
37namespace unity30namespace unity
38{31{
39namespace dash32namespace dash
40{33{
41 34
42NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsButton);35NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsButton);
4336
44FilterRatingsButton::FilterRatingsButton(NUX_FILE_LINE_DECL)37FilterRatingsButton::FilterRatingsButton(NUX_FILE_LINE_DECL)
45 : nux::ToggleButton(NUX_FILE_LINE_PARAM)38 : RatingsButton(STAR_SIZE, STAR_GAP, NUX_FILE_LINE_PARAM)
46 , focused_star_(-1)39{}
47{
48 SetAcceptKeyNavFocusOnMouseDown(false);
49 SetAcceptKeyNavFocusOnMouseEnter(true);
50
51 mouse_up.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseUp));
52 mouse_move.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseMove));
53 mouse_drag.connect(sigc::mem_fun(this, &FilterRatingsButton::RecvMouseDrag));
54
55 key_nav_focus_change.connect([this](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
56 {
57 if (has_focus)
58 focused_star_ = 0;
59 else if (!has_focus)
60 focused_star_ = -1;
61
62 QueueDraw();
63 });
64
65 key_nav_focus_activate.connect([this](nux::Area*) { filter_->rating = static_cast<float>(focused_star_+1)/num_stars; });
66 key_down.connect(sigc::mem_fun(this, &FilterRatingsButton::OnKeyDown));
67}
68
69FilterRatingsButton::~FilterRatingsButton()
70{
71}
7240
73void FilterRatingsButton::SetFilter(Filter::Ptr const& filter)41void FilterRatingsButton::SetFilter(Filter::Ptr const& filter)
74{42{
75 filter_ = std::static_pointer_cast<RatingsFilter>(filter);43 filter_ = std::static_pointer_cast<RatingsFilter>(filter);
76 filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::OnRatingsChanged));44 filter_->rating.changed.connect(sigc::mem_fun(this, &FilterRatingsButton::SetRating));
77 NeedRedraw();45 QueueDraw();
46}
47
48RatingsFilter::Ptr FilterRatingsButton::GetFilter() const
49{
50 return filter_;
78}51}
7952
80std::string FilterRatingsButton::GetFilterType()53std::string FilterRatingsButton::GetFilterType()
@@ -82,188 +55,22 @@
82 return "FilterRatingsButton";55 return "FilterRatingsButton";
83}56}
8457
85void FilterRatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)58std::string FilterRatingsButton::GetName() const
86{59{
87 int rating = 0;60 return "FilterRatingsButton";
88 if (filter_ && filter_->filtering)61}
89 rating = static_cast<int>(filter_->rating * num_stars);62
90 // FIXME: 9/26/201163void FilterRatingsButton::SetRating(float rating)
91 // We should probably support an API for saying whether the ratings64{
92 // should or shouldn't support half stars...but our only consumer at65 if (filter_)
93 // the moment is the applications scope which according to design66 filter_->rating = rating;
94 // (Bug #839759) shouldn't. So for now just force rounding.67
95 // int total_half_stars = rating % 2;68 QueueDraw();
96 // int total_full_stars = rating / 2;69}
97 int total_full_stars = rating;70
9871float FilterRatingsButton::GetRating() const
99 nux::Geometry const& geo = GetGeometry();72{
100 nux::Geometry geo_star(geo);73 return (filter_ && filter_->filtering) ? filter_->rating : 0;
101 geo_star.width = star_size;
102
103 gPainter.PaintBackground(GfxContext, geo);
104 // set up our texture mode
105 nux::TexCoordXForm texxform;
106 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
107 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
108
109 // clear what is behind us
110 unsigned int alpha = 0, src = 0, dest = 0;
111
112 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
113 GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
114
115 nux::Color col = nux::color::Black;
116 col.alpha = 0;
117 GfxContext.QRP_Color(geo.x,
118 geo.y,
119 geo.width,
120 geo.height,
121 col);
122
123 for (int index = 0; index < num_stars; ++index)
124 {
125 Style& style = Style::Instance();
126 nux::BaseTexture* texture = style.GetStarSelectedIcon();
127 if (index < total_full_stars)
128 {
129 if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
130 texture = style.GetStarSelectedIcon();
131 else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
132 texture = style.GetStarSelectedIcon();
133 else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
134 texture = style.GetStarSelectedIcon();
135 }
136 else
137 {
138 if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_NORMAL)
139 texture = style.GetStarDeselectedIcon();
140 else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
141 texture = style.GetStarDeselectedIcon();
142 else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
143 texture = style.GetStarDeselectedIcon();
144 }
145
146 GfxContext.QRP_1Tex(geo_star.x,
147 geo_star.y,
148 geo_star.width,
149 geo_star.height,
150 texture->GetDeviceTexture(),
151 texxform,
152 nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
153
154 if (focused_star_ == index)
155 {
156 GfxContext.QRP_1Tex(geo_star.x,
157 geo_star.y,
158 geo_star.width,
159 geo_star.height,
160 style.GetStarHighlightIcon()->GetDeviceTexture(),
161 texxform,
162 nux::Color(1.0f, 1.0f, 1.0f, 0.5f));
163 }
164
165 geo_star.x += geo_star.width + star_gap;
166
167 }
168
169 GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
170
171}
172
173static void _UpdateRatingToMouse(RatingsFilter::Ptr filter, int x)
174{
175 int width = 180;
176 float new_rating = (static_cast<float>(x) / width);
177
178 // FIXME: change to * 2 once we decide to support also half-stars
179 new_rating = ceil((num_stars * 1) * new_rating) / (num_stars * 1);
180 new_rating = (new_rating > 1) ? 1 : ((new_rating < 0) ? 0 : new_rating);
181
182 if (filter)
183 filter->rating = new_rating;
184}
185
186void FilterRatingsButton::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
187{
188 _UpdateRatingToMouse(filter_, x);
189}
190
191void FilterRatingsButton::RecvMouseDrag(int x, int y, int dx, int dy,
192 unsigned long button_flags,
193 unsigned long key_flags)
194{
195 _UpdateRatingToMouse(filter_, x);
196}
197
198void FilterRatingsButton::OnRatingsChanged(int rating)
199{
200 NeedRedraw();
201}
202
203void FilterRatingsButton::RecvMouseMove(int x, int y, int dx, int dy,
204 unsigned long button_flags,
205 unsigned long key_flags)
206{
207 int width = 180;
208 focused_star_ = std::max(0, std::min(static_cast<int>(ceil((static_cast<float>(x) / width) * num_stars) - 1), num_stars - 1));
209
210 if (!HasKeyFocus())
211 nux::GetWindowCompositor().SetKeyFocusArea(this);
212
213 QueueDraw();
214}
215
216
217bool FilterRatingsButton::InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character)
218{
219 nux::KeyNavDirection direction = nux::KEY_NAV_NONE;
220
221 switch (keysym)
222 {
223 case NUX_VK_LEFT:
224 direction = nux::KeyNavDirection::KEY_NAV_LEFT;
225 break;
226 case NUX_VK_RIGHT:
227 direction = nux::KeyNavDirection::KEY_NAV_RIGHT;
228 break;
229 default:
230 direction = nux::KeyNavDirection::KEY_NAV_NONE;
231 break;
232 }
233
234 if (direction == nux::KeyNavDirection::KEY_NAV_NONE)
235 return false;
236 else if (direction == nux::KEY_NAV_LEFT && (focused_star_ <= 0))
237 return false;
238 else if (direction == nux::KEY_NAV_RIGHT && (focused_star_ >= num_stars - 1))
239 return false;
240 else
241 return true;
242}
243
244
245void FilterRatingsButton::OnKeyDown(unsigned long event_type, unsigned long event_keysym,
246 unsigned long event_state, const TCHAR* character,
247 unsigned short key_repeat_count)
248{
249 switch (event_keysym)
250 {
251 case NUX_VK_LEFT:
252 --focused_star_;
253 break;
254 case NUX_VK_RIGHT:
255 ++focused_star_;
256 break;
257 default:
258 return;
259 }
260
261 QueueDraw();
262}
263
264bool FilterRatingsButton::AcceptKeyNavFocus()
265{
266 return true;
267}74}
26875
269} // namespace dash76} // namespace dash
27077
=== modified file 'dash/FilterRatingsButton.h'
--- dash/FilterRatingsButton.h 2012-12-13 09:19:34 +0000
+++ dash/FilterRatingsButton.h 2014-08-06 16:03:19 +0000
@@ -25,46 +25,33 @@
25#include <memory>25#include <memory>
2626
27#include <Nux/Nux.h>27#include <Nux/Nux.h>
28#include <Nux/ToggleButton.h>
29#include <Nux/CairoWrapper.h>
30#include <UnityCore/RatingsFilter.h>28#include <UnityCore/RatingsFilter.h>
29#include "unity-shared/RatingsButton.h"
3130
32namespace unity31namespace unity
33{32{
34namespace dash33namespace dash
35{34{
3635
37class FilterRatingsButton : public nux::ToggleButton36class FilterRatingsButton : public RatingsButton
38{37{
39 NUX_DECLARE_OBJECT_TYPE(FilterRatingsButton, nux::ToggleButton);38 NUX_DECLARE_OBJECT_TYPE(FilterRatingsButton, RatingsButton);
40public:39public:
41 FilterRatingsButton(NUX_FILE_LINE_PROTO);40 FilterRatingsButton(NUX_FILE_LINE_PROTO);
42 virtual ~FilterRatingsButton();
4341
44 void SetFilter(Filter::Ptr const& filter);42 void SetFilter(Filter::Ptr const& filter);
45 RatingsFilter::Ptr GetFilter();43 RatingsFilter::Ptr GetFilter() const;
46 std::string GetFilterType();44 std::string GetFilterType();
4745
48protected:46protected:
49 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);47 // Introspectable methods
48 std::string GetName() const;
5049
51 // Key-nav50 void SetRating(float rating) override;
52 virtual bool AcceptKeyNavFocus();51 float GetRating() const override;
53 virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
5452
55private:53private:
56 void OnKeyDown(unsigned long event_type, unsigned long event_keysym,
57 unsigned long event_state, const TCHAR* character,
58 unsigned short key_repeat_count);
59
60 void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
61 void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
62 void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
63 void OnRatingsChanged(int rating);
64
65 dash::RatingsFilter::Ptr filter_;54 dash::RatingsFilter::Ptr filter_;
66 int focused_star_;
67
68};55};
6956
70} // namespace dash57} // namespace dash
7158
=== modified file 'dash/FilterRatingsWidget.cpp'
--- dash/FilterRatingsWidget.cpp 2013-03-19 18:22:11 +0000
+++ dash/FilterRatingsWidget.cpp 2014-08-06 16:03:19 +0000
@@ -33,15 +33,14 @@
33#include "FilterRatingsButton.h"33#include "FilterRatingsButton.h"
34#include "FilterRatingsWidget.h"34#include "FilterRatingsWidget.h"
3535
36namespace
37{
38const int star_size = 28;
39}
40
41namespace unity36namespace unity
42{37{
43namespace dash38namespace dash
44{39{
40namespace
41{
42const RawPixel STAR_SIZE = 28_em;
43}
4544
46NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsWidget);45NUX_IMPLEMENT_OBJECT_TYPE(FilterRatingsWidget);
4746
@@ -49,22 +48,30 @@
49: FilterExpanderLabel(_("Rating"), NUX_FILE_LINE_PARAM)48: FilterExpanderLabel(_("Rating"), NUX_FILE_LINE_PARAM)
50, all_button_(nullptr)49, all_button_(nullptr)
51{50{
52 dash::Style& style = dash::Style::Instance();
53 const int top_padding = style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding() - 1; // -1 (PNGs have an 1px top padding)
54 const int bottom_padding = style.GetFilterHighlightPadding();
55
56 nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);51 nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
57 layout->SetTopAndBottomPadding(top_padding, bottom_padding);
58 ratings_ = new FilterRatingsButton(NUX_TRACKER_LOCATION);52 ratings_ = new FilterRatingsButton(NUX_TRACKER_LOCATION);
59 ratings_->SetMinimumHeight(star_size);
6053
61 layout->AddView(ratings_);54 layout->AddView(ratings_);
6255
56 UpdateSize();
63 SetContents(layout);57 SetContents(layout);
58
59 scale.changed.connect([this] (double scale) {
60 if (all_button_) all_button_->scale = scale;
61 UpdateSize();
62 });
64}63}
6564
66FilterRatingsWidget::~FilterRatingsWidget()65void FilterRatingsWidget::UpdateSize()
67{66{
67 dash::Style& style = dash::Style::Instance();
68 int top_padding = style.GetSpaceBetweenFilterWidgets().CP(scale) - style.GetFilterHighlightPadding().CP(scale) - (1_em).CP(scale); // -1 (PNGs have an 1px top padding)
69 int bottom_padding = style.GetFilterHighlightPadding().CP(scale);
70 static_cast<nux::VLayout*>(GetLayout())->SetTopAndBottomPadding(top_padding, bottom_padding);
71
72 ratings_->scale = scale();
73 ratings_->SetMinimumHeight(STAR_SIZE.CP(scale));
74 ratings_->ApplyMinHeight();
68}75}
6976
70void FilterRatingsWidget::SetFilter(Filter::Ptr const& filter)77void FilterRatingsWidget::SetFilter(Filter::Ptr const& filter)
@@ -77,7 +84,10 @@
77 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;84 all_button_ = show_all_button ? new FilterAllButton(NUX_TRACKER_LOCATION) : nullptr;
78 SetRightHandView(all_button_);85 SetRightHandView(all_button_);
79 if (all_button_)86 if (all_button_)
87 {
88 all_button_->scale = scale();
80 all_button_->SetFilter(filter_);89 all_button_->SetFilter(filter_);
90 }
81 };91 };
82 show_button_func(filter_->show_all_button);92 show_button_func(filter_->show_all_button);
83 filter_->show_all_button.changed.connect(show_button_func);93 filter_->show_all_button.changed.connect(show_button_func);
8494
=== modified file 'dash/FilterRatingsWidget.h'
--- dash/FilterRatingsWidget.h 2012-11-27 23:16:06 +0000
+++ dash/FilterRatingsWidget.h 2014-08-06 16:03:19 +0000
@@ -45,7 +45,6 @@
45 NUX_DECLARE_OBJECT_TYPE(FilterRatingsWidget, FilterExpanderLabel);45 NUX_DECLARE_OBJECT_TYPE(FilterRatingsWidget, FilterExpanderLabel);
46public:46public:
47 FilterRatingsWidget(NUX_FILE_LINE_PROTO);47 FilterRatingsWidget(NUX_FILE_LINE_PROTO);
48 virtual ~FilterRatingsWidget();
4948
50 void SetFilter(Filter::Ptr const& filter);49 void SetFilter(Filter::Ptr const& filter);
51 std::string GetFilterType();50 std::string GetFilterType();
@@ -54,6 +53,8 @@
54 void ClearRedirectedRenderChildArea();53 void ClearRedirectedRenderChildArea();
5554
56private:55private:
56 void UpdateSize();
57
57 FilterAllButton* all_button_;58 FilterAllButton* all_button_;
58 FilterRatingsButton* ratings_;59 FilterRatingsButton* ratings_;
59 RatingsFilter::Ptr filter_;60 RatingsFilter::Ptr filter_;
6061
=== modified file 'dash/PlacesGroup.cpp'
--- dash/PlacesGroup.cpp 2014-03-20 04:05:39 +0000
+++ dash/PlacesGroup.cpp 2014-08-06 16:03:19 +0000
@@ -33,7 +33,6 @@
33#include "unity-shared/UBusWrapper.h"33#include "unity-shared/UBusWrapper.h"
34#include "unity-shared/UBusMessages.h"34#include "unity-shared/UBusMessages.h"
35#include "unity-shared/GraphicsUtils.h"35#include "unity-shared/GraphicsUtils.h"
36#include "unity-shared/RawPixel.h"
3736
38#include "ResultView.h"37#include "ResultView.h"
39#include "ResultViewGrid.h"38#include "ResultViewGrid.h"
@@ -133,10 +132,8 @@
133 SetAcceptKeyNavFocusOnMouseEnter(false);132 SetAcceptKeyNavFocusOnMouseEnter(false);
134 scale.changed.connect(sigc::mem_fun(this, &PlacesGroup::UpdateScale));133 scale.changed.connect(sigc::mem_fun(this, &PlacesGroup::UpdateScale));
135134
136 nux::BaseTexture* arrow = _style.GetGroupExpandIcon();135 _background = _style.GetCategoryBackground().GetPointer();
137136 _background_nofilters = _style.GetCategoryBackgroundNoFilters().GetPointer();
138 _background = _style.GetCategoryBackground();
139 _background_nofilters = _style.GetCategoryBackgroundNoFilters();
140137
141 nux::ROPConfig rop;138 nux::ROPConfig rop;
142 rop.Blend = true;139 rop.Blend = true;
@@ -144,8 +141,8 @@
144 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;141 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
145142
146 nux::TexCoordXForm texxform;143 nux::TexCoordXForm texxform;
147 _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(), 144 _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(),
148 texxform, 145 texxform,
149 nux::color::White,146 nux::color::White,
150 false,147 false,
151 rop));148 rop));
@@ -160,11 +157,10 @@
160 _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);157 _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_FULL);
161158
162 _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);159 _header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
163 _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding(), 0);160 _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding().CP(scale), 0);
164 _header_view->SetLayout(_header_layout);161 _header_view->SetLayout(_header_layout);
165162
166 RawPixel const icon_size = _style.GetCategoryIconSize();163 _icon = new IconTexture("", _style.GetCategoryIconSize().CP(scale));
167 _icon = new IconTexture("", icon_size.CP(scale()));
168 _header_layout->AddView(_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);164 _header_layout->AddView(_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
169165
170 _text_layout = new nux::HLayout(NUX_TRACKER_LOCATION);166 _text_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
@@ -172,6 +168,7 @@
172168
173 _name = new StaticCairoText("", NUX_TRACKER_LOCATION);169 _name = new StaticCairoText("", NUX_TRACKER_LOCATION);
174 _name->SetFont(NAME_LABEL_FONT);170 _name->SetFont(NAME_LABEL_FONT);
171 _name->SetLines(-1);
175 _name->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);172 _name->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);
176 _name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);173 _name->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
177 _text_layout->AddView(_name, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);174 _text_layout->AddView(_name, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
@@ -184,16 +181,17 @@
184181
185 _expand_label = new StaticCairoText("", NUX_TRACKER_LOCATION);182 _expand_label = new StaticCairoText("", NUX_TRACKER_LOCATION);
186 _expand_label->SetFont(EXPANDER_LABEL_FONT);183 _expand_label->SetFont(EXPANDER_LABEL_FONT);
184 _expand_label->SetLines(-1);
187 _expand_label->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);185 _expand_label->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_END);
188 _expand_label->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);186 _expand_label->SetTextAlignment(StaticCairoText::NUX_ALIGN_LEFT);
189 _expand_label->SetTextColor(kExpandDefaultTextColor);187 _expand_label->SetTextColor(kExpandDefaultTextColor);
190 _expand_label_layout->AddView(_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);188 _expand_label_layout->AddView(_expand_label, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
191189
192 _expand_icon = new IconTexture(arrow, arrow->GetWidth(), arrow->GetHeight());190 _expand_icon = new IconTexture(_style.GetGroupExpandIcon());
191 _expand_icon->SetDrawMode(IconTexture::DrawMode::STRETCH_WITH_ASPECT);
193 _expand_icon->SetOpacity(kExpandDefaultIconOpacity);192 _expand_icon->SetOpacity(kExpandDefaultIconOpacity);
194 _expand_icon->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());
195 _expand_icon->SetVisible(false);193 _expand_icon->SetVisible(false);
196 _expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);194 _expand_layout->AddView(_expand_icon, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
197195
198 SetLayout(_group_layout);196 SetLayout(_group_layout);
199197
@@ -223,16 +221,16 @@
223void221void
224PlacesGroup::UpdatePlacesGroupSize()222PlacesGroup::UpdatePlacesGroupSize()
225{223{
226 RawPixel const icon_size = _style.GetCategoryIconSize();224 int icon_size = _style.GetCategoryIconSize().CP(scale);
227 RawPixel const group_top = _style.GetPlacesGroupTopSpace();225 int top_space = _style.GetPlacesGroupTopSpace().CP(scale);
228226
229 int top_space = group_top.CP(scale());
230 _space_layout->SetMinimumSize(top_space, top_space);227 _space_layout->SetMinimumSize(top_space, top_space);
231 _space_layout->SetMaximumSize(top_space, top_space);228 _space_layout->SetMaximumSize(top_space, top_space);
232229
233 _header_layout->SetSpaceBetweenChildren(SPACE_BETWEEN_CHILDREN.CP(scale()));230 _header_layout->SetSpaceBetweenChildren(SPACE_BETWEEN_CHILDREN.CP(scale()));
231 _header_layout->SetLeftAndRightPadding(_style.GetCategoryHeaderLeftPadding().CP(scale), 0);
234232
235 _icon->SetMinMaxSize(icon_size.CP(scale()), icon_size.CP(scale()));233 _icon->SetMinMaxSize(icon_size, icon_size);
236234
237 _text_layout->SetHorizontalInternalMargin(TEXT_INTERNAL_MARGIN.CP(scale()));235 _text_layout->SetHorizontalInternalMargin(TEXT_INTERNAL_MARGIN.CP(scale()));
238 _expand_layout->SetHorizontalInternalMargin(EXPAND_INTERNAL_MARGIN.CP(scale()));236 _expand_layout->SetHorizontalInternalMargin(EXPAND_INTERNAL_MARGIN.CP(scale()));
@@ -241,15 +239,16 @@
241void239void
242PlacesGroup::UpdateScale(double scale)240PlacesGroup::UpdateScale(double scale)
243{241{
244 RawPixel const icon_size = _style.GetCategoryIconSize();242 _name->SetMinimumSize(nux::AREA_MIN_WIDTH, nux::AREA_MIN_HEIGHT);
245243 _name->SetMaximumSize(nux::AREA_MAX_WIDTH, nux::AREA_MAX_HEIGHT);
246 _name->SetScale(scale);244 _name->SetScale(scale);
247 _expand_label->SetScale(scale);245 _expand_label->SetScale(scale);
248246
249 _icon->SetSize(icon_size.CP(scale));247 _icon->SetSize(_style.GetCategoryIconSize().CP(scale));
250 _icon->ReLoadIcon();248 _icon->ReLoadIcon();
251249
252 // FIXME _expand_icon, needs some work here. Not as easy as _icon250 auto const& arrow = _expand_icon->texture();
251 _expand_icon->SetMinMaxSize(RawPixel(arrow->GetWidth()).CP(scale), RawPixel(arrow->GetHeight()).CP(scale));
253252
254 if (_child_view)253 if (_child_view)
255 _child_view->scale = scale;254 _child_view->scale = scale;
@@ -279,7 +278,6 @@
279278
280void279void
281280
282// FIXME _expand_icon, needs some work here. Not as easy as _icon
283PlacesGroup::SetName(std::string const& name)281PlacesGroup::SetName(std::string const& name)
284{282{
285 if (_cached_name != name)283 if (_cached_name != name)
@@ -310,7 +308,7 @@
310void308void
311PlacesGroup::SetIcon(std::string const& path_to_emblem)309PlacesGroup::SetIcon(std::string const& path_to_emblem)
312{310{
313 _icon->SetByIconName(path_to_emblem, _style.GetCategoryIconSize());311 _icon->SetByIconName(path_to_emblem, _style.GetCategoryIconSize().CP(scale));
314}312}
315313
316void314void
@@ -318,11 +316,8 @@
318{316{
319 if (_child_layout)317 if (_child_layout)
320 {318 {
321 RawPixel const result_top_padding = _style.GetPlacesGroupResultTopPadding();319 _child_layout->SetTopAndBottomPadding(_style.GetPlacesGroupResultTopPadding().CP(scale), 0);
322 RawPixel const result_left_padding = _style.GetPlacesGroupResultLeftPadding();320 _child_layout->SetLeftAndRightPadding(_style.GetPlacesGroupResultLeftPadding().CP(scale), 0);
323
324 _child_layout->SetTopAndBottomPadding(result_top_padding.CP(scale()), 0);
325 _child_layout->SetLeftAndRightPadding(result_left_padding.CP(scale()), 0);
326 }321 }
327}322}
328323
@@ -462,7 +457,7 @@
462 // only the width matters457 // only the width matters
463 if (_cached_geometry.GetWidth() != geo.GetWidth())458 if (_cached_geometry.GetWidth() != geo.GetWidth())
464 {459 {
465 _focus_layer.reset(_style.FocusOverlay(geo.width - 460 _focus_layer.reset(_style.FocusOverlay(geo.width -
466 kHighlightLeftPadding.CP(scale()) -461 kHighlightLeftPadding.CP(scale()) -
467 kHighlightRightPadding.CP(scale()),462 kHighlightRightPadding.CP(scale()),
468 kHighlightHeight.CP(scale())));463 kHighlightHeight.CP(scale())));
@@ -595,6 +590,9 @@
595 else590 else
596 _expand_icon->SetTexture(_style.GetGroupExpandIcon());591 _expand_icon->SetTexture(_style.GetGroupExpandIcon());
597592
593 auto const& tex = _expand_icon->texture();
594 _expand_icon->SetMinMaxSize(RawPixel(tex->GetWidth()).CP(scale), RawPixel(tex->GetHeight()).CP(scale));
595
598 expanded.emit(this);596 expanded.emit(this);
599}597}
600598
601599
=== modified file 'dash/ResultRendererHorizontalTile.cpp'
--- dash/ResultRendererHorizontalTile.cpp 2014-03-20 05:05:21 +0000
+++ dash/ResultRendererHorizontalTile.cpp 2014-08-06 16:03:19 +0000
@@ -247,8 +247,8 @@
247 0.0f,247 0.0f,
248 0.0f,248 0.0f,
249 CARD_VIEW_HIGHLIGHT_CORNER_RADIUS,249 CARD_VIEW_HIGHLIGHT_CORNER_RADIUS,
250 width,250 width/scale(),
251 height,251 height/scale(),
252 false);252 false);
253 cairo_fill(cr);253 cairo_fill(cr);
254254
255255
=== modified file 'dash/ResultRendererTile.cpp'
--- dash/ResultRendererTile.cpp 2014-05-03 17:57:47 +0000
+++ dash/ResultRendererTile.cpp 2014-08-06 16:03:19 +0000
@@ -31,7 +31,6 @@
31#include "unity-shared/CairoTexture.h"31#include "unity-shared/CairoTexture.h"
32#include "unity-shared/DashStyle.h"32#include "unity-shared/DashStyle.h"
33#include "unity-shared/TextureCache.h"33#include "unity-shared/TextureCache.h"
34#include "unity-shared/RawPixel.h"
35#include "unity-shared/UnitySettings.h"34#include "unity-shared/UnitySettings.h"
3635
37namespace unity36namespace unity
@@ -120,13 +119,7 @@
120 return;119 return;
121120
122 dash::Style const& style = dash::Style::Instance();121 dash::Style const& style = dash::Style::Instance();
123 RawPixel const tile_size = style.GetTileImageSize();122 int tile_icon_size = style.GetTileImageSize().CP(scale);
124 RawPixel const tile_width = style.GetTileWidth();
125 RawPixel const tile_height = style.GetTileHeight();
126 RawPixel const tile_highlight_width = style.GetTileIconHightlightWidth();
127 RawPixel const tile_highlight_height = style.GetTileIconHightlightHeight();
128
129 int tile_icon_size = tile_size.CP(scale());
130123
131 // set up our texture mode124 // set up our texture mode
132 nux::TexCoordXForm texxform;125 nux::TexCoordXForm texxform;
@@ -148,8 +141,8 @@
148 // render highlight if its needed141 // render highlight if its needed
149 if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL)142 if (container->prelight && state != ResultRendererState::RESULT_RENDERER_NORMAL)
150 {143 {
151 int highlight_x = (geometry.x + geometry.width/2) - tile_highlight_width.CP(scale())/2;144 int highlight_x = (geometry.x + geometry.width/2) - style.GetTileIconHightlightWidth().CP(scale)/2;
152 int highlight_y = (geometry.y + PADDING.CP(scale()) + tile_icon_size / 2) - tile_highlight_height.CP(scale())/2;145 int highlight_y = (geometry.y + PADDING.CP(scale) + tile_icon_size / 2) - style.GetTileIconHightlightHeight().CP(scale)/2;
153146
154 RenderTexture(GfxContext,147 RenderTexture(GfxContext,
155 highlight_x,148 highlight_x,
@@ -179,10 +172,10 @@
179 if (container->text)172 if (container->text)
180 {173 {
181 RenderTexture(GfxContext,174 RenderTexture(GfxContext,
182 geometry.x + PADDING.CP(scale()),175 geometry.x + PADDING.CP(scale),
183 geometry.y + tile_icon_size + SPACING.CP(scale()),176 geometry.y + tile_icon_size + SPACING.CP(scale),
184 tile_width.CP(scale()) - (PADDING.CP(scale()) * 2),177 style.GetTileWidth().CP(scale) - (PADDING.CP(scale) * 2),
185 tile_height.CP(scale()) - tile_icon_size - SPACING.CP(scale()),178 style.GetTileHeight().CP(scale) - tile_icon_size - SPACING.CP(scale),
186 container->text->GetDeviceTexture(),179 container->text->GetDeviceTexture(),
187 texxform,180 texxform,
188 color,181 color,
@@ -273,10 +266,8 @@
273void ResultRendererTile::LoadIcon(Result const& row)266void ResultRendererTile::LoadIcon(Result const& row)
274{267{
275 Style const& style = Style::Instance();268 Style const& style = Style::Instance();
276 RawPixel const tile_size = style.GetTileImageSize();269 int tile_size = style.GetTileImageSize().CP(scale);
277 RawPixel const tile_gsize = style.GetTileGIconSize();270 int tile_gsize = style.GetTileGIconSize().CP(scale);
278 RawPixel const tile_highlight_width = style.GetTileIconHightlightWidth();
279 RawPixel const tile_highlight_height = style.GetTileIconHightlightHeight();
280271
281 std::string const& icon_hint = row.icon_hint;272 std::string const& icon_hint = row.icon_hint;
282 std::string const& icon_name = !icon_hint.empty() ? icon_hint : DEFAULT_GICON;273 std::string const& icon_name = !icon_hint.empty() ? icon_hint : DEFAULT_GICON;
@@ -288,8 +279,8 @@
288 {279 {
289 TextureCache& cache = TextureCache::GetDefault();280 TextureCache& cache = TextureCache::GetDefault();
290 BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight",281 BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight",
291 tile_highlight_width.CP(scale()),282 style.GetTileIconHightlightWidth().CP(scale),
292 tile_highlight_height.CP(scale()),283 style.GetTileIconHightlightHeight().CP(scale),
293 sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));284 sigc::mem_fun(this, &ResultRendererTile::DrawHighlight)));
294 container->prelight = texture_prelight;285 container->prelight = texture_prelight;
295 }286 }
@@ -300,13 +291,13 @@
300 {291 {
301 bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON);292 bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON);
302 container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, 293 container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name,
303 tile_size.CP(scale()),294 tile_size,
304 use_large_icon ?295 use_large_icon ?
305 tile_size.CP(scale()) : tile_gsize.CP(scale()), slot);296 tile_size : tile_gsize, slot);
306 }297 }
307 else298 else
308 {299 {
309 container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, tile_gsize.CP(scale()), slot);300 container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, tile_gsize, slot);
310 }301 }
311}302}
312303
@@ -333,15 +324,12 @@
333 }324 }
334 else325 else
335 {326 {
336 Style const& style = Style::Instance();
337 RawPixel const tile_size = style.GetTileImageSize();
338
339 // slow path for non square icons that must be resized to fit in the square327 // slow path for non square icons that must be resized to fit in the square
340 // texture328 // texture
341 float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0329 float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
342 if (aspect < 1.0f)330 if (aspect < 1.0f)
343 {331 {
344 pixbuf_width = tile_size.CP(scale());332 pixbuf_width = Style::Instance().GetTileImageSize().CP(scale);
345 pixbuf_height = pixbuf_width * aspect;333 pixbuf_height = pixbuf_width * aspect;
346334
347 if (pixbuf_height > height)335 if (pixbuf_height > height)
@@ -470,13 +458,10 @@
470void ResultRendererTile::LoadText(Result const& row)458void ResultRendererTile::LoadText(Result const& row)
471{459{
472 Style const& style = Style::Instance();460 Style const& style = Style::Instance();
473 RawPixel const tile_size = style.GetTileImageSize();
474 RawPixel const tile_width = style.GetTileWidth();
475 RawPixel const tile_height = style.GetTileHeight();
476461
477 nux::CairoGraphics _cairoGraphics(CAIRO_FORMAT_ARGB32,462 nux::CairoGraphics _cairoGraphics(CAIRO_FORMAT_ARGB32,
478 tile_width.CP(scale()) - (PADDING.CP(scale()) * 2),463 style.GetTileWidth().CP(scale()) - (PADDING.CP(scale()) * 2),
479 tile_height.CP(scale()) - tile_size.CP(scale()) - SPACING.CP(scale()));464 style.GetTileHeight().CP(scale()) - style.GetTileImageSize().CP(scale()) - SPACING.CP(scale()));
480 cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale(), scale());465 cairo_surface_set_device_scale(_cairoGraphics.GetSurface(), scale(), scale());
481466
482 cairo_t* cr = _cairoGraphics.GetInternalContext();467 cairo_t* cr = _cairoGraphics.GetInternalContext();
@@ -499,7 +484,7 @@
499484
500 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);485 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
501 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START);486 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_START);
502 pango_layout_set_width(layout, (tile_width - (PADDING * 2))* PANGO_SCALE);487 pango_layout_set_width(layout, (style.GetTileWidth() - (PADDING * 2))* PANGO_SCALE);
503 pango_layout_set_height(layout, -2);488 pango_layout_set_height(layout, -2);
504489
505 // FIXME bug #1239381490 // FIXME bug #1239381
506491
=== modified file 'dash/ScopeBar.cpp'
--- dash/ScopeBar.cpp 2014-03-20 04:05:39 +0000
+++ dash/ScopeBar.cpp 2014-08-06 16:03:19 +0000
@@ -27,7 +27,6 @@
27#include "unity-shared/StaticCairoText.h"27#include "unity-shared/StaticCairoText.h"
28#include "unity-shared/CairoTexture.h"28#include "unity-shared/CairoTexture.h"
29#include "unity-shared/GraphicsUtils.h"29#include "unity-shared/GraphicsUtils.h"
30#include "unity-shared/RawPixel.h"
31#include "unity-shared/UBusMessages.h"30#include "unity-shared/UBusMessages.h"
3231
33namespace unity32namespace unity
@@ -71,6 +70,9 @@
7170
72 for (auto icon : icons_)71 for (auto icon : icons_)
73 icon->scale = scale;72 icon->scale = scale;
73
74 QueueDraw();
75 QueueRelayout();
74}76}
7577
76void ScopeBar::SetupLayout()78void ScopeBar::SetupLayout()
7779
=== modified file 'dash/ScopeBarIcon.cpp'
--- dash/ScopeBarIcon.cpp 2014-03-20 21:43:02 +0000
+++ dash/ScopeBarIcon.cpp 2014-08-06 16:03:19 +0000
@@ -17,7 +17,6 @@
17 */17 */
1818
19#include "unity-shared/DashStyle.h"19#include "unity-shared/DashStyle.h"
20#include "unity-shared/RawPixel.h"
21#include "ScopeBarIcon.h"20#include "ScopeBarIcon.h"
2221
23#include "config.h"22#include "config.h"
2423
=== modified file 'dash/ScopeView.cpp'
--- dash/ScopeView.cpp 2014-03-20 04:05:39 +0000
+++ dash/ScopeView.cpp 2014-08-06 16:03:19 +0000
@@ -29,9 +29,8 @@
29#include "ResultRendererHorizontalTile.h"29#include "ResultRendererHorizontalTile.h"
30#include "unity-shared/UBusMessages.h"30#include "unity-shared/UBusMessages.h"
31#include "unity-shared/UBusWrapper.h"31#include "unity-shared/UBusWrapper.h"
32#include "unity-shared/PlacesOverlayVScrollBar.h"32#include "unity-shared/OverlayScrollView.h"
33#include "unity-shared/GraphicsUtils.h"33#include "unity-shared/GraphicsUtils.h"
34#include "unity-shared/RawPixel.h"
3534
36#include "config.h"35#include "config.h"
37#include <glib/gi18n-lib.h>36#include <glib/gi18n-lib.h>
@@ -52,16 +51,14 @@
52}51}
5352
54// This is so we can access some protected members in scrollview.53// This is so we can access some protected members in scrollview.
55class ScopeScrollView: public nux::ScrollView54class ScopeScrollView: public dash::ScrollView
56{55{
57public:56public:
58 ScopeScrollView(nux::VScrollBar* scroll_bar, NUX_FILE_LINE_DECL)57 ScopeScrollView(NUX_FILE_LINE_DECL)
59 : nux::ScrollView(NUX_FILE_LINE_PARAM)58 : ScrollView(NUX_FILE_LINE_PARAM)
60 , right_area_(nullptr)59 , right_area_(nullptr)
61 , up_area_(nullptr)60 , up_area_(nullptr)
62 {61 {
63 SetVScrollBar(scroll_bar);
64
65 OnVisibleChanged.connect([this] (nux::Area* /*area*/, bool visible) {62 OnVisibleChanged.connect([this] (nux::Area* /*area*/, bool visible) {
66 if (m_horizontal_scrollbar_enable)63 if (m_horizontal_scrollbar_enable)
67 _hscrollbar->SetVisible(visible);64 _hscrollbar->SetVisible(visible);
@@ -237,8 +234,8 @@
237{234{
238 layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);235 layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
239236
240 scroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION),237 scroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION);
241 NUX_TRACKER_LOCATION);238 scroll_view_->scale = scale();
242 scroll_view_->EnableVerticalScrollBar(true);239 scroll_view_->EnableVerticalScrollBar(true);
243 scroll_view_->EnableHorizontalScrollBar(false);240 scroll_view_->EnableHorizontalScrollBar(false);
244 layout_->AddView(scroll_view_);241 layout_->AddView(scroll_view_);
@@ -250,9 +247,11 @@
250 no_results_ = new StaticCairoText("", NUX_TRACKER_LOCATION);247 no_results_ = new StaticCairoText("", NUX_TRACKER_LOCATION);
251 no_results_->SetTextColor(nux::color::White);248 no_results_->SetTextColor(nux::color::White);
252 no_results_->SetVisible(false);249 no_results_->SetVisible(false);
250 no_results_->SetScale(scale);
253 scroll_layout_->AddView(no_results_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);251 scroll_layout_->AddView(no_results_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
254252
255 fscroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), NUX_TRACKER_LOCATION);253 fscroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION);
254 fscroll_view_->scale = scale();
256 fscroll_view_->EnableVerticalScrollBar(true);255 fscroll_view_->EnableVerticalScrollBar(true);
257 fscroll_view_->EnableHorizontalScrollBar(false);256 fscroll_view_->EnableHorizontalScrollBar(false);
258 fscroll_view_->SetVisible(false);257 fscroll_view_->SetVisible(false);
@@ -276,19 +275,17 @@
276{275{
277 dash::Style const& style = dash::Style::Instance();276 dash::Style const& style = dash::Style::Instance();
278277
279 RawPixel const scope_filter_space = style.GetSpaceBetweenScopeAndFilters();278 int right_padding = style.GetFilterViewRightPadding().CP(scale);
280 RawPixel const right_padding = style.GetFilterViewRightPadding();279 int filter_width = style.GetFilterBarWidth().CP(scale) +
281 RawPixel const filter_width = style.GetFilterBarWidth() +280 style.GetFilterBarLeftPadding().CP(scale) +
282 style.GetFilterBarLeftPadding() +281 style.GetFilterBarRightPadding().CP(scale);
283 style.GetFilterBarRightPadding();282
284283 layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenScopeAndFilters().CP(scale));
285 double scale = this->scale();284
286 layout_->SetSpaceBetweenChildren(scope_filter_space.CP(scale));285 fscroll_view_->SetMinimumWidth(filter_width + right_padding);
287286 fscroll_view_->SetMaximumWidth(filter_width + right_padding);
288 fscroll_view_->SetMinimumWidth(filter_width.CP(scale) + right_padding.CP(scale));287 filter_bar_->SetMinimumWidth(filter_width);
289 fscroll_view_->SetMaximumWidth(filter_width.CP(scale) + right_padding.CP(scale));288 filter_bar_->SetMaximumWidth(filter_width);
290 filter_bar_->SetMinimumWidth(filter_width.CP(scale));
291 filter_bar_->SetMaximumWidth(filter_width.CP(scale));
292}289}
293290
294void ScopeView::UpdateScale(double scale)291void ScopeView::UpdateScale(double scale)
@@ -298,7 +295,10 @@
298 for (auto& group : category_views_)295 for (auto& group : category_views_)
299 group->scale = scale;296 group->scale = scale;
300297
298 scroll_view_->scale = scale;
299 fscroll_view_->scale = scale;
301 filter_bar_->scale = scale;300 filter_bar_->scale = scale;
301 no_results_->SetScale(scale);
302}302}
303303
304void ScopeView::SetupCategories(Categories::Ptr const& categories)304void ScopeView::SetupCategories(Categories::Ptr const& categories)
305305
=== modified file 'dash/ScopeView.h'
--- dash/ScopeView.h 2014-03-20 04:05:39 +0000
+++ dash/ScopeView.h 2014-08-06 16:03:19 +0000
@@ -36,7 +36,6 @@
36#include "PlacesGroup.h"36#include "PlacesGroup.h"
37#include "ResultViewGrid.h"37#include "ResultViewGrid.h"
38#include "unity-shared/UBusWrapper.h"38#include "unity-shared/UBusWrapper.h"
39#include "unity-shared/PlacesVScrollBar.h"
4039
41namespace unity40namespace unity
42{41{
4342
=== modified file 'dash/StandaloneDash.cpp'
--- dash/StandaloneDash.cpp 2014-02-28 23:32:05 +0000
+++ dash/StandaloneDash.cpp 2014-08-06 16:03:19 +0000
@@ -36,47 +36,50 @@
36#include "unity-shared/DashStyle.h"36#include "unity-shared/DashStyle.h"
37#include "unity-shared/PanelStyle.h"37#include "unity-shared/PanelStyle.h"
38#include "unity-shared/ThumbnailGenerator.h"38#include "unity-shared/ThumbnailGenerator.h"
39#include "UnityCore/GSettingsScopes.h"39#include "unity-shared/UBusMessages.h"
40#include "unity-shared/UBusServer.h"
41#include <UnityCore/GSettingsScopes.h>
42#include <UnityCore/ScopeProxyInterface.h>
4043
41#define WIDTH 102444const unity::RawPixel WIDTH(1024);
42#define HEIGHT 76845const unity::RawPixel HEIGHT(768);
4346
44using namespace unity::dash;47using namespace unity::dash;
4548
46class TestRunner49class TestRunner
47{50{
48public:51public:
49 TestRunner ();52 TestRunner(std::string const& scope, double scale)
50 ~TestRunner ();53 : scope_(scope)
54 , scale_(scale)
55 {}
5156
52 static void InitWindowThread (nux::NThread* thread, void* InitData);57 static void InitWindowThread (nux::NThread* thread, void* InitData);
53 void Init ();58 void Init ();
59 std::string scope_;
60 double scale_;
54 nux::Layout *layout;61 nux::Layout *layout;
55};62};
5663
57TestRunner::TestRunner ()
58{
59}
60
61TestRunner::~TestRunner ()
62{
63}
64
65void TestRunner::Init ()64void TestRunner::Init ()
66{65{
67 layout = new nux::HLayout(NUX_TRACKER_LOCATION);66 layout = new nux::HLayout(NUX_TRACKER_LOCATION);
6867
69 DashView* view = new DashView(std::make_shared<unity::dash::GSettingsScopes>(), 68 DashView* view = new DashView(std::make_shared<unity::dash::GSettingsScopes>(),
70 std::make_shared<unity::ApplicationStarterImp>());69 std::make_shared<unity::ApplicationStarterImp>());
70 view->scale = scale_;
71 view->DisableBlur();71 view->DisableBlur();
72 view->SetMinMaxSize(WIDTH, HEIGHT);72 view->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));
73 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);73 layout->AddView (view, 1, nux::MINOR_POSITION_CENTER);
74 layout->SetMinMaxSize(WIDTH, HEIGHT);74 layout->SetMinMaxSize(WIDTH.CP(scale_), HEIGHT.CP(scale_));
7575
76 view->AboutToShow(0);76 view->AboutToShow(0);
7777
78 nux::GetWindowThread()->SetLayout (layout);78 nux::GetWindowThread()->SetLayout (layout);
79 nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());79 nux::GetWindowCompositor().SetKeyFocusArea(view->default_focus());
80
81 unity::UBusServer().SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST,
82 g_variant_new("(sus)", scope_.c_str(), GOTO_DASH_URI, ""));
80}83}
8184
82void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)85void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData)
@@ -87,8 +90,6 @@
8790
88int main(int argc, char **argv)91int main(int argc, char **argv)
89{92{
90 nux::WindowThread* wt = NULL;
91
92 gtk_init (&argc, &argv);93 gtk_init (&argc, &argv);
9394
94 unity::BGHash bghash;95 unity::BGHash bghash;
@@ -102,17 +103,30 @@
102 unity::dash::Style dash_style;103 unity::dash::Style dash_style;
103 unity::panel::Style panel_style;104 unity::panel::Style panel_style;
104105
105 TestRunner *test_runner = new TestRunner ();106 double scale = 1.0;
106 wt = nux::CreateGUIThread(TEXT("Unity Dash"),107 unity::glib::String scope;
107 WIDTH, HEIGHT,108 unity::glib::Error err;
108 0,109
109 &TestRunner::InitWindowThread,110 GOptionEntry args_parsed[] =
110 test_runner);111 {
112 { "scope", 's', 0, G_OPTION_ARG_STRING, &scope, "The default scope ", "S" },
113 { "scaling-factor", 'f', 0, G_OPTION_ARG_DOUBLE, &scale, "The dash scaling factor", "F" },
114 { NULL }
115 };
116
117 std::shared_ptr<GOptionContext> ctx(g_option_context_new("Standalone Dash"), g_option_context_free);
118 g_option_context_add_main_entries(ctx.get(), args_parsed, NULL);
119 if (!g_option_context_parse(ctx.get(), &argc, &argv, &err))
120 std::cerr << "Got error when parsing arguments: " << err << std::endl;
121
122 TestRunner *test_runner = new TestRunner(scope.Str(), scale);
123 std::unique_ptr<nux::WindowThread> wt(nux::CreateGUIThread(TEXT("Unity Dash"),
124 WIDTH.CP(scale), HEIGHT.CP(scale),
125 0, &TestRunner::InitWindowThread, test_runner));
111126
112 nux::NuxTimerTickSource tick_source;127 nux::NuxTimerTickSource tick_source;
113 nux::animation::AnimationController animation_controller(tick_source);128 nux::animation::AnimationController animation_controller(tick_source);
129 wt->Run(nullptr);
114130
115 wt->Run (NULL);131 return EXIT_SUCCESS;
116 delete wt;
117 return 0;
118}132}
119133
=== modified file 'dash/previews/ActionButton.cpp'
--- dash/previews/ActionButton.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/ActionButton.cpp 2014-08-06 16:03:19 +0000
@@ -26,22 +26,23 @@
26#include "unity-shared/IconTexture.h"26#include "unity-shared/IconTexture.h"
27#include "unity-shared/StaticCairoText.h"27#include "unity-shared/StaticCairoText.h"
2828
29namespace unity
30{
29namespace31namespace
30{32{
31const int kMinButtonHeight = 34;33const RawPixel MIN_BUTTON_HEIGHT = 34_em;
32const int kMinButtonWidth = 48;34const RawPixel MIN_BUTTON_WIDTH = 48_em;
3335
34const int icon_size = 24;36const RawPixel icon_size = 24_em;
35}37}
3638
37namespace unity
38{
39namespace dash39namespace dash
40{40{
41DECLARE_LOGGER(logger, "unity.dash.preview.action");41DECLARE_LOGGER(logger, "unity.dash.preview.action");
4242
43ActionButton::ActionButton(std::string const& action_hint, std::string const& label, std::string const& icon_hint, NUX_FILE_LINE_DECL)43ActionButton::ActionButton(std::string const& action_hint, std::string const& label, std::string const& icon_hint, NUX_FILE_LINE_DECL)
44 : nux::AbstractButton(NUX_FILE_LINE_PARAM)44 : nux::AbstractButton(NUX_FILE_LINE_PARAM)
45 , scale(1.0)
45 , action_hint_(action_hint)46 , action_hint_(action_hint)
46 , image_(nullptr)47 , image_(nullptr)
47{48{
@@ -49,6 +50,7 @@
49 SetAcceptKeyNavFocusOnMouseEnter(true);50 SetAcceptKeyNavFocusOnMouseEnter(true);
50 Init();51 Init();
51 BuildLayout(label, icon_hint, "");52 BuildLayout(label, icon_hint, "");
53 scale.changed.connect(sigc::mem_fun(this, &ActionButton::UpdateScale));
52}54}
5355
54ActionButton::~ActionButton()56ActionButton::~ActionButton()
@@ -84,22 +86,19 @@
8486
85void ActionButton::InitTheme()87void ActionButton::InitTheme()
86{88{
87 if (!cr_active_)89 nux::Geometry const& geo = GetGeometry();
88 {90
89 nux::Geometry const& geo = GetGeometry();91 cr_prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
9092 cr_active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
91 cr_prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));93 cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
92 cr_active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));94 cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay)));
93 cr_normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &ActionButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));95
94 cr_focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &ActionButton::RedrawFocusOverlay)));96 SetMinimumHeight(MIN_BUTTON_HEIGHT.CP(scale));
95 }97 SetMinimumWidth(MIN_BUTTON_WIDTH.CP(scale));
96
97 SetMinimumHeight(kMinButtonHeight);
98 SetMinimumWidth(kMinButtonWidth);
99}98}
10099
101void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint)100void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint)
102{ 101{
103 extra_font_hint_= font_hint;102 extra_font_hint_= font_hint;
104 if (extra_text_)103 if (extra_text_)
105 {104 {
@@ -123,13 +122,13 @@
123122
124 if (!icon_hint_.empty())123 if (!icon_hint_.empty())
125 {124 {
126 image_ = new IconTexture(icon_hint, icon_size);125 image_ = new IconTexture(icon_hint, icon_size.CP(scale));
127 image_->texture_updated.connect([this](nux::ObjectPtr<nux::BaseTexture> const&)126 image_->texture_updated.connect([this](nux::ObjectPtr<nux::BaseTexture> const&)
128 {127 {
129 BuildLayout(label_, icon_hint_, extra_hint_);128 BuildLayout(label_, icon_hint_, extra_hint_);
130 });129 });
131 image_->SetInputEventSensitivity(false);130 image_->SetInputEventSensitivity(false);
132 image_->SetMinMaxSize(icon_size, icon_size);131 image_->SetMinMaxSize(icon_size.CP(scale), icon_size.CP(scale));
133 }132 }
134 }133 }
135134
@@ -192,11 +191,13 @@
192191
193void ActionButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)192void ActionButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state)
194{193{
194 cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
195 Style::Instance().Button(cr, faked_state, "", -1, Alignment::CENTER, true);195 Style::Instance().Button(cr, faked_state, "", -1, Alignment::CENTER, true);
196}196}
197197
198void ActionButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr)198void ActionButton::RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr)
199{199{
200 cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale);
200 Style::Instance().ButtonFocusOverlay(cr, 0.20f);201 Style::Instance().ButtonFocusOverlay(cr, 0.20f);
201}202}
202203
@@ -311,5 +312,27 @@
311 return extra_hint_;312 return extra_hint_;
312}313}
313314
315void ActionButton::UpdateScale(double scale)
316{
317 InitTheme();
318
319 if (image_)
320 {
321 image_->SetSize(icon_size.CP(scale));
322 image_->SetMinMaxSize(icon_size.CP(scale), icon_size.CP(scale));
323 image_->ReLoadIcon();
324 }
325
326 if (static_text_)
327 static_text_->SetScale(scale);
328
329 if (extra_text_)
330 extra_text_->SetScale(scale);
331
332 QueueRelayout();
333 QueueDraw();
334}
335
336
314} // namespace dash337} // namespace dash
315} // namespace unity338} // namespace unity
316339
=== modified file 'dash/previews/ActionButton.h'
--- dash/previews/ActionButton.h 2013-09-19 16:44:03 +0000
+++ dash/previews/ActionButton.h 2014-08-06 16:03:19 +0000
@@ -59,6 +59,8 @@
59 std::string GetLabel() const;59 std::string GetLabel() const;
60 std::string GetExtraText() const;60 std::string GetExtraText() const;
6161
62 nux::Property<double> scale;
63
62protected:64protected:
63 virtual long ComputeContentSize();65 virtual long ComputeContentSize();
64 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);66 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
@@ -95,6 +97,8 @@
95 nux::ObjectPtr<IconTexture> image_;97 nux::ObjectPtr<IconTexture> image_;
96 nux::ObjectPtr<unity::StaticCairoText> static_text_;98 nux::ObjectPtr<unity::StaticCairoText> static_text_;
97 nux::ObjectPtr<unity::StaticCairoText> extra_text_;99 nux::ObjectPtr<unity::StaticCairoText> extra_text_;
100
101 void UpdateScale(double scale);
98};102};
99103
100} // namespace dash104} // namespace dash
101105
=== modified file 'dash/previews/ActionLink.cpp'
--- dash/previews/ActionLink.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/ActionLink.cpp 2014-08-06 16:03:19 +0000
@@ -40,12 +40,15 @@
4040
41ActionLink::ActionLink(std::string const& action_hint, std::string const& label, NUX_FILE_LINE_DECL)41ActionLink::ActionLink(std::string const& action_hint, std::string const& label, NUX_FILE_LINE_DECL)
42 : nux::AbstractButton(NUX_FILE_LINE_PARAM)42 : nux::AbstractButton(NUX_FILE_LINE_PARAM)
43 , scale(1.0)
43 , action_hint_(action_hint)44 , action_hint_(action_hint)
44 , aligment_(StaticCairoText::NUX_ALIGN_CENTRE)45 , aligment_(StaticCairoText::NUX_ALIGN_CENTRE)
45 , underline_(StaticCairoText::NUX_UNDERLINE_SINGLE)46 , underline_(StaticCairoText::NUX_UNDERLINE_SINGLE)
46{47{
47 Init();48 Init();
48 BuildLayout(label);49 BuildLayout(label);
50 UpdateScale(scale);
51 scale.changed.connect(sigc::mem_fun(this, &ActionLink::UpdateScale));
49}52}
5053
51std::string ActionLink::GetName() const54std::string ActionLink::GetName() const
@@ -109,6 +112,7 @@
109 static_text_ = new StaticCairoText(label_, true, NUX_TRACKER_LOCATION);112 static_text_ = new StaticCairoText(label_, true, NUX_TRACKER_LOCATION);
110 if (!font_hint_.empty())113 if (!font_hint_.empty())
111 static_text_->SetFont(font_hint_);114 static_text_->SetFont(font_hint_);
115 static_text_->SetScale(scale);
112 static_text_->SetInputEventSensitivity(false);116 static_text_->SetInputEventSensitivity(false);
113 static_text_->SetTextAlignment(aligment_);117 static_text_->SetTextAlignment(aligment_);
114 static_text_->SetUnderline(underline_);118 static_text_->SetUnderline(underline_);
@@ -243,5 +247,14 @@
243 return label_;247 return label_;
244}248}
245249
250void ActionLink::UpdateScale(double scale)
251{
252 if (static_text_)
253 static_text_->SetScale(scale);
254
255 QueueRelayout();
256 QueueDraw();
257}
258
246} // namespace dash259} // namespace dash
247} // namespace unity260} // namespace unity
248261
=== modified file 'dash/previews/ActionLink.h'
--- dash/previews/ActionLink.h 2013-09-19 16:44:03 +0000
+++ dash/previews/ActionLink.h 2014-08-06 16:03:19 +0000
@@ -47,6 +47,7 @@
47 nux::RWProperty<StaticCairoText::AlignState> text_aligment;47 nux::RWProperty<StaticCairoText::AlignState> text_aligment;
48 nux::RWProperty<StaticCairoText::UnderlineState> underline_state;48 nux::RWProperty<StaticCairoText::UnderlineState> underline_state;
49 nux::RWProperty<std::string> font_hint;49 nux::RWProperty<std::string> font_hint;
50 nux::Property<double> scale;
5051
51 void Activate() {}52 void Activate() {}
52 void Deactivate() {}53 void Deactivate() {}
@@ -90,8 +91,7 @@
90 StaticCairoText::UnderlineState underline_;91 StaticCairoText::UnderlineState underline_;
91private:92private:
92 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;93 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
9394 void UpdateScale(double scale);
94
95};95};
9696
97} // namespace dash97} // namespace dash
9898
=== modified file 'dash/previews/ApplicationPreview.cpp'
--- dash/previews/ApplicationPreview.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/ApplicationPreview.cpp 2014-08-06 16:03:19 +0000
@@ -24,7 +24,6 @@
24#include "unity-shared/PreviewStyle.h"24#include "unity-shared/PreviewStyle.h"
25#include "unity-shared/CoverArt.h"25#include "unity-shared/CoverArt.h"
26#include "unity-shared/IconTexture.h"26#include "unity-shared/IconTexture.h"
27#include "unity-shared/PlacesOverlayVScrollBar.h"
28#include <UnityCore/ApplicationPreview.h>27#include <UnityCore/ApplicationPreview.h>
29#include <NuxCore/Logger.h>28#include <NuxCore/Logger.h>
30#include <Nux/HLayout.h>29#include <Nux/HLayout.h>
@@ -46,23 +45,31 @@
46{45{
47namespace previews46namespace previews
48{47{
48
49namespace
50{
51 const RawPixel ICON_SPACE_CHILDREN = 3_em;
52 const RawPixel DATA_SPACE_CHILDREN = 16_em;
53 const RawPixel INFO_SPACE_CHILDREN = 12_em;
54 const RawPixel COPYRIGHT_SPACE_CHILDREN = 8_em;
55 const RawPixel ICON_SIZE = 72_em;
56}
57
49DECLARE_LOGGER(logger, "unity.dash.preview.application");58DECLARE_LOGGER(logger, "unity.dash.preview.application");
5059
51class DetailsScrollView : public nux::ScrollView
52{
53public:
54 DetailsScrollView(NUX_FILE_LINE_PROTO)
55 : ScrollView(NUX_FILE_LINE_PARAM)
56 {
57 SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION));
58 }
59
60};
61
62NUX_IMPLEMENT_OBJECT_TYPE(ApplicationPreview);60NUX_IMPLEMENT_OBJECT_TYPE(ApplicationPreview);
6361
64ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model)62ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model)
65: Preview(preview_model)63: Preview(preview_model)
64, title_subtitle_layout_(nullptr)
65, image_data_layout_(nullptr)
66, main_app_info_(nullptr)
67, icon_layout_(nullptr)
68, app_data_layout_(nullptr)
69, app_updated_copywrite_layout_(nullptr)
70, app_info_layout_(nullptr)
71, app_info_scroll_(nullptr)
72, actions_layout_(nullptr)
66{73{
67 SetupViews();74 SetupViews();
68}75}
@@ -121,12 +128,13 @@
121128
122 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); };129 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); };
123130
124 nux::HLayout* image_data_layout = new nux::HLayout();131 image_data_layout_ = new nux::HLayout();
125 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());132 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
126133
127 /////////////////////134 /////////////////////
128 // Image135 // Image
129 image_ = new CoverArt();136 image_ = new CoverArt();
137 image_->scale = scale();
130 AddChild(image_.GetPointer());138 AddChild(image_.GetPointer());
131 UpdateCoverArtImage(image_.GetPointer());139 UpdateCoverArtImage(image_.GetPointer());
132 /////////////////////140 /////////////////////
@@ -134,34 +142,36 @@
134 /////////////////////142 /////////////////////
135 // App Data Panel143 // App Data Panel
136 full_data_layout_ = new nux::VLayout();144 full_data_layout_ = new nux::VLayout();
137 full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());145 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
138 full_data_layout_->SetSpaceBetweenChildren(16);146 full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
139147
140 /////////////////////148 /////////////////////
141 // Main App Info149 // Main App Info
142 nux::HLayout* main_app_info = new nux::HLayout();150 main_app_info_ = new nux::HLayout();
143 main_app_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails());151 main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale));
144152
145 /////////////////////153 /////////////////////
146 // Icon Layout154 // Icon Layout
147 nux::VLayout* icon_layout = new nux::VLayout();155 icon_layout_ = new nux::VLayout();
148 icon_layout->SetSpaceBetweenChildren(3);156 icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale));
149 app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", 72);157 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));
150 AddChild(app_icon_.GetPointer());158 AddChild(app_icon_.GetPointer());
151 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());159 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
152 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth());160 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
153 app_icon_->mouse_click.connect(on_mouse_down);161 app_icon_->mouse_click.connect(on_mouse_down);
154 icon_layout->AddView(app_icon_.GetPointer(), 0);162 icon_layout_->AddView(app_icon_.GetPointer(), 0);
155163
156 if (app_preview_model->rating >= 0) {164 if (app_preview_model->rating >= 0)
165 {
157 app_rating_ = new PreviewRatingsWidget();166 app_rating_ = new PreviewRatingsWidget();
158 AddChild(app_rating_.GetPointer());167 AddChild(app_rating_.GetPointer());
159 app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight());168 app_rating_->scale = scale();
160 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight());169 app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
170 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
161 app_rating_->SetRating(app_preview_model->rating);171 app_rating_->SetRating(app_preview_model->rating);
162 app_rating_->SetReviews(app_preview_model->num_ratings);172 app_rating_->SetReviews(app_preview_model->num_ratings);
163 app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });173 app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
164 icon_layout->AddView(app_rating_.GetPointer(), 0);174 icon_layout_->AddView(app_rating_.GetPointer(), 0);
165 }175 }
166176
167 /////////////////////177 /////////////////////
@@ -169,15 +179,16 @@
169 /////////////////////179 /////////////////////
170 // Data180 // Data
171181
172 nux::VLayout* app_data_layout = new nux::VLayout();182 app_data_layout_ = new nux::VLayout();
173 app_data_layout->SetSpaceBetweenChildren(16);183 app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
174184
175 title_subtitle_layout_ = new nux::VLayout();185 title_subtitle_layout_ = new nux::VLayout();
176 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());186 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
177187
178 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);188 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
179 AddChild(title_.GetPointer());189 AddChild(title_.GetPointer());
180 title_->SetLines(-1);190 title_->SetLines(-1);
191 title_->SetScale(scale);
181 title_->SetFont(style.title_font().c_str());192 title_->SetFont(style.title_font().c_str());
182 title_->mouse_click.connect(on_mouse_down);193 title_->mouse_click.connect(on_mouse_down);
183 title_subtitle_layout_->AddView(title_.GetPointer(), 1);194 title_subtitle_layout_->AddView(title_.GetPointer(), 1);
@@ -188,12 +199,13 @@
188 AddChild(subtitle_.GetPointer());199 AddChild(subtitle_.GetPointer());
189 subtitle_->SetFont(style.subtitle_size_font().c_str());200 subtitle_->SetFont(style.subtitle_size_font().c_str());
190 subtitle_->SetLines(-1);201 subtitle_->SetLines(-1);
202 subtitle_->SetScale(scale);
191 subtitle_->mouse_click.connect(on_mouse_down);203 subtitle_->mouse_click.connect(on_mouse_down);
192 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);204 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);
193 }205 }
194206
195 nux::VLayout* app_updated_copywrite_layout = new nux::VLayout();207 app_updated_copywrite_layout_ = new nux::VLayout();
196 app_updated_copywrite_layout->SetSpaceBetweenChildren(8);208 app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale));
197209
198 if (!app_preview_model->license.Get().empty())210 if (!app_preview_model->license.Get().empty())
199 {211 {
@@ -201,8 +213,9 @@
201 AddChild(license_.GetPointer());213 AddChild(license_.GetPointer());
202 license_->SetFont(style.app_license_font().c_str());214 license_->SetFont(style.app_license_font().c_str());
203 license_->SetLines(-1);215 license_->SetLines(-1);
216 license_->SetScale(scale);
204 license_->mouse_click.connect(on_mouse_down);217 license_->mouse_click.connect(on_mouse_down);
205 app_updated_copywrite_layout->AddView(license_.GetPointer(), 1);218 app_updated_copywrite_layout_->AddView(license_.GetPointer(), 1);
206 }219 }
207220
208 if (!app_preview_model->last_update.Get().empty())221 if (!app_preview_model->last_update.Get().empty())
@@ -213,8 +226,9 @@
213 last_update_ = new StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION);226 last_update_ = new StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION);
214 AddChild(last_update_.GetPointer());227 AddChild(last_update_.GetPointer());
215 last_update_->SetFont(style.app_last_update_font().c_str());228 last_update_->SetFont(style.app_last_update_font().c_str());
229 last_update_->SetScale(scale);
216 last_update_->mouse_click.connect(on_mouse_down);230 last_update_->mouse_click.connect(on_mouse_down);
217 app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1);231 app_updated_copywrite_layout_->AddView(last_update_.GetPointer(), 1);
218 }232 }
219233
220 if (!app_preview_model->copyright.Get().empty())234 if (!app_preview_model->copyright.Get().empty())
@@ -223,29 +237,32 @@
223 AddChild(copywrite_.GetPointer());237 AddChild(copywrite_.GetPointer());
224 copywrite_->SetFont(style.app_copywrite_font().c_str());238 copywrite_->SetFont(style.app_copywrite_font().c_str());
225 copywrite_->SetLines(-1);239 copywrite_->SetLines(-1);
240 copywrite_->SetScale(scale);
226 copywrite_->mouse_click.connect(on_mouse_down);241 copywrite_->mouse_click.connect(on_mouse_down);
227 app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1);242 app_updated_copywrite_layout_->AddView(copywrite_.GetPointer(), 1);
228 }243 }
229244
230 app_data_layout->AddLayout(title_subtitle_layout_);245 app_data_layout_->AddLayout(title_subtitle_layout_);
231 app_data_layout->AddLayout(app_updated_copywrite_layout);246 app_data_layout_->AddLayout(app_updated_copywrite_layout_);
232247
233 // buffer space248 // buffer space
234 /////////////////////249 /////////////////////
235250
236 main_app_info->AddLayout(icon_layout, 0);251 main_app_info_->AddLayout(icon_layout_, 0);
237 main_app_info->AddLayout(app_data_layout, 1);252 main_app_info_->AddLayout(app_data_layout_, 1);
238 /////////////////////253 /////////////////////
239254
240 /////////////////////255 /////////////////////
241 // Description256 // Description
242 nux::ScrollView* app_info = new DetailsScrollView(NUX_TRACKER_LOCATION);257 auto* app_info = new ScrollView(NUX_TRACKER_LOCATION);
258 app_info_scroll_ = app_info;
259 app_info->scale = scale();
243 app_info->EnableHorizontalScrollBar(false);260 app_info->EnableHorizontalScrollBar(false);
244 app_info->mouse_click.connect(on_mouse_down);261 app_info->mouse_click.connect(on_mouse_down);
245262
246 nux::VLayout* app_info_layout = new nux::VLayout();263 app_info_layout_ = new nux::VLayout();
247 app_info_layout->SetSpaceBetweenChildren(12);264 app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale));
248 app_info->SetLayout(app_info_layout);265 app_info->SetLayout(app_info_layout_);
249266
250 if (!preview_model_->description.Get().empty())267 if (!preview_model_->description.Get().empty())
251 {268 {
@@ -256,36 +273,36 @@
256 description_->SetLines(-style.GetDescriptionLineCount());273 description_->SetLines(-style.GetDescriptionLineCount());
257 description_->SetLineSpacing(style.GetDescriptionLineSpacing());274 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
258 description_->mouse_click.connect(on_mouse_down);275 description_->mouse_click.connect(on_mouse_down);
259 app_info_layout->AddView(description_.GetPointer());276 app_info_layout_->AddView(description_.GetPointer());
260 }277 }
261278
262 if (!preview_model_->GetInfoHints().empty())279 if (!preview_model_->GetInfoHints().empty())
263 {280 {
264 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());281 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
265 AddChild(preview_info_hints_.GetPointer());282 AddChild(preview_info_hints_.GetPointer());
266 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });283 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
267 app_info_layout->AddView(preview_info_hints_.GetPointer());284 app_info_layout_->AddView(preview_info_hints_.GetPointer());
268 }285 }
269 /////////////////////286 /////////////////////
270287
271 /////////////////////288 /////////////////////
272 // Actions289 // Actions
273 action_buttons_.clear();290 action_buttons_.clear();
274 nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);291 actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
275 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());292 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
276 ///////////////////293 ///////////////////
277294
278 full_data_layout_->AddLayout(main_app_info, 0);295 full_data_layout_->AddLayout(main_app_info_, 0);
279 full_data_layout_->AddView(app_info, 1);296 full_data_layout_->AddView(app_info, 1);
280 full_data_layout_->AddLayout(actions_layout, 0);297 full_data_layout_->AddLayout(actions_layout_, 0);
281 /////////////////////298 /////////////////////
282 299
283 image_data_layout->AddView(image_.GetPointer(), 0);300 image_data_layout_->AddView(image_.GetPointer(), 0);
284 image_data_layout->AddLayout(full_data_layout_, 1);301 image_data_layout_->AddLayout(full_data_layout_, 1);
285302
286 mouse_click.connect(on_mouse_down);303 mouse_click.connect(on_mouse_down);
287304
288 SetLayout(image_data_layout);305 SetLayout(image_data_layout_);
289}306}
290307
291void ApplicationPreview::PreLayoutManagement()308void ApplicationPreview::PreLayoutManagement()
@@ -296,12 +313,16 @@
296313
297 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);314 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
298315
299 if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())316 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale)
300 geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());317 - style.GetDetailsLeftMargin().CP(scale)
318 - style.GetDetailsRightMargin().CP(scale);
319 if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
320 geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
321
301 image_->SetMinMaxSize(geo_art.width, geo_art.height);322 image_->SetMinMaxSize(geo_art.width, geo_art.height);
302323
303 int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());324 int details_width = std::max(0, content_width - geo_art.width);
304 int top_app_info_max_width = MAX(0, details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails());325 int top_app_info_max_width = std::max(0, details_width - style.GetAppIconAreaWidth().CP(scale) - style.GetSpaceBetweenIconAndDetails().CP(scale));
305326
306 if (title_) { title_->SetMaximumWidth(top_app_info_max_width); }327 if (title_) { title_->SetMaximumWidth(top_app_info_max_width); }
307 if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); }328 if (subtitle_) { subtitle_->SetMaximumWidth(top_app_info_max_width); }
@@ -310,14 +331,79 @@
310 if (copywrite_) { copywrite_->SetMaximumWidth(top_app_info_max_width); }331 if (copywrite_) { copywrite_->SetMaximumWidth(top_app_info_max_width); }
311 if (description_) { description_->SetMaximumWidth(details_width); }332 if (description_) { description_->SetMaximumWidth(details_width); }
312333
334 int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
335 int button_h = style.GetActionButtonHeight().CP(scale);
336
313 for (nux::AbstractButton* button : action_buttons_)337 for (nux::AbstractButton* button : action_buttons_)
314 {338 button->SetMinMaxSize(button_w, button_h);
315 button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
316 }
317339
318 Preview::PreLayoutManagement();340 Preview::PreLayoutManagement();
319}341}
320342
343void ApplicationPreview::UpdateScale(double scale)
344{
345 Preview::UpdateScale(scale);
346
347 previews::Style& style = dash::previews::Style::Instance();
348
349 if (app_icon_)
350 {
351 app_icon_->SetSize(ICON_SIZE.CP(scale));
352 app_icon_->SetMinimumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
353 app_icon_->SetMaximumSize(style.GetAppIconAreaWidth().CP(scale), style.GetAppIconAreaWidth().CP(scale));
354 app_icon_->ReLoadIcon();
355 }
356
357 if (app_info_scroll_)
358 app_info_scroll_->scale = scale;
359
360 if (license_)
361 license_->SetScale(scale);
362
363 if (last_update_)
364 last_update_->SetScale(scale);
365
366 if (copywrite_)
367 copywrite_->SetScale(scale);
368
369 if (app_rating_)
370 {
371 app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
372 app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
373 app_rating_->scale = scale;
374 }
375
376 if (image_data_layout_)
377 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
378
379 if (full_data_layout_)
380 {
381 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
382 full_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
383 }
384
385 if (main_app_info_)
386 main_app_info_->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails().CP(scale));
387
388 if (icon_layout_)
389 icon_layout_->SetSpaceBetweenChildren(ICON_SPACE_CHILDREN.CP(scale));
390
391 if (app_data_layout_)
392 app_data_layout_->SetSpaceBetweenChildren(DATA_SPACE_CHILDREN.CP(scale));
393
394 if (title_subtitle_layout_)
395 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
396
397 if (app_info_layout_)
398 app_info_layout_->SetSpaceBetweenChildren(INFO_SPACE_CHILDREN.CP(scale));
399
400 if (actions_layout_)
401 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
402
403 if (app_updated_copywrite_layout_)
404 app_updated_copywrite_layout_->SetSpaceBetweenChildren(COPYRIGHT_SPACE_CHILDREN.CP(scale));
405}
406
321} // namespace previews407} // namespace previews
322} // namespace dash408} // namespace dash
323} // namepsace unity409} // namepsace unity
324410
=== modified file 'dash/previews/ApplicationPreview.h'
--- dash/previews/ApplicationPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/ApplicationPreview.h 2014-08-06 16:03:19 +0000
@@ -24,6 +24,7 @@
24#define APPLICATIONPREVIEW_H24#define APPLICATIONPREVIEW_H
2525
26#include "Preview.h"26#include "Preview.h"
27#include "unity-shared/OverlayScrollView.h"
2728
28namespace unity29namespace unity
29{30{
@@ -54,9 +55,18 @@
54 virtual void PreLayoutManagement();55 virtual void PreLayoutManagement();
5556
56 virtual void SetupViews();57 virtual void SetupViews();
58 void UpdateScale(double scale) override;
5759
58protected:60protected:
59 nux::VLayout* title_subtitle_layout_;61 nux::VLayout* title_subtitle_layout_;
62 nux::HLayout* image_data_layout_;
63 nux::HLayout* main_app_info_;
64 nux::VLayout* icon_layout_;
65 nux::VLayout* app_data_layout_;
66 nux::VLayout* app_updated_copywrite_layout_;
67 nux::VLayout* app_info_layout_;
68 ScrollView* app_info_scroll_;
69 nux::Layout* actions_layout_;
6070
61 nux::ObjectPtr<IconTexture> app_icon_;71 nux::ObjectPtr<IconTexture> app_icon_;
62 nux::ObjectPtr<PreviewRatingsWidget> app_rating_;72 nux::ObjectPtr<PreviewRatingsWidget> app_rating_;
6373
=== modified file 'dash/previews/ErrorPreview.cpp'
--- dash/previews/ErrorPreview.cpp 2013-09-19 16:44:03 +0000
+++ dash/previews/ErrorPreview.cpp 2014-08-06 16:03:19 +0000
@@ -26,7 +26,6 @@
26#include "unity-shared/PreviewStyle.h"26#include "unity-shared/PreviewStyle.h"
27#include "unity-shared/CoverArt.h"27#include "unity-shared/CoverArt.h"
28#include "unity-shared/StaticCairoText.h"28#include "unity-shared/StaticCairoText.h"
29#include "unity-shared/PlacesVScrollBar.h"
30#include <NuxCore/Logger.h>29#include <NuxCore/Logger.h>
31#include <Nux/VLayout.h>30#include <Nux/VLayout.h>
32#include <Nux/HLayout.h>31#include <Nux/HLayout.h>
@@ -50,22 +49,18 @@
50{49{
51nux::logging::Logger logger("unity.dash.previews.ErrorPreview");50nux::logging::Logger logger("unity.dash.previews.ErrorPreview");
5251
52const RawPixel TITLE_DATA_MAX_SIZE = 76_em;
53const RawPixel TITLE_DATA_CHILDREN_SPACE = 10_em;
54const RawPixel LINE_SPACING = 10_em;
55const RawPixel TITLE_MAX_WIDTH = 480_em;
56const RawPixel CHILDREN_SPACE = 5_em;
57const RawPixel BUTTONS_DATA_SPACE = 20_em;
58const RawPixel INTRO_SPACE = 110_em;
53}59}
5460
55const std::string ErrorPreview::CANCEL_ACTION = "cancel";61const std::string ErrorPreview::CANCEL_ACTION = "cancel";
56const std::string ErrorPreview::GO_TO_U1_ACTION = "open_u1_link";62const std::string ErrorPreview::GO_TO_U1_ACTION = "open_u1_link";
5763
58class DetailsScrollView : public nux::ScrollView
59{
60public:
61 DetailsScrollView(NUX_FILE_LINE_PROTO)
62 : ScrollView(NUX_FILE_LINE_PARAM)
63 {
64 SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION));
65 }
66
67};
68
69NUX_IMPLEMENT_OBJECT_TYPE(ErrorPreview)64NUX_IMPLEMENT_OBJECT_TYPE(ErrorPreview)
7065
71ErrorPreview::ErrorPreview(dash::Preview::Ptr preview_model)66ErrorPreview::ErrorPreview(dash::Preview::Ptr preview_model)
@@ -73,6 +68,9 @@
73{68{
74 PaymentPreview::SetupBackground();69 PaymentPreview::SetupBackground();
75 SetupViews();70 SetupViews();
71
72 UpdateScale(scale);
73 scale.changed.connect(sigc::mem_fun(this, &ErrorPreview::UpdateScale));
76}74}
7775
78ErrorPreview::~ErrorPreview()76ErrorPreview::~ErrorPreview()
@@ -114,6 +112,7 @@
114 for (dash::Preview::ActionPtr action : preview_model_->GetActions())112 for (dash::Preview::ActionPtr action : preview_model_->GetActions())
115 {113 {
116 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);114 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);
115 button->scale = scale();
117 button->activate.connect(sigc::mem_fun(this, &ErrorPreview::OnActionActivated));116 button->activate.connect(sigc::mem_fun(this, &ErrorPreview::OnActionActivated));
118 buttons_map_.insert(std::make_pair(action->id, button));117 buttons_map_.insert(std::make_pair(action->id, button));
119 }118 }
@@ -123,8 +122,8 @@
123{122{
124 previews::Style& style = dash::previews::Style::Instance();123 previews::Style& style = dash::previews::Style::Instance();
125 nux::VLayout* title_data_layout = new nux::VLayout();124 nux::VLayout* title_data_layout = new nux::VLayout();
126 title_data_layout->SetMaximumHeight(76);125 title_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale));
127 title_data_layout->SetSpaceBetweenChildren(10);126 title_data_layout->SetSpaceBetweenChildren(TITLE_DATA_CHILDREN_SPACE.CP(scale));
128127
129 title_ = new StaticCairoText(128 title_ = new StaticCairoText(
130 preview_model_->title.Get(), true,129 preview_model_->title.Get(), true,
@@ -133,7 +132,7 @@
133 title_->SetFont(style.payment_title_font());132 title_->SetFont(style.payment_title_font());
134 title_->SetLines(-1);133 title_->SetLines(-1);
135 title_->SetFont(style.title_font());134 title_->SetFont(style.title_font());
136 title_->SetMaximumWidth(480);135 title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
137 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);136 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
138 title_data_layout->AddView(title_.GetPointer(), 1);137 title_data_layout->AddView(title_.GetPointer(), 1);
139138
@@ -151,9 +150,9 @@
151{150{
152 previews::Style& style = dash::previews::Style::Instance();151 previews::Style& style = dash::previews::Style::Instance();
153 nux::VLayout *prize_data_layout = new nux::VLayout();152 nux::VLayout *prize_data_layout = new nux::VLayout();
154 prize_data_layout->SetMaximumHeight(76);153 prize_data_layout->SetMaximumHeight(TITLE_DATA_MAX_SIZE.CP(scale));
155 prize_data_layout->SetSpaceBetweenChildren(5);154 prize_data_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
156 prize_data_layout->SetPadding(0, 10, 0, 0);155 prize_data_layout->SetPadding(0, TITLE_DATA_CHILDREN_SPACE.CP(scale), 0, 0);
157156
158 purchase_prize_ = new StaticCairoText(157 purchase_prize_ = new StaticCairoText(
159 error_preview_model_->purchase_prize.Get(), true,158 error_preview_model_->purchase_prize.Get(), true,
@@ -188,16 +187,17 @@
188 nux::HLayout *intro_layout = new nux::HLayout();187 nux::HLayout *intro_layout = new nux::HLayout();
189 nux::VLayout *icon_layout = new nux::VLayout();188 nux::VLayout *icon_layout = new nux::VLayout();
190189
191 icon_layout->SetPadding(78, 10, 90, 43);190 icon_layout->SetPadding((78_em).CP(scale), (10_em).CP(scale), (90_em).CP(scale), (43_em).CP(scale));
192 intro_layout->SetPadding(75, 20, 0, 0);191 intro_layout->SetPadding((75_em).CP(scale), (20_em).CP(scale), 0, 0);
193 intro_layout->SetSpaceBetweenChildren(5);192 intro_layout->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
194193
195 intro_ = new StaticCairoText(194 intro_ = new StaticCairoText(
196 error_preview_model_->header.Get(), true,195 error_preview_model_->header.Get(), true,
197 NUX_TRACKER_LOCATION);196 NUX_TRACKER_LOCATION);
198 intro_->SetFont(style.payment_intro_font().c_str());197 intro_->SetFont(style.payment_intro_font().c_str());
198 intro_->SetScale(scale);
199 intro_->SetLines(-3);199 intro_->SetLines(-3);
200 intro_->SetLineSpacing(10);200 intro_->SetLineSpacing(LINE_SPACING.CP(scale));
201 intro_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);201 intro_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
202202
203 intro_layout->AddView(intro_.GetPointer());//, 0, nux::MINOR_POSITION_CENTER);203 intro_layout->AddView(intro_.GetPointer());//, 0, nux::MINOR_POSITION_CENTER);
@@ -220,9 +220,9 @@
220 actions_buffer_h->AddSpace(0, 1);220 actions_buffer_h->AddSpace(0, 1);
221221
222 nux::HLayout* buttons_data_layout = new TabIteratorHLayout(tab_iterator_);222 nux::HLayout* buttons_data_layout = new TabIteratorHLayout(tab_iterator_);
223 buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());223 buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
224224
225 buttons_data_layout->AddSpace(20, 1);225 buttons_data_layout->AddSpace(BUTTONS_DATA_SPACE.CP(scale), 1);
226 if(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer()){226 if(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer()){
227 ActionButton* button = (ActionButton*)buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer();227 ActionButton* button = (ActionButton*)buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer();
228 buttons_data_layout->AddView(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer(),228 buttons_data_layout->AddView(buttons_map_[ErrorPreview::CANCEL_ACTION].GetPointer(),
@@ -249,11 +249,11 @@
249249
250 previews::Style& style = dash::previews::Style::Instance();250 previews::Style& style = dash::previews::Style::Instance();
251251
252 int width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());252 int width = std::max(0, geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
253253
254 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }254 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }
255 if(header_layout_) { header_layout_->SetMaximumWidth(width); }255 if(header_layout_) { header_layout_->SetMaximumWidth(width); }
256 if(intro_) { intro_->SetMaximumWidth(width - 110); }256 if(intro_) { intro_->SetMaximumWidth(width - INTRO_SPACE.CP(scale)); }
257 if(footer_layout_) { footer_layout_->SetMaximumWidth(width); }257 if(footer_layout_) { footer_layout_->SetMaximumWidth(width); }
258258
259 Preview::PreLayoutManagement();259 Preview::PreLayoutManagement();
@@ -274,6 +274,33 @@
274 PaymentPreview::SetupViews();274 PaymentPreview::SetupViews();
275}275}
276276
277void ErrorPreview::UpdateScale(double scale)
278{
279 if (intro_)
280 intro_->SetScale(scale);
281
282 if (purchase_hint_)
283 purchase_hint_->SetScale(scale);
284 if (purchase_prize_)
285 purchase_prize_->SetScale(scale);
286 if (purchase_type_)
287 purchase_type_->SetScale(scale);
288
289 if (warning_texture_)
290 {
291 previews::Style& style = dash::previews::Style::Instance();
292 RawPixel width(style.GetWarningIcon()->GetWidth());
293 RawPixel height(style.GetWarningIcon()->GetHeight());
294
295 warning_texture_->SetSize(std::max(width, height).CP(scale));
296 warning_texture_->ReLoadIcon();
297 }
298
299 if (title_)
300 title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
301
302 Preview::UpdateScale(scale);
303}
277304
278}305}
279}306}
280307
=== modified file 'dash/previews/ErrorPreview.h'
--- dash/previews/ErrorPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/ErrorPreview.h 2014-08-06 16:03:19 +0000
@@ -94,6 +94,8 @@
94 void PreLayoutManagement();94 void PreLayoutManagement();
9595
96 virtual void SetupViews();96 virtual void SetupViews();
97 virtual void UpdateScale(double scale);
98
97 // content elements99 // content elements
98 nux::ObjectPtr<CoverArt> image_;100 nux::ObjectPtr<CoverArt> image_;
99 nux::ObjectPtr<StaticCairoText> intro_;101 nux::ObjectPtr<StaticCairoText> intro_;
100102
=== modified file 'dash/previews/GenericPreview.cpp'
--- dash/previews/GenericPreview.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/GenericPreview.cpp 2014-08-06 16:03:19 +0000
@@ -23,7 +23,6 @@
23#include "unity-shared/IntrospectableWrappers.h"23#include "unity-shared/IntrospectableWrappers.h"
24#include "unity-shared/PreviewStyle.h"24#include "unity-shared/PreviewStyle.h"
25#include "unity-shared/CoverArt.h"25#include "unity-shared/CoverArt.h"
26#include "unity-shared/PlacesOverlayVScrollBar.h"
27#include <NuxCore/Logger.h>26#include <NuxCore/Logger.h>
28#include <Nux/HLayout.h>27#include <Nux/HLayout.h>
29#include <Nux/VLayout.h>28#include <Nux/VLayout.h>
@@ -40,25 +39,28 @@
40{39{
41namespace previews40namespace previews
42{41{
42
43namespace
44{
45 const RawPixel CHILDREN_SPACE = 12_em;
46 const RawPixel FULL_CHILDREN_SPACE = 16_em;
47}
48
43DECLARE_LOGGER(logger, "unity.dash.preview.generic");49DECLARE_LOGGER(logger, "unity.dash.preview.generic");
4450
45class DetailsScrollView : public nux::ScrollView
46{
47public:
48 DetailsScrollView(NUX_FILE_LINE_PROTO)
49 : ScrollView(NUX_FILE_LINE_PARAM)
50 {
51 SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION));
52 }
53
54};
55
56NUX_IMPLEMENT_OBJECT_TYPE(GenericPreview);51NUX_IMPLEMENT_OBJECT_TYPE(GenericPreview);
5752
58GenericPreview::GenericPreview(dash::Preview::Ptr preview_model)53GenericPreview::GenericPreview(dash::Preview::Ptr preview_model)
59: Preview(preview_model)54: Preview(preview_model)
55, image_data_layout_(nullptr)
56, preview_info_layout_(nullptr)
57, preview_info_scroll_(nullptr)
58, preview_data_layout_(nullptr)
59, actions_layout_(nullptr)
60{60{
61 SetupViews();61 SetupViews();
62 UpdateScale(scale);
63 scale.changed.connect(sigc::mem_fun(this, &GenericPreview::UpdateScale));
62}64}
6365
64GenericPreview::~GenericPreview()66GenericPreview::~GenericPreview()
@@ -72,7 +74,7 @@
72 gfx_engine.PushClippingRectangle(base);74 gfx_engine.PushClippingRectangle(base);
73 nux::GetPainter().PaintBackground(gfx_engine, base);75 nux::GetPainter().PaintBackground(gfx_engine, base);
7476
75 gfx_engine.PopClippingRectangle(); 77 gfx_engine.PopClippingRectangle();
76}78}
7779
78void GenericPreview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)80void GenericPreview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw)
@@ -113,8 +115,8 @@
113115
114 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); };116 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); };
115117
116 nux::HLayout* image_data_layout = new nux::HLayout();118 image_data_layout_ = new nux::HLayout();
117 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());119 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
118120
119 /////////////////////121 /////////////////////
120 // Image122 // Image
@@ -126,21 +128,22 @@
126 /////////////////////128 /////////////////////
127 // Data Panel129 // Data Panel
128 full_data_layout_ = new nux::VLayout();130 full_data_layout_ = new nux::VLayout();
129 full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());131 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0,
130 full_data_layout_->SetSpaceBetweenChildren(16);132 style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
133 full_data_layout_->SetSpaceBetweenChildren(FULL_CHILDREN_SPACE.CP(scale));
131134
132 /////////////////////135 /////////////////////
133 // Data136 // Data
134137
135 nux::VLayout* preview_data_layout = new nux::VLayout();138 preview_data_layout_ = new nux::VLayout();
136 preview_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());139 preview_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
137140
138 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);141 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
139 AddChild(title_.GetPointer());142 AddChild(title_.GetPointer());
140 title_->SetLines(-1);143 title_->SetLines(-1);
141 title_->SetFont(style.title_font().c_str());144 title_->SetFont(style.title_font().c_str());
142 title_->mouse_click.connect(on_mouse_down);145 title_->mouse_click.connect(on_mouse_down);
143 preview_data_layout->AddView(title_.GetPointer(), 1);146 preview_data_layout_->AddView(title_.GetPointer(), 1);
144147
145 if (!preview_model_->subtitle.Get().empty())148 if (!preview_model_->subtitle.Get().empty())
146 {149 {
@@ -149,19 +152,21 @@
149 subtitle_->SetLines(-1);152 subtitle_->SetLines(-1);
150 subtitle_->SetFont(style.subtitle_size_font().c_str());153 subtitle_->SetFont(style.subtitle_size_font().c_str());
151 subtitle_->mouse_click.connect(on_mouse_down);154 subtitle_->mouse_click.connect(on_mouse_down);
152 preview_data_layout->AddView(subtitle_.GetPointer(), 1);155 preview_data_layout_->AddView(subtitle_.GetPointer(), 1);
153 }156 }
154 /////////////////////157 /////////////////////
155158
156 /////////////////////159 /////////////////////
157 // Description160 // Description
158 nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION);161 auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION);
162 preview_info_scroll_ = preview_info;
163 preview_info->scale = scale();
159 preview_info->EnableHorizontalScrollBar(false);164 preview_info->EnableHorizontalScrollBar(false);
160 preview_info->mouse_click.connect(on_mouse_down);165 preview_info->mouse_click.connect(on_mouse_down);
161166
162 nux::VLayout* preview_info_layout = new nux::VLayout();167 preview_info_layout_ = new nux::VLayout();
163 preview_info_layout->SetSpaceBetweenChildren(12);168 preview_info_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
164 preview_info->SetLayout(preview_info_layout);169 preview_info->SetLayout(preview_info_layout_);
165170
166 if (!preview_model_->description.Get().empty())171 if (!preview_model_->description.Get().empty())
167 {172 {
@@ -172,37 +177,37 @@
172 description_->SetLines(-style.GetDescriptionLineCount());177 description_->SetLines(-style.GetDescriptionLineCount());
173 description_->SetLineSpacing(style.GetDescriptionLineSpacing());178 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
174 description_->mouse_click.connect(on_mouse_down);179 description_->mouse_click.connect(on_mouse_down);
175 preview_info_layout->AddView(description_.GetPointer());180 preview_info_layout_->AddView(description_.GetPointer());
176 }181 }
177182
178 if (!preview_model_->GetInfoHints().empty())183 if (!preview_model_->GetInfoHints().empty())
179 {184 {
180 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());185 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
181 AddChild(preview_info_hints_.GetPointer());186 AddChild(preview_info_hints_.GetPointer());
182 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });187 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
183 preview_info_layout->AddView(preview_info_hints_.GetPointer());188 preview_info_layout_->AddView(preview_info_hints_.GetPointer());
184 }189 }
185 /////////////////////190 /////////////////////
186191
187 /////////////////////192 /////////////////////
188 // Actions193 // Actions
189 action_buttons_.clear();194 action_buttons_.clear();
190 nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);195 actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
191 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());196 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
192 ///////////////////197 ///////////////////
193198
194 full_data_layout_->AddLayout(preview_data_layout, 0);199 full_data_layout_->AddLayout(preview_data_layout_, 0);
195 full_data_layout_->AddView(preview_info, 1);200 full_data_layout_->AddView(preview_info, 1);
196 full_data_layout_->AddView(actions_layout, 0);201 full_data_layout_->AddView(actions_layout_, 0);
197 /////////////////////202 /////////////////////
198 203
199 image_data_layout->AddView(image_.GetPointer(), 0);204 image_data_layout_->AddView(image_.GetPointer(), 0);
200205
201 image_data_layout->AddLayout(full_data_layout_, 1);206 image_data_layout_->AddLayout(full_data_layout_, 1);
202207
203 mouse_click.connect(on_mouse_down);208 mouse_click.connect(on_mouse_down);
204209
205 SetLayout(image_data_layout);210 SetLayout(image_data_layout_);
206}211}
207212
208void GenericPreview::PreLayoutManagement()213void GenericPreview::PreLayoutManagement()
@@ -213,24 +218,63 @@
213218
214 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);219 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
215220
216 if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())221 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale)
217 geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());222 - style.GetDetailsLeftMargin().CP(scale)
223 - style.GetDetailsRightMargin().CP(scale);
224
225 if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
226 geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
227
218 image_->SetMinMaxSize(geo_art.width, geo_art.height);228 image_->SetMinMaxSize(geo_art.width, geo_art.height);
219229 int details_width = std::max(0, content_width - geo_art.width);
220 int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());
221230
222 if (title_) { title_->SetMaximumWidth(details_width); }231 if (title_) { title_->SetMaximumWidth(details_width); }
223 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }232 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
224 if (description_) { description_->SetMaximumWidth(details_width); }233 if (description_) { description_->SetMaximumWidth(details_width); }
225234
235 int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
236 int button_h = style.GetActionButtonHeight().CP(scale);
237
226 for (nux::AbstractButton* button : action_buttons_)238 for (nux::AbstractButton* button : action_buttons_)
227 {239 button->SetMinMaxSize(button_w, button_h);
228 button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());
229 }
230240
231 Preview::PreLayoutManagement();241 Preview::PreLayoutManagement();
232}242}
233243
244void GenericPreview::UpdateScale(double scale)
245{
246 if (image_)
247 image_->scale = scale;
248
249 if (preview_info_scroll_)
250 preview_info_scroll_->scale = scale;
251
252 if (preview_info_hints_)
253 preview_info_hints_->scale = scale;
254
255 previews::Style& style = dash::previews::Style::Instance();
256
257 if (full_data_layout_)
258 {
259 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
260 full_data_layout_->SetSpaceBetweenChildren(FULL_CHILDREN_SPACE.CP(scale));
261 }
262
263 if (image_data_layout_)
264 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
265
266 if (preview_info_layout_)
267 preview_info_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
268
269 if (preview_data_layout_)
270 preview_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
271
272 if (actions_layout_)
273 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
274
275 Preview::UpdateScale(scale);
276}
277
234278
235}279}
236}280}
237281
=== modified file 'dash/previews/GenericPreview.h'
--- dash/previews/GenericPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/GenericPreview.h 2014-08-06 16:03:19 +0000
@@ -23,8 +23,9 @@
23#ifndef GENERICPREVIEW_H23#ifndef GENERICPREVIEW_H
24#define GENERICPREVIEW_H24#define GENERICPREVIEW_H
2525
26#include <UnityCore/GenericPreview.h>
26#include "Preview.h"27#include "Preview.h"
27#include <UnityCore/GenericPreview.h>28#include "unity-shared/OverlayScrollView.h"
2829
29namespace unity30namespace unity
30{31{
@@ -52,6 +53,13 @@
52 virtual void PreLayoutManagement();53 virtual void PreLayoutManagement();
5354
54 virtual void SetupViews();55 virtual void SetupViews();
56 virtual void UpdateScale(double scale);
57
58 nux::HLayout* image_data_layout_;
59 nux::VLayout* preview_info_layout_;
60 ScrollView* preview_info_scroll_;
61 nux::VLayout* preview_data_layout_;
62 nux::Layout* actions_layout_;
55};63};
5664
57}65}
5866
=== modified file 'dash/previews/MoviePreview.cpp'
--- dash/previews/MoviePreview.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/MoviePreview.cpp 2014-08-06 16:03:19 +0000
@@ -23,7 +23,6 @@
23#include "unity-shared/IntrospectableWrappers.h"23#include "unity-shared/IntrospectableWrappers.h"
24#include "unity-shared/PreviewStyle.h"24#include "unity-shared/PreviewStyle.h"
25#include "unity-shared/CoverArt.h"25#include "unity-shared/CoverArt.h"
26#include "unity-shared/PlacesOverlayVScrollBar.h"
27#include <UnityCore/MoviePreview.h>26#include <UnityCore/MoviePreview.h>
28#include <NuxCore/Logger.h>27#include <NuxCore/Logger.h>
29#include <Nux/HLayout.h>28#include <Nux/HLayout.h>
@@ -41,23 +40,23 @@
41{40{
42namespace previews41namespace previews
43{42{
43
44namespace
45{
46 const RawPixel CHILDREN_SPACE = 16_em;
47 const RawPixel PREVIEW_INFO_CHILDREN_SPACE = 12_em;
48}
49
44DECLARE_LOGGER(logger, "unity.dash.preview.movie");50DECLARE_LOGGER(logger, "unity.dash.preview.movie");
4551
46class DetailsScrollView : public nux::ScrollView
47{
48public:
49 DetailsScrollView(NUX_FILE_LINE_PROTO)
50 : ScrollView(NUX_FILE_LINE_PARAM)
51 {
52 SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION));
53 }
54
55};
56
57NUX_IMPLEMENT_OBJECT_TYPE(MoviePreview);52NUX_IMPLEMENT_OBJECT_TYPE(MoviePreview);
5853
59MoviePreview::MoviePreview(dash::Preview::Ptr preview_model)54MoviePreview::MoviePreview(dash::Preview::Ptr preview_model)
60: Preview(preview_model)55: Preview(preview_model)
56, image_data_layout_(nullptr)
57, preview_info_layout_(nullptr)
58, preview_info_scroll_(nullptr)
59, actions_layout_(nullptr)
61{60{
62 SetupViews();61 SetupViews();
63}62}
@@ -123,8 +122,8 @@
123122
124 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); };123 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); };
125124
126 nux::HLayout* image_data_layout = new nux::HLayout();125 image_data_layout_ = new nux::HLayout();
127 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());126 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
128127
129 /////////////////////128 /////////////////////
130 // Image129 // Image
@@ -136,8 +135,8 @@
136 /////////////////////135 /////////////////////
137 // Data Panel136 // Data Panel
138 full_data_layout_ = new nux::VLayout();137 full_data_layout_ = new nux::VLayout();
139 full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());138 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
140 full_data_layout_->SetSpaceBetweenChildren(16);139 full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
141140
142 /////////////////////141 /////////////////////
143 // Data142 // Data
@@ -148,6 +147,7 @@
148 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);147 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
149 AddChild(title_.GetPointer());148 AddChild(title_.GetPointer());
150 title_->SetLines(-1);149 title_->SetLines(-1);
150 title_->SetScale(scale);
151 title_->SetFont(style.title_font().c_str());151 title_->SetFont(style.title_font().c_str());
152 title_->mouse_click.connect(on_mouse_down);152 title_->mouse_click.connect(on_mouse_down);
153 app_data_layout->AddView(title_.GetPointer(), 1);153 app_data_layout->AddView(title_.GetPointer(), 1);
@@ -157,6 +157,7 @@
157 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);157 subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
158 AddChild(subtitle_.GetPointer());158 AddChild(subtitle_.GetPointer());
159 subtitle_->SetLines(-1);159 subtitle_->SetLines(-1);
160 subtitle_->SetScale(scale);
160 subtitle_->SetFont(style.subtitle_size_font().c_str());161 subtitle_->SetFont(style.subtitle_size_font().c_str());
161 subtitle_->mouse_click.connect(on_mouse_down);162 subtitle_->mouse_click.connect(on_mouse_down);
162 app_data_layout->AddView(subtitle_.GetPointer(), 1);163 app_data_layout->AddView(subtitle_.GetPointer(), 1);
@@ -166,8 +167,8 @@
166 if (movie_preview_model->rating >= 0) {167 if (movie_preview_model->rating >= 0) {
167 rating_ = new PreviewRatingsWidget();168 rating_ = new PreviewRatingsWidget();
168 AddChild(rating_.GetPointer());169 AddChild(rating_.GetPointer());
169 rating_->SetMaximumHeight(style.GetRatingWidgetHeight());170 rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
170 rating_->SetMinimumHeight(style.GetRatingWidgetHeight());171 rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
171 rating_->SetRating(movie_preview_model->rating);172 rating_->SetRating(movie_preview_model->rating);
172 rating_->SetReviews(movie_preview_model->num_ratings);173 rating_->SetReviews(movie_preview_model->num_ratings);
173 rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });174 rating_->request_close().connect([this]() { preview_container_->request_close.emit(); });
@@ -175,20 +176,23 @@
175176
176 /////////////////////177 /////////////////////
177 // Description178 // Description
178 nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION);179 auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION);
180 preview_info_scroll_ = preview_info;
181 preview_info->scale = scale();
179 preview_info->EnableHorizontalScrollBar(false);182 preview_info->EnableHorizontalScrollBar(false);
180 preview_info->mouse_click.connect(on_mouse_down);183 preview_info->mouse_click.connect(on_mouse_down);
181184
182 nux::VLayout* preview_info_layout = new nux::VLayout();185 preview_info_layout_ = new nux::VLayout();
183 preview_info_layout->SetSpaceBetweenChildren(12);186 preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE.CP(scale));
184 preview_info->SetLayout(preview_info_layout);187 preview_info->SetLayout(preview_info_layout_);
185188
186 if (!preview_model_->GetInfoHints().empty())189 if (!preview_model_->GetInfoHints().empty())
187 {190 {
188 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());191 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());
192 preview_info_hints_->scale = scale();
189 AddChild(preview_info_hints_.GetPointer());193 AddChild(preview_info_hints_.GetPointer());
190 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });194 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
191 preview_info_layout->AddView(preview_info_hints_.GetPointer(), 0);195 preview_info_layout_->AddView(preview_info_hints_.GetPointer(), 0);
192 }196 }
193197
194 if (!preview_model_->description.Get().empty())198 if (!preview_model_->description.Get().empty())
@@ -196,34 +200,35 @@
196 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!200 description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
197 AddChild(description_.GetPointer());201 AddChild(description_.GetPointer());
198 description_->SetFont(style.description_font().c_str());202 description_->SetFont(style.description_font().c_str());
203 description_->SetScale(scale);
199 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);204 description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP);
200 description_->SetLines(-style.GetDescriptionLineCount());205 description_->SetLines(-style.GetDescriptionLineCount());
201 description_->SetLineSpacing(style.GetDescriptionLineSpacing());206 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
202 description_->mouse_click.connect(on_mouse_down);207 description_->mouse_click.connect(on_mouse_down);
203 preview_info_layout->AddView(description_.GetPointer());208 preview_info_layout_->AddView(description_.GetPointer());
204 }209 }
205 /////////////////////210 /////////////////////
206211
207 /////////////////////212 /////////////////////
208 // Actions213 // Actions
209 action_buttons_.clear();214 action_buttons_.clear();
210 nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);215 actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
211 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());216 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
212 ///////////////////217 ///////////////////
213218
214 full_data_layout_->AddLayout(app_data_layout, 0);219 full_data_layout_->AddLayout(app_data_layout, 0);
215 if (rating_ != NULL)220 if (rating_ != NULL)
216 full_data_layout_->AddView(rating_.GetPointer(), 0);221 full_data_layout_->AddView(rating_.GetPointer(), 0);
217 full_data_layout_->AddView(preview_info, 1);222 full_data_layout_->AddView(preview_info, 1);
218 full_data_layout_->AddView(actions_layout, 0);223 full_data_layout_->AddView(actions_layout_, 0);
219 /////////////////////224 /////////////////////
220 225
221 image_data_layout->AddView(image_.GetPointer(), 0);226 image_data_layout_->AddView(image_.GetPointer(), 0);
222 image_data_layout->AddLayout(full_data_layout_, 1);227 image_data_layout_->AddLayout(full_data_layout_, 1);
223228
224 mouse_click.connect(on_mouse_down);229 mouse_click.connect(on_mouse_down);
225230
226 SetLayout(image_data_layout);231 SetLayout(image_data_layout_);
227}232}
228233
229234
@@ -235,11 +240,13 @@
235240
236 nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height);241 nux::Geometry geo_art(geo.x, geo.y, style.GetVideoImageAspectRatio() * geo.height, geo.height);
237242
238 if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())243 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
239 geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());244 if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
245 geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
246
240 image_->SetMinMaxSize(geo_art.width, geo_art.height);247 image_->SetMinMaxSize(geo_art.width, geo_art.height);
241248
242 int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());249 int details_width = std::max(0, geo.width - geo_art.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale));
243250
244 if (title_) { title_->SetMaximumWidth(details_width); }251 if (title_) { title_->SetMaximumWidth(details_width); }
245 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }252 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
@@ -247,12 +254,49 @@
247254
248 for (nux::AbstractButton* button : action_buttons_)255 for (nux::AbstractButton* button : action_buttons_)
249 {256 {
250 button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions()) / 2, 0, style.GetActionButtonMaximumWidth()), style.GetActionButtonHeight());257 button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale));
251 }258 }
252259
253 Preview::PreLayoutManagement();260 Preview::PreLayoutManagement();
254}261}
255262
263void MoviePreview::UpdateScale(double scale)
264{
265 Preview::UpdateScale(scale);
266
267 if (image_)
268 image_->scale = scale;
269
270 if (preview_info_hints_)
271 preview_info_hints_->scale = scale;
272
273 previews::Style& style = dash::previews::Style::Instance();
274
275 if (full_data_layout_)
276 {
277 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
278 full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
279 }
280
281 if (image_data_layout_)
282 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
283
284 if (rating_)
285 {
286 rating_->SetMaximumHeight(style.GetRatingWidgetHeight().CP(scale));
287 rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale));
288 }
289
290 if (preview_info_scroll_)
291 preview_info_scroll_->scale = scale;
292
293 if (preview_info_layout_)
294 preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE);
295
296 if (actions_layout_)
297 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
298}
299
256} // namespace previews300} // namespace previews
257} // namespace dash301} // namespace dash
258} // namespace unity302} // namespace unity
259303
=== modified file 'dash/previews/MoviePreview.h'
--- dash/previews/MoviePreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/MoviePreview.h 2014-08-06 16:03:19 +0000
@@ -24,6 +24,7 @@
24#define MOVIEPREVIEW_H24#define MOVIEPREVIEW_H
2525
26#include "Preview.h"26#include "Preview.h"
27#include "unity-shared/OverlayScrollView.h"
2728
28namespace unity29namespace unity
29{30{
@@ -55,9 +56,15 @@
55 virtual void OnNavigateInComplete();56 virtual void OnNavigateInComplete();
5657
57 virtual void SetupViews();58 virtual void SetupViews();
58 59 virtual void UpdateScale(double scale);
60
59protected:61protected:
60 nux::ObjectPtr<PreviewRatingsWidget> rating_;62 nux::ObjectPtr<PreviewRatingsWidget> rating_;
63
64 nux::HLayout* image_data_layout_;
65 nux::VLayout* preview_info_layout_;
66 ScrollView* preview_info_scroll_;
67 nux::Layout* actions_layout_;
61};68};
6269
63}70}
6471
=== modified file 'dash/previews/MusicPaymentPreview.cpp'
--- dash/previews/MusicPaymentPreview.cpp 2013-09-19 16:44:03 +0000
+++ dash/previews/MusicPaymentPreview.cpp 2014-08-06 16:03:19 +0000
@@ -24,7 +24,6 @@
24#include "unity-shared/PreviewStyle.h"24#include "unity-shared/PreviewStyle.h"
25#include "unity-shared/CoverArt.h"25#include "unity-shared/CoverArt.h"
26#include "unity-shared/StaticCairoText.h"26#include "unity-shared/StaticCairoText.h"
27#include "unity-shared/PlacesVScrollBar.h"
28#include "config.h"27#include "config.h"
2928
30#include <glib/gi18n-lib.h>29#include <glib/gi18n-lib.h>
@@ -49,6 +48,22 @@
49{48{
50nux::logging::Logger logger("unity.dash.previews.payment.preview.music");49nux::logging::Logger logger("unity.dash.previews.payment.preview.music");
5150
51const RawPixel DATA_MAX_HEIGHT = 76_em;
52const RawPixel TITLE_CHILDREN_SPACE = 10_em;
53const RawPixel PRIZE_CHILDREN_SPACE = 5_em;
54const RawPixel TITLE_MAX_WIDTH = 480_em;
55const RawPixel INTRO_MIN_HEIGHT = 50_em;
56const RawPixel FORM_MIN_HEIGHT = 107_em;
57const RawPixel FORM_PADDING = 20_em;
58const RawPixel LABELS_CHILDREN_SPACE = 18_em;
59const RawPixel PASSWORD_MIN_HEIGHT = 40_em;
60const RawPixel PASSWORD_MIN_WIDTH = 240_em;
61const RawPixel ACTIONS_CHILDREN_SPACE_MAX = 16_em;
62const RawPixel ACTIONS_CHILDREN_SPACE_MIN = 8_em;
63const RawPixel BUTTONS_SPACE = 20_em;
64const RawPixel HEADER_CHILDREN_SPACE = 10_em;
65const RawPixel HEADER_MAX_SIZE = 76_em;
66const RawPixel BODY_CHILDREN_SPACE = 20_em;
52}67}
5368
54// static string definitions69// static string definitions
@@ -59,17 +74,6 @@
59const std::string MusicPaymentPreview::CANCEL_PURCHASE_ACTION = "cancel_purchase";74const std::string MusicPaymentPreview::CANCEL_PURCHASE_ACTION = "cancel_purchase";
60const std::string MusicPaymentPreview::PURCHASE_ALBUM_ACTION = "purchase_album";75const std::string MusicPaymentPreview::PURCHASE_ALBUM_ACTION = "purchase_album";
6176
62class DetailsScrollView : public nux::ScrollView
63{
64public:
65 DetailsScrollView(NUX_FILE_LINE_PROTO)
66 : ScrollView(NUX_FILE_LINE_PARAM)
67 {
68 SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION));
69 }
70
71};
72
73NUX_IMPLEMENT_OBJECT_TYPE(MusicPaymentPreview)77NUX_IMPLEMENT_OBJECT_TYPE(MusicPaymentPreview)
7478
75MusicPaymentPreview::MusicPaymentPreview(dash::Preview::Ptr preview_model)79MusicPaymentPreview::MusicPaymentPreview(dash::Preview::Ptr preview_model)
@@ -77,6 +81,7 @@
77{81{
78 SetupViews();82 SetupViews();
79 PaymentPreview::SetupBackground();83 PaymentPreview::SetupBackground();
84 UpdateScale(scale);
80}85}
8186
82std::string MusicPaymentPreview::GetName() const87std::string MusicPaymentPreview::GetName() const
@@ -127,6 +132,7 @@
127 || MusicPaymentPreview::FORGOT_PASSWORD_ACTION == action_id)132 || MusicPaymentPreview::FORGOT_PASSWORD_ACTION == action_id)
128 {133 {
129 nux::ObjectPtr<ActionLink> link = this->CreateLink(action);134 nux::ObjectPtr<ActionLink> link = this->CreateLink(action);
135 link->scale = scale();
130 link->activate.connect(sigc::mem_fun(this,136 link->activate.connect(sigc::mem_fun(this,
131 &MusicPaymentPreview::OnActionLinkActivated));137 &MusicPaymentPreview::OnActionLinkActivated));
132138
@@ -137,6 +143,7 @@
137 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);143 nux::ObjectPtr<ActionButton> button = this->CreateButton(action);
138 button->activate.connect(sigc::mem_fun(this,144 button->activate.connect(sigc::mem_fun(this,
139 &MusicPaymentPreview::OnActionActivated));145 &MusicPaymentPreview::OnActionActivated));
146 button->scale = scale();
140147
141 buttons_map_.insert(std::make_pair(action->id, button));148 buttons_map_.insert(std::make_pair(action->id, button));
142 }149 }
@@ -148,8 +155,8 @@
148{155{
149 previews::Style& style = dash::previews::Style::Instance();156 previews::Style& style = dash::previews::Style::Instance();
150 nux::VLayout* title_data_layout = new nux::VLayout();157 nux::VLayout* title_data_layout = new nux::VLayout();
151 title_data_layout->SetMaximumHeight(76);158 title_data_layout->SetMaximumHeight(DATA_MAX_HEIGHT.CP(scale));
152 title_data_layout->SetSpaceBetweenChildren(10);159 title_data_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
153160
154 title_ = new StaticCairoText(161 title_ = new StaticCairoText(
155 preview_model_->title.Get(), true,162 preview_model_->title.Get(), true,
@@ -157,8 +164,9 @@
157164
158 title_->SetFont(style.payment_title_font());165 title_->SetFont(style.payment_title_font());
159 title_->SetLines(-1);166 title_->SetLines(-1);
167 title_->SetScale(scale);
160 title_->SetFont(style.title_font());168 title_->SetFont(style.title_font());
161 title_->SetMaximumWidth(480);169 title_->SetMaximumWidth(TITLE_MAX_WIDTH.CP(scale));
162 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);170 title_->SetTextEllipsize(StaticCairoText::EllipsizeState::NUX_ELLIPSIZE_END);
163 title_data_layout->AddView(title_.GetPointer(), 1);171 title_data_layout->AddView(title_.GetPointer(), 1);
164172
@@ -166,6 +174,7 @@
166 preview_model_->subtitle.Get(), true,174 preview_model_->subtitle.Get(), true,
167 NUX_TRACKER_LOCATION);175 NUX_TRACKER_LOCATION);
168 subtitle_->SetLines(-1);176 subtitle_->SetLines(-1);
177 subtitle_->SetScale(scale);
169 subtitle_->SetFont(style.payment_subtitle_font());178 subtitle_->SetFont(style.payment_subtitle_font());
170 title_data_layout->AddView(subtitle_.GetPointer(), 1);179 title_data_layout->AddView(subtitle_.GetPointer(), 1);
171 title_data_layout->AddSpace(1, 1);180 title_data_layout->AddSpace(1, 1);
@@ -176,14 +185,15 @@
176{185{
177 previews::Style& style = dash::previews::Style::Instance();186 previews::Style& style = dash::previews::Style::Instance();
178 nux::VLayout *prize_data_layout = new nux::VLayout();187 nux::VLayout *prize_data_layout = new nux::VLayout();
179 prize_data_layout->SetMaximumHeight(76);188 prize_data_layout->SetMaximumHeight(DATA_MAX_HEIGHT.CP(scale));
180 prize_data_layout->SetSpaceBetweenChildren(5);189 prize_data_layout->SetSpaceBetweenChildren(PRIZE_CHILDREN_SPACE.CP(scale));
181 prize_data_layout->SetPadding(0, 10, 0, 0);190 prize_data_layout->SetPadding(0, TITLE_CHILDREN_SPACE.CP(scale), 0, 0);
182191
183 purchase_prize_ = new StaticCairoText(192 purchase_prize_ = new StaticCairoText(
184 payment_preview_model_->purchase_prize.Get(), true,193 payment_preview_model_->purchase_prize.Get(), true,
185 NUX_TRACKER_LOCATION);194 NUX_TRACKER_LOCATION);
186 purchase_prize_->SetLines(-1);195 purchase_prize_->SetLines(-1);
196 purchase_prize_->SetScale(scale);
187 purchase_prize_->SetFont(style.payment_prize_title_font());197 purchase_prize_->SetFont(style.payment_prize_title_font());
188 prize_data_layout->AddView(purchase_prize_.GetPointer(), 1,198 prize_data_layout->AddView(purchase_prize_.GetPointer(), 1,
189 nux::MINOR_POSITION_END);199 nux::MINOR_POSITION_END);
@@ -192,6 +202,7 @@
192 _("Ubuntu One best offer"),202 _("Ubuntu One best offer"),
193 true, NUX_TRACKER_LOCATION);203 true, NUX_TRACKER_LOCATION);
194 purchase_hint_->SetLines(-1);204 purchase_hint_->SetLines(-1);
205 purchase_hint_->SetScale(scale);
195 purchase_hint_->SetFont(style.payment_prize_subtitle_font());206 purchase_hint_->SetFont(style.payment_prize_subtitle_font());
196 prize_data_layout->AddView(purchase_hint_.GetPointer(), 1,207 prize_data_layout->AddView(purchase_hint_.GetPointer(), 1,
197 nux::MINOR_POSITION_END);208 nux::MINOR_POSITION_END);
@@ -200,6 +211,7 @@
200 payment_preview_model_->purchase_type.Get(), true,211 payment_preview_model_->purchase_type.Get(), true,
201 NUX_TRACKER_LOCATION);212 NUX_TRACKER_LOCATION);
202 purchase_type_->SetLines(-1);213 purchase_type_->SetLines(-1);
214 purchase_type_->SetScale(scale);
203 purchase_type_->SetFont(style.payment_prize_subtitle_font());215 purchase_type_->SetFont(style.payment_prize_subtitle_font());
204 prize_data_layout->AddView(purchase_type_.GetPointer(), 1,216 prize_data_layout->AddView(purchase_type_.GetPointer(), 1,
205 nux::MINOR_POSITION_END);217 nux::MINOR_POSITION_END);
@@ -210,31 +222,30 @@
210{222{
211 previews::Style& style = dash::previews::Style::Instance();223 previews::Style& style = dash::previews::Style::Instance();
212 nux::VLayout *body_layout = new nux::VLayout();224 nux::VLayout *body_layout = new nux::VLayout();
213 body_layout->SetSpaceBetweenChildren(20);225 body_layout->SetSpaceBetweenChildren(BODY_CHILDREN_SPACE.CP(scale));
214226
215 intro_ = new StaticCairoText(227 intro_ = new StaticCairoText(
216 payment_preview_model_->header.Get(), true,228 payment_preview_model_->header.Get(), true,
217 NUX_TRACKER_LOCATION);229 NUX_TRACKER_LOCATION);
218 intro_->SetFont(style.payment_intro_font());230 intro_->SetFont(style.payment_intro_font());
219 intro_->SetLineSpacing(10);231 intro_->SetScale(scale);
232 intro_->SetLineSpacing(TITLE_CHILDREN_SPACE.CP(scale));
220 intro_->SetLines(-style.GetDescriptionLineCount());233 intro_->SetLines(-style.GetDescriptionLineCount());
221 intro_->SetMinimumHeight(50);234 intro_->SetMinimumHeight(INTRO_MIN_HEIGHT.CP(scale));
222235
223 form_layout_ = new nux::HLayout();236 form_layout_ = new nux::HLayout();
224 form_layout_->SetSpaceBetweenChildren(10);237 form_layout_->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
225 form_layout_->SetMinimumHeight(107);238 form_layout_->SetMinimumHeight(FORM_MIN_HEIGHT.CP(scale));
226 form_layout_->SetLeftAndRightPadding(20);239 form_layout_->SetLeftAndRightPadding(FORM_PADDING.CP(scale));
227 form_layout_->SetTopAndBottomPadding(10);240 form_layout_->SetTopAndBottomPadding(TITLE_CHILDREN_SPACE.CP(scale));
228241
229 form_layout_->AddLayout(GetFormLabels(), 1, nux::MINOR_POSITION_END);242 form_layout_->AddLayout(GetFormLabels(), 1, nux::MINOR_POSITION_END);
230 form_layout_->AddLayout(GetFormFields(), 1, nux::MINOR_POSITION_END);243 form_layout_->AddLayout(GetFormFields(), 1, nux::MINOR_POSITION_END);
231 form_layout_->AddLayout(GetFormActions(), 1, nux::MINOR_POSITION_END);244 form_layout_->AddLayout(GetFormActions(), 1, nux::MINOR_POSITION_END);
232245
233
234 body_layout->AddView(intro_.GetPointer(), 1);246 body_layout->AddView(intro_.GetPointer(), 1);
235 body_layout->AddLayout(form_layout_.GetPointer(), 1);247 body_layout->AddLayout(form_layout_.GetPointer(), 1);
236248
237
238 return body_layout;249 return body_layout;
239}250}
240251
@@ -244,17 +255,18 @@
244 nux::VLayout *labels_layout = new nux::VLayout();255 nux::VLayout *labels_layout = new nux::VLayout();
245 if (error_message_.empty())256 if (error_message_.empty())
246 {257 {
247 labels_layout->SetSpaceBetweenChildren(18);258 labels_layout->SetSpaceBetweenChildren(LABELS_CHILDREN_SPACE.CP(scale));
248 }259 }
249 else260 else
250 {261 {
251 labels_layout->SetSpaceBetweenChildren(10);262 labels_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
252 }263 }
253264
254 email_label_ = new StaticCairoText(265 email_label_ = new StaticCairoText(
255 _("Ubuntu One email:"), true,266 _("Ubuntu One email:"), true,
256 NUX_TRACKER_LOCATION);267 NUX_TRACKER_LOCATION);
257 email_label_->SetLines(-1);268 email_label_->SetLines(-1);
269 email_label_->SetScale(scale);
258 email_label_->SetFont(style.payment_form_labels_font());270 email_label_->SetFont(style.payment_form_labels_font());
259 labels_layout->AddView(email_label_.GetPointer(), 0, nux::MINOR_POSITION_END);271 labels_layout->AddView(email_label_.GetPointer(), 0, nux::MINOR_POSITION_END);
260272
@@ -262,6 +274,7 @@
262 _("Payment method:"), true,274 _("Payment method:"), true,
263 NUX_TRACKER_LOCATION);275 NUX_TRACKER_LOCATION);
264 payment_label_->SetLines(-1);276 payment_label_->SetLines(-1);
277 payment_label_->SetScale(scale);
265 payment_label_->SetFont(style.payment_form_labels_font());278 payment_label_->SetFont(style.payment_form_labels_font());
266 labels_layout->AddView(payment_label_.GetPointer(), 0, nux::MINOR_POSITION_END);279 labels_layout->AddView(payment_label_.GetPointer(), 0, nux::MINOR_POSITION_END);
267280
@@ -269,8 +282,9 @@
269 _("Ubuntu One password:"), true,282 _("Ubuntu One password:"), true,
270 NUX_TRACKER_LOCATION);283 NUX_TRACKER_LOCATION);
271 password_label_->SetLines(-1);284 password_label_->SetLines(-1);
285 password_label_->SetScale(scale);
272 password_label_->SetFont(style.payment_form_labels_font());286 password_label_->SetFont(style.payment_form_labels_font());
273 password_label_->SetMinimumHeight(40);287 password_label_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale));
274 labels_layout->AddView(password_label_.GetPointer(), 0, nux::MINOR_POSITION_END);288 labels_layout->AddView(password_label_.GetPointer(), 0, nux::MINOR_POSITION_END);
275289
276 return labels_layout;290 return labels_layout;
@@ -282,17 +296,18 @@
282 nux::VLayout *fields_layout = new nux::VLayout();296 nux::VLayout *fields_layout = new nux::VLayout();
283 if (error_message_.empty())297 if (error_message_.empty())
284 {298 {
285 fields_layout->SetSpaceBetweenChildren(18);299 fields_layout->SetSpaceBetweenChildren(LABELS_CHILDREN_SPACE.CP(scale));
286 }300 }
287 else301 else
288 {302 {
289 fields_layout->SetSpaceBetweenChildren(10);303 fields_layout->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
290 }304 }
291305
292 email_ = new StaticCairoText(306 email_ = new StaticCairoText(
293 payment_preview_model_->email.Get(), true,307 payment_preview_model_->email.Get(), true,
294 NUX_TRACKER_LOCATION);308 NUX_TRACKER_LOCATION);
295 email_->SetLines(-1);309 email_->SetLines(-1);
310 email_->SetScale(scale);
296 email_->SetFont(style.payment_form_data_font());311 email_->SetFont(style.payment_form_data_font());
297 fields_layout->AddView(email_.GetPointer(), 1,312 fields_layout->AddView(email_.GetPointer(), 1,
298 nux::MINOR_POSITION_START);313 nux::MINOR_POSITION_START);
@@ -301,13 +316,14 @@
301 payment_preview_model_->payment_method.Get(), true,316 payment_preview_model_->payment_method.Get(), true,
302 NUX_TRACKER_LOCATION);317 NUX_TRACKER_LOCATION);
303 payment_->SetLines(-1);318 payment_->SetLines(-1);
319 payment_->SetScale(scale);
304 payment_->SetFont(style.payment_form_data_font());320 payment_->SetFont(style.payment_form_data_font());
305 fields_layout->AddView(payment_.GetPointer(), 1,321 fields_layout->AddView(payment_.GetPointer(), 1,
306 nux::MINOR_POSITION_START);322 nux::MINOR_POSITION_START);
307323
308 password_entry_ = new TextInput();324 password_entry_ = new TextInput();
309 password_entry_->SetMinimumHeight(40);325 password_entry_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale));
310 password_entry_->SetMinimumWidth(240);326 password_entry_->SetMinimumWidth(PASSWORD_MIN_WIDTH.CP(scale));
311 password_entry_->input_hint = _("Password");327 password_entry_->input_hint = _("Password");
312328
313 fields_layout->AddView(password_entry_.GetPointer(),329 fields_layout->AddView(password_entry_.GetPointer(),
@@ -322,6 +338,7 @@
322 StaticCairoText* error = new StaticCairoText(338 StaticCairoText* error = new StaticCairoText(
323 _("Wrong password"), true, NUX_TRACKER_LOCATION);339 _("Wrong password"), true, NUX_TRACKER_LOCATION);
324 error->SetLines(-1);340 error->SetLines(-1);
341 error->SetScale(scale);
325 error->SetFont(style.payment_form_data_font());342 error->SetFont(style.payment_form_data_font());
326 // ensure it is an error using red343 // ensure it is an error using red
327 error->SetTextColor(style.payment_error_color());344 error->SetTextColor(style.payment_error_color());
@@ -337,11 +354,11 @@
337 nux::VLayout *actions_layout = new nux::VLayout();354 nux::VLayout *actions_layout = new nux::VLayout();
338 if (error_message_.empty())355 if (error_message_.empty())
339 {356 {
340 actions_layout->SetSpaceBetweenChildren(16);357 actions_layout->SetSpaceBetweenChildren(ACTIONS_CHILDREN_SPACE_MAX.CP(scale));
341 }358 }
342 else359 else
343 {360 {
344 actions_layout->SetSpaceBetweenChildren(8);361 actions_layout->SetSpaceBetweenChildren(ACTIONS_CHILDREN_SPACE_MIN.CP(scale));
345 }362 }
346363
347 nux::ObjectPtr<StaticCairoText> empty_;364 nux::ObjectPtr<StaticCairoText> empty_;
@@ -349,6 +366,7 @@
349 "", true,366 "", true,
350 NUX_TRACKER_LOCATION);367 NUX_TRACKER_LOCATION);
351 empty_->SetLines(-1);368 empty_->SetLines(-1);
369 empty_->SetScale(scale);
352 empty_->SetFont(style.payment_form_labels_font());370 empty_->SetFont(style.payment_form_labels_font());
353 actions_layout->AddView(empty_.GetPointer(), 1,371 actions_layout->AddView(empty_.GetPointer(), 1,
354 nux::MINOR_POSITION_START);372 nux::MINOR_POSITION_START);
@@ -374,14 +392,14 @@
374 actions_buffer_h->AddSpace(0, 1);392 actions_buffer_h->AddSpace(0, 1);
375393
376 nux::HLayout* buttons_data_layout = new nux::HLayout();394 nux::HLayout* buttons_data_layout = new nux::HLayout();
377 buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());395 buttons_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
378396
379 lock_texture_ = new IconTexture(style.GetLockIcon(), style.GetPaymentLockWidth(),397 lock_texture_ = new IconTexture(style.GetLockIcon(), style.GetPaymentLockWidth().CP(scale),
380 style.GetPaymentLockHeight());398 style.GetPaymentLockHeight().CP(scale));
381 buttons_data_layout->AddView(lock_texture_.GetPointer(), 0, nux::MINOR_POSITION_CENTER,399 buttons_data_layout->AddView(lock_texture_.GetPointer(), 0, nux::MINOR_POSITION_CENTER,
382 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);400 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
383401
384 buttons_data_layout->AddSpace(20, 1);402 buttons_data_layout->AddSpace(BUTTONS_SPACE.CP(scale), 1);
385 if(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer())403 if(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer())
386 buttons_data_layout->AddView(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer(),404 buttons_data_layout->AddView(buttons_map_[MusicPaymentPreview::CANCEL_PURCHASE_ACTION].GetPointer(),
387 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f,405 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0f,
@@ -413,7 +431,8 @@
413431
414 previews::Style& style = dash::previews::Style::Instance();432 previews::Style& style = dash::previews::Style::Instance();
415433
416 int width = std::max<int>(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());434 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
435 int width = std::max<int>(0, content_width);
417436
418 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }437 if(full_data_layout_) { full_data_layout_->SetMaximumWidth(width); }
419 if(header_layout_) { header_layout_->SetMaximumWidth(width); }438 if(header_layout_) { header_layout_->SetMaximumWidth(width); }
@@ -460,6 +479,49 @@
460 PaymentPreview::SetupViews();479 PaymentPreview::SetupViews();
461}480}
462481
482void MusicPaymentPreview::UpdateScale(double scale)
483{
484 PaymentPreview::UpdateScale(scale);
485
486 if (intro_)
487 intro_->SetScale(scale);
488 if (email_label_)
489 email_label_->SetScale(scale);
490 if (payment_label_)
491 payment_label_->SetScale(scale);
492 if (payment_)
493 payment_->SetScale(scale);
494 if (password_label_)
495 password_label_->SetScale(scale);
496 if (purchase_hint_)
497 purchase_hint_->SetScale(scale);
498 if (purchase_prize_)
499 purchase_prize_->SetScale(scale);
500 if (purchase_type_)
501 purchase_type_->SetScale(scale);
502 if (change_payment_)
503 change_payment_->SetScale(scale);
504 if (error_label_)
505 error_label_->SetScale(scale);
506
507 previews::Style& style = dash::previews::Style::Instance();
508 if (lock_texture_)
509 lock_texture_->SetSize(std::max(style.GetPaymentLockWidth().CP(scale), style.GetPaymentLockHeight().CP(scale)));
510
511 if (password_entry_)
512 {
513 password_entry_->SetMinimumHeight(PASSWORD_MIN_HEIGHT.CP(scale));
514 password_entry_->SetMinimumWidth(PASSWORD_MIN_WIDTH.CP(scale));
515 }
516
517 if (form_layout_)
518 {
519 form_layout_->SetSpaceBetweenChildren(TITLE_CHILDREN_SPACE.CP(scale));
520 form_layout_->SetMinimumHeight(FORM_MIN_HEIGHT.CP(scale));
521 form_layout_->SetLeftAndRightPadding(FORM_PADDING.CP(scale));
522 form_layout_->SetTopAndBottomPadding(TITLE_CHILDREN_SPACE.CP(scale));
523 }
524}
463525
464}526}
465}527}
466528
=== modified file 'dash/previews/MusicPaymentPreview.h'
--- dash/previews/MusicPaymentPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/MusicPaymentPreview.h 2014-08-06 16:03:19 +0000
@@ -90,6 +90,7 @@
90 void OnActionLinkActivated(ActionLink* link, std::string const& id);90 void OnActionLinkActivated(ActionLink* link, std::string const& id);
9191
92 virtual void SetupViews();92 virtual void SetupViews();
93 virtual void UpdateScale(double scale) override;
9394
94 void PreLayoutManagement();95 void PreLayoutManagement();
9596
9697
=== modified file 'dash/previews/MusicPreview.cpp'
--- dash/previews/MusicPreview.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/MusicPreview.cpp 2014-08-06 16:03:19 +0000
@@ -42,14 +42,27 @@
42{42{
43namespace previews43namespace previews
44{44{
45
46namespace
47{
48 const RawPixel CHILDREN_SPACE = 16_em;
49 const RawPixel ICON_LEFT_RIGHT_PADDING = 10_em;
50 const RawPixel WARNING_MIN_HEIGHT = 50_em;
51 const RawPixel WARNING_MAX_WIDTH = 300_em;
52}
53
45DECLARE_LOGGER(logger, "unity.dash.preview.music");54DECLARE_LOGGER(logger, "unity.dash.preview.music");
4655
47NUX_IMPLEMENT_OBJECT_TYPE(MusicPreview);56NUX_IMPLEMENT_OBJECT_TYPE(MusicPreview);
4857
49MusicPreview::MusicPreview(dash::Preview::Ptr preview_model)58MusicPreview::MusicPreview(dash::Preview::Ptr preview_model)
50: Preview(preview_model)59: Preview(preview_model)
60, actions_layout_(nullptr)
61, image_data_layout_(nullptr)
62, icon_layout_(nullptr)
51{63{
52 SetupViews();64 SetupViews();
65 UpdateScale(scale);
53}66}
5467
55MusicPreview::~MusicPreview()68MusicPreview::~MusicPreview()
@@ -130,13 +143,13 @@
130143
131 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); };144 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); };
132145
133 nux::HLayout* image_data_layout = new nux::HLayout();146 image_data_layout_ = new nux::HLayout();
134 image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth());147 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
135148
136 /////////////////////149 /////////////////////
137 // Image150 // Image
138 image_ = new CoverArt();151 image_ = new CoverArt();
139 152 image_->scale = scale();
140 AddChild(image_.GetPointer());153 AddChild(image_.GetPointer());
141 UpdateCoverArtImage(image_.GetPointer());154 UpdateCoverArtImage(image_.GetPointer());
142 /////////////////////155 /////////////////////
@@ -144,20 +157,21 @@
144 /////////////////////157 /////////////////////
145 // App Data Panel158 // App Data Panel
146 full_data_layout_ = new nux::VLayout();159 full_data_layout_ = new nux::VLayout();
147 full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin());160 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
148 full_data_layout_->SetSpaceBetweenChildren(16);161 full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
149162
150 /////////////////////163 /////////////////////
151 // Music Info164 // Music Info
152 nux::VLayout* album_data_layout = new nux::VLayout();165 album_data_layout_ = new nux::VLayout();
153 album_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());166 album_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
154167
155 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);168 title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
156 AddChild(title_.GetPointer());169 AddChild(title_.GetPointer());
157 title_->SetFont(style.title_font().c_str());170 title_->SetFont(style.title_font().c_str());
158 title_->SetLines(-1);171 title_->SetLines(-1);
172 title_->SetScale(scale);
159 title_->mouse_click.connect(on_mouse_down);173 title_->mouse_click.connect(on_mouse_down);
160 album_data_layout->AddView(title_.GetPointer(), 1);174 album_data_layout_->AddView(title_.GetPointer(), 1);
161175
162 if (!preview_model_->subtitle.Get().empty())176 if (!preview_model_->subtitle.Get().empty())
163 {177 {
@@ -165,8 +179,9 @@
165 AddChild(subtitle_.GetPointer());179 AddChild(subtitle_.GetPointer());
166 subtitle_->SetFont(style.subtitle_size_font().c_str());180 subtitle_->SetFont(style.subtitle_size_font().c_str());
167 subtitle_->SetLines(-1);181 subtitle_->SetLines(-1);
182 subtitle_->SetScale(scale);
168 subtitle_->mouse_click.connect(on_mouse_down);183 subtitle_->mouse_click.connect(on_mouse_down);
169 album_data_layout->AddView(subtitle_.GetPointer(), 1);184 album_data_layout_->AddView(subtitle_.GetPointer(), 1);
170 }185 }
171186
172 /////////////////////187 /////////////////////
@@ -177,6 +192,7 @@
177 if (tracks_model)192 if (tracks_model)
178 {193 {
179 tracks_ = new previews::Tracks(tracks_model, NUX_TRACKER_LOCATION);194 tracks_ = new previews::Tracks(tracks_model, NUX_TRACKER_LOCATION);
195 tracks_->scale = scale();
180 AddChild(tracks_.GetPointer());196 AddChild(tracks_.GetPointer());
181 tracks_->mouse_click.connect(on_mouse_down);197 tracks_->mouse_click.connect(on_mouse_down);
182 }198 }
@@ -187,7 +203,7 @@
187 /////////////////////203 /////////////////////
188 // Hints && Actions204 // Hints && Actions
189 nux::VLayout* hints_layout = NULL;205 nux::VLayout* hints_layout = NULL;
190 nux::Layout* actions_layout = NULL;206 actions_layout_ = NULL;
191 bool has_u1_creds = HasUbuntuOneCredentials();207 bool has_u1_creds = HasUbuntuOneCredentials();
192208
193 if (has_u1_creds)209 if (has_u1_creds)
@@ -197,70 +213,72 @@
197 hints_layout = new nux::VLayout();213 hints_layout = new nux::VLayout();
198 hints_layout->SetSpaceBetweenChildren(0);214 hints_layout->SetSpaceBetweenChildren(0);
199 hints_layout->AddSpace(0, 1);215 hints_layout->AddSpace(0, 1);
200 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth());216 preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth().CP(scale));
217 preview_info_hints_->scale = scale();
201 AddChild(preview_info_hints_.GetPointer());218 AddChild(preview_info_hints_.GetPointer());
202 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });219 preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); });
203 hints_layout->AddView(preview_info_hints_.GetPointer(), 0);220 hints_layout->AddView(preview_info_hints_.GetPointer(), 0);
204221
205 // If there are actions, we use a vertical layout222 // If there are actions, we use a vertical layout
206 action_buttons_.clear();223 action_buttons_.clear();
207 actions_layout = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);224 actions_layout_ = BuildVerticalActionsLayout(preview_model_->GetActions(), action_buttons_);
208 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());225 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
209 }226 }
210 else // otherwise we add a grid layout.227 else // otherwise we add a grid layout.
211 {228 {
212 action_buttons_.clear();229 action_buttons_.clear();
213 actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);230 actions_layout_ = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_);
214 if (action_buttons_.size() < 2)231 if (action_buttons_.size() < 2)
215 hint_actions_layout->AddSpace(0, 1);232 hint_actions_layout->AddSpace(0, 1);
216 actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin());233 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
217 }234 }
218 }235 }
219 else236 else
220 {237 {
221 // let the user know he needs to connect238 // let the user know he needs to connect
222 previews::Style& style = dash::previews::Style::Instance();239 previews::Style& style = dash::previews::Style::Instance();
223 actions_layout = new nux::HLayout();240 nux::HLayout* actions_layout = new nux::HLayout();
224 nux::VLayout* icon_layout = new nux::VLayout();241 icon_layout_ = new nux::VLayout();
225 icon_layout->SetLeftAndRightPadding(10);242 icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
226243
227 warning_texture_ = new IconTexture(style.GetWarningIcon());244 warning_texture_ = new IconTexture(style.GetWarningIcon());
228 icon_layout->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START,245 icon_layout_->AddView(warning_texture_.GetPointer(), 0, nux::MINOR_POSITION_START,
229 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);246 nux::MINOR_SIZE_FULL, 100.0f, nux::NUX_LAYOUT_BEGIN);
230 actions_layout->AddLayout(icon_layout, 0, nux::MINOR_POSITION_CENTER);247 actions_layout->AddLayout(icon_layout_, 0, nux::MINOR_POSITION_CENTER);
231248
232 warning_msg_ = new StaticCairoText(249 warning_msg_ = new StaticCairoText(
233 no_credentials_message_, true,250 no_credentials_message_, true,
234 NUX_TRACKER_LOCATION);251 NUX_TRACKER_LOCATION);
235 AddChild(warning_msg_.GetPointer());252 AddChild(warning_msg_.GetPointer());
236 warning_msg_->SetFont(style.u1_warning_font().c_str());253 warning_msg_->SetFont(style.u1_warning_font().c_str());
237 warning_msg_->SetLines(-2);254 warning_msg_->SetLines(-2);
238 warning_msg_->SetMinimumHeight(50);255 warning_msg_->SetScale(scale);
239 warning_msg_->SetMaximumWidth(300);256 warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale));
257 warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale));
240258
241 actions_layout->AddView(warning_msg_.GetPointer(), 0, nux::MINOR_POSITION_CENTER);259 actions_layout->AddView(warning_msg_.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
242260
243 }261 }
244 262
245 /////////////////////263 /////////////////////
246264
247 if (hints_layout) hint_actions_layout->AddView(hints_layout, 1);265 if (hints_layout) hint_actions_layout->AddView(hints_layout, 1);
248 hint_actions_layout->AddView(actions_layout, 0);266 hint_actions_layout->AddView(actions_layout_, 0);
249267
250 full_data_layout_->AddLayout(album_data_layout, 0);268 full_data_layout_->AddLayout(album_data_layout_, 0);
251 if (tracks_)269 if (tracks_)
252 {270 {
253 full_data_layout_->AddView(tracks_.GetPointer(), 1);271 full_data_layout_->AddView(tracks_.GetPointer(), 1);
254 }272 }
255 full_data_layout_->AddLayout(hint_actions_layout, 0);273 full_data_layout_->AddLayout(hint_actions_layout, 0);
256 /////////////////////274 /////////////////////
257 275
258 image_data_layout->AddView(image_.GetPointer(), 0);276 image_data_layout_->AddView(image_.GetPointer(), 0);
259 image_data_layout->AddLayout(full_data_layout_, 1);277 image_data_layout_->AddLayout(full_data_layout_, 1);
260278
261 mouse_click.connect(on_mouse_down);279 mouse_click.connect(on_mouse_down);
262280
263 SetLayout(image_data_layout);281 SetLayout(image_data_layout_);
264}282}
265283
266void MusicPreview::PreLayoutManagement()284void MusicPreview::PreLayoutManagement()
@@ -272,23 +290,23 @@
272290
273 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);291 nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height);
274292
275 if (geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() < style.GetDetailsPanelMinimumWidth())293 int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale);
276 geo_art.width = MAX(0, geo.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin() - style.GetDetailsPanelMinimumWidth());294 if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale))
295 geo_art.width = MAX(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale));
277 image_->SetMinMaxSize(geo_art.width, geo_art.height);296 image_->SetMinMaxSize(geo_art.width, geo_art.height);
278297
279 int details_width = MAX(0, geo.width - geo_art.width - style.GetPanelSplitWidth() - style.GetDetailsLeftMargin() - style.GetDetailsRightMargin());298 int details_width = MAX(0, content_width - geo_art.width);
280299
281 if (title_) { title_->SetMaximumWidth(details_width); }300 if (title_) { title_->SetMaximumWidth(details_width); }
282 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }301 if (subtitle_) { subtitle_->SetMaximumWidth(details_width); }
283302
284 for (nux::AbstractButton* button : action_buttons_)303 for (nux::AbstractButton* button : action_buttons_)
285 {304 {
286 int action_width = CLAMP((details_width - style.GetSpaceBetweenActions()) /305 int action_width = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale));
287 2, 0, style.GetActionButtonMaximumWidth());
288 // do not use SetMinMax because width has to be able to grow306 // do not use SetMinMax because width has to be able to grow
289 button->SetMinimumWidth(action_width);307 button->SetMinimumWidth(action_width);
290 button->SetMinimumHeight(style.GetActionButtonHeight());308 button->SetMinimumHeight(style.GetActionButtonHeight().CP(scale));
291 button->SetMaximumHeight(style.GetActionButtonHeight());309 button->SetMaximumHeight(style.GetActionButtonHeight().CP(scale));
292 }310 }
293311
294 Preview::PreLayoutManagement();312 Preview::PreLayoutManagement();
@@ -300,6 +318,47 @@
300 player.Stop();318 player.Stop();
301}319}
302320
321void MusicPreview::UpdateScale(double scale)
322{
323 Preview::UpdateScale(scale);
324
325 if (tracks_)
326 tracks_->scale = scale;
327
328 if (preview_info_hints_)
329 preview_info_hints_->scale = scale;
330
331 if (icon_layout_)
332 icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
333
334 if (warning_msg_)
335 {
336 warning_msg_->SetScale(scale);
337 warning_msg_->SetMinimumHeight(WARNING_MIN_HEIGHT.CP(scale));
338 warning_msg_->SetMaximumWidth(WARNING_MAX_WIDTH.CP(scale));
339 }
340
341 previews::Style& style = dash::previews::Style::Instance();
342
343 if (image_data_layout_)
344 image_data_layout_->SetSpaceBetweenChildren(style.GetPanelSplitWidth().CP(scale));
345
346 if (full_data_layout_)
347 {
348 full_data_layout_->SetPadding(style.GetDetailsTopMargin().CP(scale), 0, style.GetDetailsBottomMargin().CP(scale), style.GetDetailsLeftMargin().CP(scale));
349 full_data_layout_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
350 }
351
352 if (album_data_layout_)
353 album_data_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle().CP(scale));
354
355 if (actions_layout_)
356 actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale));
357
358 if (icon_layout_)
359 icon_layout_->SetLeftAndRightPadding(ICON_LEFT_RIGHT_PADDING.CP(scale));
360}
361
303} // namespace previews362} // namespace previews
304} // namespace dash363} // namespace dash
305} // namespace unity364} // namespace unity
306365
=== modified file 'dash/previews/MusicPreview.h'
--- dash/previews/MusicPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/MusicPreview.h 2014-08-06 16:03:19 +0000
@@ -24,6 +24,7 @@
24#define MUSICPREVIEW_H24#define MUSICPREVIEW_H
2525
26#include "Preview.h"26#include "Preview.h"
27#include "unity-shared/OverlayScrollView.h"
27#include "unity-shared/IconTexture.h"28#include "unity-shared/IconTexture.h"
2829
29namespace unity30namespace unity
@@ -53,6 +54,7 @@
53 virtual void PreLayoutManagement();54 virtual void PreLayoutManagement();
5455
55 virtual void SetupViews();56 virtual void SetupViews();
57 virtual void UpdateScale(double scale);
5658
57 virtual void OnNavigateOut();59 virtual void OnNavigateOut();
5860
@@ -64,6 +66,10 @@
64 nux::ObjectPtr<IconTexture> warning_texture_;66 nux::ObjectPtr<IconTexture> warning_texture_;
65 std::string no_credentials_message_;67 std::string no_credentials_message_;
6668
69 nux::Layout* actions_layout_;
70 nux::HLayout* image_data_layout_;
71 nux::VLayout* icon_layout_;
72 nux::VLayout* album_data_layout_;
67 };73 };
6874
69}75}
7076
=== modified file 'dash/previews/PaymentPreview.cpp'
--- dash/previews/PaymentPreview.cpp 2013-09-19 16:44:03 +0000
+++ dash/previews/PaymentPreview.cpp 2014-08-06 16:03:19 +0000
@@ -23,6 +23,7 @@
23#include <NuxCore/Logger.h>23#include <NuxCore/Logger.h>
24#include "PaymentPreview.h"24#include "PaymentPreview.h"
25#include "unity-shared/CoverArt.h"25#include "unity-shared/CoverArt.h"
26#include "unity-shared/DashStyle.h"
26#include "unity-shared/PreviewStyle.h"27#include "unity-shared/PreviewStyle.h"
2728
28namespace unity29namespace unity
@@ -39,6 +40,15 @@
3940
40nux::logging::Logger logger("unity.dash.previews.payment.preview");41nux::logging::Logger logger("unity.dash.previews.payment.preview");
4142
43const RawPixel CONTENT_DATA_CHILDREN_SPACE = 5_em;
44const RawPixel CONTENT_DATA_PADDING = 10_em;
45const RawPixel OVERLAY_LAYOUT_SPACE = 20_em;
46const RawPixel HEADER_CHILDREN_SPACE = 10_em;
47const RawPixel HEADER_MAX_SIZE = 76_em;
48const RawPixel IMAGE_MIN_MAX_SIZE = 64_em;
49const RawPixel HEADER_SPACE = 10_em;
50const RawPixel LINK_MIN_WIDTH = 178_em;
51const RawPixel LINK_MAX_HEIGHT = 34_em;
42}52}
4353
44class OverlaySpinner : public unity::debug::Introspectable, public nux::View54class OverlaySpinner : public unity::debug::Introspectable, public nux::View
@@ -47,6 +57,8 @@
47public:57public:
48 OverlaySpinner();58 OverlaySpinner();
4959
60 nux::Property<double> scale;
61
50 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);62 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
51 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);63 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
5264
@@ -61,7 +73,7 @@
61private:73private:
62 bool OnFrameTimeout();74 bool OnFrameTimeout();
6375
64 nux::BaseTexture* spin_;76 nux::ObjectPtr<nux::BaseTexture> spin_;
6577
66 glib::Source::UniquePtr frame_timeout_;78 glib::Source::UniquePtr frame_timeout_;
6779
@@ -72,15 +84,19 @@
72NUX_IMPLEMENT_OBJECT_TYPE(OverlaySpinner);84NUX_IMPLEMENT_OBJECT_TYPE(OverlaySpinner);
7385
74OverlaySpinner::OverlaySpinner()86OverlaySpinner::OverlaySpinner()
75 : nux::View(NUX_TRACKER_LOCATION),87 : nux::View(NUX_TRACKER_LOCATION)
76 rotation_(0.0f)88 , scale(1.0)
89 , rotation_(0.0f)
77{90{
78 previews::Style& style = dash::previews::Style::Instance();91 spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
79
80 spin_ = style.GetSearchSpinIcon();
8192
82 rotate_.Identity();93 rotate_.Identity();
83 rotate_.Rotate_z(0.0);94 rotate_.Rotate_z(0.0);
95
96 scale.changed.connect([this] (double scale) {
97 spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
98 QueueDraw();
99 });
84}100}
85101
86void OverlaySpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)102void OverlaySpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
@@ -183,8 +199,12 @@
183: Preview(preview_model)199: Preview(preview_model)
184, data_(nullptr)200, data_(nullptr)
185, full_data_layout_(nullptr)201, full_data_layout_(nullptr)
186{202, content_data_layout_(nullptr)
187}203, overlay_layout_(nullptr)
204, header_layout_(nullptr)
205, body_layout_(nullptr)
206, footer_layout_(nullptr)
207{}
188208
189std::string PaymentPreview::GetName() const209std::string PaymentPreview::GetName() const
190{210{
@@ -199,18 +219,18 @@
199nux::Layout* PaymentPreview::GetHeader()219nux::Layout* PaymentPreview::GetHeader()
200{220{
201 nux::HLayout* header_data_layout = new nux::HLayout();221 nux::HLayout* header_data_layout = new nux::HLayout();
202 header_data_layout->SetSpaceBetweenChildren(10);222 header_data_layout->SetSpaceBetweenChildren(HEADER_CHILDREN_SPACE.CP(scale));
203 header_data_layout->SetMaximumHeight(76);223 header_data_layout->SetMaximumHeight(HEADER_MAX_SIZE.CP(scale));
204 header_data_layout->SetMinimumHeight(76);224 header_data_layout->SetMinimumHeight(HEADER_MAX_SIZE.CP(scale));
205225
206 image_ = new CoverArt();226 image_ = new CoverArt();
207 image_->SetMinMaxSize(64, 64);227 image_->SetMinMaxSize(IMAGE_MIN_MAX_SIZE.CP(scale), IMAGE_MIN_MAX_SIZE.CP(scale));
208 AddChild(image_.GetPointer());228 AddChild(image_.GetPointer());
209 UpdateCoverArtImage(image_.GetPointer());229 UpdateCoverArtImage(image_.GetPointer());
210230
211 header_data_layout->AddView(image_.GetPointer(), 0);231 header_data_layout->AddView(image_.GetPointer(), 0);
212 header_data_layout->AddLayout(GetTitle(), 0);232 header_data_layout->AddLayout(GetTitle(), 0);
213 header_data_layout->AddSpace(10, 1);233 header_data_layout->AddSpace(HEADER_SPACE.CP(scale), 1);
214 header_data_layout->AddLayout(GetPrice(), 0);234 header_data_layout->AddLayout(GetPrice(), 0);
215 return header_data_layout;235 return header_data_layout;
216}236}
@@ -223,8 +243,8 @@
223 link = new ActionLink(action->id,243 link = new ActionLink(action->id,
224 action->display_name, NUX_TRACKER_LOCATION);244 action->display_name, NUX_TRACKER_LOCATION);
225 link->font_hint.Set(style.payment_form_labels_font().c_str());245 link->font_hint.Set(style.payment_form_labels_font().c_str());
226 link->SetMinimumWidth(178);246 link->SetMinimumWidth(LINK_MIN_WIDTH.CP(scale));
227 link->SetMaximumHeight(34);247 link->SetMaximumHeight(LINK_MAX_HEIGHT.CP(scale));
228 return link;248 return link;
229}249}
230250
@@ -239,8 +259,8 @@
239 NUX_TRACKER_LOCATION);259 NUX_TRACKER_LOCATION);
240 button->SetFont(style.action_font());260 button->SetFont(style.action_font());
241 button->SetExtraHint(action->extra_text, style.action_extra_font());261 button->SetExtraHint(action->extra_text, style.action_extra_font());
242 button->SetMinimumWidth(178);262 button->SetMinimumWidth(LINK_MIN_WIDTH.CP(scale));
243 button->SetMaximumHeight(34);263 button->SetMaximumHeight(LINK_MAX_HEIGHT.CP(scale));
244 return button;264 return button;
245}265}
246266
@@ -327,8 +347,8 @@
327347
328 // layout to be used to show the info348 // layout to be used to show the info
329 content_data_layout_ = new nux::VLayout();349 content_data_layout_ = new nux::VLayout();
330 content_data_layout_->SetSpaceBetweenChildren(5);350 content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale));
331 content_data_layout_->SetPadding(10, 10, 0, 10);351 content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale));
332352
333 header_layout_ = GetHeader();353 header_layout_ = GetHeader();
334354
@@ -344,21 +364,37 @@
344364
345 // layout to draw an overlay365 // layout to draw an overlay
346 overlay_layout_ = new nux::VLayout();366 overlay_layout_ = new nux::VLayout();
347 StaticCairoText* calculating = new StaticCairoText(367 calculating_ = new StaticCairoText(
348 "Performing purchase", true,368 "Performing purchase", true,
349 NUX_TRACKER_LOCATION);369 NUX_TRACKER_LOCATION);
350370
351 OverlaySpinner* spinner_ = new OverlaySpinner();371 OverlaySpinner* spinner_ = new OverlaySpinner();
352 overlay_layout_->AddSpace(20, 1);372 overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1);
353 overlay_layout_->AddView(calculating, 0, nux::MINOR_POSITION_CENTER);373 overlay_layout_->AddView(calculating_, 0, nux::MINOR_POSITION_CENTER);
354 overlay_layout_->AddView(spinner_, 1, nux::MINOR_POSITION_CENTER);374 overlay_layout_->AddView(spinner_, 1, nux::MINOR_POSITION_CENTER);
355 overlay_layout_->AddSpace(20, 1);375 overlay_layout_->AddSpace(OVERLAY_LAYOUT_SPACE.CP(scale), 1);
376 scale.changed.connect([this, spinner_] (double scale) { spinner_->scale = scale; });
356377
357 full_data_layout_->AddLayout(overlay_layout_.GetPointer());378 full_data_layout_->AddLayout(overlay_layout_.GetPointer());
358379
380 UpdateScale(scale);
359 SetLayout(full_data_layout_.GetPointer());381 SetLayout(full_data_layout_.GetPointer());
360}382}
361383
384void PaymentPreview::UpdateScale(double scale)
385{
386 Preview::UpdateScale(scale);
387
388 if (calculating_)
389 calculating_->SetScale(scale);
390
391 if (content_data_layout_)
392 {
393 content_data_layout_->SetSpaceBetweenChildren(CONTENT_DATA_CHILDREN_SPACE.CP(scale));
394 content_data_layout_->SetPadding(CONTENT_DATA_PADDING.CP(scale), CONTENT_DATA_PADDING.CP(scale), 0, CONTENT_DATA_PADDING.CP(scale));
395 }
396}
397
362}398}
363399
364}400}
365401
=== modified file 'dash/previews/PaymentPreview.h'
--- dash/previews/PaymentPreview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/PaymentPreview.h 2014-08-06 16:03:19 +0000
@@ -106,6 +106,7 @@
106106
107 virtual void LoadActions() = 0;107 virtual void LoadActions() = 0;
108 virtual void SetupViews();108 virtual void SetupViews();
109 virtual void UpdateScale(double scale) override;
109 virtual void SetupBackground();110 virtual void SetupBackground();
110111
111 nux::ObjectPtr<nux::LayeredLayout> full_data_layout_;112 nux::ObjectPtr<nux::LayeredLayout> full_data_layout_;
@@ -115,6 +116,8 @@
115 nux::ObjectPtr<nux::Layout> body_layout_;116 nux::ObjectPtr<nux::Layout> body_layout_;
116 nux::ObjectPtr<nux::Layout> footer_layout_;117 nux::ObjectPtr<nux::Layout> footer_layout_;
117118
119 StaticCairoText* calculating_;
120
118 // content elements121 // content elements
119 nux::ObjectPtr<CoverArt> image_;122 nux::ObjectPtr<CoverArt> image_;
120123
121124
=== modified file 'dash/previews/Preview.cpp'
--- dash/previews/Preview.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/Preview.cpp 2014-08-06 16:03:19 +0000
@@ -38,6 +38,7 @@
38#include "MusicPaymentPreview.h"38#include "MusicPaymentPreview.h"
39#include "SocialPreview.h"39#include "SocialPreview.h"
40#include "PreviewInfoHintWidget.h"40#include "PreviewInfoHintWidget.h"
41#include "ActionButton.h"
4142
42namespace unity43namespace unity
43{44{
@@ -100,14 +101,16 @@
100101
101Preview::Preview(dash::Preview::Ptr preview_model)102Preview::Preview(dash::Preview::Ptr preview_model)
102 : View(NUX_TRACKER_LOCATION)103 : View(NUX_TRACKER_LOCATION)
104 , scale(1.0f)
103 , preview_model_(preview_model)105 , preview_model_(preview_model)
104 , tab_iterator_(new TabIterator())106 , tab_iterator_(new TabIterator())
105 , full_data_layout_(nullptr)107 , full_data_layout_(nullptr)
106 , image_(nullptr)108 , image_(nullptr)
107 , title_(nullptr)109 , title_(nullptr)
108 , subtitle_(nullptr)110 , subtitle_(nullptr)
111 , preview_container_(new PreviewContainer)
109{112{
110 preview_container_ = new PreviewContainer;113 scale.changed.connect(sigc::mem_fun(this, &Preview::UpdateScale));
111}114}
112115
113Preview::~Preview()116Preview::~Preview()
@@ -138,13 +141,13 @@
138 previews::Style& style = dash::previews::Style::Instance();141 previews::Style& style = dash::previews::Style::Instance();
139142
140 nux::VLayout* actions_layout_v = new nux::VLayout();143 nux::VLayout* actions_layout_v = new nux::VLayout();
141 actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());144 actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
142 uint rows = actions.size() / 2 + ((actions.size() % 2 > 0) ? 1 : 0);145 uint rows = actions.size() / 2 + ((actions.size() % 2 > 0) ? 1 : 0);
143 uint action_iter = 0;146 uint action_iter = 0;
144 for (uint i = 0; i < rows; i++)147 for (uint i = 0; i < rows; i++)
145 {148 {
146 nux::HLayout* actions_layout_h = new TabIteratorHLayout(tab_iterator_);149 nux::HLayout* actions_layout_h = new TabIteratorHLayout(tab_iterator_);
147 actions_layout_h->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());150 actions_layout_h->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
148151
149 for (uint j = 0; j < 2 && action_iter < actions.size(); j++, action_iter++)152 for (uint j = 0; j < 2 && action_iter < actions.size(); j++, action_iter++)
150 {153 {
@@ -172,7 +175,7 @@
172 previews::Style& style = dash::previews::Style::Instance();175 previews::Style& style = dash::previews::Style::Instance();
173176
174 nux::VLayout* actions_layout_v = new TabIteratorVLayout(tab_iterator_);177 nux::VLayout* actions_layout_v = new TabIteratorVLayout(tab_iterator_);
175 actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions());178 actions_layout_v->SetSpaceBetweenChildren(style.GetSpaceBetweenActions().CP(scale));
176179
177 uint action_iter = 0;180 uint action_iter = 0;
178 for (uint i = 0; i < actions.size(); i++)181 for (uint i = 0; i < actions.size(); i++)
@@ -215,7 +218,7 @@
215 else218 else
216 cover_art->SetNoImageAvailable();219 cover_art->SetNoImageAvailable();
217 cover_art->SetFont(style.no_preview_image_font());220 cover_art->SetFont(style.no_preview_image_font());
218 221
219 cover_art->mouse_click.connect(on_mouse_down);222 cover_art->mouse_click.connect(on_mouse_down);
220}223}
221224
@@ -279,6 +282,37 @@
279 return preview_container_->request_close;282 return preview_container_->request_close;
280}283}
281284
282}285void Preview::UpdateScale(double scale)
283}286{
284}287 if (image_)
288 image_->scale = scale;
289
290 if (title_)
291 title_->SetScale(scale);
292 if (subtitle_)
293 subtitle_->SetScale(scale);
294 if (description_)
295 description_->SetScale(scale);
296
297 if (preview_container_)
298 preview_container_->scale = scale;
299
300 if (preview_info_hints_)
301 preview_info_hints_->scale = scale;
302
303 for (nux::AbstractButton* button : action_buttons_)
304 {
305 if (ActionButton* bn = dynamic_cast<ActionButton*>(button))
306 bn->scale = scale;
307
308 if (ActionLink* link = dynamic_cast<ActionLink*>(button))
309 link->scale = scale;
310 }
311
312 QueueRelayout();
313 QueueDraw();
314}
315
316} // preview
317} // dash
318} // unity
285319
=== modified file 'dash/previews/Preview.h'
--- dash/previews/Preview.h 2013-09-19 16:44:03 +0000
+++ dash/previews/Preview.h 2014-08-06 16:03:19 +0000
@@ -74,6 +74,8 @@
74 unsigned long special_keys_state);74 unsigned long special_keys_state);
75 virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction);75 virtual nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
7676
77 nux::Property<double> scale;
78
77protected:79protected:
78 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {}80 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {}
79 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}81 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}
@@ -88,6 +90,8 @@
8890
89 virtual void SetupViews() = 0;91 virtual void SetupViews() = 0;
9092
93 virtual void UpdateScale(double scale);
94
91 nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);95 nux::Layout* BuildGridActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
92 nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);96 nux::Layout* BuildVerticalActionsLayout(dash::Preview::ActionPtrList actions, std::list<nux::AbstractButton*>& buttons);
9397
9498
=== modified file 'dash/previews/PreviewContainer.cpp'
--- dash/previews/PreviewContainer.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/PreviewContainer.cpp 2014-08-06 16:03:19 +0000
@@ -23,11 +23,11 @@
23#include "PreviewContainer.h"23#include "PreviewContainer.h"
24#include <NuxCore/Logger.h>24#include <NuxCore/Logger.h>
25#include <Nux/HLayout.h>25#include <Nux/HLayout.h>
26#include <Nux/VLayout.h>
2726
28#include "unity-shared/IntrospectableWrappers.h"27#include "unity-shared/IntrospectableWrappers.h"
29#include "unity-shared/TimeUtil.h"28#include "unity-shared/TimeUtil.h"
30#include "unity-shared/PreviewStyle.h"29#include "unity-shared/PreviewStyle.h"
30#include "unity-shared/DashStyle.h"
31#include "unity-shared/GraphicsUtils.h"31#include "unity-shared/GraphicsUtils.h"
32#include "PreviewNavigator.h"32#include "PreviewNavigator.h"
33#include <boost/math/constants/constants.hpp>33#include <boost/math/constants/constants.hpp>
@@ -52,13 +52,15 @@
52const int PREVIEW_SPINNER_WAIT = 2000;52const int PREVIEW_SPINNER_WAIT = 2000;
5353
54const std::string ANIMATION_IDLE = "animation-idle";54const std::string ANIMATION_IDLE = "animation-idle";
55const RawPixel CHILDREN_SPACE = 6_em;
55}56}
5657
57class PreviewContent : public nux::Layout, public debug::Introspectable58class PreviewContent : public nux::Layout, public debug::Introspectable
58{59{
59public:60public:
60 PreviewContent(PreviewContainer*const parent)61 PreviewContent(PreviewContainer*const parent)
61 : parent_(parent)62 : scale(1.0)
63 , parent_(parent)
62 , progress_(0.0)64 , progress_(0.0)
63 , curve_progress_(0.0)65 , curve_progress_(0.0)
64 , animating_(false)66 , animating_(false)
@@ -73,9 +75,19 @@
73 // Need to update the preview geometries when updating the container geo.75 // Need to update the preview geometries when updating the container geo.
74 UpdateAnimationProgress(progress_, curve_progress_);76 UpdateAnimationProgress(progress_, curve_progress_);
75 });77 });
76 Style& style = previews::Style::Instance();78
7779 spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
78 spin_= style.GetSearchSpinIcon(32);80 scale.changed.connect(sigc::mem_fun(this, &PreviewContent::UpdateScale));
81 }
82
83 void UpdateScale(double scale)
84 {
85 spin_ = dash::Style::Instance().GetSearchSpinIcon(scale);
86
87 for (auto* area : GetChildren())
88 static_cast<previews::Preview*>(area)->scale = scale;
89
90 QueueDraw();
79 }91 }
8092
81 // From debug::Introspectable93 // From debug::Introspectable
@@ -107,6 +119,7 @@
107 AddChild(preview.GetPointer());119 AddChild(preview.GetPointer());
108 AddView(preview.GetPointer());120 AddView(preview.GetPointer());
109 preview->SetVisible(false);121 preview->SetVisible(false);
122 preview->scale = scale();
110 }123 }
111 else124 else
112 {125 {
@@ -355,6 +368,7 @@
355 sigc::signal<void> start_navigation;368 sigc::signal<void> start_navigation;
356 sigc::signal<void> continue_navigation;369 sigc::signal<void> continue_navigation;
357 sigc::signal<void> end_navigation;370 sigc::signal<void> end_navigation;
371 nux::Property<double> scale;
358372
359private:373private:
360 PreviewContainer*const parent_;374 PreviewContainer*const parent_;
@@ -394,6 +408,7 @@
394408
395PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL)409PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL)
396 : View(NUX_FILE_LINE_PARAM)410 : View(NUX_FILE_LINE_PARAM)
411 , scale(1.0)
397 , preview_layout_(nullptr)412 , preview_layout_(nullptr)
398 , nav_disabled_(Navigation::NONE)413 , nav_disabled_(Navigation::NONE)
399 , navigation_progress_speed_(0.0)414 , navigation_progress_speed_(0.0)
@@ -408,6 +423,7 @@
408423
409 key_down.connect(sigc::mem_fun(this, &PreviewContainer::OnKeyDown));424 key_down.connect(sigc::mem_fun(this, &PreviewContainer::OnKeyDown));
410 mouse_click.connect(sigc::mem_fun(this, &PreviewContainer::OnMouseDown));425 mouse_click.connect(sigc::mem_fun(this, &PreviewContainer::OnMouseDown));
426 scale.changed.connect(sigc::mem_fun(this, &PreviewContainer::UpdateScale));
411}427}
412428
413PreviewContainer::~PreviewContainer()429PreviewContainer::~PreviewContainer()
@@ -417,13 +433,12 @@
417void PreviewContainer::Preview(dash::Preview::Ptr preview_model, Navigation direction)433void PreviewContainer::Preview(dash::Preview::Ptr preview_model, Navigation direction)
418{434{
419 previews::Preview::Ptr preview_view = preview_model ? previews::Preview::PreviewForModel(preview_model) : previews::Preview::Ptr();435 previews::Preview::Ptr preview_view = preview_model ? previews::Preview::PreviewForModel(preview_model) : previews::Preview::Ptr();
420 436
421 if (preview_view)437 if (preview_view)
422 {438 {
423 preview_view->request_close().connect([this]() { request_close.emit(); });439 preview_view->request_close().connect([this]() { request_close.emit(); });
440 preview_layout_->PushPreview(preview_view, direction);
424 }441 }
425
426 preview_layout_->PushPreview(preview_view, direction);
427}442}
428443
429void PreviewContainer::DisableNavButton(Navigation button)444void PreviewContainer::DisableNavButton(Navigation button)
@@ -458,29 +473,32 @@
458473
459 nux::VLayout* layout = new nux::VLayout();474 nux::VLayout* layout = new nux::VLayout();
460 SetLayout(layout);475 SetLayout(layout);
461 layout->AddLayout(new nux::SpaceLayout(0,0,style.GetPreviewTopPadding(),style.GetPreviewTopPadding()));476
477 layout->SetTopAndBottomPadding(style.GetPreviewTopPadding().CP(scale), 0);
462478
463 layout_content_ = new nux::HLayout();479 layout_content_ = new nux::HLayout();
464 layout_content_->SetSpaceBetweenChildren(6);480 layout_content_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
465 layout->AddLayout(layout_content_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);481 layout->AddLayout(layout_content_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
466482
467 layout_content_->AddSpace(0, 1);483 layout_content_->AddSpace(0, 1);
468 nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);484 nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
469 AddChild(nav_left_);485 AddChild(nav_left_);
470 nav_left_->SetMinimumWidth(style.GetNavigatorWidth());486 nav_left_->scale = scale();
471 nav_left_->SetMaximumWidth(style.GetNavigatorWidth());487 nav_left_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
488 nav_left_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
472 nav_left_->activated.connect([this]() { navigate_left.emit(); });489 nav_left_->activated.connect([this]() { navigate_left.emit(); });
473 layout_content_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);490 layout_content_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
474491
475 preview_layout_ = new PreviewContent(this);492 preview_layout_ = new PreviewContent(this);
476 preview_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight());493 preview_layout_->SetMinMaxSize(style.GetPreviewWidth().CP(scale), style.GetPreviewHeight().CP(scale));
477 AddChild(preview_layout_);494 AddChild(preview_layout_);
478 layout_content_->AddLayout(preview_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);495 layout_content_->AddLayout(preview_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
479496
480 nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);497 nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
481 AddChild(nav_right_);498 AddChild(nav_right_);
482 nav_right_->SetMinimumWidth(style.GetNavigatorWidth());499 nav_right_->scale = scale();
483 nav_right_->SetMaximumWidth(style.GetNavigatorWidth());500 nav_right_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
501 nav_right_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
484 nav_right_->activated.connect([this]() { navigate_right.emit(); });502 nav_right_->activated.connect([this]() { navigate_right.emit(); });
485 layout_content_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);503 layout_content_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
486 layout_content_->AddSpace(0, 1);504 layout_content_->AddSpace(0, 1);
@@ -492,7 +510,7 @@
492 // reset animation clock.510 // reset animation clock.
493 if (navigation_count_ == 0)511 if (navigation_count_ == 0)
494 clock_gettime(CLOCK_MONOTONIC, &last_progress_time_);512 clock_gettime(CLOCK_MONOTONIC, &last_progress_time_);
495 513
496 float navigation_progress_remaining = CLAMP((1.0 - preview_layout_->GetAnimationProgress()) + navigation_count_, 1.0f, 10.0f);514 float navigation_progress_remaining = CLAMP((1.0 - preview_layout_->GetAnimationProgress()) + navigation_count_, 1.0f, 10.0f);
497 navigation_count_++;515 navigation_count_++;
498516
@@ -534,7 +552,7 @@
534 gfx_engine.GetRenderStates().SetBlend(false);552 gfx_engine.GetRenderStates().SetBlend(false);
535 gfx_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f));553 gfx_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
536 }554 }
537 555
538 // rely on the compiz event loop to come back to us in a nice throttling556 // rely on the compiz event loop to come back to us in a nice throttling
539 if (AnimationInProgress())557 if (AnimationInProgress())
540 {558 {
@@ -595,11 +613,12 @@
595bool PreviewContainer::QueueAnimation()613bool PreviewContainer::QueueAnimation()
596{614{
597 animation_timer_.reset();615 animation_timer_.reset();
598 616
599 timespec current;617 timespec current;
600 clock_gettime(CLOCK_MONOTONIC, &current);618 clock_gettime(CLOCK_MONOTONIC, &current);
601 float progress = GetSwipeAnimationProgress(current);619 float progress = GetSwipeAnimationProgress(current);
602 preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out.620 if (preview_layout_)
621 preview_layout_->UpdateAnimationProgress(progress, easeInOutQuart(progress)); // ease in/out.
603 last_progress_time_ = current;622 last_progress_time_ = current;
604623
605 QueueDraw();624 QueueDraw();
@@ -691,7 +710,30 @@
691710
692nux::Geometry PreviewContainer::GetLayoutGeometry() const711nux::Geometry PreviewContainer::GetLayoutGeometry() const
693{712{
694 return layout_content_->GetAbsoluteGeometry(); 713 return layout_content_->GetAbsoluteGeometry();
714}
715
716void PreviewContainer::UpdateScale(double scale)
717{
718 previews::Style& style = previews::Style::Instance();
719
720 GetLayout()->SetTopAndBottomPadding(style.GetPreviewTopPadding().CP(scale), 0);
721
722 preview_layout_->SetMinMaxSize(style.GetPreviewWidth().CP(scale), style.GetPreviewHeight().CP(scale));
723 preview_layout_->scale = scale;
724
725 layout_content_->SetSpaceBetweenChildren(CHILDREN_SPACE.CP(scale));
726
727 nav_left_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
728 nav_left_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
729 nav_left_->scale = scale;
730
731 nav_right_->SetMinimumWidth(style.GetNavigatorWidth().CP(scale));
732 nav_right_->SetMaximumWidth(style.GetNavigatorWidth().CP(scale));
733 nav_right_->scale = scale;
734
735 QueueRelayout();
736 QueueDraw();
695}737}
696738
697} // namespace previews739} // namespace previews
698740
=== modified file 'dash/previews/PreviewContainer.h'
--- dash/previews/PreviewContainer.h 2013-09-19 16:44:03 +0000
+++ dash/previews/PreviewContainer.h 2014-08-06 16:03:19 +0000
@@ -25,6 +25,7 @@
2525
26#include <Nux/Nux.h>26#include <Nux/Nux.h>
27#include <Nux/View.h>27#include <Nux/View.h>
28#include <Nux/VLayout.h>
28#include <UnityCore/Preview.h>29#include <UnityCore/Preview.h>
29#include "Preview.h"30#include "Preview.h"
30#include "unity-shared/Introspectable.h"31#include "unity-shared/Introspectable.h"
@@ -74,6 +75,8 @@
74 sigc::signal<void> navigate_right;75 sigc::signal<void> navigate_right;
75 sigc::signal<void> request_close;76 sigc::signal<void> request_close;
7677
78 nux::Property<double> scale;
79
77 bool AcceptKeyNavFocus();80 bool AcceptKeyNavFocus();
7881
79 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);82 nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
@@ -91,7 +94,7 @@
9194
92 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);95 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
93 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);96 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
94 97
95private:98private:
96 void SetupViews();99 void SetupViews();
97100
@@ -101,6 +104,8 @@
101 bool QueueAnimation();104 bool QueueAnimation();
102105
103private:106private:
107 void UpdateScale(double scale);
108
104 // View related109 // View related
105 nux::HLayout* layout_content_;110 nux::HLayout* layout_content_;
106 PreviewNavigator* nav_left_;111 PreviewNavigator* nav_left_;
@@ -112,7 +117,7 @@
112 struct timespec last_progress_time_;117 struct timespec last_progress_time_;
113 float navigation_progress_speed_;118 float navigation_progress_speed_;
114 int navigation_count_;119 int navigation_count_;
115 120
116 glib::Source::UniquePtr animation_timer_;121 glib::Source::UniquePtr animation_timer_;
117 friend class PreviewContent;122 friend class PreviewContent;
118};123};
119124
=== modified file 'dash/previews/PreviewInfoHintWidget.cpp'
--- dash/previews/PreviewInfoHintWidget.cpp 2013-11-19 18:48:35 +0000
+++ dash/previews/PreviewInfoHintWidget.cpp 2014-08-06 16:03:19 +0000
@@ -17,6 +17,7 @@
17 * <http://www.gnu.org/licenses/>17 * <http://www.gnu.org/licenses/>
18 *18 *
19 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>19 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
20 * Marco Trevisan <marco.trevisan@canonical.com>
20 *21 *
21 */22 */
2223
@@ -41,21 +42,23 @@
41DECLARE_LOGGER(logger, "unity.dash.preview.infohintwidget");42DECLARE_LOGGER(logger, "unity.dash.preview.infohintwidget");
42namespace43namespace
43{44{
44const int layout_spacing = 12;45const RawPixel LAYOUT_SPACING = 12_em;
46const RawPixel HINTS_SPACING = 6_em;
45}47}
4648
47NUX_IMPLEMENT_OBJECT_TYPE(PreviewInfoHintWidget);49NUX_IMPLEMENT_OBJECT_TYPE(PreviewInfoHintWidget);
4850
49PreviewInfoHintWidget::PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size)51PreviewInfoHintWidget::PreviewInfoHintWidget(dash::Preview::Ptr preview_model, int icon_size)
50: View(NUX_TRACKER_LOCATION)52: View(NUX_TRACKER_LOCATION)
53, scale(1.0)
51, icon_size_(icon_size)54, icon_size_(icon_size)
55, layout_(nullptr)
56, info_names_layout_(nullptr)
57, info_values_layout_(nullptr)
52, preview_model_(preview_model)58, preview_model_(preview_model)
53{59{
54 SetupViews();60 SetupViews();
55}61 scale.changed.connect(sigc::mem_fun(this, &PreviewInfoHintWidget::UpdateScale));
56
57PreviewInfoHintWidget::~PreviewInfoHintWidget()
58{
59}62}
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: