diff options
| author | Marco Trevisan (TreviƱo) <mail@3v1n0.net> | 2014-07-31 18:38:48 +0000 |
|---|---|---|
| committer | CI bot <ps-jenkins@lists.canonical.com> | 2014-07-31 18:38:48 +0000 |
| commit | 7ca6f5931385f949ae6707b9e1a502ac518f96cb (patch) | |
| tree | 0683d4e1d3f0c0adaa73f7b946bc877f4cdeeec1 /dash | |
| parent | 1e0b49b54c44e656d0f34dad96486c29c3a89a70 (diff) | |
| parent | 760b988cc92e97dc2be3d773aac8004609e8ae95 (diff) | |
PlacesOverlayVScrollBar and VScrollBarOverlayWindow: add support for scaling
Add a new ScrollView class to create ScrollViews with an OverlayScrollbar and with scaling support. Using them in dash Scopes and Previews. Fixes: 1340996 Approved by: Brandon Schaefer, PS Jenkins bot (bzr r3846)
Diffstat (limited to 'dash')
| -rwxr-xr-x | dash/ScopeView.cpp | 19 | ||||
| -rw-r--r-- | dash/ScopeView.h | 1 | ||||
| -rw-r--r-- | dash/previews/ApplicationPreview.cpp | 25 | ||||
| -rw-r--r-- | dash/previews/ApplicationPreview.h | 2 | ||||
| -rw-r--r-- | dash/previews/ErrorPreview.cpp | 12 | ||||
| -rw-r--r-- | dash/previews/GenericPreview.cpp | 22 | ||||
| -rw-r--r-- | dash/previews/GenericPreview.h | 5 | ||||
| -rw-r--r-- | dash/previews/MoviePreview.cpp | 20 | ||||
| -rw-r--r-- | dash/previews/MoviePreview.h | 2 | ||||
| -rw-r--r-- | dash/previews/MusicPaymentPreview.cpp | 12 | ||||
| -rw-r--r-- | dash/previews/MusicPreview.h | 1 | ||||
| -rw-r--r-- | dash/previews/Preview.cpp | 6 | ||||
| -rw-r--r-- | dash/previews/SocialPreview.cpp | 20 | ||||
| -rw-r--r-- | dash/previews/SocialPreview.h | 2 | ||||
| -rw-r--r-- | dash/previews/Tracks.cpp | 4 | ||||
| -rw-r--r-- | dash/previews/Tracks.h | 5 |
16 files changed, 59 insertions, 99 deletions
diff --git a/dash/ScopeView.cpp b/dash/ScopeView.cpp index 8ced06853..8465c5da0 100755 --- a/dash/ScopeView.cpp +++ b/dash/ScopeView.cpp @@ -29,7 +29,7 @@ #include "ResultRendererHorizontalTile.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UBusWrapper.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" +#include "unity-shared/OverlayScrollView.h" #include "unity-shared/GraphicsUtils.h" #include "config.h" @@ -51,16 +51,14 @@ const double DEFAULT_SCALE = 1.0; } // This is so we can access some protected members in scrollview. -class ScopeScrollView: public nux::ScrollView +class ScopeScrollView: public dash::ScrollView { public: - ScopeScrollView(nux::VScrollBar* scroll_bar, NUX_FILE_LINE_DECL) - : nux::ScrollView(NUX_FILE_LINE_PARAM) + ScopeScrollView(NUX_FILE_LINE_DECL) + : ScrollView(NUX_FILE_LINE_PARAM) , right_area_(nullptr) , up_area_(nullptr) { - SetVScrollBar(scroll_bar); - OnVisibleChanged.connect([this] (nux::Area* /*area*/, bool visible) { if (m_horizontal_scrollbar_enable) _hscrollbar->SetVisible(visible); @@ -236,8 +234,8 @@ void ScopeView::SetupViews(nux::Area* show_filters) { layout_ = new nux::HLayout(NUX_TRACKER_LOCATION); - scroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), - NUX_TRACKER_LOCATION); + scroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION); + scroll_view_->scale = scale(); scroll_view_->EnableVerticalScrollBar(true); scroll_view_->EnableHorizontalScrollBar(false); layout_->AddView(scroll_view_); @@ -252,7 +250,8 @@ void ScopeView::SetupViews(nux::Area* show_filters) no_results_->SetScale(scale); scroll_layout_->AddView(no_results_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT); - fscroll_view_ = new ScopeScrollView(new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION), NUX_TRACKER_LOCATION); + fscroll_view_ = new ScopeScrollView(NUX_TRACKER_LOCATION); + fscroll_view_->scale = scale(); fscroll_view_->EnableVerticalScrollBar(true); fscroll_view_->EnableHorizontalScrollBar(false); fscroll_view_->SetVisible(false); @@ -296,6 +295,8 @@ void ScopeView::UpdateScale(double scale) for (auto& group : category_views_) group->scale = scale; + scroll_view_->scale = scale; + fscroll_view_->scale = scale; filter_bar_->scale = scale; no_results_->SetScale(scale); } diff --git a/dash/ScopeView.h b/dash/ScopeView.h index ac0659a43..b229a072e 100644 --- a/dash/ScopeView.h +++ b/dash/ScopeView.h @@ -36,7 +36,6 @@ #include "PlacesGroup.h" #include "ResultViewGrid.h" #include "unity-shared/UBusWrapper.h" -#include "unity-shared/PlacesVScrollBar.h" namespace unity { diff --git a/dash/previews/ApplicationPreview.cpp b/dash/previews/ApplicationPreview.cpp index 7b4375acc..19d517250 100644 --- a/dash/previews/ApplicationPreview.cpp +++ b/dash/previews/ApplicationPreview.cpp @@ -24,7 +24,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/IconTexture.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include <UnityCore/ApplicationPreview.h> #include <NuxCore/Logger.h> #include <Nux/HLayout.h> @@ -58,17 +57,6 @@ namespace DECLARE_LOGGER(logger, "unity.dash.preview.application"); -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(ApplicationPreview); ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model) @@ -80,6 +68,7 @@ ApplicationPreview::ApplicationPreview(dash::Preview::Ptr preview_model) , app_data_layout_(nullptr) , app_updated_copywrite_layout_(nullptr) , app_info_layout_(nullptr) +, app_info_scroll_(nullptr) , actions_layout_(nullptr) { SetupViews(); @@ -172,7 +161,8 @@ void ApplicationPreview::SetupViews() app_icon_->mouse_click.connect(on_mouse_down); icon_layout_->AddView(app_icon_.GetPointer(), 0); - if (app_preview_model->rating >= 0) { + if (app_preview_model->rating >= 0) + { app_rating_ = new PreviewRatingsWidget(); AddChild(app_rating_.GetPointer()); app_rating_->scale = scale(); @@ -264,7 +254,9 @@ void ApplicationPreview::SetupViews() ///////////////////// // Description - nux::ScrollView* app_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* app_info = new ScrollView(NUX_TRACKER_LOCATION); + app_info_scroll_ = app_info; + app_info->scale = scale(); app_info->EnableHorizontalScrollBar(false); app_info->mouse_click.connect(on_mouse_down); @@ -362,10 +354,15 @@ void ApplicationPreview::UpdateScale(double scale) app_icon_->ReLoadIcon(); } + if (app_info_scroll_) + app_info_scroll_->scale = scale; + if (license_) license_->SetScale(scale); + if (last_update_) last_update_->SetScale(scale); + if (copywrite_) copywrite_->SetScale(scale); diff --git a/dash/previews/ApplicationPreview.h b/dash/previews/ApplicationPreview.h index 6472fdd1a..6a6e86bb7 100644 --- a/dash/previews/ApplicationPreview.h +++ b/dash/previews/ApplicationPreview.h @@ -24,6 +24,7 @@ #define APPLICATIONPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -64,6 +65,7 @@ protected: nux::VLayout* app_data_layout_; nux::VLayout* app_updated_copywrite_layout_; nux::VLayout* app_info_layout_; + ScrollView* app_info_scroll_; nux::Layout* actions_layout_; nux::ObjectPtr<IconTexture> app_icon_; diff --git a/dash/previews/ErrorPreview.cpp b/dash/previews/ErrorPreview.cpp index 8fa4a68fe..da0912af5 100644 --- a/dash/previews/ErrorPreview.cpp +++ b/dash/previews/ErrorPreview.cpp @@ -26,7 +26,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/StaticCairoText.h" -#include "unity-shared/PlacesVScrollBar.h" #include <NuxCore/Logger.h> #include <Nux/VLayout.h> #include <Nux/HLayout.h> @@ -62,17 +61,6 @@ const RawPixel INTRO_SPACE = 110_em; const std::string ErrorPreview::CANCEL_ACTION = "cancel"; const std::string ErrorPreview::GO_TO_U1_ACTION = "open_u1_link"; -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(ErrorPreview) ErrorPreview::ErrorPreview(dash::Preview::Ptr preview_model) diff --git a/dash/previews/GenericPreview.cpp b/dash/previews/GenericPreview.cpp index b79b50ff3..6f705515e 100644 --- a/dash/previews/GenericPreview.cpp +++ b/dash/previews/GenericPreview.cpp @@ -23,7 +23,6 @@ #include "unity-shared/IntrospectableWrappers.h" #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include <NuxCore/Logger.h> #include <Nux/HLayout.h> #include <Nux/VLayout.h> @@ -49,23 +48,13 @@ namespace DECLARE_LOGGER(logger, "unity.dash.preview.generic"); -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(GenericPreview); GenericPreview::GenericPreview(dash::Preview::Ptr preview_model) : Preview(preview_model) , image_data_layout_(nullptr) , preview_info_layout_(nullptr) +, preview_info_scroll_(nullptr) , preview_data_layout_(nullptr) , actions_layout_(nullptr) { @@ -85,7 +74,7 @@ void GenericPreview::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) gfx_engine.PushClippingRectangle(base); nux::GetPainter().PaintBackground(gfx_engine, base); - gfx_engine.PopClippingRectangle(); + gfx_engine.PopClippingRectangle(); } void GenericPreview::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw) @@ -169,7 +158,9 @@ void GenericPreview::SetupViews() ///////////////////// // Description - nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION); + preview_info_scroll_ = preview_info; + preview_info->scale = scale(); preview_info->EnableHorizontalScrollBar(false); preview_info->mouse_click.connect(on_mouse_down); @@ -255,6 +246,9 @@ void GenericPreview::UpdateScale(double scale) if (image_) image_->scale = scale; + if (preview_info_scroll_) + preview_info_scroll_->scale = scale; + if (preview_info_hints_) preview_info_hints_->scale = scale; diff --git a/dash/previews/GenericPreview.h b/dash/previews/GenericPreview.h index be81f4ad7..6c5d84694 100644 --- a/dash/previews/GenericPreview.h +++ b/dash/previews/GenericPreview.h @@ -23,8 +23,9 @@ #ifndef GENERICPREVIEW_H #define GENERICPREVIEW_H -#include "Preview.h" #include <UnityCore/GenericPreview.h> +#include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -56,9 +57,9 @@ protected: nux::HLayout* image_data_layout_; nux::VLayout* preview_info_layout_; + ScrollView* preview_info_scroll_; nux::VLayout* preview_data_layout_; nux::Layout* actions_layout_; - }; } diff --git a/dash/previews/MoviePreview.cpp b/dash/previews/MoviePreview.cpp index e32ad29c6..0ff62d26a 100644 --- a/dash/previews/MoviePreview.cpp +++ b/dash/previews/MoviePreview.cpp @@ -23,7 +23,6 @@ #include "unity-shared/IntrospectableWrappers.h" #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include <UnityCore/MoviePreview.h> #include <NuxCore/Logger.h> #include <Nux/HLayout.h> @@ -50,23 +49,13 @@ namespace DECLARE_LOGGER(logger, "unity.dash.preview.movie"); -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(MoviePreview); MoviePreview::MoviePreview(dash::Preview::Ptr preview_model) : Preview(preview_model) , image_data_layout_(nullptr) , preview_info_layout_(nullptr) +, preview_info_scroll_(nullptr) , actions_layout_(nullptr) { SetupViews(); @@ -187,7 +176,9 @@ void MoviePreview::SetupViews() ///////////////////// // Description - nux::ScrollView* preview_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* preview_info = new ScrollView(NUX_TRACKER_LOCATION); + preview_info_scroll_ = preview_info; + preview_info->scale = scale(); preview_info->EnableHorizontalScrollBar(false); preview_info->mouse_click.connect(on_mouse_down); @@ -296,6 +287,9 @@ void MoviePreview::UpdateScale(double scale) rating_->SetMinimumHeight(style.GetRatingWidgetHeight().CP(scale)); } + if (preview_info_scroll_) + preview_info_scroll_->scale = scale; + if (preview_info_layout_) preview_info_layout_->SetSpaceBetweenChildren(PREVIEW_INFO_CHILDREN_SPACE); diff --git a/dash/previews/MoviePreview.h b/dash/previews/MoviePreview.h index 6eba646b6..a0866b6a6 100644 --- a/dash/previews/MoviePreview.h +++ b/dash/previews/MoviePreview.h @@ -24,6 +24,7 @@ #define MOVIEPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -62,6 +63,7 @@ protected: nux::HLayout* image_data_layout_; nux::VLayout* preview_info_layout_; + ScrollView* preview_info_scroll_; nux::Layout* actions_layout_; }; diff --git a/dash/previews/MusicPaymentPreview.cpp b/dash/previews/MusicPaymentPreview.cpp index e2c893a71..f98d7fd3d 100644 --- a/dash/previews/MusicPaymentPreview.cpp +++ b/dash/previews/MusicPaymentPreview.cpp @@ -24,7 +24,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/StaticCairoText.h" -#include "unity-shared/PlacesVScrollBar.h" #include "config.h" #include <glib/gi18n-lib.h> @@ -75,17 +74,6 @@ const std::string MusicPaymentPreview::FORGOT_PASSWORD_ACTION = "forgot_password const std::string MusicPaymentPreview::CANCEL_PURCHASE_ACTION = "cancel_purchase"; const std::string MusicPaymentPreview::PURCHASE_ALBUM_ACTION = "purchase_album"; -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(MusicPaymentPreview) MusicPaymentPreview::MusicPaymentPreview(dash::Preview::Ptr preview_model) diff --git a/dash/previews/MusicPreview.h b/dash/previews/MusicPreview.h index f3d2776ca..fda986e21 100644 --- a/dash/previews/MusicPreview.h +++ b/dash/previews/MusicPreview.h @@ -24,6 +24,7 @@ #define MUSICPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" #include "unity-shared/IconTexture.h" namespace unity diff --git a/dash/previews/Preview.cpp b/dash/previews/Preview.cpp index d5010eaeb..d6328aa1e 100644 --- a/dash/previews/Preview.cpp +++ b/dash/previews/Preview.cpp @@ -313,6 +313,6 @@ void Preview::UpdateScale(double scale) QueueDraw(); } -} -} -} +} // preview +} // dash +} // unity diff --git a/dash/previews/SocialPreview.cpp b/dash/previews/SocialPreview.cpp index dfb7386fe..e70ba6981 100644 --- a/dash/previews/SocialPreview.cpp +++ b/dash/previews/SocialPreview.cpp @@ -24,7 +24,6 @@ #include "unity-shared/PreviewStyle.h" #include "unity-shared/CoverArt.h" #include "unity-shared/IconTexture.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include <UnityCore/SocialPreview.h> #include <NuxCore/Logger.h> #include <Nux/HLayout.h> @@ -56,17 +55,6 @@ namespace const RawPixel SOCIAL_INFO_CHILDREN_SPACE = 12_em; } -class DetailsScrollView : public nux::ScrollView -{ -public: - DetailsScrollView(NUX_FILE_LINE_PROTO) - : ScrollView(NUX_FILE_LINE_PARAM) - { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); - } - -}; - NUX_IMPLEMENT_OBJECT_TYPE(SocialPreview); SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) @@ -77,6 +65,7 @@ SocialPreview::SocialPreview(dash::Preview::Ptr preview_model) , social_content_layout_(nullptr) , social_data_layout_(nullptr) , social_info_layout_(nullptr) +, social_info_scroll_(nullptr) , icon_layout_(nullptr) , actions_layout_(nullptr) { @@ -215,7 +204,9 @@ void SocialPreview::SetupViews() ///////////////////// // Details - nux::ScrollView* social_info = new DetailsScrollView(NUX_TRACKER_LOCATION); + auto* social_info = new ScrollView(NUX_TRACKER_LOCATION); + social_info_scroll_ = social_info; + social_info->scale = scale(); social_info->EnableHorizontalScrollBar(false); social_info->mouse_click.connect(on_mouse_down); @@ -345,6 +336,9 @@ void SocialPreview::UpdateScale(double scale) if (social_info_layout_) social_info_layout_->SetSpaceBetweenChildren(SOCIAL_INFO_CHILDREN_SPACE.CP(scale)); + if (social_info_scroll_) + social_info_scroll_->scale = scale; + if (actions_layout_) actions_layout_->SetLeftAndRightPadding(0, style.GetDetailsRightMargin().CP(scale)); diff --git a/dash/previews/SocialPreview.h b/dash/previews/SocialPreview.h index 00b1d41ea..72b4c2e43 100644 --- a/dash/previews/SocialPreview.h +++ b/dash/previews/SocialPreview.h @@ -24,6 +24,7 @@ #define SOCIALPREVIEW_H #include "Preview.h" +#include "unity-shared/OverlayScrollView.h" namespace unity { @@ -68,6 +69,7 @@ protected: nux::VLayout* social_content_layout_; nux::VLayout* social_data_layout_; nux::VLayout* social_info_layout_; + ScrollView* social_info_scroll_; nux::VLayout* icon_layout_; nux::Layout* actions_layout_; diff --git a/dash/previews/Tracks.cpp b/dash/previews/Tracks.cpp index d78b7c6c7..3e973961e 100644 --- a/dash/previews/Tracks.cpp +++ b/dash/previews/Tracks.cpp @@ -24,7 +24,6 @@ #include <NuxCore/Logger.h> #include <Nux/VLayout.h> #include "unity-shared/IntrospectableWrappers.h" -#include "unity-shared/PlacesOverlayVScrollBar.h" #include "unity-shared/PreviewStyle.h" #include <UnityCore/Track.h> @@ -45,7 +44,6 @@ NUX_IMPLEMENT_OBJECT_TYPE(Tracks); Tracks::Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_DECL) : ScrollView(NUX_FILE_LINE_PARAM) - , scale(1.0) , tracks_(tracks) { SetupViews(); @@ -60,6 +58,7 @@ Tracks::Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_DECL) for (std::size_t i = 0; i < tracks_->count.Get(); ++i) OnTrackAdded(tracks_->RowAtIndex(i)); } + UpdateScale(scale); scale.changed.connect(sigc::mem_fun(this, &Tracks::UpdateScale)); } @@ -77,7 +76,6 @@ void Tracks::AddProperties(debug::IntrospectionData& introspection) void Tracks::SetupViews() { - SetVScrollBar(new dash::PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION)); EnableHorizontalScrollBar(false); layout_ = new nux::VLayout(); layout_->SetPadding(0, previews::Style::Instance().GetDetailsRightMargin().CP(scale), 0, 0); diff --git a/dash/previews/Tracks.h b/dash/previews/Tracks.h index 220c50e2a..0cc7acfc2 100644 --- a/dash/previews/Tracks.h +++ b/dash/previews/Tracks.h @@ -27,6 +27,7 @@ #include <Nux/ScrollView.h> #include <UnityCore/Tracks.h> #include <UnityCore/ConnectionManager.h> +#include "unity-shared/OverlayScrollView.h" #include "unity-shared/Introspectable.h" #include "Track.h" @@ -44,7 +45,7 @@ class Track; namespace previews { -class Tracks : public debug::Introspectable, public nux::ScrollView +class Tracks : public debug::Introspectable, public dash::ScrollView { public: typedef nux::ObjectPtr<Tracks> Ptr; @@ -52,8 +53,6 @@ public: Tracks(dash::Tracks::Ptr tracks, NUX_FILE_LINE_PROTO); - nux::Property<double> scale; - protected: virtual bool AcceptKeyNavFocus() { return false; } |
