diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-07-05 18:25:03 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-07-05 18:25:03 +0200 |
| commit | 2efb531091731ee467d368c2394bf17e2fa9d0d2 (patch) | |
| tree | 5df0a9c21daf8b6825c68bc382ea08a68edea837 /dash | |
| parent | fdc47abdeb13a9e8dad7b4a5bf4408415b32cb59 (diff) | |
Dash previews: various code cleanups and improvements
(bzr r3830.3.6)
Diffstat (limited to 'dash')
| -rw-r--r-- | dash/previews/ActionButton.cpp | 2 | ||||
| -rw-r--r-- | dash/previews/ActionLink.h | 1 | ||||
| -rw-r--r-- | dash/previews/ApplicationPreview.cpp | 11 | ||||
| -rw-r--r-- | dash/previews/GenericPreview.cpp | 7 | ||||
| -rw-r--r-- | dash/previews/Preview.cpp | 6 | ||||
| -rw-r--r-- | dash/previews/PreviewInfoHintWidget.cpp | 4 | ||||
| -rw-r--r-- | dash/previews/StandaloneMusicPaymentPreview.cpp | 4 | ||||
| -rw-r--r-- | dash/previews/StandaloneSocialPreview.cpp | 1 |
8 files changed, 17 insertions, 19 deletions
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<StaticCairoText::AlignState> text_aligment; nux::RWProperty<StaticCairoText::UnderlineState> underline_state; nux::RWProperty<std::string> font_hint; - nux::Property<double> 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<ActionButton*>(button); - if (bn) + if (ActionButton* bn = dynamic_cast<ActionButton*>(button)) bn->scale = scale; - ActionLink* link = dynamic_cast<ActionLink*>(button); - if (link) + if (ActionLink* link = dynamic_cast<ActionLink*>(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() |
