From 2efb531091731ee467d368c2394bf17e2fa9d0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 5 Jul 2014 18:25:03 +0200 Subject: Dash previews: various code cleanups and improvements (bzr r3830.3.6) --- dash/previews/ActionButton.cpp | 2 +- dash/previews/ActionLink.h | 1 - dash/previews/ApplicationPreview.cpp | 11 +++++++---- dash/previews/GenericPreview.cpp | 7 ++++--- dash/previews/Preview.cpp | 6 ++---- dash/previews/PreviewInfoHintWidget.cpp | 4 ++-- dash/previews/StandaloneMusicPaymentPreview.cpp | 4 +--- dash/previews/StandaloneSocialPreview.cpp | 1 - 8 files changed, 17 insertions(+), 19 deletions(-) (limited to 'dash') diff --git a/dash/previews/ActionButton.cpp b/dash/previews/ActionButton.cpp index 57b1b3edb..09d4d663a 100644 --- a/dash/previews/ActionButton.cpp +++ b/dash/previews/ActionButton.cpp @@ -102,7 +102,7 @@ void ActionButton::InitTheme() } void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint) -{ +{ extra_font_hint_= font_hint; if (extra_text_) { diff --git a/dash/previews/ActionLink.h b/dash/previews/ActionLink.h index a60692e01..553f5dba7 100644 --- a/dash/previews/ActionLink.h +++ b/dash/previews/ActionLink.h @@ -47,7 +47,6 @@ public: nux::RWProperty text_aligment; nux::RWProperty underline_state; nux::RWProperty font_hint; - nux::Property scale; void Activate() {} diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp index 0fe137148..7b4375acc 100644 --- a/dash/previews/ApplicationPreview.cpp +++ b/dash/previews/ApplicationPreview.cpp @@ -321,7 +321,9 @@ void ApplicationPreview::PreLayoutManagement() nux::Geometry geo_art(geo.x, geo.y, style.GetAppImageAspectRatio() * geo.height, geo.height); - int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) - style.GetDetailsLeftMargin().CP(scale) - style.GetDetailsRightMargin().CP(scale); + int content_width = geo.width - style.GetPanelSplitWidth().CP(scale) + - style.GetDetailsLeftMargin().CP(scale) + - style.GetDetailsRightMargin().CP(scale); if (content_width - geo_art.width < style.GetDetailsPanelMinimumWidth().CP(scale)) geo_art.width = std::max(0, content_width - style.GetDetailsPanelMinimumWidth().CP(scale)); @@ -337,10 +339,11 @@ void ApplicationPreview::PreLayoutManagement() if (copywrite_) { copywrite_->SetMaximumWidth(top_app_info_max_width); } if (description_) { description_->SetMaximumWidth(details_width); } + int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)); + int button_h = style.GetActionButtonHeight().CP(scale); + for (nux::AbstractButton* button : action_buttons_) - { - button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale)); - } + button->SetMinMaxSize(button_w, button_h); Preview::PreLayoutManagement(); } diff --git a/dash/previews/GenericPreview.cpp b/dash/previews/GenericPreview.cpp index 250f1181e..b79b50ff3 100644 --- a/dash/previews/GenericPreview.cpp +++ b/dash/previews/GenericPreview.cpp @@ -241,10 +241,11 @@ void GenericPreview::PreLayoutManagement() if (subtitle_) { subtitle_->SetMaximumWidth(details_width); } if (description_) { description_->SetMaximumWidth(details_width); } + int button_w = CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)); + int button_h = style.GetActionButtonHeight().CP(scale); + for (nux::AbstractButton* button : action_buttons_) - { - button->SetMinMaxSize(CLAMP((details_width - style.GetSpaceBetweenActions().CP(scale)) / 2, 0, style.GetActionButtonMaximumWidth().CP(scale)), style.GetActionButtonHeight().CP(scale)); - } + button->SetMinMaxSize(button_w, button_h); Preview::PreLayoutManagement(); } diff --git a/dash/previews/Preview.cpp b/dash/previews/Preview.cpp index ed27452f3..af538f051 100644 --- a/dash/previews/Preview.cpp +++ b/dash/previews/Preview.cpp @@ -303,12 +303,10 @@ void Preview::UpdateScale(double scale) for (nux::AbstractButton* button : action_buttons_) { - ActionButton* bn = dynamic_cast(button); - if (bn) + if (ActionButton* bn = dynamic_cast(button)) bn->scale = scale; - ActionLink* link = dynamic_cast(button); - if (link) + if (ActionLink* link = dynamic_cast(button)) link->scale = scale; } diff --git a/dash/previews/PreviewInfoHintWidget.cpp b/dash/previews/PreviewInfoHintWidget.cpp index ed570713c..b7f51aeb1 100644 --- a/dash/previews/PreviewInfoHintWidget.cpp +++ b/dash/previews/PreviewInfoHintWidget.cpp @@ -198,10 +198,10 @@ void PreviewInfoHintWidget::PreLayoutManagement() { nux::Geometry const& geo = GetGeometry(); info_names_layout_->SetMaximumWidth(info_names_layout_->GetContentWidth()); - int max_width = geo.width - info_names_layout_->GetWidth() - LAYOUT_SPACING.CP(scale) -1; + int max_width = std::max(0, geo.width - info_names_layout_->GetWidth() - LAYOUT_SPACING.CP(scale) -1); for (auto value : info_values_layout_->GetChildren()) - value->SetMaximumWidth(max_width > 0 ? max_width : 0); + value->SetMaximumWidth(max_width); } View::PreLayoutManagement(); diff --git a/dash/previews/StandaloneMusicPaymentPreview.cpp b/dash/previews/StandaloneMusicPaymentPreview.cpp index 0f5597145..4f21b093a 100644 --- a/dash/previews/StandaloneMusicPaymentPreview.cpp +++ b/dash/previews/StandaloneMusicPaymentPreview.cpp @@ -147,7 +147,6 @@ TestRunner::~TestRunner () void TestRunner::Init () { container_ = new previews::PreviewContainer(NUX_TRACKER_LOCATION); -// container_->scale = 1.62; container_->request_close.connect([this]() { exit(0); }); container_->DisableNavButton(previews::Navigation::BOTH); @@ -190,8 +189,7 @@ void TestRunner::Init () glib::StealRef()); dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v)); - if (container_) - container_->Preview(preview_model, previews::Navigation::LEFT); + container_->Preview(preview_model, previews::Navigation::LEFT); } void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) diff --git a/dash/previews/StandaloneSocialPreview.cpp b/dash/previews/StandaloneSocialPreview.cpp index cb1736f14..9da0c0bce 100644 --- a/dash/previews/StandaloneSocialPreview.cpp +++ b/dash/previews/StandaloneSocialPreview.cpp @@ -180,7 +180,6 @@ void TestRunner::Init () dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v)); container_->Preview(preview_model, previews::Navigation::RIGHT); - } void TestRunner::NavRight() -- cgit v1.2.3