diff options
70 files changed, 455 insertions, 397 deletions
diff --git a/UnityCore/CheckOptionFilter.cpp b/UnityCore/CheckOptionFilter.cpp index f3ea6333f..ef1c50bf2 100644 --- a/UnityCore/CheckOptionFilter.cpp +++ b/UnityCore/CheckOptionFilter.cpp @@ -19,13 +19,10 @@ #include "CheckOptionFilter.h" -#include <NuxCore/Logger.h> - namespace unity { namespace dash { -DECLARE_LOGGER(logger, "unity.dash.filter.checkoption"); CheckOptionFilter::CheckOptionFilter(DeeModel* model, DeeModelIter* iter) : Filter(model, iter) diff --git a/UnityCore/Filter.cpp b/UnityCore/Filter.cpp index 6e182653d..c34909787 100644 --- a/UnityCore/Filter.cpp +++ b/UnityCore/Filter.cpp @@ -20,8 +20,6 @@ #include "Filter.h" #include "Filters.h" -#include <NuxCore/Logger.h> - #include "CheckOptionFilter.h" #include "MultiRangeFilter.h" #include "RadioOptionFilter.h" @@ -32,7 +30,6 @@ namespace unity { namespace dash { -DECLARE_LOGGER(logger, "unity.dash.filter"); using unity::glib::Signal; diff --git a/UnityCore/MultiRangeFilter.cpp b/UnityCore/MultiRangeFilter.cpp index e7f1e6637..2919fb8a9 100644 --- a/UnityCore/MultiRangeFilter.cpp +++ b/UnityCore/MultiRangeFilter.cpp @@ -19,13 +19,10 @@ #include "MultiRangeFilter.h" -#include <NuxCore/Logger.h> - namespace unity { namespace dash { -DECLARE_LOGGER(logger, "unity.dash.filter.multirange"); MultiRangeFilter::MultiRangeFilter(DeeModel* model, DeeModelIter* iter) : Filter(model, iter) diff --git a/UnityCore/MusicPreview.cpp b/UnityCore/MusicPreview.cpp index 1ff05f4f4..f81c5a417 100644 --- a/UnityCore/MusicPreview.cpp +++ b/UnityCore/MusicPreview.cpp @@ -29,7 +29,6 @@ namespace unity { namespace dash { -DECLARE_LOGGER(logger, "unity.dash.musicpreview"); class MusicPreview::Impl { diff --git a/UnityCore/RadioOptionFilter.cpp b/UnityCore/RadioOptionFilter.cpp index f65dd8c6b..ba664154a 100644 --- a/UnityCore/RadioOptionFilter.cpp +++ b/UnityCore/RadioOptionFilter.cpp @@ -19,13 +19,10 @@ #include "RadioOptionFilter.h" -#include <NuxCore/Logger.h> - namespace unity { namespace dash { -DECLARE_LOGGER(logger, "unity.dash.filter.radiooption"); RadioOptionFilter::RadioOptionFilter(DeeModel* model, DeeModelIter* iter) : Filter(model, iter) diff --git a/UnityCore/Scope.cpp b/UnityCore/Scope.cpp index 35937490c..498722413 100644 --- a/UnityCore/Scope.cpp +++ b/UnityCore/Scope.cpp @@ -32,6 +32,12 @@ namespace dash { DECLARE_LOGGER(logger, "unity.dash.scope"); +GQuark +g_scope_error_quark (void) +{ + return g_quark_from_static_string ("g-scope-error-quark"); +} + class Scope::Impl { public: diff --git a/UnityCore/Scope.h b/UnityCore/Scope.h index 9622f30c5..7c06c285b 100644 --- a/UnityCore/Scope.h +++ b/UnityCore/Scope.h @@ -31,9 +31,8 @@ namespace unity namespace dash { -namespace -{ #define G_SCOPE_ERROR g_scope_error_quark () + typedef enum { G_SCOPE_ERROR_NO_ACTIVATION_HANDLER = (1 << 0), @@ -41,11 +40,7 @@ typedef enum } GScopeError; GQuark -g_scope_error_quark (void) -{ - return g_quark_from_static_string ("g-scope-error-quark"); -} -} +g_scope_error_quark (void); class Scope : public sigc::trackable, boost::noncopyable { diff --git a/dash/ScopeBar.cpp b/dash/ScopeBar.cpp index a595c7460..f7ed43189 100644 --- a/dash/ScopeBar.cpp +++ b/dash/ScopeBar.cpp @@ -18,7 +18,6 @@ #include <glib/gstdio.h> #include "ScopeBar.h" -#include <NuxCore/Logger.h> #include "config.h" #include <Nux/HLayout.h> #include <Nux/LayeredLayout.h> @@ -33,7 +32,6 @@ namespace unity { namespace dash { -DECLARE_LOGGER(logger, "unity.dash.scopebar"); namespace { // according to Q design the inner area of the scopebar should be 40px 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/ActionButton.cpp b/dash/previews/ActionButton.cpp index 607f9b81b..981c625bb 100644 --- a/dash/previews/ActionButton.cpp +++ b/dash/previews/ActionButton.cpp @@ -21,7 +21,6 @@ #include "unity-shared/DashStyle.h" #include "ActionButton.h" -#include <NuxCore/Logger.h> #include <Nux/HLayout.h> #include "unity-shared/IconTexture.h" #include "unity-shared/StaticCairoText.h" @@ -38,7 +37,6 @@ const RawPixel icon_size = 24_em; namespace dash { -DECLARE_LOGGER(logger, "unity.dash.preview.action"); ActionButton::ActionButton(std::string const& action_hint, std::string const& label, std::string const& icon_hint, NUX_FILE_LINE_DECL) : nux::AbstractButton(NUX_FILE_LINE_PARAM) 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/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp index 066079711..63f6e55c1 100644 --- a/dash/previews/PreviewContainer.cpp +++ b/dash/previews/PreviewContainer.cpp @@ -21,7 +21,6 @@ */ #include "PreviewContainer.h" -#include <NuxCore/Logger.h> #include <Nux/HLayout.h> #include "unity-shared/IntrospectableWrappers.h" @@ -39,7 +38,6 @@ namespace dash { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.container"); Navigation operator&(const Navigation lhs, const Navigation rhs) { diff --git a/dash/previews/PreviewInfoHintWidget.cpp b/dash/previews/PreviewInfoHintWidget.cpp index b7f51aeb1..e3ab81d53 100644 --- a/dash/previews/PreviewInfoHintWidget.cpp +++ b/dash/previews/PreviewInfoHintWidget.cpp @@ -26,7 +26,6 @@ #include "PreviewInfoHintWidget.h" #include "unity-shared/IntrospectableWrappers.h" -#include <NuxCore/Logger.h> #include <Nux/HLayout.h> #include <Nux/VLayout.h> #include <unity-shared/StaticCairoText.h> @@ -39,7 +38,6 @@ namespace dash { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.infohintwidget"); namespace { const RawPixel LAYOUT_SPACING = 12_em; diff --git a/dash/previews/PreviewNavigator.cpp b/dash/previews/PreviewNavigator.cpp index 9f4479d24..2b4fe7eb0 100644 --- a/dash/previews/PreviewNavigator.cpp +++ b/dash/previews/PreviewNavigator.cpp @@ -22,7 +22,6 @@ #include "PreviewNavigator.h" -#include <NuxCore/Logger.h> #include <Nux/HLayout.h> #include <Nux/VLayout.h> #include <unity-shared/IconTexture.h> @@ -34,7 +33,6 @@ namespace dash { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.navigator"); NUX_IMPLEMENT_OBJECT_TYPE(PreviewNavigator); 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/SocialPreviewComments.cpp b/dash/previews/SocialPreviewComments.cpp index 688964893..df6839756 100644 --- a/dash/previews/SocialPreviewComments.cpp +++ b/dash/previews/SocialPreviewComments.cpp @@ -23,7 +23,6 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/PreviewStyle.h" #include <UnityCore/SocialPreview.h> -#include <NuxCore/Logger.h> #include <Nux/Layout.h> #include <Nux/VLayout.h> #include <Nux/HLayout.h> @@ -36,7 +35,6 @@ namespace dash { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.social.comments"); namespace { diff --git a/dash/previews/SocialPreviewContent.cpp b/dash/previews/SocialPreviewContent.cpp index 5183aac30..fecb12d35 100644 --- a/dash/previews/SocialPreviewContent.cpp +++ b/dash/previews/SocialPreviewContent.cpp @@ -23,7 +23,6 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/PreviewStyle.h" -#include <NuxCore/Logger.h> #include <Nux/Layout.h> #include "SocialPreviewContent.h" @@ -34,7 +33,6 @@ namespace dash { namespace previews { -DECLARE_LOGGER(logger, "unity.dash.previews.social.content"); namespace { diff --git a/dash/previews/Track.cpp b/dash/previews/Track.cpp index 7edf4e2a6..42b5fdad0 100644 --- a/dash/previews/Track.cpp +++ b/dash/previews/Track.cpp @@ -22,7 +22,6 @@ #include "Track.h" #include "unity-shared/IntrospectableWrappers.h" -#include <NuxCore/Logger.h> #include <Nux/HLayout.h> #include <Nux/LayeredLayout.h> #include <unity-shared/StaticCairoText.h> @@ -37,7 +36,6 @@ namespace dash namespace previews { -DECLARE_LOGGER(logger, "unity.dash.preview.music.track"); namespace { const RawPixel LAYOUT_SPACING = 6_em; 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; } diff --git a/debian/changelog b/debian/changelog index 741604e3e..d44d7ce3f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,43 @@ +unity (7.3.0+14.10.20140731.1-0ubuntu1) utopic; urgency=low + + [ Ubuntu daily release ] + * New rebuild forced + + [ Brandon Schaefer ] + * Fixes FTBFS caused by gcc 4.9. Mostly unused functions. (LP: + #1350052) + + [ Andrea Azzarone ] + * == Problem == Lockscreen capslock detection doesn't work well with + remapped capslocks == Fix == Use gdk keymap to get the state of the + caps lock. (LP: #1347735) + + [ Marco Trevisan (Treviño) ] + * 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. (LP: #1340996) + * LockScreenShield: Add GrabScreen function and retry to make sure we + really get grab It might happen that the grab is not possible + because the PluginAdapter::IsScreenGrabbed request has still not + being fully processed, and thus nux is not able to grab the + pointer/keyboard. By doing this we instead try to grab the screen, + and if this is not happening, we wait a little until we don't get + the ungrab event. In this way, if we eventually get the grab, all + will work as expected. Otherwise, we cancel the lock request (very + unlikely to happen). (LP: #1349128) + * PlacesOverlayVScrollBar: redirect the mouse wheel scroll events + coming from the thumb to the scrollview This will make the + scrollview to handle then and perform the same scrolling action it + would do otherwise. (LP: #1340992) + * This has a "soft" dependency on lp:~3v1n0/nux/horizontal-scroll- + delta/+merge/227070, this means that this code would just work as it + used to do (except for the SwitcerView fix) if that nux branch is + not used, while it will support correctly horizontal scroll events + when both the branches are used. (LP: #1342208) + + -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 31 Jul 2014 18:40:00 +0000 + unity (7.3.0+14.10.20140711-0ubuntu1) utopic; urgency=low [ Eleni Maria Stea ] diff --git a/decorations/DecoratedWindow.cpp b/decorations/DecoratedWindow.cpp index d07d6282e..32be3488b 100644 --- a/decorations/DecoratedWindow.cpp +++ b/decorations/DecoratedWindow.cpp @@ -17,7 +17,6 @@ * Authored by: Marco Trevisan <marco.trevisan@canonical.com> */ -#include <NuxCore/Logger.h> #include "DecorationsPriv.h" #include "DecorationsForceQuitDialog.h" #include "DecorationsEdgeBorders.h" @@ -35,7 +34,6 @@ namespace decoration { namespace { -DECLARE_LOGGER(logger, "unity.decoration.window"); const std::string MENUS_PANEL_NAME = "WindowLIM"; } diff --git a/decorations/DecorationsInputMixer.cpp b/decorations/DecorationsInputMixer.cpp index bdc122a4a..d3162f7e0 100644 --- a/decorations/DecorationsInputMixer.cpp +++ b/decorations/DecorationsInputMixer.cpp @@ -17,17 +17,12 @@ * Authored by: Marco Trevisan <marco.trevisan@canonical.com> */ -#include <NuxCore/Logger.h> #include "DecorationsInputMixer.h" namespace unity { namespace decoration { -namespace -{ -DECLARE_LOGGER(logger, "unity.decorations.inputmixer"); -} InputMixer::InputMixer() : mouse_down_(false) diff --git a/decorations/DecorationsManager.cpp b/decorations/DecorationsManager.cpp index 58174ffb9..88648e7db 100644 --- a/decorations/DecorationsManager.cpp +++ b/decorations/DecorationsManager.cpp @@ -20,7 +20,6 @@ #include "DecorationsPriv.h" #include <core/atoms.h> -#include <NuxCore/Logger.h> #include <NuxGraphics/CairoGraphics.h> #include <UnityCore/DBusIndicators.h> #include <X11/Xatom.h> @@ -34,8 +33,6 @@ Manager* manager_ = nullptr; namespace { -DECLARE_LOGGER(logger, "unity.decoration.manager"); - namespace atom { Atom _NET_REQUEST_FRAME_EXTENTS = 0; diff --git a/hud/HudButton.cpp b/hud/HudButton.cpp index 3ab96ac53..65aafaa45 100644 --- a/hud/HudButton.cpp +++ b/hud/HudButton.cpp @@ -27,7 +27,6 @@ #include <Nux/Nux.h> #include <Nux/HLayout.h> -#include <NuxCore/Logger.h> #include <NuxGraphics/CairoGraphics.h> #include <NuxGraphics/NuxGraphics.h> #include <UnityCore/GLibWrapper.h> @@ -45,7 +44,6 @@ namespace hud namespace { -DECLARE_LOGGER(logger, "unity.hud.button"); const RawPixel HLAYOUT_LEFT_PADDING = 46_em; const RawPixel HEIGHT = 42_em; const char* const button_font = "Ubuntu 13"; // 17px = 13 diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index 21aa4088e..2420f4dc7 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -2200,7 +2200,7 @@ void Launcher::RecvMouseWheel(int /*x*/, int /*y*/, int wheel_delta, unsigned lo return; bool alt_pressed = nux::GetKeyModifierState(key_flags, nux::NUX_STATE_ALT); - if (alt_pressed) + if (alt_pressed && abs(wheel_delta) != NUX_MOUSEWHEEL_DELTA) { ScrollLauncher(wheel_delta); } diff --git a/launcher/LauncherHideMachine.cpp b/launcher/LauncherHideMachine.cpp index f348778de..035dea90d 100644 --- a/launcher/LauncherHideMachine.cpp +++ b/launcher/LauncherHideMachine.cpp @@ -19,14 +19,10 @@ #include "LauncherHideMachine.h" -#include <NuxCore/Logger.h> - namespace unity { namespace launcher { -DECLARE_LOGGER(logger, "unity.launcher.hide"); - namespace { const unsigned int HIDE_DELAY_TIMEOUT_LENGTH = 400; diff --git a/launcher/SimpleLauncherIcon.cpp b/launcher/SimpleLauncherIcon.cpp index 2fe5b29d8..e0c509f25 100644 --- a/launcher/SimpleLauncherIcon.cpp +++ b/launcher/SimpleLauncherIcon.cpp @@ -22,8 +22,6 @@ #include "SimpleLauncherIcon.h" -#include <NuxCore/Logger.h> - #include "unity-shared/UBusWrapper.h" #include "unity-shared/UBusMessages.h" @@ -31,8 +29,6 @@ namespace unity { namespace launcher { -DECLARE_LOGGER(logger, "unity.launcher.icon"); - NUX_IMPLEMENT_OBJECT_TYPE(SimpleLauncherIcon); SimpleLauncherIcon::SimpleLauncherIcon(IconType type) diff --git a/launcher/SwitcherView.cpp b/launcher/SwitcherView.cpp index befcc4678..48a660238 100644 --- a/launcher/SwitcherView.cpp +++ b/launcher/SwitcherView.cpp @@ -49,6 +49,7 @@ namespace unsigned int const ANIMATION_LENGTH = 250; unsigned int const MAX_DIRECTIONS_CHANGED = 3; + unsigned int const SCROLL_WHEEL_EVENTS_DISTANCE = 75; double const TEXT_TILE_MULTIPLIER = 3.5; } @@ -69,6 +70,7 @@ SwitcherView::SwitcherView(ui::AbstractIconRenderer::Ptr const& renderer) , animation_(animation_length) , last_icon_selected_(-1) , last_detail_icon_selected_(-1) + , last_mouse_scroll_time_(0) , check_mouse_first_time_(true) { icon_renderer_->pip_style = OVER_TILE; @@ -437,6 +439,13 @@ void SwitcherView::HandleMouseUp(int x, int y, int button) void SwitcherView::RecvMouseWheel(int /*x*/, int /*y*/, int wheel_delta, unsigned long /*button_flags*/, unsigned long /*key_flags*/) { + auto timestamp = nux::GetGraphicsDisplay()->GetCurrentEvent().x11_timestamp; + + if (timestamp - last_mouse_scroll_time_ <= SCROLL_WHEEL_EVENTS_DISTANCE) + return; + + last_mouse_scroll_time_ = timestamp; + if (model_->detail_selection) { HandleDetailMouseWheel(wheel_delta); @@ -449,7 +458,7 @@ void SwitcherView::RecvMouseWheel(int /*x*/, int /*y*/, int wheel_delta, unsigne void SwitcherView::HandleDetailMouseWheel(int wheel_delta) { - if (wheel_delta > 0) + if (wheel_delta < 0) { model_->NextDetail(); } @@ -461,7 +470,7 @@ void SwitcherView::HandleDetailMouseWheel(int wheel_delta) void SwitcherView::HandleMouseWheel(int wheel_delta) { - if (wheel_delta > 0) + if (wheel_delta < 0) { model_->Next(); } diff --git a/launcher/SwitcherView.h b/launcher/SwitcherView.h index 392aac293..2dd595a11 100644 --- a/launcher/SwitcherView.h +++ b/launcher/SwitcherView.h @@ -157,6 +157,7 @@ private: int last_icon_selected_; int last_detail_icon_selected_; + uint64_t last_mouse_scroll_time_; bool check_mouse_first_time_; DeltaTracker delta_tracker_; diff --git a/launcher/VolumeLauncherIcon.cpp b/launcher/VolumeLauncherIcon.cpp index 0cec6afeb..e6cbe1cc7 100644 --- a/launcher/VolumeLauncherIcon.cpp +++ b/launcher/VolumeLauncherIcon.cpp @@ -21,7 +21,6 @@ #include "config.h" #include <glib/gi18n-lib.h> -#include <NuxCore/Logger.h> #include <UnityCore/ConnectionManager.h> #include <UnityCore/GLibSignal.h> @@ -32,7 +31,6 @@ namespace unity { namespace launcher { -DECLARE_LOGGER(logger, "unity.launcher.icon.volume"); // // Start private implementation diff --git a/lockscreen/LockScreenController.cpp b/lockscreen/LockScreenController.cpp index 3054afc2f..a4cd5714a 100644 --- a/lockscreen/LockScreenController.cpp +++ b/lockscreen/LockScreenController.cpp @@ -45,9 +45,9 @@ public: bool AcceptKeyNavFocus() override { return true; } bool InspectKeyEvent(unsigned int, unsigned int, const char*) override { return true; }; }; -} DECLARE_LOGGER(logger, "unity.lockscreen"); +} Controller::Controller(DBusManager::Ptr const& dbus_manager, session::Manager::Ptr const& session_manager, diff --git a/lockscreen/LockScreenShield.cpp b/lockscreen/LockScreenShield.cpp index 50dd1e42e..4a2cfdd11 100644 --- a/lockscreen/LockScreenShield.cpp +++ b/lockscreen/LockScreenShield.cpp @@ -19,6 +19,7 @@ #include "LockScreenShield.h" +#include <NuxCore/Logger.h> #include <Nux/VLayout.h> #include <Nux/HLayout.h> #include <Nux/PaintLayer.h> @@ -35,6 +36,11 @@ namespace unity { namespace lockscreen { +namespace +{ +DECLARE_LOGGER(logger, "unity.lockscreen.shield"); +const unsigned MAX_GRAB_WAIT = 50; +} Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicators::Ptr const& indicators, Accelerators::Ptr const& accelerators, int monitor_num, bool is_primary) : AbstractShield(session_manager, indicators, accelerators, monitor_num, is_primary) @@ -56,12 +62,7 @@ Shield::Shield(session::Manager::Ptr const& session_manager, indicator::Indicato }); primary.changed.connect([this] (bool is_primary) { - if (!is_primary) - { - UnGrabPointer(); - UnGrabKeyboard(); - } - + regrab_conn_->disconnect(); is_primary ? ShowPrimaryView() : ShowSecondaryView(); if (panel_view_) panel_view_->SetInputEventSensitivity(is_primary); QueueRelayout(); @@ -86,17 +87,41 @@ void Shield::UpdateBackgroundTexture() } } -void Shield::ShowPrimaryView() +void Shield::GrabScreen(bool cancel_on_failure) { - GrabPointer(); - GrabKeyboard(); + auto& wc = nux::GetWindowCompositor(); + if (wc.GrabPointerAdd(this) && wc.GrabKeyboardAdd(this)) + { + regrab_conn_->disconnect(); + regrab_timeout_.reset(); + } + else + { + auto const& retry_cb = sigc::bind(sigc::mem_fun(this, &Shield::GrabScreen), false); + regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect(retry_cb); + + if (cancel_on_failure) + { + regrab_timeout_.reset(new glib::Timeout(MAX_GRAB_WAIT, [this] { + LOG_ERROR(logger) << "Impossible to get the grab to lock the screen"; + session_manager_->unlock_requested.emit(); + return false; + })); + } + } +} + +void Shield::ShowPrimaryView() +{ if (primary_layout_) { + GrabScreen(false); SetLayout(primary_layout_.GetPointer()); return; } + GrabScreen(true); nux::Layout* main_layout = new nux::VLayout(); primary_layout_ = main_layout; SetLayout(primary_layout_.GetPointer()); @@ -149,19 +174,7 @@ Panel* Shield::CreatePanel() } else { - auto& wc = nux::GetWindowCompositor(); - - if (!wc.GrabPointerAdd(this) || !wc.GrabKeyboardAdd(this)) - { - regrab_conn_ = WindowManager::Default().screen_ungrabbed.connect([this] { - if (primary()) - { - GrabPointer(); - GrabKeyboard(); - } - regrab_conn_->disconnect(); - }); - } + GrabScreen(false); } } }); diff --git a/lockscreen/LockScreenShield.h b/lockscreen/LockScreenShield.h index 25846334d..6a020d1cb 100644 --- a/lockscreen/LockScreenShield.h +++ b/lockscreen/LockScreenShield.h @@ -21,6 +21,7 @@ #define UNITY_LOCKSCREEN_SHIELD_H #include <UnityCore/ConnectionManager.h> +#include <UnityCore/GLibSource.h> #include "LockScreenAbstractShield.h" namespace unity @@ -48,6 +49,7 @@ protected: private: void UpdateBackgroundTexture(); + void GrabScreen(bool cancel_on_failure); void ShowPrimaryView(); void ShowSecondaryView(); Panel* CreatePanel(); @@ -59,6 +61,7 @@ private: nux::ObjectPtr<nux::Layout> cof_layout_; connection::Wrapper panel_active_conn_; connection::Wrapper regrab_conn_; + glib::Source::UniquePtr regrab_timeout_; UserPromptView* prompt_view_; Panel* panel_view_; }; diff --git a/panel/PanelController.cpp b/panel/PanelController.cpp index e9c1cefa1..2df5ba7bc 100644 --- a/panel/PanelController.cpp +++ b/panel/PanelController.cpp @@ -21,7 +21,6 @@ #include "PanelController.h" #include <vector> -#include <NuxCore/Logger.h> #include <Nux/BaseWindow.h> #include "unity-shared/UScreen.h" @@ -31,7 +30,6 @@ namespace unity { namespace panel { -DECLARE_LOGGER(logger, "unity.panel.controller"); const char* window_title = "unity-panel"; diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp index 4debdd8d3..fd6c45ad2 100644 --- a/panel/PanelView.cpp +++ b/panel/PanelView.cpp @@ -21,7 +21,6 @@ #include <Nux/Nux.h> #include <Nux/HLayout.h> -#include <NuxCore/Logger.h> #include <UnityCore/GLibWrapper.h> #include "unity-shared/PanelStyle.h" @@ -34,8 +33,6 @@ #include "PanelView.h" -DECLARE_LOGGER(logger, "unity.panel.view"); - namespace { const int refine_gradient_midpoint = 959; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 7f7b44e03..16ca2e17c 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -109,8 +109,11 @@ void capture_g_log_calls(const gchar* log_domain, GLogLevelFlags log_level, const gchar* message, gpointer user_data); + +#ifndef USE_GLES gboolean is_extension_supported(const gchar* extensions, const gchar* extension); gfloat get_opengl_version_f32(const gchar* version_string); +#endif inline CompRegion CompRegionFromNuxGeo(nux::Geometry const& geo) { @@ -3821,7 +3824,7 @@ void UnityScreen::OnScreenLocked() // We notify that super/alt have been released, to avoid to leave unity in inconsistent state CompOption::Vector options(8); options[7].setName("time", CompOption::TypeInt); - options[7].value().set((int) screen->getCurrentTime()); + options[7].value().set<int>(screen->getCurrentTime()); showLauncherKeyTerminate(&optionGetShowLauncher(), CompAction::StateTermKey, options); showMenuBarTerminate(&optionGetShowMenuBar(), CompAction::StateTermKey, options); @@ -4597,6 +4600,8 @@ void configure_logging() /* Checks whether an extension is supported by the GLX or OpenGL implementation * given the extension name and the list of supported extensions. */ + +#ifndef USE_GLES gboolean is_extension_supported(const gchar* extensions, const gchar* extension) { if (extensions != NULL && extension != NULL) @@ -4635,6 +4640,7 @@ gfloat get_opengl_version_f32(const gchar* version_string) else return 0.0f; } +#endif nux::logging::Level glog_level_to_nux(GLogLevelFlags log_level) { diff --git a/services/panel-service.c b/services/panel-service.c index a161cacbd..f25e9bc42 100644 --- a/services/panel-service.c +++ b/services/panel-service.c @@ -46,6 +46,9 @@ G_DEFINE_TYPE (PanelService, panel_service, G_TYPE_OBJECT); #define N_TIMEOUT_SLOTS 50 #define MAX_INDICATOR_ENTRIES 100 +#define NUX_VERTICAL_SCROLL_DELTA 120 +#define NUX_HORIZONTAL_SCROLL_DELTA (NUX_VERTICAL_SCROLL_DELTA ^ 2) + #define COMPIZ_OPTION_SCHEMA "org.compiz.unityshell" #define COMPIZ_OPTION_PATH "/org/compiz/profiles/unity/plugins/" #define MENU_TOGGLE_KEYBINDING_KEY "panel-first-menu" @@ -2399,9 +2402,28 @@ panel_service_scroll_entry (PanelService *self, entry = get_indicator_entry_by_id (self, entry_id); g_return_if_fail (entry); - GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP; + GdkScrollDirection direction = G_MAXINT; - object = get_entry_parent_indicator (entry); - g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry, - abs(delta/120), direction); + switch (delta) + { + case NUX_VERTICAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_UP; + break; + case -NUX_VERTICAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_DOWN; + break; + case NUX_HORIZONTAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_LEFT; + break; + case -NUX_HORIZONTAL_SCROLL_DELTA: + direction = INDICATOR_OBJECT_SCROLL_RIGHT; + break; + } + + if (direction != G_MAXINT) + { + object = get_entry_parent_indicator (entry); + g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, + entry, 1, direction); + } } diff --git a/tests/test_glib_object.cpp b/tests/test_glib_object.cpp index 4a1c4f22d..a731689b4 100644 --- a/tests/test_glib_object.cpp +++ b/tests/test_glib_object.cpp @@ -44,11 +44,6 @@ bool IsGOBject(TestObjectWrapper const& g_obj) return IsGOBject(g_obj.RawPtr()); } -bool IsNotGOBject(TestGObject* t_obj) -{ - return !IsGOBject(t_obj); -} - bool IsNotGOBject(TestObjectWrapper const& g_obj) { return !IsGOBject(g_obj); diff --git a/tests/test_icon_loader.cpp b/tests/test_icon_loader.cpp index e50e8996a..c817832aa 100644 --- a/tests/test_icon_loader.cpp +++ b/tests/test_icon_loader.cpp @@ -35,15 +35,6 @@ bool IsValidPixbuf(GdkPixbuf *pixbuf) return GDK_IS_PIXBUF (pixbuf); } -gboolean TimeoutReached (gpointer data) -{ - bool *b = static_cast<bool*>(data); - - *b = true; - - return FALSE; -} - struct LoadResult { glib::Object<GdkPixbuf> pixbuf; diff --git a/tests/test_result_renderer.cpp b/tests/test_result_renderer.cpp index 64d5bcd05..7a99d6c6c 100644 --- a/tests/test_result_renderer.cpp +++ b/tests/test_result_renderer.cpp @@ -41,29 +41,6 @@ namespace #define DEFAULT_GICON ". GThemedIcon cmake" -GdkPixbuf* GetIconData(std::string icon_hint, int size) -{ - GdkPixbuf *pbuf; - GtkIconTheme *theme; - glib::Error error; - - theme = gtk_icon_theme_get_default(); - glib::Object<GIcon> icon(g_icon_new_for_string(icon_hint.c_str(), NULL)); - - if (icon.IsType(G_TYPE_ICON)) - { - gtk::IconInfo info(gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0)); - pbuf = gtk_icon_info_load_icon(info, &error); - - if (error) - { - pbuf = NULL; - } - } - - return pbuf; -} - } // namespace [anonymous] class TestResultRenderer : public testing::Test diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index b56c77990..ed39e5809 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -44,6 +44,7 @@ set (UNITY_SHARED_SOURCES LineSeparator.cpp MenuManager.cpp OverlayRenderer.cpp + OverlayScrollView.cpp OverlayWindowButtons.cpp PanelStyle.cpp PlacesVScrollBar.cpp diff --git a/unity-shared/OverlayScrollView.cpp b/unity-shared/OverlayScrollView.cpp new file mode 100644 index 000000000..c8cc72280 --- /dev/null +++ b/unity-shared/OverlayScrollView.cpp @@ -0,0 +1,56 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2014 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> + */ + +#include "OverlayScrollView.h" +#include "PlacesOverlayVScrollBar.h" +#include "RawPixel.h" + +namespace unity +{ +namespace dash +{ +namespace +{ + const RawPixel MOUSE_WHEEL_SCROLL_SIZE = 32_em; +} + +ScrollView::ScrollView(NUX_FILE_LINE_DECL) + : nux::ScrollView(NUX_FILE_LINE_PARAM) +{ + auto* scrollbar = new PlacesOverlayVScrollBar(NUX_TRACKER_LOCATION); + SetVScrollBar(scrollbar); + + scale.SetGetterFunction([scrollbar] { return scrollbar->scale(); }); + scale.SetSetterFunction([scrollbar] (double scale) { + if (scrollbar->scale() == scale) + return false; + + scrollbar->scale = scale; + return true; + }); + + m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale); + + scale.changed.connect([this] (double scale) { + m_MouseWheelScrollSize = MOUSE_WHEEL_SCROLL_SIZE.CP(scale); + }); +} + +} // dash namespace +} // unity namespace \ No newline at end of file diff --git a/unity-shared/OverlayScrollView.h b/unity-shared/OverlayScrollView.h new file mode 100644 index 000000000..1cabd05a8 --- /dev/null +++ b/unity-shared/OverlayScrollView.h @@ -0,0 +1,43 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2014 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Marco Trevisan <marco.trevisan@canonical.com> + */ + +#ifndef _UNITY_SCROLL_VIEW_H_ +#define _UNITY_SCROLL_VIEW_H_ + +#include <Nux/Nux.h> + +namespace unity +{ +namespace dash +{ + +class ScrollView : public nux::ScrollView +{ +public: + ScrollView(NUX_FILE_LINE_PROTO); + + nux::RWProperty<double> scale; + + using nux::ScrollView::SetVScrollBar; +}; + +} // dash namespace +} // unity namespace + +#endif // _UNITY_SCROLL_VIEW_H_ diff --git a/unity-shared/OverlayWindowButtons.cpp b/unity-shared/OverlayWindowButtons.cpp index 857bde245..089d0e319 100644 --- a/unity-shared/OverlayWindowButtons.cpp +++ b/unity-shared/OverlayWindowButtons.cpp @@ -45,7 +45,7 @@ OverlayWindowButtons::OverlayWindowButtons() SetBackgroundColor(nux::color::Transparent); } -bool OverlayWindowButtons::IsVisibleOnMonitor(unsigned int monitor) const +bool OverlayWindowButtons::IsVisibleOnMonitor(int monitor) const { if (window_buttons_->monitor == monitor) return true; diff --git a/unity-shared/OverlayWindowButtons.h b/unity-shared/OverlayWindowButtons.h index 5c0666bc2..fe3bf4c55 100644 --- a/unity-shared/OverlayWindowButtons.h +++ b/unity-shared/OverlayWindowButtons.h @@ -40,7 +40,7 @@ public: nux::Area* FindAreaUnderMouse(nux::Point const& mouse_position, nux::NuxEventType event_type); - bool IsVisibleOnMonitor(unsigned int monitor) const; + bool IsVisibleOnMonitor(int monitor) const; protected: void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); diff --git a/unity-shared/PlacesOverlayVScrollBar.cpp b/unity-shared/PlacesOverlayVScrollBar.cpp index b715f62cf..6295bda52 100644 --- a/unity-shared/PlacesOverlayVScrollBar.cpp +++ b/unity-shared/PlacesOverlayVScrollBar.cpp @@ -19,33 +19,46 @@ #include <Nux/Nux.h> -#include "PlacesOverlayVScrollBar.h" #include "CairoTexture.h" +#include "PlacesOverlayVScrollBar.h" +#include "RawPixel.h" +namespace unity +{ +namespace dash +{ namespace { - int const PROXIMITY = 7; - int const SCROLL_ANIMATION = 400; - int const MAX_CONNECTOR_ANIMATION = 200; + const RawPixel PROXIMITY = 7_em; + const int SCROLL_ANIMATION = 400; + const int MAX_CONNECTOR_ANIMATION = 200; + const nux::Color CONNECTOR_COLOR = nux::color::Gray; } -namespace unity -{ -namespace dash +class PlacesOverlayVScrollBar::ProximityArea : public nux::InputAreaProximity, public sigc::trackable { +public: + ProximityArea(nux::InputArea* area, unsigned prox) + : nux::InputAreaProximity(area, prox) + , proximity([this] { return proximity_; }, [this] (unsigned px) { proximity_ = px; return false; }) + {} + + nux::RWProperty<unsigned> proximity; +}; PlacesOverlayVScrollBar::PlacesOverlayVScrollBar(NUX_FILE_LINE_DECL) : PlacesVScrollBar(NUX_FILE_LINE_PARAM) , overlay_window_(new VScrollBarOverlayWindow(_track->GetAbsoluteGeometry())) - , area_prox_(this, PROXIMITY) + , area_prox_(std::make_shared<ProximityArea>(this, PROXIMITY.CP(scale))) , thumb_above_slider_(false) , connector_height_(0) , mouse_down_offset_(0) , delta_update_(0) { - area_prox_.mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); - area_prox_.mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); + area_prox_->mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); + area_prox_->mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); + overlay_window_->scale = scale(); overlay_window_->mouse_enter.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseEnter)); overlay_window_->mouse_leave.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseLeave)); overlay_window_->mouse_down.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseDown)); @@ -53,11 +66,17 @@ PlacesOverlayVScrollBar::PlacesOverlayVScrollBar(NUX_FILE_LINE_DECL) overlay_window_->mouse_click.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseClick)); overlay_window_->mouse_move.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseMove)); overlay_window_->mouse_drag.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseDrag)); + overlay_window_->mouse_wheel.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseWheel)); overlay_window_->sigHidden.connect(sigc::hide(sigc::mem_fun(this, &PlacesOverlayVScrollBar::ResetConnector))); _track->geometry_changed.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnTrackGeometryChanged)); OnVisibleChanged.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnVisibilityChanged)); OnSensitiveChanged.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnSensitivityChanged)); + + scale.changed.connect([this] (double scale) { + area_prox_->proximity = PROXIMITY.CP(scale); + overlay_window_->scale = scale; + }); } void PlacesOverlayVScrollBar::OnTrackGeometryChanged(nux::Area* /*area*/, nux::Geometry& /*geo*/) @@ -353,6 +372,12 @@ void PlacesOverlayVScrollBar::OnMouseDrag(int /*x*/, int y, int /*dx*/, int dy, MouseDraggingOverlay(y, dy); } +void PlacesOverlayVScrollBar::OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state) +{ + mouse_wheel.emit(x, y, delta, mouse_state, key_state); + UpdateConnectorPosition(); +} + void PlacesOverlayVScrollBar::MouseDraggingOverlay(int y, int dy) { int const thumb_offset = overlay_window_->GetThumbOffsetY() + mouse_down_offset_; @@ -410,30 +435,25 @@ void PlacesOverlayVScrollBar::UpdateConnectorTexture() if (connector_height_ < 0) return; - int width = 3; + int width = _slider->GetWidth(); int height = connector_height_; - float const radius = 1.5f; - float const aspect = 1.0f; - - cairo_t* cr = NULL; - nux::color::RedGreenBlue const& connector_bg = nux::color::Gray; + if (connector_texture_ && connector_texture_->GetWidth() == width && connector_texture_->GetHeight() == height) + return; nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height); - cr = cairoGraphics.GetInternalContext(); - cairo_save(cr); + cairo_t* cr = cairoGraphics.GetInternalContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_save(cr); - - cairo_set_source_rgba(cr, connector_bg.red, connector_bg.green, connector_bg.blue, 0.8); - cairoGraphics.DrawRoundedRectangle(cr, aspect, 0.0f, 0.0f, radius, width, height); - cairo_fill_preserve(cr); + cairo_set_source_rgba(cr, CONNECTOR_COLOR.red, CONNECTOR_COLOR.green, CONNECTOR_COLOR.blue, 0.8); + cairo_rectangle(cr, 0, 0, static_cast<double>(width)/scale(), static_cast<double>(height)/scale()); + cairo_fill(cr); - connector_texture_.Adopt(texture_from_cairo_graphics(cairoGraphics)); + connector_texture_ = texture_ptr_from_cairo_graphics(cairoGraphics); QueueDraw(); } diff --git a/unity-shared/PlacesOverlayVScrollBar.h b/unity-shared/PlacesOverlayVScrollBar.h index b9697ef47..59a9778e1 100644 --- a/unity-shared/PlacesOverlayVScrollBar.h +++ b/unity-shared/PlacesOverlayVScrollBar.h @@ -67,10 +67,10 @@ private: void OnMouseDown(int x, int y, unsigned int button_flags, unsigned int key_flags); void OnMouseUp(int x, int y, unsigned int button_flags, unsigned int key_flags); - void OnMouseMove(int x, int y, int dx, int dy, unsigned int button_flags, unsigned int key_flags); - void OnMouseDrag(int x, int y, int dx, int dy, unsigned int button_flags, unsigned int key_flags); + void OnMouseWheel(int x, int y, int delta, unsigned long mouse_state, unsigned long key_state); + void MouseDraggingOverlay(int y, int dy); bool IsMouseInTopHalfOfThumb(int y); @@ -80,7 +80,7 @@ private: void UpdateConnectorPosition(); void ResetConnector(); - + void UpdateStepY(); void SetupAnimation(int start, int stop, int milliseconds); @@ -93,7 +93,9 @@ private: void UpdateConnectorTexture(); nux::ObjectPtr<VScrollBarOverlayWindow> overlay_window_; - nux::InputAreaProximity area_prox_; + + class ProximityArea; + std::shared_ptr<ProximityArea> area_prox_; nux::animation::AnimateValue<int> animation_; connection::Wrapper tweening_connection_; diff --git a/unity-shared/PlacesVScrollBar.cpp b/unity-shared/PlacesVScrollBar.cpp index 0058fb465..25eba0dfc 100644 --- a/unity-shared/PlacesVScrollBar.cpp +++ b/unity-shared/PlacesVScrollBar.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2011 Canonical Ltd + * Copyright (C) 2011-2014 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -15,44 +15,53 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Authored by: Mirco Müller <mirco.mueller@canonical.com> + * Marco Trevisan <marco.trevisan@canonical.com> */ #include <Nux/Nux.h> +#include <NuxGraphics/CairoGraphics.h> #include "unity-shared/CairoTexture.h" +#include "unity-shared/RawPixel.h" #include "PlacesVScrollBar.h" -using unity::texture_from_cairo_graphics; - namespace unity { namespace dash { +namespace +{ +const RawPixel BUTTONS_HEIGHT = 15_em; +const RawPixel WIDTH = 3_em; +} PlacesVScrollBar::PlacesVScrollBar(NUX_FILE_LINE_DECL) - : VScrollBar(NUX_FILE_LINE_PARAM), - _slider_texture(NULL) + : nux::VScrollBar(NUX_FILE_LINE_PARAM) + , scale(1.0) { - _scroll_up_button->SetMaximumHeight(15); - _scroll_up_button->SetMinimumHeight(15); - - _scroll_down_button->SetMaximumHeight(15); - _scroll_down_button->SetMinimumHeight(15); - - _slider->SetMinimumWidth(3); - _slider->SetMaximumWidth(3); - SetMinimumWidth(3); - SetMaximumWidth(3); + UpdateSize(); + scale.changed.connect([this] (double scale) { + UpdateSize(); + QueueRelayout(); + QueueDraw(); + }); } -PlacesVScrollBar::~PlacesVScrollBar() +void PlacesVScrollBar::UpdateSize() { - if (_slider_texture) - _slider_texture->UnReference(); + _scroll_up_button->SetMaximumHeight(BUTTONS_HEIGHT.CP(scale)); + _scroll_up_button->SetMinimumHeight(BUTTONS_HEIGHT.CP(scale)); + + _scroll_down_button->SetMaximumHeight(BUTTONS_HEIGHT.CP(scale)); + _scroll_down_button->SetMinimumHeight(BUTTONS_HEIGHT.CP(scale)); + + _slider->SetMinimumWidth(WIDTH.CP(scale)); + _slider->SetMaximumWidth(WIDTH.CP(scale)); + SetMinimumWidth(WIDTH.CP(scale)); + SetMaximumWidth(WIDTH.CP(scale)); } -void -PlacesVScrollBar::PreLayoutManagement() +void PlacesVScrollBar::PreLayoutManagement() { nux::VScrollBar::PreLayoutManagement(); } @@ -69,8 +78,8 @@ PlacesVScrollBar::PostLayoutManagement(long LayoutResult) void PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { - if(!RedirectedAncestor()) - { + if (!RedirectedAncestor()) + { DrawScrollbar(graphics_engine); } } @@ -78,15 +87,19 @@ PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) void PlacesVScrollBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { - if(RedirectedAncestor()) - { - DrawScrollbar(graphics_engine); + if (RedirectedAncestor()) + { + DrawScrollbar(graphics_engine); } } void PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) { + // check if textures have been computed... if they haven't, exit function + if (!slider_texture_) + return; + nux::Color color = nux::color::White; nux::Geometry const& base = GetGeometry(); nux::TexCoordXForm texxform; @@ -95,9 +108,6 @@ PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) unsigned int alpha = 0, src = 0, dest = 0; graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - // check if textures have been computed... if they haven't, exit function - if (!_slider_texture) - return; texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD); @@ -112,7 +122,7 @@ PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) slider_geo.y, slider_geo.width, slider_geo.height, - _slider_texture->GetDeviceTexture(), + slider_texture_->GetDeviceTexture(), texxform, color); } @@ -123,35 +133,26 @@ PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) void PlacesVScrollBar::UpdateTexture() { - nux::CairoGraphics* cairoGraphics = NULL; - cairo_t* cr = NULL; - // update texture of slider int width = _slider->GetBaseWidth(); int height = _slider->GetBaseHeight(); - cairoGraphics = new nux::CairoGraphics(CAIRO_FORMAT_ARGB32, width, height); - cr = cairoGraphics->GetContext(); + + if (slider_texture_ && slider_texture_->GetWidth() == width && slider_texture_->GetHeight() == height) + return; + + nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height); + auto* cr = cg.GetContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f); - cairoGraphics->DrawRoundedRectangle(cr, - 1.0f, - 0.0, - 0.0, - 1.5, - 3.0, - (double) height - 3.0); + cg.DrawRoundedRectangle(cr, 1.0f, 0.0, 0.0, 1.5, 3.0, static_cast<double>(height)/scale() - 3.0); cairo_fill(cr); - if (_slider_texture) - _slider_texture->UnReference(); - _slider_texture = texture_from_cairo_graphics(*cairoGraphics); - - cairo_destroy(cr); - delete cairoGraphics; + slider_texture_ = texture_ptr_from_cairo_graphics(cg); } } // namespace dash diff --git a/unity-shared/PlacesVScrollBar.h b/unity-shared/PlacesVScrollBar.h index c6bc201cb..2a7fc16b2 100644 --- a/unity-shared/PlacesVScrollBar.h +++ b/unity-shared/PlacesVScrollBar.h @@ -20,12 +20,7 @@ #ifndef PLACES_VSCROLLBAR_H #define PLACES_VSCROLLBAR_H -#include <Nux/Nux.h> -#include <Nux/View.h> -#include <Nux/ScrollView.h> -#include <Nux/BaseWindow.h> #include <Nux/VScrollBar.h> -#include <NuxGraphics/CairoGraphics.h> namespace unity { @@ -36,23 +31,23 @@ class PlacesVScrollBar : public nux::VScrollBar { public: PlacesVScrollBar(NUX_FILE_LINE_PROTO); - virtual ~PlacesVScrollBar(); + + nux::Property<double> scale; protected: virtual void PreLayoutManagement(); virtual long PostLayoutManagement(long LayoutResult); - void Draw(nux::GraphicsEngine& gfxContext, - bool forceDraw); - void DrawContent(nux::GraphicsEngine& gfxContext, - bool forceDraw); + void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw); + void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw); private: + void UpdateSize(); void UpdateTexture(); void DrawScrollbar(nux::GraphicsEngine& graphics_engine); private: - nux::BaseTexture* _slider_texture; + nux::ObjectPtr<nux::BaseTexture> slider_texture_; }; } // namespace dash diff --git a/unity-shared/PluginAdapter.cpp b/unity-shared/PluginAdapter.cpp index 4ba844d5a..180455585 100644 --- a/unity-shared/PluginAdapter.cpp +++ b/unity-shared/PluginAdapter.cpp @@ -1254,6 +1254,7 @@ bool PluginAdapter::IsScreenGrabbed() const if (ret == GrabSuccess) { XUngrabKeyboard(dpy, CurrentTime); + XFlush(dpy); if (CompWindow* w = m_Screen->findWindow(m_Screen->activeWindow())) w->moveInputFocusTo(); diff --git a/unity-shared/StandaloneAppManager.cpp b/unity-shared/StandaloneAppManager.cpp index 35c3a14b8..9bb830e8c 100644 --- a/unity-shared/StandaloneAppManager.cpp +++ b/unity-shared/StandaloneAppManager.cpp @@ -31,8 +31,6 @@ using namespace std; using namespace unity; -DECLARE_LOGGER(logger, "unity.appmanager.test"); - GMainLoop *loop; void dump_app(ApplicationPtr const& app, std::string const& prefix = "") diff --git a/unity-shared/StandaloneWindowManager.cpp b/unity-shared/StandaloneWindowManager.cpp index 8ae2e4d09..a25ede2ce 100644 --- a/unity-shared/StandaloneWindowManager.cpp +++ b/unity-shared/StandaloneWindowManager.cpp @@ -24,13 +24,10 @@ #include "StandaloneWindowManager.h" #include "UScreen.h" -#include <NuxCore/Logger.h> - // Entirely stubs for now, unless we need this functionality at some point namespace unity { -DECLARE_LOGGER(logger, "unity.wm"); StandaloneWindow::StandaloneWindow(Window xid) : xid(xid) diff --git a/unity-shared/TextInput.cpp b/unity-shared/TextInput.cpp index 23a4e3196..d8144990e 100644 --- a/unity-shared/TextInput.cpp +++ b/unity-shared/TextInput.cpp @@ -23,8 +23,6 @@ #include "unity-shared/RawPixel.h" #include "unity-shared/PreviewStyle.h" -#include <X11/XKBlib.h> - namespace unity { @@ -42,9 +40,6 @@ const RawPixel TOOLTIP_Y_OFFSET = 3_em; const RawPixel TOOLTIP_OFFSET = 10_em; const RawPixel DEFAULT_ICON_SIZE = 22_em; -// Caps is on 0x1, couldn't find any #define in /usr/include/X11 -const int CAPS_STATE_ON = 0x1; - std::string WARNING_ICON = "dialog-warning-symbolic"; // Fonts const std::string HINT_LABEL_DEFAULT_FONT_NAME = "Ubuntu"; @@ -114,7 +109,6 @@ TextInput::TextInput(NUX_FILE_LINE_DECL) pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE); pango_entry_->cursor_moved.connect([this](int i) { QueueDraw(); }); pango_entry_->mouse_down.connect(sigc::mem_fun(this, &TextInput::OnMouseButtonDown)); - pango_entry_->key_up.connect(sigc::mem_fun(this, &TextInput::OnKeyUp)); pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &TextInput::OnEndKeyFocus)); pango_entry_->text_changed.connect([this](nux::TextEntry*) { hint_->SetVisible(input_string().empty()); @@ -155,6 +149,10 @@ TextInput::TextInput(NUX_FILE_LINE_DECL) "notify::gtk-font-name", sigc::mem_fun(this, &TextInput::OnFontChanged)); OnFontChanged(gtk_settings_get_default()); + sig_manager_.Add<void, GdkKeymap*>(gdk_keymap_get_default(), "state-changed", [this](GdkKeymap*) { + CheckIfCapsLockOn(); + }); + input_string.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_input_string)); input_string.SetSetterFunction(sigc::mem_fun(this, &TextInput::set_input_string)); im_active.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_im_active)); @@ -174,14 +172,8 @@ TextInput::TextInput(NUX_FILE_LINE_DECL) void TextInput::CheckIfCapsLockOn() { - Display *dpy = nux::GetGraphicsDisplay()->GetX11Display(); - unsigned int state = 0; - XkbGetIndicatorState(dpy, XkbUseCoreKbd, &state); - - if ((state & CAPS_STATE_ON) == 1) - caps_lock_on = true; - else - caps_lock_on = false; + GdkKeymap* keymap = gdk_keymap_get_default(); + caps_lock_on = gdk_keymap_get_caps_lock_state(keymap) == FALSE ? false : true; } void TextInput::SetSpinnerVisible(bool visible) @@ -418,16 +410,6 @@ void TextInput::UpdateBackground(bool force) texture2D->UnReference(); } -void TextInput::OnKeyUp(unsigned keysym, - unsigned long keycode, - unsigned long state) -{ - if (!caps_lock_on && keysym == NUX_VK_CAPITAL) - caps_lock_on = true; - else if (caps_lock_on && keysym == NUX_VK_CAPITAL) - caps_lock_on = false; -} - void TextInput::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) { hint_->SetVisible(false); diff --git a/unity-shared/TextInput.h b/unity-shared/TextInput.h index 1e708511e..a494997b9 100644 --- a/unity-shared/TextInput.h +++ b/unity-shared/TextInput.h @@ -99,7 +99,6 @@ private: protected: void OnInputHintChanged(); void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags); - void OnKeyUp(unsigned keysym, unsigned long keycode, unsigned long state); void OnEndKeyFocus(); // getters & setters diff --git a/unity-shared/TextureCache.cpp b/unity-shared/TextureCache.cpp index 232cfd52e..42d3be63f 100644 --- a/unity-shared/TextureCache.cpp +++ b/unity-shared/TextureCache.cpp @@ -21,12 +21,10 @@ #include "TextureCache.h" #include <sstream> -#include <NuxCore/Logger.h> #include "config.h" namespace unity { -DECLARE_LOGGER(logger, "unity.internal.texturecache"); namespace { // Stolen from boost diff --git a/unity-shared/UBusServer.cpp b/unity-shared/UBusServer.cpp index 105983bfc..4c5bf546d 100644 --- a/unity-shared/UBusServer.cpp +++ b/unity-shared/UBusServer.cpp @@ -16,13 +16,12 @@ * Authored by: Michal Hruby <michal.hruby@canonical.com> */ -#include <NuxCore/Logger.h> +#include <algorithm> #include "UBusServer.h" namespace unity { -DECLARE_LOGGER(logger, "unity.ubus"); UBusServer::UBusServer() : last_id_(0) diff --git a/unity-shared/VScrollBarOverlayWindow.cpp b/unity-shared/VScrollBarOverlayWindow.cpp index 6f2587de5..46f40eab3 100644 --- a/unity-shared/VScrollBarOverlayWindow.cpp +++ b/unity-shared/VScrollBarOverlayWindow.cpp @@ -31,15 +31,15 @@ namespace unity namespace { - int const THUMB_WIDTH = 21; - int const THUMB_HEIGHT = 68; - int const THUMB_RADIUS = 3; - int const ANIMATION_DURATION = 90; + const RawPixel THUMB_WIDTH = 21_em; + const RawPixel THUMB_HEIGHT = 68_em; + const int THUMB_RADIUS = 3; + const int ANIMATION_DURATION = 90; } - VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo) : nux::BaseWindow("") + , scale(1.0) , content_size_(geo) , content_offset_x_(0) , mouse_offset_y_(0) @@ -47,8 +47,9 @@ VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo) , current_action_(ThumbAction::NONE) , show_animator_(ANIMATION_DURATION) { - Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH, content_size_.height); + Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height); SetBackgroundColor(nux::color::Transparent); + SetAcceptMouseWheelEvent(true); show_animator_.updated.connect(sigc::mem_fun(this, &BaseWindow::SetOpacity)); show_animator_.finished.connect([this] { @@ -58,6 +59,17 @@ VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo) SetOpacity(0.0f); UpdateTexture(); + + scale.changed.connect([this] (double scale) { + UpdateContentGeometry(); + UpdateTexture(); + }); +} + +void VScrollBarOverlayWindow::UpdateContentGeometry() +{ + UpdateMouseOffsetX(); + Area::SetGeometry(content_size_.x + content_offset_x_, content_size_.y, THUMB_WIDTH.CP(scale), content_size_.height); } void VScrollBarOverlayWindow::UpdateGeometry(nux::Geometry const& geo) @@ -67,9 +79,7 @@ void VScrollBarOverlayWindow::UpdateGeometry(nux::Geometry const& geo) content_size_.height != geo.height) { content_size_ = geo; - UpdateMouseOffsetX(); - - Area::SetGeometry(content_size_.x + content_offset_x_, content_size_.y, THUMB_WIDTH, content_size_.height); + UpdateContentGeometry(); } } @@ -91,8 +101,8 @@ int VScrollBarOverlayWindow::GetValidOffsetYValue(int new_offset) const { if (new_offset < 0) return 0; - else if (new_offset > content_size_.height - THUMB_HEIGHT) - return content_size_.height - THUMB_HEIGHT; + else if (new_offset > content_size_.height - THUMB_HEIGHT.CP(scale)) + return content_size_.height - THUMB_HEIGHT.CP(scale); return new_offset; } @@ -102,15 +112,15 @@ void VScrollBarOverlayWindow::UpdateMouseOffsetX() int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse(); nux::Geometry const& geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor); - if (content_size_.x + THUMB_WIDTH > geo.x + geo.width) - content_offset_x_ = geo.x + geo.width - (content_size_.x + THUMB_WIDTH); + if (content_size_.x + THUMB_WIDTH.CP(scale) > geo.x + geo.width) + content_offset_x_ = geo.x + geo.width - (content_size_.x + THUMB_WIDTH.CP(scale)); else content_offset_x_ = 0; } bool VScrollBarOverlayWindow::IsMouseInsideThumb(int y) const { - nux::Geometry const thumb(0, mouse_offset_y_, THUMB_WIDTH, THUMB_HEIGHT); + nux::Geometry const thumb(0, mouse_offset_y_, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); return thumb.IsPointInside(0,y); } @@ -121,7 +131,7 @@ bool VScrollBarOverlayWindow::IsMouseBeingDragged() const int VScrollBarOverlayWindow::GetThumbHeight() const { - return THUMB_HEIGHT; + return THUMB_HEIGHT.CP(scale); } int VScrollBarOverlayWindow::GetThumbOffsetY() const @@ -133,7 +143,7 @@ nux::Geometry VScrollBarOverlayWindow::GetThumbGeometry() const { return nux::Geometry(content_size_.x + content_offset_x_, content_size_.y + mouse_offset_y_, - THUMB_WIDTH, THUMB_HEIGHT); + THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); } void VScrollBarOverlayWindow::MouseDown() @@ -267,7 +277,7 @@ void VScrollBarOverlayWindow::Draw(nux::GraphicsEngine& graphics_engine, bool fo if (!thumb_texture_) return; - nux::Geometry base(0, mouse_offset_y_, THUMB_WIDTH, THUMB_HEIGHT); + nux::Geometry base(0, mouse_offset_y_, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); nux::TexCoordXForm texxform; graphics_engine.QRP_1Tex(base.x, @@ -372,7 +382,7 @@ void DrawLineSeperator(cairo_t* cr, nux::color::RedGreenBlue const& top, } -void DrawArrow (cairo_t* cr, nux::color::RedGreenBlue const& rgb, double x, double y, double width, double height) +void DrawArrow(cairo_t* cr, nux::color::RedGreenBlue const& rgb, double x, double y, double width, double height) { cairo_save (cr); @@ -417,37 +427,30 @@ void VScrollBarOverlayWindow::UpdateTexture() { int width = THUMB_WIDTH; int height = THUMB_HEIGHT; - int radius = THUMB_RADIUS; float const aspect = 1.0f; float current_x = 0.0f; float current_y = 0.0f; - cairo_t* cr = NULL; - cairo_pattern_t* pat = NULL; + auto const& bg = nux::color::WhiteSmoke; + auto const& bg_selected = nux::color::White; + auto const& bg_active = nux::color::Gray; + auto const& arrow_color = nux::color::DarkSlateGray; - nux::color::RedGreenBlue const& bg = nux::color::WhiteSmoke; - nux::color::RedGreenBlue const& bg_selected = nux::color::White; - nux::color::RedGreenBlue const& bg_active = nux::color::Gray; - nux::color::RedGreenBlue const& arrow_color = nux::color::DarkSlateGray; + auto const& bg_arrow_up = ProduceColorShade(bg, 0.86); + auto const& bg_arrow_down = ProduceColorShade(bg, 1.1); + auto const& bg_shadow = ProduceColorShade(bg, 0.2); - nux::color::RedGreenBlue const& bg_arrow_up = ProduceColorShade(bg, 0.86); - nux::color::RedGreenBlue const& bg_arrow_down = ProduceColorShade(bg, 1.1); - nux::color::RedGreenBlue const& bg_shadow = ProduceColorShade(bg, 0.2); + auto const& bg_dark_line = ProduceColorShade(bg, 0.4); + auto const& bg_bright_line = ProduceColorShade(bg, 1.2); - nux::color::RedGreenBlue const& bg_dark_line = ProduceColorShade(bg, 0.4); - nux::color::RedGreenBlue const& bg_bright_line = ProduceColorShade(bg, 1.2); - - nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, width, height); - cr = cairoGraphics.GetInternalContext(); - - cairo_save(cr); + nux::CairoGraphics cairoGraphics(CAIRO_FORMAT_ARGB32, THUMB_WIDTH.CP(scale), THUMB_HEIGHT.CP(scale)); + cairo_t* cr = cairoGraphics.GetInternalContext(); + cairo_surface_set_device_scale(cairo_get_target(cr), scale, scale); cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); - cairo_save(cr); - cairo_translate (cr, 0.5, 0.5); width--; height--; @@ -455,15 +458,14 @@ void VScrollBarOverlayWindow::UpdateTexture() cairo_set_line_width (cr, 1.0); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_save(cr); // Draw backgound SetSourceRGB(cr, bg, 1.0); - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius, width, height); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS, width, height); cairo_fill_preserve(cr); // Draw shaded background - pat = cairo_pattern_create_linear(0, 0, 0, height); + cairo_pattern_t* pat = cairo_pattern_create_linear(0, 0, 0, height); PatternAddRGBStop(pat, bg_arrow_up, 0.0, 0.8); PatternAddRGBStop(pat, bg_arrow_down, 1.0, 0.8); @@ -502,7 +504,7 @@ void VScrollBarOverlayWindow::UpdateTexture() current_x += 0.5; current_y += 0.5; - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 1, height - 1); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS - 1, width - 1, height - 1); if (HasState(ThumbState::INSIDE_SLIDER)) SetSourceRGB(cr, bg_selected, 1.0); @@ -545,12 +547,12 @@ void VScrollBarOverlayWindow::UpdateTexture() current_x += 0.5; current_y += 0.5; - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius, width- 2, height - 2); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS, width- 2, height - 2); cairo_stroke(cr); current_x += 1.0; current_y += 1.0; - cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 4, height- 4); + cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, THUMB_RADIUS - 1, width - 4, height- 4); SetSourceRGB(cr, bg_bright_line, 0.6); cairo_stroke(cr); @@ -558,7 +560,7 @@ void VScrollBarOverlayWindow::UpdateTexture() DrawLineSeperator(cr, bg_dark_line, bg_bright_line, width, height); DrawBothArrows(cr, arrow_color, width, height); - thumb_texture_.Adopt(unity::texture_from_cairo_graphics(cairoGraphics)); + thumb_texture_ = texture_ptr_from_cairo_graphics(cairoGraphics); QueueDraw(); } diff --git a/unity-shared/VScrollBarOverlayWindow.h b/unity-shared/VScrollBarOverlayWindow.h index ce78e8c14..5c8ad75f0 100644 --- a/unity-shared/VScrollBarOverlayWindow.h +++ b/unity-shared/VScrollBarOverlayWindow.h @@ -32,7 +32,8 @@ class VScrollBarOverlayWindow : public nux::BaseWindow { public: VScrollBarOverlayWindow(nux::Geometry const& geo); - virtual ~VScrollBarOverlayWindow() {} + + nux::Property<double> scale; void UpdateGeometry(nux::Geometry const& geo); void SetThumbOffsetY(int y); @@ -85,6 +86,7 @@ private: void MouseDragging(); void UpdateMouseOffsetX(); + void UpdateContentGeometry(); int GetValidOffsetYValue(int y) const; void ShouldShow(); |
