diff options
74 files changed, 2333 insertions, 1571 deletions
diff --git a/dash/CoverflowResultView.cpp b/dash/CoverflowResultView.cpp index 742b0297a..2f20642d4 100755 --- a/dash/CoverflowResultView.cpp +++ b/dash/CoverflowResultView.cpp @@ -24,6 +24,7 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UBusWrapper.h" +#include "unity-shared/GraphicsUtils.h" #include <Nux/Nux.h> #include <Nux/View.h> #include <Nux/Coverflow.h> @@ -268,18 +269,7 @@ void CoverflowResultView::DrawContent(nux::GraphicsEngine& GfxContext, bool forc GfxContext.PushClippingRectangle(base); if (RedirectedAncestor()) - { - // This is necessary when doing redirected rendering. Clean the area below this view. - unsigned int current_alpha_blend; - unsigned int current_src_blend_factor; - unsigned int current_dest_blend_factor; - GfxContext.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - - GfxContext.GetRenderStates().SetBlend(false); - GfxContext.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - - GfxContext.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - } + graphics::ClearGeometry(GetGeometry()); if (GetCompositionLayout()) { diff --git a/dash/DashController.cpp b/dash/DashController.cpp index f4c0eb4e3..7877610ed 100644 --- a/dash/DashController.cpp +++ b/dash/DashController.cpp @@ -66,14 +66,14 @@ Controller::Controller(Controller::WindowCreator const& create_window) , visible_(false) , need_show_(false) , view_(nullptr) + , dbus_connect_cancellable_(g_cancellable_new()) , ensure_timeout_(PRELOAD_TIMEOUT_LENGTH) , timeline_animator_(90) - , dbus_connect_cancellable_(g_cancellable_new()) { RegisterUBusInterests(); ensure_timeout_.Run([&]() { EnsureDash(); return false; }); - timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); + timeline_animator_.updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); // As a default. the create_window_ function should just create a base window. if (create_window_ == nullptr) @@ -308,6 +308,19 @@ void Controller::ShowDash() view_->AboutToShow(); + FocusWindow(); + + need_show_ = false; + visible_ = true; + + StartShowHideTimeline(); + + GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_); + ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info); +} + +void Controller::FocusWindow() +{ window_->ShowWindow(true); window_->PushToFront(); if (!Settings::Instance().is_standalone) // in standalone mode, we do not need an input window. we are one. @@ -317,18 +330,9 @@ void Controller::ShowDash() window_->UpdateInputWindowGeometry(); } window_->SetInputFocus(); - window_->CaptureMouseDownAnyWhereElse(true); window_->QueueDraw(); nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); - - need_show_ = false; - visible_ = true; - - StartShowHideTimeline(); - - GVariant* info = g_variant_new(UBUS_OVERLAY_FORMAT_STRING, "dash", TRUE, monitor_); - ubus_manager_.SendMessage(UBUS_OVERLAY_SHOWN, info); } void Controller::HideDash(bool restore) @@ -361,16 +365,24 @@ void Controller::StartShowHideTimeline() { EnsureDash(); - double current_opacity = window_->GetOpacity(); - timeline_animator_.Stop(); - timeline_animator_.Start(visible_ ? current_opacity : 1.0f - current_opacity); + if (timeline_animator_.CurrentState() == nux::animation::Animation::State::Running) + { + timeline_animator_.Reverse(); + } + else + { + if (visible_) + timeline_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start(); + else + timeline_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start(); + } } -void Controller::OnViewShowHideFrame(double progress) +void Controller::OnViewShowHideFrame(double opacity) { - window_->SetOpacity(visible_ ? progress : 1.0f - progress); + window_->SetOpacity(opacity); - if (progress == 1.0f && !visible_) + if (opacity == 0.0f && !visible_) { window_->ShowWindow(false); } @@ -419,6 +431,15 @@ void Controller::AddProperties(GVariantBuilder* builder) .add("monitor", monitor_); } +void Controller::ReFocusKeyInput() +{ + if (visible_) + { + window_->PushToFront(); + window_->SetInputFocus(); + } +} + bool Controller::IsVisible() const { return visible_; diff --git a/dash/DashController.h b/dash/DashController.h index 5ff1b10d8..c4f38302a 100644 --- a/dash/DashController.h +++ b/dash/DashController.h @@ -24,12 +24,12 @@ #include <gdk/gdk.h> #include <UnityCore/GLibSignal.h> +#include <NuxCore/Animation.h> #include <NuxCore/Property.h> #include <NuxGraphics/GraphicsEngine.h> #include <Nux/Nux.h> #include "DashView.h" -#include "unity-shared/Animator.h" #include "unity-shared/Introspectable.h" #include "unity-shared/UBusWrapper.h" #include "unity-shared/ResizingBaseWindow.h" @@ -61,6 +61,8 @@ public: void HideDash(bool restore_focus = true); void ShowDash(); + void ReFocusKeyInput(); + bool IsVisible() const; nux::Geometry GetInputWindowGeometry(); @@ -84,6 +86,8 @@ private: void OnExternalHideDash(GVariant* variant); void OnActivateRequest(GVariant* variant); + void FocusWindow(); + void StartShowHideTimeline(); void OnViewShowHideFrame(double progress); @@ -105,13 +109,13 @@ private: DashView* view_; sigc::connection screen_ungrabbed_slot_; - glib::TimeoutSeconds ensure_timeout_; - Animator timeline_animator_; - UBusManager ubus_manager_; unsigned int dbus_owner_; unsigned place_entry_request_id_; glib::Object<GCancellable> dbus_connect_cancellable_; static GDBusInterfaceVTable interface_vtable; + glib::TimeoutSeconds ensure_timeout_; + nux::animation::AnimateValue<double> timeline_animator_; + UBusManager ubus_manager_; }; diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 878845456..8aaaf873c 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -555,28 +555,29 @@ void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw preview_redraw = preview_container_->IsRedrawNeeded(); } - if (!preview_displaying_ && layout_->RedirectRenderingToTexture() && (fade_in_value_ == 0.0f)) - { - nux::Geometry layout_geo = layout_->GetGeometry(); - graphics_engine.PushClippingRectangle(layout_geo); - nux::GetPainter().PaintBackground(graphics_engine, layout_geo); - graphics_engine.PopClippingRectangle(); - } - - if (preview_displaying_ && (IsFullRedraw() || force_draw || preview_redraw) && layout_->RedirectRenderingToTexture()) - { - display_ghost = true; - nux::Geometry layout_geo = layout_->GetGeometry(); - graphics_engine.PushClippingRectangle(layout_geo); - nux::GetPainter().PaintBackground(graphics_engine, layout_geo); - graphics_engine.PopClippingRectangle(); - } - if (IsFullRedraw()) { nux::GetPainter().PushBackgroundStack(); } + else + { + if (!preview_displaying_ && layout_->RedirectRenderingToTexture() && (fade_in_value_ == 0.0f)) + { + nux::Geometry layout_geo = layout_->GetGeometry(); + graphics_engine.PushClippingRectangle(layout_geo); + nux::GetPainter().PaintBackground(graphics_engine, layout_geo); + graphics_engine.PopClippingRectangle(); + } + if (preview_displaying_ && (force_draw || preview_redraw) && layout_->RedirectRenderingToTexture()) + { + display_ghost = true; + nux::Geometry layout_geo = layout_->GetGeometry(); + graphics_engine.PushClippingRectangle(layout_geo); + nux::GetPainter().PaintBackground(graphics_engine, layout_geo); + graphics_engine.PopClippingRectangle(); + } + } if (preview_displaying_) { diff --git a/dash/FilterAllButton.cpp b/dash/FilterAllButton.cpp index 55280366f..78dc57c7b 100644 --- a/dash/FilterAllButton.cpp +++ b/dash/FilterAllButton.cpp @@ -39,10 +39,6 @@ FilterAllButton::FilterAllButton(NUX_FILE_LINE_DECL) SetInputEventSensitivity(false); state_change.connect(sigc::mem_fun(this, &FilterAllButton::OnStateChanged)); - - SetRedirectRenderingToTexture(true); - //SetCopyPreviousFboTexture(false); - SetClearBeforeDraw(true); } FilterAllButton::~FilterAllButton() diff --git a/dash/FilterBar.cpp b/dash/FilterBar.cpp index 5e78becc1..60135a0c1 100644 --- a/dash/FilterBar.cpp +++ b/dash/FilterBar.cpp @@ -24,6 +24,7 @@ #include <NuxCore/Logger.h> #include "unity-shared/DashStyle.h" +#include "unity-shared/GraphicsUtils.h" #include "FilterBar.h" #include "FilterExpanderLabel.h" #include "FilterFactory.h" @@ -102,6 +103,17 @@ void FilterBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) void FilterBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { graphics_engine.PushClippingRectangle(GetGeometry()); + + if (!IsFullRedraw() && RedirectedAncestor()) + { + for (auto iter: filter_map_) + { + FilterExpanderLabel* filter_view = iter.second; + if (filter_view && filter_view->IsVisible() && filter_view->IsRedrawNeeded()) + graphics::ClearGeometry(filter_view->GetGeometry()); + } + } + GetLayout()->ProcessDraw(graphics_engine, force_draw); graphics_engine.PopClippingRectangle(); } diff --git a/dash/FilterBasicButton.cpp b/dash/FilterBasicButton.cpp index fe1c9e9bf..0d8b40a71 100644 --- a/dash/FilterBasicButton.cpp +++ b/dash/FilterBasicButton.cpp @@ -138,6 +138,7 @@ void FilterBasicButton::SetClearBeforeDraw(bool clear_before_draw) void FilterBasicButton::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { nux::Geometry const& geo = GetGeometry(); + graphics_engine.PushClippingRectangle(geo); // set up our texture mode nux::TexCoordXForm texxform; @@ -147,13 +148,6 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& graphics_engine, bool force_dr // clear what is behind us unsigned int alpha = 0, src = 0, dest = 0; graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - if (RedirectedAncestor() && clear_before_draw_) - { - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - } graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); nux::Color col = nux::color::Black; @@ -192,6 +186,8 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& graphics_engine, bool force_dr } graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); + + graphics_engine.PopClippingRectangle(); } } // namespace dash diff --git a/dash/FilterExpanderLabel.cpp b/dash/FilterExpanderLabel.cpp index 86ac24b9a..e505ef423 100644 --- a/dash/FilterExpanderLabel.cpp +++ b/dash/FilterExpanderLabel.cpp @@ -21,6 +21,7 @@ */ #include "unity-shared/DashStyle.h" +#include "unity-shared/GraphicsUtils.h" #include "FilterExpanderLabel.h" namespace @@ -226,28 +227,17 @@ void FilterExpanderLabel::Draw(nux::GraphicsEngine& graphics_engine, bool force_ graphics_engine.PushClippingRectangle(base); - if (RedirectedAncestor()) - { - unsigned int alpha = 0, src = 0, dest = 0; - graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); - } - if (ShouldBeHighlighted()) { nux::Geometry geo(top_bar_layout_->GetGeometry()); geo.x = base.x; geo.width = base.width; - if (!highlight_layer_) - highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height)); + if (!focus_layer_) + focus_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height)); - highlight_layer_->SetGeometry(geo); - highlight_layer_->Renderlayer(graphics_engine); + focus_layer_->SetGeometry(geo); + focus_layer_->Renderlayer(graphics_engine); } graphics_engine.PopClippingRectangle(); @@ -257,36 +247,45 @@ void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& graphics_engine, bool { graphics_engine.PushClippingRectangle(GetGeometry()); - if (RedirectedAncestor() && !IsFullRedraw()) - { - unsigned int alpha = 0, src = 0, dest = 0; - graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); - } - int pushed_paint_layers = 0; - if (RedirectedAncestor()) + if (!IsFullRedraw()) { - if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw()) - nux::GetPainter().RenderSinglePaintLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get()); + if (RedirectedAncestor()) + { + if (cairo_label_->IsRedrawNeeded()) + graphics::ClearGeometry(cairo_label_->GetGeometry()); + if (expand_icon_->IsRedrawNeeded()) + graphics::ClearGeometry(expand_icon_->GetGeometry()); + if (right_hand_contents_ && right_hand_contents_->IsRedrawNeeded()) + graphics::ClearGeometry(right_hand_contents_->GetGeometry()); + + if (expanded()) + ClearRedirectedRenderChildArea(); + } + + if (focus_layer_ && ShouldBeHighlighted()) + { + ++pushed_paint_layers; + nux::GetPainter().PushLayer(graphics_engine, focus_layer_->GetGeometry(), focus_layer_.get()); + } } - else if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw()) + else { - ++pushed_paint_layers; - nux::GetPainter().PushLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get()); + nux::GetPainter().PushPaintLayerStack(); } - GetLayout()->ProcessDraw(graphics_engine, true); - graphics_engine.PopClippingRectangle(); + GetLayout()->ProcessDraw(graphics_engine, force_draw); - if (pushed_paint_layers) + if (IsFullRedraw()) + { + nux::GetPainter().PopPaintLayerStack(); + } + else if (pushed_paint_layers > 0) { nux::GetPainter().PopBackground(pushed_paint_layers); } + + graphics_engine.PopClippingRectangle(); } // diff --git a/dash/FilterExpanderLabel.h b/dash/FilterExpanderLabel.h index e3798b506..4d0764ab6 100644 --- a/dash/FilterExpanderLabel.h +++ b/dash/FilterExpanderLabel.h @@ -71,6 +71,8 @@ protected: virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); + virtual void ClearRedirectedRenderChildArea() = 0; + // Introspection virtual std::string GetName() const; virtual void AddProperties(GVariantBuilder* builder); @@ -94,7 +96,7 @@ private: IconTexture* expand_icon_; nux::ObjectPtr<nux::Layout> contents_; - std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_; + std::unique_ptr<nux::AbstractPaintLayer> focus_layer_; }; } // namespace dash diff --git a/dash/FilterGenreWidget.cpp b/dash/FilterGenreWidget.cpp index 50761ec7e..ea638e95e 100644 --- a/dash/FilterGenreWidget.cpp +++ b/dash/FilterGenreWidget.cpp @@ -26,6 +26,7 @@ #include <UnityCore/GLibWrapper.h> #include "unity-shared/DashStyle.h" +#include "unity-shared/GraphicsUtils.h" #include "FilterGenreWidget.h" #include "FilterGenreButton.h" #include "FilterBasicButton.h" @@ -124,5 +125,14 @@ void FilterGenre::InitTheme() //FIXME - build theme here - store images, cache them, fun fun fun } +void FilterGenre::ClearRedirectedRenderChildArea() +{ + for (auto button : buttons_) + { + if (button->IsRedrawNeeded()) + graphics::ClearGeometry(button->GetGeometry()); + } +} + } // namespace dash } // namespace unity diff --git a/dash/FilterGenreWidget.h b/dash/FilterGenreWidget.h index 84baa0ae0..d1e20f9f5 100644 --- a/dash/FilterGenreWidget.h +++ b/dash/FilterGenreWidget.h @@ -54,6 +54,8 @@ public: protected: void InitTheme(); + void ClearRedirectedRenderChildArea(); + private: void OnOptionAdded(FilterOption::Ptr const& new_filter); void OnOptionRemoved(FilterOption::Ptr const& removed_filter); diff --git a/dash/FilterMultiRangeButton.cpp b/dash/FilterMultiRangeButton.cpp index 9aef960ad..5fd1701bb 100644 --- a/dash/FilterMultiRangeButton.cpp +++ b/dash/FilterMultiRangeButton.cpp @@ -226,13 +226,6 @@ void FilterMultiRangeButton::Draw(nux::GraphicsEngine& GfxContext, bool force_dr // clear what is behind us unsigned int alpha = 0, src = 0, dest = 0; GfxContext.GetRenderStates().GetBlend(alpha, src, dest); - if (RedirectedAncestor()) - { - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - GfxContext.GetRenderStates().SetBlend(false); - GfxContext.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - } GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); nux::Color col = nux::color::Black; diff --git a/dash/FilterMultiRangeWidget.cpp b/dash/FilterMultiRangeWidget.cpp index e23e4f2de..cefba465f 100644 --- a/dash/FilterMultiRangeWidget.cpp +++ b/dash/FilterMultiRangeWidget.cpp @@ -23,6 +23,7 @@ #include <Nux/Nux.h> #include "unity-shared/DashStyle.h" +#include "unity-shared/GraphicsUtils.h" #include "FilterMultiRangeWidget.h" #include "FilterMultiRangeButton.h" #include "FilterBasicButton.h" @@ -164,5 +165,14 @@ void FilterMultiRange::InitTheme() //FIXME - build theme here - store images, cache them, fun fun fun } +void FilterMultiRange::ClearRedirectedRenderChildArea() +{ + for (auto button : buttons_) + { + if (button->IsRedrawNeeded()) + graphics::ClearGeometry(button->GetGeometry()); + } +} + } // namespace dash } // namespace unity diff --git a/dash/FilterMultiRangeWidget.h b/dash/FilterMultiRangeWidget.h index 1d4b9b8ca..7b3c8b47b 100644 --- a/dash/FilterMultiRangeWidget.h +++ b/dash/FilterMultiRangeWidget.h @@ -52,6 +52,8 @@ public: protected: void InitTheme(); + void ClearRedirectedRenderChildArea(); + private: void OnAllActivated(nux::View* view); void OnOptionAdded(dash::FilterOption::Ptr const& new_filter); diff --git a/dash/FilterRatingsButton.cpp b/dash/FilterRatingsButton.cpp index 9be5a4015..0c4628c05 100644 --- a/dash/FilterRatingsButton.cpp +++ b/dash/FilterRatingsButton.cpp @@ -107,13 +107,6 @@ void FilterRatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) unsigned int alpha = 0, src = 0, dest = 0; GfxContext.GetRenderStates().GetBlend(alpha, src, dest); - if (RedirectedAncestor()) - { - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - GfxContext.GetRenderStates().SetBlend(false); - GfxContext.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - } GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); nux::Color col = nux::color::Black; diff --git a/dash/FilterRatingsWidget.cpp b/dash/FilterRatingsWidget.cpp index d4451e428..ae89d965d 100644 --- a/dash/FilterRatingsWidget.cpp +++ b/dash/FilterRatingsWidget.cpp @@ -26,6 +26,7 @@ #include <glib/gi18n-lib.h> #include "unity-shared/DashStyle.h" +#include "unity-shared/GraphicsUtils.h" #include "FilterGenreWidget.h" #include "FilterGenreButton.h" #include "FilterBasicButton.h" @@ -85,5 +86,11 @@ std::string FilterRatingsWidget::GetFilterType() return "FilterRatingsWidget"; } +void FilterRatingsWidget::ClearRedirectedRenderChildArea() +{ + if (ratings_->IsRedrawNeeded()) + graphics::ClearGeometry(ratings_->GetGeometry()); +} + } // namespace dash } // namespace unity diff --git a/dash/FilterRatingsWidget.h b/dash/FilterRatingsWidget.h index 6d002eb7d..d694c0800 100644 --- a/dash/FilterRatingsWidget.h +++ b/dash/FilterRatingsWidget.h @@ -50,6 +50,9 @@ public: void SetFilter(Filter::Ptr const& filter); std::string GetFilterType(); +protected: + void ClearRedirectedRenderChildArea(); + private: FilterAllButton* all_button_; FilterRatingsButton* ratings_; diff --git a/dash/LensBar.cpp b/dash/LensBar.cpp index 4616147d3..e618c79a9 100644 --- a/dash/LensBar.cpp +++ b/dash/LensBar.cpp @@ -26,6 +26,8 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/StaticCairoText.h" #include "unity-shared/CairoTexture.h" +#include "unity-shared/GraphicsUtils.h" +#include "LensBar.h" #include "unity-shared/UBusMessages.h" namespace unity @@ -176,9 +178,15 @@ void LensBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) graphics_engine.PushClippingRectangle(base); - bg_layer_->SetGeometry(base); - nux::GetPainter().RenderSinglePaintLayer(graphics_engine, base, bg_layer_.get()); - + if (RedirectedAncestor()) + graphics::ClearGeometry(base); + + if (bg_layer_) + { + bg_layer_->SetGeometry(base); + bg_layer_->Renderlayer(graphics_engine); + } + graphics_engine.PopClippingRectangle(); } @@ -189,30 +197,35 @@ void LensBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) graphics_engine.PushClippingRectangle(base); int pushed_paint_layers = 0; - if(RedirectedAncestor()) + if (!IsFullRedraw()) { - { - unsigned int alpha = 0, src = 0, dest = 0; - graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); + if (RedirectedAncestor()) + { + // Whole Lens bar needs to be cleared because the PaintAll forces redraw. + graphics::ClearGeometry(base); } - nux::GetPainter().RenderSinglePaintLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + if (bg_layer_) + { + nux::GetPainter().PushLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + pushed_paint_layers++; + } } - else if (!IsFullRedraw()) + else { - pushed_paint_layers += 2; - nux::GetPainter().PushLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + nux::GetPainter().PushPaintLayerStack(); } GetLayout()->ProcessDraw(graphics_engine, true); - if (pushed_paint_layers) + if (IsFullRedraw()) + { + nux::GetPainter().PopPaintLayerStack(); + } + else if (pushed_paint_layers > 0) + { nux::GetPainter().PopBackground(pushed_paint_layers); + } for (auto icon: icons_) { diff --git a/dash/LensBarIcon.cpp b/dash/LensBarIcon.cpp index 783c17302..3f4a7682b 100644 --- a/dash/LensBarIcon.cpp +++ b/dash/LensBarIcon.cpp @@ -58,7 +58,6 @@ LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint) active.changed.connect(sigc::mem_fun(this, &LensBarIcon::OnActiveChanged)); key_nav_focus_change.connect([&](nux::Area*, bool, nux::KeyNavDirection){ QueueDraw(); }); - SetRedirectRenderingToTexture(true); } LensBarIcon::~LensBarIcon() @@ -70,12 +69,6 @@ void LensBarIcon::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) graphics_engine.PushClippingRectangle(geo); - if (!texture()) - { - graphics_engine.PopClippingRectangle(); - return; - } - if (HasKeyFocus() && focus_layer_) { nux::Geometry geo(GetGeometry()); @@ -85,22 +78,33 @@ void LensBarIcon::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) layer->Renderlayer(graphics_engine); } - float opacity = active ? 1.0f : inactive_opacity_; - int width = 0, height = 0; - GetTextureSize(&width, &height); - - nux::Color col(1.0f * opacity, 1.0f * opacity, 1.0f * opacity, opacity); - nux::TexCoordXForm texxform; - texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); - texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); - - graphics_engine.QRP_1Tex(geo.x + ((geo.width - width) / 2), - geo.y + ((geo.height - height) / 2), - width, - height, - texture()->GetDeviceTexture(), - texxform, - col); + if (texture()) + { + unsigned int current_alpha_blend; + unsigned int current_src_blend_factor; + unsigned int current_dest_blend_factor; + graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + float opacity = active ? 1.0f : inactive_opacity_; + int width = 0, height = 0; + GetTextureSize(&width, &height); + + nux::Color col(1.0f * opacity, 1.0f * opacity, 1.0f * opacity, opacity); + nux::TexCoordXForm texxform; + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); + + graphics_engine.QRP_1Tex(geo.x + ((geo.width - width) / 2), + geo.y + ((geo.height - height) / 2), + width, + height, + texture()->GetDeviceTexture(), + texxform, + col); + + graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + } graphics_engine.PopClippingRectangle(); } diff --git a/dash/LensView.cpp b/dash/LensView.cpp index 59919d391..47cb97555 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -34,6 +34,7 @@ #include "unity-shared/UBusWrapper.h" #include "unity-shared/PlacesVScrollBar.h" #include "unity-shared/PlacesOverlayVScrollBar.h" +#include "unity-shared/GraphicsUtils.h" #include "config.h" #include <glib/gi18n-lib.h> @@ -106,12 +107,22 @@ public: up_area_ = area; } - void RedrawScrollbars() + void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { - if (m_horizontal_scrollbar_enable) - _hscrollbar->QueueDraw(); - if (m_vertical_scrollbar_enable) - _vscrollbar->QueueDraw(); + if (RedirectedAncestor()) + { + if (m_horizontal_scrollbar_enable && _hscrollbar->IsRedrawNeeded()) + graphics::ClearGeometry(_hscrollbar->GetGeometry()); + if (m_vertical_scrollbar_enable && _vscrollbar->IsRedrawNeeded()) + graphics::ClearGeometry(_vscrollbar->GetGeometry()); + } + + ScrollView::DrawContent(graphics_engine, force_draw); + } + + void EnableScrolling(bool enable_scrolling) + { + _vscrollbar->SetInputEventSensitivity(enable_scrolling); } protected: @@ -715,46 +726,30 @@ void LensView::OnLensFilterExpanded(bool expanded) } } -void LensView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) +void LensView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { - nux::Geometry const& geo = GetGeometry(); - - gfx_context.PushClippingRectangle(geo); - if (RedirectedAncestor()) - { - unsigned int alpha = 0, src = 0, dest = 0; - gfx_context.GetRenderStates().GetBlend(alpha, src, dest); - gfx_context.GetRenderStates().SetBlend(false); - gfx_context.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - gfx_context.GetRenderStates().SetBlend(alpha, src, dest); - } - - nux::GetPainter().PaintBackground(gfx_context, geo); - gfx_context.PopClippingRectangle(); + graphics::ClearGeometry(GetGeometry()); } -void LensView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) +void LensView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { - gfx_context.PushClippingRectangle(GetGeometry()); + nux::Geometry const& geo(GetGeometry()); + graphics_engine.PushClippingRectangle(geo); - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - if (RedirectedAncestor() && !IsFullRedraw()) + if (!IsFullRedraw() && RedirectedAncestor()) { - // scrollbars are drawn in Draw, not DrawContent, so we need to flag them to redraw. - scroll_view_->RedrawScrollbars(); - fscroll_view_->RedrawScrollbars(); - - unsigned int alpha = 0, src = 0, dest = 0; - gfx_context.GetRenderStates().GetBlend(alpha, src, dest); - gfx_context.GetRenderStates().SetBlend(false); - gfx_context.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - gfx_context.GetRenderStates().SetBlend(alpha, src, dest); + for (PlacesGroup* category : categories_) + { + if (category->IsRedrawNeeded() && category->IsVisible()) + graphics::ClearGeometry(category->GetGeometry()); + } + if (filter_bar_ && filter_bar_->IsVisible() && filter_bar_->IsRedrawNeeded()) + graphics::ClearGeometry(filter_bar_->GetGeometry()); } - layout_->ProcessDraw(gfx_context, force_draw); - gfx_context.PopClippingRectangle(); + layout_->ProcessDraw(graphics_engine, force_draw); + graphics_engine.PopClippingRectangle(); } Lens::Ptr LensView::lens() const diff --git a/dash/LensView.h b/dash/LensView.h index 3f49eb224..af88fa2a3 100644 --- a/dash/LensView.h +++ b/dash/LensView.h @@ -43,6 +43,7 @@ namespace dash { class LensScrollView; + class LensView : public nux::View, public unity::debug::Introspectable { NUX_DECLARE_OBJECT_TYPE(LensView, nux::View); diff --git a/dash/PlacesGroup.cpp b/dash/PlacesGroup.cpp index 7b94e03a8..ddc96212e 100755 --- a/dash/PlacesGroup.cpp +++ b/dash/PlacesGroup.cpp @@ -34,6 +34,7 @@ #include "unity-shared/StaticCairoText.h" #include "unity-shared/UBusWrapper.h" #include "unity-shared/UBusMessages.h" +#include "unity-shared/GraphicsUtils.h" #include "ResultView.h" #include "ResultViewGrid.h" @@ -64,6 +65,8 @@ const int kHighlightLeftPadding = 10; const char* const NAME_LABEL_FONT = "Ubuntu 13"; // 17px = 13 const char* const EXPANDER_LABEL_FONT = "Ubuntu 10"; // 13px = 10 +} + class HeaderView : public nux::View { public: @@ -81,12 +84,16 @@ protected: void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { - if (IsFullRedraw() && GetLayout()) + graphics_engine.PushClippingRectangle(GetGeometry()); + nux::GetPainter().PushPaintLayerStack(); + + if (GetLayout()) { - nux::GetPainter().PushPaintLayerStack(); GetLayout()->ProcessDraw(graphics_engine, force_draw); - nux::GetPainter().PopPaintLayerStack(); } + + nux::GetPainter().PopPaintLayerStack(); + graphics_engine.PopClippingRectangle(); } bool AcceptKeyNavFocus() @@ -104,8 +111,6 @@ protected: } }; -} - NUX_IMPLEMENT_OBJECT_TYPE(PlacesGroup); PlacesGroup::PlacesGroup(dash::StyleInterface& style) @@ -389,7 +394,6 @@ PlacesGroup::OnIdleRelayout() { if (GetChildView()) { - Refresh(); QueueDraw(); _group_layout->QueueDraw(); @@ -419,30 +423,11 @@ long PlacesGroup::ComputeContentSize() void PlacesGroup::Draw(nux::GraphicsEngine& graphics_engine, bool forceDraw) { + nux::Geometry const& base(GetGeometry()); -} - -void -PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) -{ - nux::Geometry const& base = GetGeometry(); graphics_engine.PushClippingRectangle(base); - if (RedirectedAncestor()) - { - // This is necessary when doing redirected rendering. Clean the area below this view. - unsigned int current_alpha_blend; - unsigned int current_src_blend_factor; - unsigned int current_dest_blend_factor; - graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - - graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - } - - if (ShouldBeHighlighted()) + if (ShouldBeHighlighted() && _focus_layer) { nux::Geometry geo(_header_layout->GetGeometry()); geo.width = base.width - kHighlightRightPadding - kHighlightLeftPadding; @@ -454,11 +439,10 @@ PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) if (_background_layer) { - nux::Geometry bg_geo = GetGeometry(); + nux::Geometry bg_geo = base; int bg_width = _background_layer->GetDeviceTexture()->GetWidth(); - bg_geo.x = std::max(bg_geo.width - bg_width,0); - + bg_geo.width = std::min(bg_width, bg_geo.GetWidth()) + 1; // to render into a space left over by the scrollview bg_geo.height = _background->GetHeight(); @@ -466,10 +450,61 @@ PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) _background_layer->Renderlayer(graphics_engine); } - _group_layout->ProcessDraw(graphics_engine, true); - graphics_engine.PopClippingRectangle(); +} +void +PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) +{ + nux::Geometry const& base = GetGeometry(); + graphics_engine.PushClippingRectangle(base); + + int pushed_paint_layers = 0; + if (!IsFullRedraw()) + { + if (RedirectedAncestor()) + { + // Bit tedious. Need to clear the area of the redirected window taken by views + if (_icon->IsRedrawNeeded()) + graphics::ClearGeometry(_icon->GetGeometry()); + if (_name->IsRedrawNeeded()) + graphics::ClearGeometry(_name->GetGeometry()); + if (_expand_label->IsRedrawNeeded()) + graphics::ClearGeometry(_expand_label->GetGeometry()); + if (_expand_icon->IsRedrawNeeded()) + graphics::ClearGeometry(_expand_icon->GetGeometry()); + if (_child_view && _child_view->IsRedrawNeeded()) + graphics::ClearGeometry(_child_view->GetGeometry()); + } + + if (ShouldBeHighlighted() && _focus_layer) + { + ++pushed_paint_layers; + nux::GetPainter().PushLayer(graphics_engine, _focus_layer->GetGeometry(), _focus_layer.get()); + } + if (_background_layer) + { + ++pushed_paint_layers; + nux::GetPainter().PushLayer(graphics_engine, _background_layer->GetGeometry(), _background_layer.get()); + } + } + else + { + nux::GetPainter().PushPaintLayerStack(); + } + + _group_layout->ProcessDraw(graphics_engine, force_draw); + + if (IsFullRedraw()) + { + nux::GetPainter().PopPaintLayerStack(); + } + else if (pushed_paint_layers > 0) + { + nux::GetPainter().PopBackground(pushed_paint_layers); + } + + graphics_engine.PopClippingRectangle(); } void @@ -630,5 +665,5 @@ void PlacesGroup::AddProperties(GVariantBuilder* builder) wrapper.add("name-label-baseline", _name->GetBaseline()); } -} +} // namespace dash } // namespace unity diff --git a/dash/PlacesGroup.h b/dash/PlacesGroup.h index 0ab6c75a6..7f2389835 100644 --- a/dash/PlacesGroup.h +++ b/dash/PlacesGroup.h @@ -41,6 +41,7 @@ namespace nux { class AbstractPaintLayer; +class TextureLayer; } namespace unity @@ -157,7 +158,7 @@ private: friend class TestLensView; }; -} -} +} // namespace dash +} // namespace unity #endif diff --git a/hud/HudController.cpp b/hud/HudController.cpp index 306c3b5f1..6cf992bca 100644 --- a/hud/HudController.cpp +++ b/hud/HudController.cpp @@ -45,11 +45,11 @@ Controller::Controller(Controller::ViewCreator const& create_view, , hud_service_("com.canonical.hud", "/com/canonical/hud") , visible_(false) , need_show_(false) - , timeline_animator_(90) , view_(nullptr) , monitor_index_(0) , create_view_(create_view) , create_window_(create_window) + , timeline_animator_(90) { LOG_DEBUG(logger) << "hud startup"; @@ -101,7 +101,7 @@ Controller::Controller(Controller::ViewCreator const& create_view, wm.initiate_spread.connect(sigc::bind(sigc::mem_fun(this, &Controller::HideHud), true)); hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished)); - timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); + timeline_animator_.updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); EnsureHud(); } @@ -302,6 +302,15 @@ void Controller::ShowHideHud() visible_ ? HideHud(true) : ShowHud(); } +void Controller::ReFocusKeyInput() +{ + if (visible_) + { + window_->PushToFront(); + window_->SetInputFocus(); + } +} + bool Controller::IsVisible() { return visible_; @@ -351,14 +360,7 @@ void Controller::ShowHud() LOG_DEBUG(logger) << "Taking application icon: " << focused_app_icon_; SetIcon(focused_app_icon_); - window_->ShowWindow(true); - window_->PushToFront(); - window_->EnableInputWindow(true, "Hud", true, false); - window_->UpdateInputWindowGeometry(); - window_->SetInputFocus(); - window_->CaptureMouseDownAnyWhereElse(true); - view_->CaptureMouseDownAnyWhereElse(true); - window_->QueueDraw(); + FocusWindow(); view_->ResetToDefault(); need_show_ = true; @@ -376,6 +378,16 @@ void Controller::ShowHud() window_->SetEnterFocusInputArea(view_->default_focus()); } +void Controller::FocusWindow() +{ + window_->ShowWindow(true); + window_->PushToFront(); + window_->EnableInputWindow(true, "Hud", true, false); + window_->UpdateInputWindowGeometry(); + window_->SetInputFocus(); + window_->QueueDraw(); +} + void Controller::HideHud(bool restore) { LOG_DEBUG (logger) << "hiding the hud"; @@ -411,27 +423,31 @@ void Controller::StartShowHideTimeline() { EnsureHud(); - double current_opacity = window_->GetOpacity(); - timeline_animator_.Stop(); - timeline_animator_.Start(visible_ ? current_opacity : 1.0f - current_opacity); + if (timeline_animator_.CurrentState() == nux::animation::Animation::State::Running) + { + timeline_animator_.Reverse(); + } + else + { + if (visible_) + timeline_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start(); + else + timeline_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start(); + } } -void Controller::OnViewShowHideFrame(double progress) +void Controller::OnViewShowHideFrame(double opacity) { - window_->SetOpacity(visible_ ? progress : 1.0f - progress); + window_->SetOpacity(opacity); - if (progress == 1.0f) + if (opacity == 0.0f && !visible_) { - if (!visible_) - { - window_->ShowWindow(false); - view_->ResetToDefault(); - } - else - { - // ensure the text entry is focused - nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); - } + window_->ShowWindow(false); + } + else if (opacity == 1.0f && visible_) + { + // ensure the text entry is focused + nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); } } diff --git a/hud/HudController.h b/hud/HudController.h index fb9467913..15fcdf6a9 100644 --- a/hud/HudController.h +++ b/hud/HudController.h @@ -26,11 +26,11 @@ #include <UnityCore/Hud.h> #include <UnityCore/GLibSignal.h> +#include <NuxCore/Animation.h> #include <NuxCore/Property.h> #include <NuxGraphics/GraphicsEngine.h> #include <Nux/Nux.h> -#include "unity-shared/Animator.h" #include "unity-shared/UBusWrapper.h" #include "unity-shared/ResizingBaseWindow.h" #include "HudView.h" @@ -61,6 +61,7 @@ public: void ShowHideHud(); void ShowHud(); void HideHud(bool restore_focus = true); + void ReFocusKeyInput(); bool IsVisible(); nux::Geometry GetInputWindowGeometry(); @@ -77,6 +78,8 @@ private: void RegisterUBusInterests(); void SetIcon(std::string const& icon_name); + void FocusWindow(); + int GetIdealMonitor(); bool IsLockedToLauncher(int monitor); @@ -103,14 +106,10 @@ private: private: nux::ObjectPtr<ResizingBaseWindow> window_; - UBusManager ubus; - glib::SignalManager sig_manager_; Hud hud_service_; bool visible_; bool need_show_; - Animator timeline_animator_; - AbstractView* view_; std::string focused_app_icon_; nux::Layout* layout_; @@ -119,6 +118,10 @@ private: ViewCreator create_view_; WindowCreator create_window_; + + UBusManager ubus; + glib::SignalManager sig_manager_; + nux::animation::AnimateValue<double> timeline_animator_; }; } // namespace hud diff --git a/launcher/ApplicationLauncherIcon.cpp b/launcher/ApplicationLauncherIcon.cpp index e9cc7bde8..cbae24243 100644 --- a/launcher/ApplicationLauncherIcon.cpp +++ b/launcher/ApplicationLauncherIcon.cpp @@ -973,16 +973,21 @@ std::string ApplicationLauncherIcon::GetDesktopID() return DesktopUtilities::GetDesktopID(desktop_file); } -std::string ApplicationLauncherIcon::GetRemoteUri() +void ApplicationLauncherIcon::UpdateRemoteUri() { - if (_remote_uri.empty()) - { std::string const& desktop_id = GetDesktopID(); if (!desktop_id.empty()) { _remote_uri = FavoriteStore::URI_PREFIX_APP + desktop_id; } +} + +std::string ApplicationLauncherIcon::GetRemoteUri() +{ + if (_remote_uri.empty()) + { + UpdateRemoteUri(); } return _remote_uri; diff --git a/launcher/ApplicationLauncherIcon.h b/launcher/ApplicationLauncherIcon.h index ceef2323f..6e756bfdd 100644 --- a/launcher/ApplicationLauncherIcon.h +++ b/launcher/ApplicationLauncherIcon.h @@ -89,6 +89,12 @@ protected: bool HandlesSpread() { return true; } std::string GetName() const; +protected: + void UpdateDesktopFile(); + void UpdateRemoteUri(); + std::string _desktop_file; + ApplicationPtr app_; + private: typedef unsigned long int WindowFilterMask; enum WindowFilter @@ -102,7 +108,6 @@ private: void EnsureWindowState(); void EnsureMenuItemsReady(); void UpdateBackgroundColor(); - void UpdateDesktopFile(); void UpdateMenus(); void UpdateDesktopQuickList(); @@ -117,10 +122,8 @@ private: const std::set<std::string> GetSupportedTypes(); std::string GetDesktopID(); - ApplicationPtr app_; - std::string _remote_uri; - std::string _desktop_file; + std::set<std::string> _supported_types; std::map<std::string, glib::Object<DbusmenuClient>> _menu_clients; std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items; std::map<std::string, glib::Object<DbusmenuMenuitem>> _menu_items_extra; diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index 4f549cc3d..c3f52b3fa 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -36,21 +36,6 @@ struct EdgeBarrierController::Impl void OnPointerBarrierEvent(PointerBarrierWrapper* owner, BarrierEvent::Ptr event); void BarrierRelease(PointerBarrierWrapper* owner, int event); - bool StickyEdgeSetter(bool const& new_val) - { - if (parent_->options() && new_val != parent_->options()->edge_resist()) - { - parent_->options()->edge_resist = new_val; - return true; - } - return false; - } - - bool StickyEdgeGetter() - { - return parent_->options() ? parent_->options()->edge_resist() : false; - } - std::vector<PointerBarrierWrapper::Ptr> barriers_; std::vector<EdgeBarrierSubscriber*> subscribers_; Decaymulator decaymulator_; @@ -73,15 +58,11 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) SetupBarriers(layout); }); - parent_->sticky_edges.SetGetterFunction(sigc::mem_fun(this, &Impl::StickyEdgeGetter)); - parent_->sticky_edges.SetSetterFunction(sigc::mem_fun(this, &Impl::StickyEdgeSetter)); - -/* Set this back, once lp:~3v1n0/nux/use-std-function is merged - parent_->sticky_edges.SetGetterFunction([parent_] { + parent_->sticky_edges.SetGetterFunction([this] { return parent_->options() ? parent_->options()->edge_resist() : false; }); - parent_->sticky_edges.SetSetterFunction([parent_] (bool const& new_val) { + parent_->sticky_edges.SetSetterFunction([this] (bool const& new_val) { if (parent_->options() && new_val != parent_->options()->edge_resist()) { parent_->options()->edge_resist = new_val; @@ -89,7 +70,6 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) } return false; }); - */ parent_->options.changed.connect([&](launcher::Options::Ptr options) { options->option_changed.connect([&]() { diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index b8b6da0d8..a06f0da49 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -1193,14 +1193,16 @@ void LauncherIcon::EmitRemove() void LauncherIcon::Stick(bool save) { + // allow save() even for already "_sticky" icons that may have been + // made _sticky without "save" (like SoftwareCenterApplications) + if (save) + position_saved.emit(); + if (_sticky) return; _sticky = true; - if (save) - position_saved.emit(); - SetQuirk(Quirk::VISIBLE, true); } diff --git a/launcher/SoftwareCenterLauncherIcon.cpp b/launcher/SoftwareCenterLauncherIcon.cpp index cd94f06ae..3d024cfe7 100644 --- a/launcher/SoftwareCenterLauncherIcon.cpp +++ b/launcher/SoftwareCenterLauncherIcon.cpp @@ -16,15 +16,19 @@ * * Authored by: Bilal Akhtar <bilalakhtar@ubuntu.com> * Marco Trevisan (Treviño) <3v1n0@ubuntu.com> + * Michael Vogt <mvo@ubuntu.com> */ -#include <NuxCore/Logger.h> #include "config.h" + +#include <NuxCore/Logger.h> +#include <glib.h> #include <glib/gi18n-lib.h> #include "SoftwareCenterLauncherIcon.h" #include "Launcher.h" #include "LauncherDragWindow.h" #include "LauncherModel.h" +#include "DesktopUtilities.h" namespace unity { @@ -69,6 +73,14 @@ void SoftwareCenterLauncherIcon::Animate(nux::ObjectPtr<Launcher> const& launche { launcher_ = launcher; + // FIXME: this needs testing, if there is no useful coordinates + // then do not animate + if(start_x <= 0 && start_y <= 0) + { + SetQuirk(Quirk::VISIBLE, true); + return; + } + icon_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableDeviceTexture( launcher->GetWidth(), launcher->GetWidth(), @@ -118,6 +130,63 @@ void SoftwareCenterLauncherIcon::ActivateLauncherIcon(ActionArg arg) } } +std::string SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall() +{ + // Fixup the _desktop_file because the one we get from software-center + // is not the final one, e.g. the s-c-agent does send a temp one and + // app-install-data points to the "wrong" one in /usr/share/app-install + // + // So: + // - if there is a desktop file already and it startswith + // /usr/share/app-install/desktop, then transform to + // /usr/share/application + // - if there is a desktop file with prefix /tmp/software-center-agent: + // transform to /usr/share/application + // (its using "/tmp/software-center-agent:$random:$pkgname.desktop") + // maybe: + // - and search in /var/lib/apt/lists/$pkgname.list + // for a desktop file that roughly matches what we want + std::string filename = _desktop_file; + + // take /usr/share/app-install/desktop/foo:subdir__bar.desktop + // and tranform it + if (_desktop_file.find("/share/app-install/desktop/") != std::string::npos) + { + filename = filename.substr(filename.rfind(":") + 1, + filename.length() - filename.rfind(":")); + // the app-install-data package encodes subdirs in a funny way, once + // that is fixed, this code can be dropped + if (filename.find("__") != std::string::npos) + { + int pos = filename.find("__"); + filename = filename.replace(pos, 2, "-"); + } + filename = DesktopUtilities::GetDesktopPathById(filename); + return filename; + } + else if (_desktop_file.find("/tmp/software-center-agent:") == 0) + { + // by convention the software-center-agent uses + // /usr/share/applications/$pkgname.desktop + // or + // /usr/share/applications/extras-$pkgname.desktop + std::string desktopf = filename.substr(filename.rfind(":") + 1, + filename.length() - filename.rfind(":")); + filename = DesktopUtilities::GetDesktopPathById(desktopf); + if (filename.size() > 0) + return filename; + // now try extras-$pkgname.desktop + filename = DesktopUtilities::GetDesktopPathById(std::string("extras-") + desktopf); + if (filename.size() > 0) + return filename; + + // FIXME: test if there is a file now and if not, search + // /var/lib/dpkg/info/$pkgname.list for a desktop file + } + + return _desktop_file; +} + void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) { glib::String exit_state; @@ -132,6 +201,18 @@ void SoftwareCenterLauncherIcon::OnFinished(GVariant *params) finished_ = true; needs_urgent_ = true; + // find and update to the real desktop file + std::string new_desktop_path = GetActualDesktopFileAfterInstall(); + + // exchange the temp Application with the real one + app_ = ApplicationManager::Default().GetApplicationForDesktopFile(new_desktop_path); + + UpdateDesktopFile(); + UpdateRemoteUri(); + + // make it permanent + Stick(true); + _source_manager.AddIdle([this]() { ShowTooltip(); diff --git a/launcher/SoftwareCenterLauncherIcon.h b/launcher/SoftwareCenterLauncherIcon.h index 6f0306855..1b1b6970c 100644 --- a/launcher/SoftwareCenterLauncherIcon.h +++ b/launcher/SoftwareCenterLauncherIcon.h @@ -47,11 +47,12 @@ public: std::string GetName() const; protected: + std::string GetActualDesktopFileAfterInstall(); void ActivateLauncherIcon(ActionArg arg); + void OnFinished(GVariant *params); private: void OnPropertyChanged(GVariant* params); - void OnFinished(GVariant *params); void OnDragAnimationFinished(); glib::DBusProxy aptdaemon_trans_; @@ -61,7 +62,6 @@ private: nux::ObjectPtr<Launcher> launcher_; bool finished_; bool needs_urgent_; - std::string aptdaemon_trans_id_; std::string app_title_; }; diff --git a/panel/PanelIndicatorsView.cpp b/panel/PanelIndicatorsView.cpp index 7a1d6f028..7f8e0671e 100644 --- a/panel/PanelIndicatorsView.cpp +++ b/panel/PanelIndicatorsView.cpp @@ -51,7 +51,7 @@ PanelIndicatorsView::PanelIndicatorsView() PanelIndicatorsView::~PanelIndicatorsView() { - for (auto ind : indicators_connections_) + for (auto const& ind : indicators_connections_) { for (auto conn : ind.second) conn.disconnect(); @@ -81,13 +81,13 @@ PanelIndicatorsView::RemoveIndicator(Indicator::Ptr const& indicator) auto connections = indicators_connections_.find(indicator); if (connections != indicators_connections_.end()) { - for (auto conn : connections->second) + for (auto& conn : connections->second) conn.disconnect(); indicators_connections_.erase(indicator); } - for (auto entry : indicator->GetEntries()) + for (auto const& entry : indicator->GetEntries()) OnEntryRemoved(entry->id()); for (auto i = indicators_.begin(); i != indicators_.end(); i++) @@ -205,7 +205,7 @@ PanelIndicatorsView::ActivateEntryAt(int x, int y, int button) // which causes visible lag in many cases. // - for (auto entry : entries_) + for (auto const& entry : entries_) { PanelIndicatorEntryView* view = entry.second; @@ -227,7 +227,7 @@ PanelIndicatorsView::ActivateEntryAt(int x, int y, int button) if (target && !found_old_active) { - for (auto entry : entries_) + for (auto const& entry : entries_) { PanelIndicatorEntryView* view = entry.second; @@ -372,7 +372,7 @@ PanelIndicatorsView::SetOpacity(double opacity) { opacity = CLAMP(opacity, 0.0f, 1.0f); - for (auto entry: entries_) + for (auto const& entry : entries_) entry.second->SetOpacity(opacity); if (opacity_ != opacity) diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp index d01b52b09..9631b73d0 100644 --- a/panel/PanelMenuView.cpp +++ b/panel/PanelMenuView.cpp @@ -34,6 +34,8 @@ #include "config.h" #include <glib/gi18n-lib.h> +namespace na = nux::animation; + namespace unity { DECLARE_LOGGER(logger, "unity.panel.menu"); @@ -57,68 +59,66 @@ namespace } PanelMenuView::PanelMenuView() - : _matcher(bamf_matcher_get_default()), - _is_inside(false), - _is_grabbed(false), - _is_maximized(false), - _last_active_view(nullptr), - _new_application(nullptr), - _overlay_showing(false), - _switcher_showing(false), - _launcher_keynav(false), - _show_now_activated(false), - _we_control_active(false), - _new_app_menu_shown(false), - _monitor(0), - _active_xid(0), - _desktop_name(_("Ubuntu Desktop")), - _menus_fadein(DEFAULT_MENUS_FADEIN), - _menus_fadeout(DEFAULT_MENUS_FADEOUT), - _menus_discovery(DEFAULT_MENUS_DISCOVERY), - _menus_discovery_fadein(DEFAULT_DISCOVERY_FADEIN), - _menus_discovery_fadeout(DEFAULT_DISCOVERY_FADEOUT), - _fade_in_animator(_menus_fadein), - _fade_out_animator(_menus_fadeout) + : matcher_(bamf_matcher_get_default()) + , is_inside_(false) + , is_grabbed_(false) + , is_maximized_(false) + , last_active_view_(nullptr) + , new_application_(nullptr) + , overlay_showing_(false) + , switcher_showing_(false) + , launcher_keynav_(false) + , show_now_activated_(false) + , we_control_active_(false) + , new_app_menu_shown_(false) + , monitor_(0) + , active_xid_(0) + , desktop_name_(_("Ubuntu Desktop")) + , menus_fadein_(DEFAULT_MENUS_FADEIN) + , menus_fadeout_(DEFAULT_MENUS_FADEOUT) + , menus_discovery_(DEFAULT_MENUS_DISCOVERY) + , menus_discovery_fadein_(DEFAULT_DISCOVERY_FADEIN) + , menus_discovery_fadeout_(DEFAULT_DISCOVERY_FADEOUT) { layout_->SetContentDistribution(nux::MAJOR_POSITION_START); - BamfWindow* active_win = bamf_matcher_get_active_window(_matcher); + BamfWindow* active_win = bamf_matcher_get_active_window(matcher_); if (BAMF_IS_WINDOW(active_win)) - _active_xid = bamf_window_get_xid(active_win); + active_xid_ = bamf_window_get_xid(active_win); - _view_opened_signal.Connect(_matcher, "view-opened", + view_opened_signal_.Connect(matcher_, "view-opened", sigc::mem_fun(this, &PanelMenuView::OnViewOpened)); - _view_closed_signal.Connect(_matcher, "view-closed", + view_closed_signal_.Connect(matcher_, "view-closed", sigc::mem_fun(this, &PanelMenuView::OnViewClosed)); - _active_win_changed_signal.Connect(_matcher, "active-window-changed", + active_win_changed_signal_.Connect(matcher_, "active-window-changed", sigc::mem_fun(this, &PanelMenuView::OnActiveWindowChanged)); - _active_app_changed_signal.Connect(_matcher, "active-application-changed", + active_app_changed_signal_.Connect(matcher_, "active-application-changed", sigc::mem_fun(this, &PanelMenuView::OnActiveAppChanged)); - _window_buttons = new WindowButtons(); - _window_buttons->SetParentObject(this); - _window_buttons->SetMonitor(_monitor); - _window_buttons->SetControlledWindow(_active_xid); - _window_buttons->SetLeftAndRightPadding(MAIN_LEFT_PADDING, MENUBAR_PADDING); - _window_buttons->SetMaximumHeight(panel::Style::Instance().panel_height); - _window_buttons->ComputeContentSize(); + window_buttons_ = new WindowButtons(); + window_buttons_->SetParentObject(this); + window_buttons_->SetMonitor(monitor_); + window_buttons_->SetControlledWindow(active_xid_); + window_buttons_->SetLeftAndRightPadding(MAIN_LEFT_PADDING, MENUBAR_PADDING); + window_buttons_->SetMaximumHeight(panel::Style::Instance().panel_height); + window_buttons_->ComputeContentSize(); - _window_buttons->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); - _window_buttons->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); - AddChild(_window_buttons.GetPointer()); + window_buttons_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); + window_buttons_->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); + AddChild(window_buttons_.GetPointer()); - layout_->SetLeftAndRightPadding(_window_buttons->GetContentWidth(), 0); + layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0); layout_->SetBaseHeight(panel::Style::Instance().panel_height); - _titlebar_grab_area = new PanelTitlebarGrabArea(); - _titlebar_grab_area->SetParentObject(this); - _titlebar_grab_area->activate_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedActivate)); - _titlebar_grab_area->restore_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedRestore)); - _titlebar_grab_area->lower_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedLower)); - _titlebar_grab_area->grab_started.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabStart)); - _titlebar_grab_area->grab_move.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabMove)); - _titlebar_grab_area->grab_end.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd)); - AddChild(_titlebar_grab_area.GetPointer()); + titlebar_grab_area_ = new PanelTitlebarGrabArea(); + titlebar_grab_area_->SetParentObject(this); + titlebar_grab_area_->activate_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedActivate)); + titlebar_grab_area_->restore_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedRestore)); + titlebar_grab_area_->lower_request.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedLower)); + titlebar_grab_area_->grab_started.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabStart)); + titlebar_grab_area_->grab_move.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabMove)); + titlebar_grab_area_->grab_end.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd)); + AddChild(titlebar_grab_area_.GetPointer()); WindowManager& wm = WindowManager::Default(); wm.window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized)); @@ -137,9 +137,9 @@ PanelMenuView::PanelMenuView() wm.terminate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); - _style_changed_connection = panel::Style::Instance().changed.connect([&] { - _window_buttons->ComputeContentSize(); - layout_->SetLeftAndRightPadding(_window_buttons->GetContentWidth(), 0); + style_changed_connection_ = panel::Style::Instance().changed.connect([&] { + window_buttons_->ComputeContentSize(); + layout_->SetLeftAndRightPadding(window_buttons_->GetContentWidth(), 0); Refresh(true); FullRedraw(); @@ -149,24 +149,21 @@ PanelMenuView::PanelMenuView() mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); //mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); - _titlebar_grab_area->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); - _titlebar_grab_area->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); + titlebar_grab_area_->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); + titlebar_grab_area_->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); - _ubus_manager.RegisterInterest(UBUS_SWITCHER_SHOWN, sigc::mem_fun(this, &PanelMenuView::OnSwitcherShown)); + ubus_manager_.RegisterInterest(UBUS_SWITCHER_SHOWN, sigc::mem_fun(this, &PanelMenuView::OnSwitcherShown)); - _ubus_manager.RegisterInterest(UBUS_LAUNCHER_START_KEY_NAV, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavStarted)); - _ubus_manager.RegisterInterest(UBUS_LAUNCHER_END_KEY_NAV, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavEnded)); - _ubus_manager.RegisterInterest(UBUS_LAUNCHER_START_KEY_SWITCHER, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavStarted)); - _ubus_manager.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWITCHER, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavEnded)); - _ubus_manager.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, sigc::mem_fun(this, &PanelMenuView::OnLauncherSelectionChanged)); + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_NAV, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavStarted)); + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_NAV, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavEnded)); + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_START_KEY_SWITCHER, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavStarted)); + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWITCHER, sigc::mem_fun(this, &PanelMenuView::OnLauncherKeyNavEnded)); + ubus_manager_.RegisterInterest(UBUS_LAUNCHER_SELECTION_CHANGED, sigc::mem_fun(this, &PanelMenuView::OnLauncherSelectionChanged)); - _fade_in_animator.animation_updated.connect(sigc::mem_fun(this, &PanelMenuView::OnFadeInChanged)); - _fade_in_animator.animation_ended.connect(sigc::mem_fun(this, &PanelMenuView::FullRedraw)); - _fade_out_animator.animation_updated.connect(sigc::mem_fun(this, &PanelMenuView::OnFadeOutChanged)); - _fade_out_animator.animation_ended.connect(sigc::mem_fun(this, &PanelMenuView::FullRedraw)); + opacity_animator_.updated.connect(sigc::mem_fun(this, &PanelMenuView::OnFadeAnimatorUpdated)); SetOpacity(0.0f); - _window_buttons->SetOpacity(0.0f); + window_buttons_->SetOpacity(0.0f); Refresh(); FullRedraw(); @@ -174,20 +171,20 @@ PanelMenuView::PanelMenuView() PanelMenuView::~PanelMenuView() { - _style_changed_connection.disconnect(); - _window_buttons->UnParentObject(); - _titlebar_grab_area->UnParentObject(); + style_changed_connection_.disconnect(); + window_buttons_->UnParentObject(); + titlebar_grab_area_->UnParentObject(); } void PanelMenuView::OverlayShown() { - _overlay_showing = true; + overlay_showing_ = true; QueueDraw(); } void PanelMenuView::OverlayHidden() { - _overlay_showing = false; + overlay_showing_ = false; QueueDraw(); } @@ -206,31 +203,25 @@ void PanelMenuView::SetMenuShowTimings(int fadein, int fadeout, int discovery, int discovery_fadein, int discovery_fadeout) { if (fadein > -1) - { - _menus_fadein = fadein; - _fade_in_animator.SetDuration(_menus_fadein); - } + menus_fadein_ = fadein; if (fadeout > -1) - { - _menus_fadeout = fadeout; - _fade_out_animator.SetDuration(_menus_fadeout); - } + menus_fadeout_ = fadeout; if (discovery > -1) - _menus_discovery = discovery; + menus_discovery_ = discovery; if (discovery_fadein > -1) - _menus_discovery_fadein = discovery_fadein; + menus_discovery_fadein_ = discovery_fadein; if (discovery_fadeout > -1) - _menus_discovery_fadeout = discovery_fadeout; + menus_discovery_fadeout_ = discovery_fadeout; } void PanelMenuView::FullRedraw() { QueueDraw(); - _window_buttons->QueueDraw(); + window_buttons_->QueueDraw(); } nux::Area* PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type) @@ -242,31 +233,31 @@ nux::Area* PanelMenuView::FindAreaUnderMouse(const nux::Point& mouse_position, n Area* found_area = nullptr; - if (_overlay_showing) + if (overlay_showing_) { - if (_window_buttons) - return _window_buttons->FindAreaUnderMouse(mouse_position, event_type); + if (window_buttons_) + return window_buttons_->FindAreaUnderMouse(mouse_position, event_type); } - if (!_we_control_active) + if (!we_control_active_) { /* When the current panel is not active, it all behaves like a grab-area */ if (GetAbsoluteGeometry().IsInside(mouse_position)) - return _titlebar_grab_area.GetPointer(); + return titlebar_grab_area_.GetPointer(); } - if (_is_maximized) + if (is_maximized_) { - if (_window_buttons) + if (window_buttons_) { - found_area = _window_buttons->FindAreaUnderMouse(mouse_position, event_type); + found_area = window_buttons_->FindAreaUnderMouse(mouse_position, event_type); NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area); } } - if (_titlebar_grab_area && !_overlay_showing) + if (titlebar_grab_area_ && !overlay_showing_) { - found_area = _titlebar_grab_area->FindAreaUnderMouse(mouse_position, event_type); + found_area = titlebar_grab_area_->FindAreaUnderMouse(mouse_position, event_type); NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area); } @@ -278,43 +269,67 @@ void PanelMenuView::PreLayoutManagement() PanelIndicatorsView::PreLayoutManagement(); nux::Geometry const& geo = GetGeometry(); - _window_buttons->ComputeContentSize(); - int buttons_diff = geo.height - _window_buttons->GetContentHeight(); - _window_buttons->SetBaseY(buttons_diff > 0 ? std::ceil(buttons_diff/2.0f) : 0); + window_buttons_->ComputeContentSize(); + int buttons_diff = geo.height - window_buttons_->GetContentHeight(); + window_buttons_->SetBaseY(buttons_diff > 0 ? std::ceil(buttons_diff/2.0f) : 0); layout_->ComputeContentSize(); int layout_width = layout_->GetContentWidth(); - _titlebar_grab_area->SetBaseX(layout_width); - _titlebar_grab_area->SetBaseHeight(geo.height); - _titlebar_grab_area->SetMinimumWidth(geo.width - layout_width); - _titlebar_grab_area->SetMaximumWidth(geo.width - layout_width); + titlebar_grab_area_->SetBaseX(layout_width); + titlebar_grab_area_->SetBaseHeight(geo.height); + titlebar_grab_area_->SetMinimumWidth(geo.width - layout_width); + titlebar_grab_area_->SetMaximumWidth(geo.width - layout_width); - SetMaximumEntriesWidth(geo.width - _window_buttons->GetContentWidth()); + SetMaximumEntriesWidth(geo.width - window_buttons_->GetContentWidth()); } -void PanelMenuView::OnFadeInChanged(double opacity) +void PanelMenuView::StartFadeIn(int duration) { - if (DrawMenus() && GetOpacity() != 1.0f) - SetOpacity(opacity); + if (opacity_animator_.CurrentState() == na::Animation::State::Running) + { + if (opacity_animator_.GetFinishValue() != 1.0f) + opacity_animator_.Reverse(); - if (DrawWindowButtons() && _window_buttons->GetOpacity() != 1.0f) - _window_buttons->SetOpacity(opacity); + return; + } - QueueDraw(); + opacity_animator_.SetDuration(duration >= 0 ? duration : menus_fadein_); + opacity_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start(); } -void PanelMenuView::OnFadeOutChanged(double progress) +void PanelMenuView::StartFadeOut(int duration) { - double opacity = CLAMP(1.0f - progress, 0.0f, 1.0f); + if (opacity_animator_.CurrentState() == na::Animation::State::Running) + { + if (opacity_animator_.GetFinishValue() != 0.0f) + opacity_animator_.Reverse(); - if (!DrawMenus() && GetOpacity() != 0.0f) - SetOpacity(opacity); + return; + } - if (!DrawWindowButtons() && _window_buttons->GetOpacity() != 0.0f) - _window_buttons->SetOpacity(opacity); + opacity_animator_.SetDuration(duration >= 0 ? duration : menus_fadeout_); + opacity_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start(); +} - QueueDraw(); +void PanelMenuView::OnFadeAnimatorUpdated(double opacity) +{ + if (opacity_animator_.GetFinishValue() == 1.0f) /* Fading in... */ + { + if (DrawMenus() && GetOpacity() != 1.0f) + SetOpacity(opacity); + + if (DrawWindowButtons() && window_buttons_->GetOpacity() != 1.0f) + window_buttons_->SetOpacity(opacity); + } + else if (opacity_animator_.GetFinishValue() == 0.0f) /* Fading out... */ + { + if (!DrawMenus() && GetOpacity() != 0.0f) + SetOpacity(opacity); + + if (!DrawWindowButtons() && window_buttons_->GetOpacity() != 0.0f) + window_buttons_->SetOpacity(opacity); + } } bool PanelMenuView::DrawMenus() const @@ -322,10 +337,10 @@ bool PanelMenuView::DrawMenus() const WindowManager& wm = WindowManager::Default(); bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive()); - if (_we_control_active && !_overlay_showing && !screen_grabbed && - !_switcher_showing && !_launcher_keynav) + if (we_control_active_ && !overlay_showing_ && !screen_grabbed && + !switcher_showing_ && !launcher_keynav_ && !entries_.empty()) { - if (_is_inside || _last_active_view || _show_now_activated || _new_application) + if (is_inside_ || last_active_view_ || show_now_activated_ || new_application_) { return true; } @@ -339,13 +354,13 @@ bool PanelMenuView::DrawWindowButtons() const WindowManager& wm = WindowManager::Default(); bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive()); - if (_overlay_showing) + if (overlay_showing_) return true; - if (_we_control_active && _is_maximized && !screen_grabbed && - !_launcher_keynav && !_switcher_showing) + if (we_control_active_ && is_maximized_ && !screen_grabbed && + !launcher_keynav_ && !switcher_showing_) { - if (_is_inside || _show_now_activated || _new_application) + if (is_inside_ || show_now_activated_ || new_application_) { return true; } @@ -357,13 +372,13 @@ bool PanelMenuView::DrawWindowButtons() const void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { nux::Geometry const& geo = GetGeometry(); - int button_width = _window_buttons->GetContentWidth(); + int button_width = window_buttons_->GetContentWidth(); const float factor = 4; button_width /= factor; - if (geo != _last_geo) + if (geo != last_geo_) { - _last_geo = geo; + last_geo_ = geo; QueueRelayout(); Refresh(true); } @@ -379,7 +394,7 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) nux::ColorLayer layer(nux::Color(0x00000000), true, rop); nux::GetPainter().PushDrawLayer(GfxContext, GetGeometry(), &layer); - if (_title_texture) + if (title_texture_) { guint blend_alpha = 0, blend_src = 0, blend_dest = 0; bool draw_menus = DrawMenus(); @@ -389,7 +404,7 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) GfxContext.GetRenderStates().GetBlend(blend_alpha, blend_src, blend_dest); - for (auto entry : entries_) + for (auto const& entry : entries_) { if (entry.second->IsVisible()) { @@ -398,8 +413,8 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) } } - if (!draw_window_buttons && _we_control_active && has_menu && - (draw_menus || (GetOpacity() > 0.0f && _window_buttons->GetOpacity() == 0.0f))) + if (!draw_window_buttons && we_control_active_ && has_menu && + (draw_menus || (GetOpacity() > 0.0f && window_buttons_->GetOpacity() == 0.0f))) { draw_faded_title = true; } @@ -411,13 +426,13 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) lockrect.pBits = 0; bool locked = false; - if (_gradient_texture.IsNull() || (_gradient_texture->GetWidth() != geo.width)) + if (gradient_texture_.IsNull() || (gradient_texture_->GetWidth() != geo.width)) { build_gradient = true; } else { - if (_gradient_texture->LockRect(0, &lockrect, nullptr) != OGL_OK) + if (gradient_texture_->LockRect(0, &lockrect, nullptr) != OGL_OK) build_gradient = true; else locked = true; @@ -427,7 +442,7 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) build_gradient = true; if (locked) - _gradient_texture->UnlockRect(0); + gradient_texture_->UnlockRect(0); } } @@ -435,15 +450,15 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { nux::NTextureData texture_data(nux::BITFMT_R8G8B8A8, geo.width, 1, 1); - _gradient_texture = nux::GetGraphicsDisplay()->GetGpuDevice()-> + gradient_texture_ = nux::GetGraphicsDisplay()->GetGpuDevice()-> CreateSystemCapableDeviceTexture(texture_data.GetWidth(), texture_data.GetHeight(), 1, texture_data.GetFormat()); - locked = (_gradient_texture->LockRect(0, &lockrect, nullptr) == OGL_OK); + locked = (gradient_texture_->LockRect(0, &lockrect, nullptr) == OGL_OK); } BYTE* dest_buffer = (BYTE*) lockrect.pBits; int gradient_opacity = 255.0f * GetOpacity(); - int buttons_opacity = 255.0f * _window_buttons->GetOpacity(); + int buttons_opacity = 255.0f * window_buttons_->GetOpacity(); int first_step = button_width * (factor - 1); int second_step = button_width * factor; @@ -492,7 +507,7 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) // FIXME Nux shouldn't make unity to crash if we try to unlock a wrong rect if (locked) - _gradient_texture->UnlockRect(0); + gradient_texture_->UnlockRect(0); GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -502,17 +517,17 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) // Modulate the checkboard and the gradient texture GfxContext.QRP_2TexMod(geo.x, geo.y, geo.width, geo.height, - _gradient_texture, texxform0, + gradient_texture_, texxform0, nux::color::White, - _title_texture->GetDeviceTexture(), + title_texture_->GetDeviceTexture(), texxform1, nux::color::White); } - else if (!_overlay_showing) + else if (!overlay_showing_) { double title_opacity = 0.0f; - if (_we_control_active && _window_buttons->GetOpacity() == 0.0 && + if (we_control_active_ && window_buttons_->GetOpacity() == 0.0 && (!has_menu || (has_menu && GetOpacity() == 0.0))) { title_opacity = 1.0f; @@ -522,9 +537,9 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) title_opacity = 1.0f; if (has_menu) - title_opacity -= MAX(GetOpacity(), _window_buttons->GetOpacity()); + title_opacity -= MAX(GetOpacity(), window_buttons_->GetOpacity()); else - title_opacity -= _window_buttons->GetOpacity(); + title_opacity -= window_buttons_->GetOpacity(); if (!draw_window_buttons && !draw_menus) { @@ -542,7 +557,7 @@ void PanelMenuView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { nux::TexCoordXForm texxform; GfxContext.QRP_1Tex(geo.x, geo.y, geo.width, geo.height, - _title_texture->GetDeviceTexture(), texxform, + title_texture_->GetDeviceTexture(), texxform, nux::color::White * title_opacity); } } @@ -565,65 +580,51 @@ void PanelMenuView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw if (draw_menus) { - for (auto entry : entries_) + for (auto const& entry : entries_) entry.second->SetDisabled(false); layout_->ProcessDraw(GfxContext, true); - _fade_out_animator.Stop(); - - if (_new_application && !_is_inside) + if (new_application_ && !is_inside_) { - _fade_in_animator.Start(_menus_discovery_fadein, GetOpacity()); + if (GetOpacity() != 1.0f) + StartFadeIn(menus_discovery_fadein_); } else { - _fade_in_animator.Start(GetOpacity()); - _new_app_menu_shown = false; + if (GetOpacity() != 1.0f) + StartFadeIn(); + + new_app_menu_shown_ = false; } } - else - { - for (auto entry : entries_) - entry.second->SetDisabled(true); - } - - if (GetOpacity() != 0.0f && !draw_menus && !_overlay_showing) + else /* if (!draw_menus) */ { - layout_->ProcessDraw(GfxContext, true); - - _fade_in_animator.Stop(); - - if (!_new_app_menu_shown) + if (GetOpacity() != 0.0f && !overlay_showing_) { - _fade_out_animator.Start(1.0f - GetOpacity()); - } - else - { - _fade_out_animator.Start(_menus_discovery_fadeout, 1.0f - GetOpacity()); + layout_->ProcessDraw(GfxContext, true); + StartFadeOut(new_app_menu_shown_ ? menus_discovery_fadeout_ : -1); } + + for (auto const& entry : entries_) + entry.second->SetDisabled(true); } if (draw_buttons) { - _window_buttons->ProcessDraw(GfxContext, true); + window_buttons_->ProcessDraw(GfxContext, true); - if (_window_buttons->GetOpacity() != 1.0f) - { - _fade_out_animator.Stop(); - _fade_in_animator.Start(_window_buttons->GetOpacity()); - } + if (window_buttons_->GetOpacity() != 1.0f) + StartFadeIn(); } - - if (_window_buttons->GetOpacity() != 0.0f && !draw_buttons) + else if (/*!draw_buttons &&*/ window_buttons_->GetOpacity() != 0.0f) { - _window_buttons->ProcessDraw(GfxContext, true); - _fade_in_animator.Stop(); + window_buttons_->ProcessDraw(GfxContext, true); /* If we try to hide only the buttons, then use a faster fadeout */ - if (!_fade_out_animator.IsRunning()) + if (opacity_animator_.CurrentState() != na::Animation::Running) { - _fade_out_animator.Start(_menus_fadeout/3, 1.0f - _window_buttons->GetOpacity()); + StartFadeOut(menus_fadeout_/3); } } @@ -635,7 +636,7 @@ std::string PanelMenuView::GetActiveViewName(bool use_appname) const std::string label; BamfWindow* window; - window = bamf_matcher_get_active_window(_matcher); + window = bamf_matcher_get_active_window(matcher_); if (BAMF_IS_WINDOW(window)) { @@ -661,7 +662,7 @@ std::string PanelMenuView::GetActiveViewName(bool use_appname) const if (bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) { - label = _desktop_name; + label = desktop_name_; } else if (!IsValidWindow(window_xid)) { @@ -676,7 +677,7 @@ std::string PanelMenuView::GetActiveViewName(bool use_appname) const if (label.empty()) { BamfApplication* app; - app = bamf_matcher_get_application_for_window(_matcher, window); + app = bamf_matcher_get_application_for_window(matcher_, window); if (BAMF_IS_APPLICATION(app)) { @@ -780,7 +781,7 @@ void PanelMenuView::DrawTitle(cairo_t *cr_real, nux::Geometry const& geo, std::s std::string PanelMenuView::GetCurrentTitle() const { - if (!_switcher_showing && !_launcher_keynav) + if (!switcher_showing_ && !launcher_keynav_) { WindowManager& wm = WindowManager::Default(); std::string new_title; @@ -789,24 +790,24 @@ std::string PanelMenuView::GetCurrentTitle() const { if (wm.IsScaleActiveForGroup()) new_title = GetActiveViewName(true); - else if (_we_control_active) - new_title = _desktop_name; + else if (we_control_active_) + new_title = desktop_name_; } else if (wm.IsExpoActive()) { - new_title = _desktop_name; + new_title = desktop_name_; } - else if (!_we_control_active) + else if (!we_control_active_) { new_title = ""; } else { new_title = GetActiveViewName(); - _window_buttons->SetControlledWindow(_active_xid); + window_buttons_->SetControlledWindow(active_xid_); } - // _panel_title needs to be only escaped when computed + // panel_title_ needs to be only escaped when computed // in this function, if it comes from OnLauncherSelectionChanged // it is already escaped glib::String escaped(g_markup_escape_text(new_title.c_str(), -1)); @@ -814,7 +815,7 @@ std::string PanelMenuView::GetCurrentTitle() const } else { - return _panel_title; + return panel_title_; } } @@ -824,20 +825,20 @@ void PanelMenuView::Refresh(bool force) // We can get into a race that causes the geometry to be wrong as there hasn't been a // layout cycle before the first callback. This is to protect from that. - if (geo.width > _monitor_geo.width) + if (geo.width > monitor_geo_.width) return; const std::string& new_title = GetCurrentTitle(); - if (new_title == _panel_title && !force && _last_geo == geo && _title_texture) + if (new_title == panel_title_ && !force && last_geo_ == geo && title_texture_) { // No need to redraw the title, let's save some CPU time! return; } - _panel_title = new_title; + panel_title_ = new_title; - if (_panel_title.empty()) + if (panel_title_.empty()) { - _title_texture = nullptr; + title_texture_ = nullptr; return; } @@ -847,24 +848,24 @@ void PanelMenuView::Refresh(bool force) cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); cairo_paint(cr); - DrawTitle(cr, geo, _panel_title); + DrawTitle(cr, geo, panel_title_); cairo_destroy(cr); - _title_texture = texture_ptr_from_cairo_graphics(cairo_graphics); + title_texture_ = texture_ptr_from_cairo_graphics(cairo_graphics); } void PanelMenuView::OnActiveChanged(PanelIndicatorEntryView* view, bool is_active) { if (is_active) { - _last_active_view = view; + last_active_view_ = view; } else { - if (_last_active_view == view) + if (last_active_view_ == view) { - _last_active_view = nullptr; + last_active_view_ = nullptr; } } @@ -888,10 +889,10 @@ void PanelMenuView::OnEntryAdded(indicator::Entry::Ptr const& entry) void PanelMenuView::NotifyAllMenusClosed() { - _last_active_view = nullptr; + last_active_view_ = nullptr; auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); - _is_inside = GetAbsoluteGeometry().IsInside(mouse); + is_inside_ = GetAbsoluteGeometry().IsInside(mouse); FullRedraw(); } @@ -903,25 +904,25 @@ void PanelMenuView::OnNameChanged(BamfView* bamf_view, gchar* new_name, gchar* o bool PanelMenuView::OnNewAppShow() { - BamfApplication* active_app = bamf_matcher_get_active_application(_matcher); - _new_application = glib::Object<BamfApplication>(active_app, glib::AddRef()); + BamfApplication* active_app = bamf_matcher_get_active_application(matcher_); + new_application_ = glib::Object<BamfApplication>(active_app, glib::AddRef()); QueueDraw(); - if (_sources.GetSource(NEW_APP_HIDE_TIMEOUT)) + if (sources_.GetSource(NEW_APP_HIDE_TIMEOUT)) { - _new_app_menu_shown = false; + new_app_menu_shown_ = false; } auto cb_func = sigc::mem_fun(this, &PanelMenuView::OnNewAppHide); - _sources.AddTimeoutSeconds(_menus_discovery, cb_func, NEW_APP_HIDE_TIMEOUT); + sources_.AddTimeoutSeconds(menus_discovery_, cb_func, NEW_APP_HIDE_TIMEOUT); return false; } bool PanelMenuView::OnNewAppHide() { - OnApplicationClosed(_new_application); - _new_app_menu_shown = true; + OnApplicationClosed(new_application_); + new_app_menu_shown_ = true; QueueDraw(); return false; @@ -935,43 +936,43 @@ void PanelMenuView::OnViewOpened(BamfMatcher *matcher, BamfView *view) if (!BAMF_IS_APPLICATION(view)) return; - _new_apps.push_front(glib::Object<BamfApplication>(BAMF_APPLICATION(view), glib::AddRef())); + new_apps_.push_front(glib::Object<BamfApplication>(BAMF_APPLICATION(view), glib::AddRef())); } void PanelMenuView::OnApplicationClosed(BamfApplication* app) { if (BAMF_IS_APPLICATION(app)) { - if (std::find(_new_apps.begin(), _new_apps.end(), app) != _new_apps.end()) + if (std::find(new_apps_.begin(), new_apps_.end(), app) != new_apps_.end()) { - _new_apps.remove(glib::Object<BamfApplication>(app, glib::AddRef())); + new_apps_.remove(glib::Object<BamfApplication>(app, glib::AddRef())); } - else if (_new_apps.empty()) + else if (new_apps_.empty()) { - _new_application = nullptr; + new_application_ = nullptr; } } - if (app == _new_application) + if (app == new_application_) { - _new_application = nullptr; + new_application_ = nullptr; } } void PanelMenuView::OnViewClosed(BamfMatcher *matcher, BamfView *view) { - if (reinterpret_cast<BamfView*>(_view_name_changed_signal.object()) == view) + if (reinterpret_cast<BamfView*>(view_name_changed_signal_.object()) == view) { - _view_name_changed_signal.Disconnect(); + view_name_changed_signal_.Disconnect(); } if (BAMF_IS_APPLICATION(view)) { OnApplicationClosed(reinterpret_cast<BamfApplication*>(view)); } - else if (reinterpret_cast<BamfApplication*>(view) == _new_application) + else if (reinterpret_cast<BamfApplication*>(view) == new_application_) { - _new_application = nullptr; + new_application_ = nullptr; } else if (BAMF_IS_WINDOW(view)) { @@ -988,9 +989,9 @@ void PanelMenuView::OnActiveAppChanged(BamfMatcher *matcher, { if (BAMF_IS_APPLICATION(new_app)) { - if (std::find(_new_apps.begin(), _new_apps.end(), new_app) != _new_apps.end()) + if (std::find(new_apps_.begin(), new_apps_.end(), new_app) != new_apps_.end()) { - if (_new_application != new_app) + if (new_application_ != new_app) { /* Add a small delay before showing the menus, this is done both * to fix the issues with applications that takes some time to loads @@ -998,21 +999,21 @@ void PanelMenuView::OnActiveAppChanged(BamfMatcher *matcher, * kept active for some time */ auto cb_func = sigc::mem_fun(this, &PanelMenuView::OnNewAppShow); - _sources.AddTimeout(300, cb_func, NEW_APP_SHOW_TIMEOUT); + sources_.AddTimeout(300, cb_func, NEW_APP_SHOW_TIMEOUT); } } else { - _sources.Remove(NEW_APP_SHOW_TIMEOUT); + sources_.Remove(NEW_APP_SHOW_TIMEOUT); - if (_sources.GetSource(NEW_APP_HIDE_TIMEOUT)) + if (sources_.GetSource(NEW_APP_HIDE_TIMEOUT)) { - _sources.Remove(NEW_APP_HIDE_TIMEOUT); - _new_app_menu_shown = false; + sources_.Remove(NEW_APP_HIDE_TIMEOUT); + new_app_menu_shown_ = false; } - if (_new_application) - OnApplicationClosed(_new_application); + if (new_application_) + OnApplicationClosed(new_application_); } } } @@ -1021,47 +1022,47 @@ void PanelMenuView::OnActiveWindowChanged(BamfMatcher *matcher, BamfView* old_view, BamfView* new_view) { - _show_now_activated = false; - _is_maximized = false; - _active_xid = 0; + show_now_activated_ = false; + is_maximized_ = false; + active_xid_ = 0; - _sources.Remove(WINDOW_MOVED_TIMEOUT); + sources_.Remove(WINDOW_MOVED_TIMEOUT); if (BAMF_IS_WINDOW(new_view)) { WindowManager& wm = WindowManager::Default(); BamfWindow* window = reinterpret_cast<BamfWindow*>(new_view); guint32 xid = bamf_window_get_xid(window); - _active_xid = xid; - _is_maximized = wm.IsWindowMaximized(xid); + active_xid_ = xid; + is_maximized_ = wm.IsWindowMaximized(xid); if (bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) - _we_control_active = true; + we_control_active_ = true; else - _we_control_active = IsWindowUnderOurControl(xid); + we_control_active_ = IsWindowUnderOurControl(xid); - if (_decor_map.find(xid) == _decor_map.end()) + if (decor_map_.find(xid) == decor_map_.end()) { - _decor_map[xid] = true; + decor_map_[xid] = true; // if we've just started tracking this window and it is maximized, let's // make sure it's undecorated just in case it slipped by us earlier // (I'm looking at you, Chromium!) - if (_is_maximized && wm.HasWindowDecorations(xid)) + if (is_maximized_ && wm.HasWindowDecorations(xid)) { wm.Undecorate(xid); - _maximized_set.insert(xid); + maximized_set_.insert(xid); } } // first see if we need to remove and old callback - _view_name_changed_signal.Disconnect(); + view_name_changed_signal_.Disconnect(); // register callback for new view - _view_name_changed_signal.Connect(new_view, "name-changed", + view_name_changed_signal_.Connect(new_view, "name-changed", sigc::mem_fun(this, &PanelMenuView::OnNameChanged)); - _window_buttons->SetControlledWindow(_is_maximized ? _active_xid : 0); + window_buttons_->SetControlledWindow(is_maximized_ ? active_xid_ : 0); } Refresh(); @@ -1098,7 +1099,7 @@ void PanelMenuView::OnWindowMinimized(guint32 xid) if (wm.IsWindowMaximized(xid)) { wm.Decorate(xid); - _maximized_set.erase(xid); + maximized_set_.erase(xid); Refresh(); QueueDraw(); @@ -1111,7 +1112,7 @@ void PanelMenuView::OnWindowUnminimized(guint32 xid) if (wm.IsWindowMaximized(xid)) { wm.Undecorate(xid); - _maximized_set.insert(xid); + maximized_set_.insert(xid); Refresh(); QueueDraw(); @@ -1122,11 +1123,11 @@ void PanelMenuView::OnWindowUnmapped(guint32 xid) { // FIXME: compiz doesn't give us a valid xid (is always 0 on unmap) // we need to do this again on BamfView closed signal. - if (_maximized_set.find(xid) != _maximized_set.end()) + if (maximized_set_.find(xid) != maximized_set_.end()) { WindowManager::Default().Decorate(xid); - _maximized_set.erase(xid); - _decor_map.erase(xid); + maximized_set_.erase(xid); + decor_map_.erase(xid); Refresh(); QueueDraw(); @@ -1139,7 +1140,7 @@ void PanelMenuView::OnWindowMapped(guint32 xid) if (wm.IsWindowMaximized(xid)) { wm.Undecorate(xid); - _maximized_set.insert(xid); + maximized_set_.insert(xid); Refresh(); QueueDraw(); @@ -1148,9 +1149,9 @@ void PanelMenuView::OnWindowMapped(guint32 xid) void PanelMenuView::OnWindowDecorated(guint32 xid) { - _decor_map[xid] = true; + decor_map_[xid] = true; - if (_maximized_set.find(xid) != _maximized_set.end ()) + if (maximized_set_.find(xid) != maximized_set_.end ()) { WindowManager::Default().Undecorate(xid); } @@ -1158,32 +1159,32 @@ void PanelMenuView::OnWindowDecorated(guint32 xid) void PanelMenuView::OnWindowUndecorated(guint32 xid) { - _decor_map[xid] = false; + decor_map_[xid] = false; } void PanelMenuView::OnWindowMaximized(guint xid) { bool updated = false; - bool is_active = (_active_xid == xid); + bool is_active = (active_xid_ == xid); if (is_active) { - // We need to update the _is_inside state in the case of maximization by grab + // We need to update the is_inside_ state in the case of maximization by grab auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); - _is_inside = GetAbsoluteGeometry().IsInside(mouse); + is_inside_ = GetAbsoluteGeometry().IsInside(mouse); - _is_maximized = true; + is_maximized_ = true; updated = true; } - // update the state of the window in the _decor_map + // update the state of the window in the decor_map_ WindowManager& wm = WindowManager::Default(); - _decor_map[xid] = wm.HasWindowDecorations(xid); + decor_map_[xid] = wm.HasWindowDecorations(xid); - if (_decor_map[xid]) + if (decor_map_[xid]) wm.Undecorate(xid); - _maximized_set.insert(xid); + maximized_set_.insert(xid); if (updated) { @@ -1194,19 +1195,19 @@ void PanelMenuView::OnWindowMaximized(guint xid) void PanelMenuView::OnWindowRestored(guint xid) { - if (_maximized_set.find(xid) == _maximized_set.end()) + if (maximized_set_.find(xid) == maximized_set_.end()) return; - if (_active_xid == xid) + if (active_xid_ == xid) { - _is_maximized = false; - _is_grabbed = false; + is_maximized_ = false; + is_grabbed_ = false; } - if (_decor_map[xid]) + if (decor_map_[xid]) WindowManager::Default().Decorate(xid); - _maximized_set.erase(xid); + maximized_set_.erase(xid); Refresh(); FullRedraw(); @@ -1214,11 +1215,11 @@ void PanelMenuView::OnWindowRestored(guint xid) bool PanelMenuView::UpdateActiveWindowPosition() { - bool we_control_window = IsWindowUnderOurControl(_active_xid); + bool we_control_window = IsWindowUnderOurControl(active_xid_); - if (we_control_window != _we_control_active) + if (we_control_window != we_control_active_) { - _we_control_active = we_control_window; + we_control_active_ = we_control_window; Refresh(); QueueDraw(); @@ -1229,7 +1230,7 @@ bool PanelMenuView::UpdateActiveWindowPosition() void PanelMenuView::OnWindowMoved(guint xid) { - if (_active_xid == xid) + if (active_xid_ == xid) { /* When moving the active window, if the current panel is controlling * the active window, then we postpone the timeout function every movement @@ -1239,20 +1240,20 @@ void PanelMenuView::OnWindowMoved(guint xid) unsigned int timeout_length = 250; - if (_we_control_active) + if (we_control_active_) { - _sources.Remove(WINDOW_MOVED_TIMEOUT); + sources_.Remove(WINDOW_MOVED_TIMEOUT); } else { - if (_sources.GetSource(WINDOW_MOVED_TIMEOUT)) + if (sources_.GetSource(WINDOW_MOVED_TIMEOUT)) return; timeout_length = 60; } auto cb_func = sigc::mem_fun(this, &PanelMenuView::UpdateActiveWindowPosition); - _sources.AddTimeout(timeout_length, cb_func, WINDOW_MOVED_TIMEOUT); + sources_.AddTimeout(timeout_length, cb_func, WINDOW_MOVED_TIMEOUT); } } @@ -1262,7 +1263,7 @@ bool PanelMenuView::IsWindowUnderOurControl(Window xid) const { WindowManager& wm = WindowManager::Default(); nux::Geometry const& window_geo = wm.GetWindowGeometry(xid); - nux::Geometry const& intersect = _monitor_geo.Intersect(window_geo); + nux::Geometry const& intersect = monitor_geo_.Intersect(window_geo); /* We only care of the horizontal window portion */ return (intersect.width > window_geo.width/2 && intersect.height > 0); @@ -1291,7 +1292,7 @@ Window PanelMenuView::GetMaximizedWindow() const Window window_xid = 0; // Find the front-most of the maximized windows we are controlling - for (auto xid : _maximized_set) + for (auto xid : maximized_set_) { // We can safely assume only the front-most is visible if (IsValidWindow(xid)) @@ -1307,7 +1308,7 @@ Window PanelMenuView::GetMaximizedWindow() const Window PanelMenuView::GetTopWindow() const { Window window_xid = 0; - GList* windows = bamf_matcher_get_window_stack_for_monitor(_matcher, _monitor); + GList* windows = bamf_matcher_get_window_stack_for_monitor(matcher_, monitor_); for (GList* l = windows; l; l = l->next) { @@ -1334,7 +1335,7 @@ BamfWindow* PanelMenuView::GetBamfWindowForXid(Window xid) const if (xid != 0) { - GList* windows = bamf_matcher_get_windows(_matcher); + GList* windows = bamf_matcher_get_windows(matcher_); for (GList* l = windows; l; l = l->next) { @@ -1368,7 +1369,7 @@ void PanelMenuView::OnMaximizedActivate(int x, int y) void PanelMenuView::OnMaximizedRestore(int x, int y) { - if (_overlay_showing) + if (overlay_showing_) return; Window maximized = GetMaximizedWindow(); @@ -1376,13 +1377,13 @@ void PanelMenuView::OnMaximizedRestore(int x, int y) if (maximized != 0) { WindowManager::Default().Restore(maximized); - _is_inside = true; + is_inside_ = true; } } void PanelMenuView::OnMaximizedLower(int x, int y) { - if (_overlay_showing) + if (overlay_showing_) return; Window maximized = GetMaximizedWindow(); @@ -1407,7 +1408,7 @@ void PanelMenuView::OnMaximizedGrabStart(int x, int y) { /* Always activate the window in case it is on another monitor */ WindowManager::Default().Activate(maximized); - _titlebar_grab_area->SetGrabbed(true); + titlebar_grab_area_->SetGrabbed(true); } } @@ -1419,8 +1420,8 @@ void PanelMenuView::OnMaximizedGrabMove(int x, int y) return; /* Adjusting the x, y coordinates to get the absolute values */ - x += _titlebar_grab_area->GetAbsoluteX(); - y += _titlebar_grab_area->GetAbsoluteY(); + x += titlebar_grab_area_->GetAbsoluteX(); + y += titlebar_grab_area_->GetAbsoluteY(); Window maximized = GetMaximizedWindow(); @@ -1458,13 +1459,13 @@ void PanelMenuView::OnMaximizedGrabMove(int x, int y) wm.Activate(maximized); wm.RestoreAt(maximized, restore_x, restore_y); - _is_inside = true; - _is_grabbed = true; + is_inside_ = true; + is_grabbed_ = true; Refresh(); FullRedraw(); /* Ungrab the pointer and start the X move, to make the decorator handle it */ - _titlebar_grab_area->SetGrabbed(false); + titlebar_grab_area_->SetGrabbed(false); wm.StartMove(maximized, x, y); } } @@ -1472,14 +1473,14 @@ void PanelMenuView::OnMaximizedGrabMove(int x, int y) void PanelMenuView::OnMaximizedGrabEnd(int x, int y) { - _titlebar_grab_area->SetGrabbed(false); + titlebar_grab_area_->SetGrabbed(false); - x += _titlebar_grab_area->GetAbsoluteX(); - y += _titlebar_grab_area->GetAbsoluteY(); - _is_inside = GetAbsoluteGeometry().IsPointInside(x, y); + x += titlebar_grab_area_->GetAbsoluteX(); + y += titlebar_grab_area_->GetAbsoluteY(); + is_inside_ = GetAbsoluteGeometry().IsPointInside(x, y); - if (!_is_inside) - _is_grabbed = false; + if (!is_inside_) + is_grabbed_ = false; Refresh(); FullRedraw(); @@ -1497,21 +1498,21 @@ void PanelMenuView::AddProperties(GVariantBuilder* builder) PanelIndicatorsView::AddProperties(builder); variant::BuilderWrapper(builder) - .add("mouse_inside", _is_inside) - .add("grabbed", _is_grabbed) - .add("active_win_maximized", _is_maximized) - .add("panel_title", _panel_title) - .add("desktop_active", (_panel_title == _desktop_name)) - .add("monitor", _monitor) - .add("active_window", _active_xid) + .add("mouse_inside", is_inside_) + .add("grabbed", is_grabbed_) + .add("active_win_maximized", is_maximized_) + .add("panel_title", panel_title_) + .add("desktop_active", (panel_title_ == desktop_name_)) + .add("monitor", monitor_) + .add("active_window", active_xid_) .add("draw_menus", DrawMenus()) .add("draw_window_buttons", DrawWindowButtons()) - .add("controls_active_window", _we_control_active) - .add("fadein_duration", _menus_fadein) - .add("fadeout_duration", _menus_fadeout) - .add("discovery_duration", _menus_discovery) - .add("discovery_fadein_duration", _menus_discovery_fadein) - .add("discovery_fadeout_duration", _menus_discovery_fadeout); + .add("controls_active_window", we_control_active_) + .add("fadein_duration", menus_fadein_) + .add("fadeout_duration", menus_fadeout_) + .add("discovery_duration", menus_discovery_) + .add("discovery_fadein_duration", menus_discovery_fadein_) + .add("discovery_fadeout_duration", menus_discovery_fadeout_); } void PanelMenuView::OnSwitcherShown(GVariant* data) @@ -1523,19 +1524,19 @@ void PanelMenuView::OnSwitcherShown(GVariant* data) gint monitor; g_variant_get(data, "(bi)", &switcher_shown, &monitor); - if (switcher_shown == _switcher_showing || monitor != _monitor) + if (switcher_shown == switcher_showing_ || monitor != monitor_) return; - _switcher_showing = switcher_shown; + switcher_showing_ = switcher_shown; - if (!_switcher_showing) + if (!switcher_showing_) { auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); - _is_inside = GetAbsoluteGeometry().IsInside(mouse); + is_inside_ = GetAbsoluteGeometry().IsInside(mouse); } else { - _show_now_activated = false; + show_now_activated_ = false; } Refresh(); @@ -1544,25 +1545,25 @@ void PanelMenuView::OnSwitcherShown(GVariant* data) void PanelMenuView::OnLauncherKeyNavStarted(GVariant* data) { - if (_launcher_keynav) + if (launcher_keynav_) return; - if (!data || (data && g_variant_get_int32(data) == _monitor)) + if (!data || (data && g_variant_get_int32(data) == monitor_)) { - _launcher_keynav = true; + launcher_keynav_ = true; } } void PanelMenuView::OnLauncherKeyNavEnded(GVariant* data) { - if (!_launcher_keynav) + if (!launcher_keynav_) return; - _launcher_keynav = false; + launcher_keynav_ = false; auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); - _is_inside = GetAbsoluteGeometry().IsInside(mouse); + is_inside_ = GetAbsoluteGeometry().IsInside(mouse); Refresh(); QueueDraw(); @@ -1570,11 +1571,11 @@ void PanelMenuView::OnLauncherKeyNavEnded(GVariant* data) void PanelMenuView::OnLauncherSelectionChanged(GVariant* data) { - if (!data || !_launcher_keynav) + if (!data || !launcher_keynav_) return; const gchar *title = g_variant_get_string(data, 0); - _panel_title = (title ? title : ""); + panel_title_ = (title ? title : ""); Refresh(true); QueueDraw(); @@ -1584,7 +1585,7 @@ bool PanelMenuView::UpdateShowNowWithDelay() { bool active = false; - for (auto entry : entries_) + for (auto const& entry : entries_) { if (entry.second->GetShowNow()) { @@ -1595,7 +1596,7 @@ bool PanelMenuView::UpdateShowNowWithDelay() if (active) { - _show_now_activated = true; + show_now_activated_ = true; QueueDraw(); } @@ -1610,29 +1611,29 @@ void PanelMenuView::UpdateShowNow(bool status) * If the status is false, we just check that the menus entries are hidden * and we remove any eventual delayed request */ - _sources.Remove(UPDATE_SHOW_NOW_TIMEOUT); + sources_.Remove(UPDATE_SHOW_NOW_TIMEOUT); - if (!status && _show_now_activated) + if (!status && show_now_activated_) { - _show_now_activated = false; + show_now_activated_ = false; QueueDraw(); return; } - if (status && !_show_now_activated) + if (status && !show_now_activated_) { auto cb_func = sigc::mem_fun(this, &PanelMenuView::UpdateShowNowWithDelay); - _sources.AddTimeout(180, cb_func, UPDATE_SHOW_NOW_TIMEOUT); + sources_.AddTimeout(180, cb_func, UPDATE_SHOW_NOW_TIMEOUT); } } void PanelMenuView::SetMonitor(int monitor) { - _monitor = monitor; - _monitor_geo = UScreen::GetDefault()->GetMonitorGeometry(_monitor); + monitor_ = monitor; + monitor_geo_ = UScreen::GetDefault()->GetMonitorGeometry(monitor_); - _maximized_set.clear(); - GList* windows = bamf_matcher_get_window_stack_for_monitor(_matcher, _monitor); + maximized_set_.clear(); + GList* windows = bamf_matcher_get_window_stack_for_monitor(matcher_, monitor_); WindowManager& wm = WindowManager::Default(); for (GList* l = windows; l; l = l->next) @@ -1645,44 +1646,44 @@ void PanelMenuView::SetMonitor(int monitor) if (bamf_view_is_active(view)) { - _active_xid = bamf_window_get_xid(window); + active_xid_ = bamf_window_get_xid(window); } if (bamf_window_maximized(window) == BAMF_WINDOW_MAXIMIZED) { Window xid = bamf_window_get_xid(window); - _decor_map[xid] = wm.HasWindowDecorations(xid); + decor_map_[xid] = wm.HasWindowDecorations(xid); - if (_decor_map[xid]) + if (decor_map_[xid]) wm.Undecorate(xid); - _maximized_set.insert(xid); + maximized_set_.insert(xid); } } Window maximized = GetMaximizedWindow(); - Window buttons_win = (maximized == _active_xid) ? maximized : 0; + Window buttons_win = (maximized == active_xid_) ? maximized : 0; - _window_buttons->SetMonitor(_monitor); - _window_buttons->SetControlledWindow(buttons_win); + window_buttons_->SetMonitor(monitor_); + window_buttons_->SetControlledWindow(buttons_win); g_list_free(windows); } bool PanelMenuView::GetControlsActive() const { - return _we_control_active; + return we_control_active_; } void PanelMenuView::OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state) { - if (!_is_inside) + if (!is_inside_) { - if (_is_grabbed) - _is_grabbed = false; + if (is_grabbed_) + is_grabbed_ = false; else - _is_inside = true; + is_inside_ = true; FullRedraw(); } @@ -1690,9 +1691,9 @@ void PanelMenuView::OnPanelViewMouseEnter(int x, int y, unsigned long mouse_butt void PanelMenuView::OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state) { - if (_is_inside) + if (is_inside_) { - _is_inside = false; + is_inside_ = false; FullRedraw(); } } @@ -1702,20 +1703,20 @@ void PanelMenuView::OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned void PanelMenuView::SetMousePosition(int x, int y) { - if (_last_active_view || + if (last_active_view_ || (x >= 0 && y >= 0 && GetAbsoluteGeometry().IsPointInside(x, y))) { - if (!_is_inside) + if (!is_inside_) { - _is_inside = true; + is_inside_ = true; FullRedraw(); } } else { - if (_is_inside) + if (is_inside_) { - _is_inside = false; + is_inside_ = false; FullRedraw(); } } diff --git a/panel/PanelMenuView.h b/panel/PanelMenuView.h index 8914172f3..756982c68 100644 --- a/panel/PanelMenuView.h +++ b/panel/PanelMenuView.h @@ -21,6 +21,7 @@ #ifndef PANEL_MENU_VIEW_H #define PANEL_MENU_VIEW_H +#include <NuxCore/Animation.h> #include <UnityCore/GLibWrapper.h> #include <UnityCore/GLibSignal.h> #include <libbamf/libbamf.h> @@ -29,7 +30,6 @@ #include "unity-shared/StaticCairoText.h" #include "WindowButtons.h" #include "PanelTitlebarGrabAreaView.h" -#include "unity-shared/Animator.h" #include "unity-shared/UBusWrapper.h" namespace unity @@ -131,60 +131,60 @@ private: bool DrawMenus() const; bool DrawWindowButtons() const; - void OnFadeInChanged(double); - void OnFadeOutChanged(double); - - glib::Object<BamfMatcher> _matcher; - - nux::TextureLayer* _title_layer; - nux::ObjectPtr<WindowButtons> _window_buttons; - nux::ObjectPtr<PanelTitlebarGrabArea> _titlebar_grab_area; - nux::ObjectPtr<nux::BaseTexture> _title_texture; - nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture; - - bool _is_inside; - bool _is_grabbed; - bool _is_maximized; - - PanelIndicatorEntryView* _last_active_view; - glib::Object<BamfApplication> _new_application; - - std::map<Window, bool> _decor_map; - std::set<Window> _maximized_set; - std::list<glib::Object<BamfApplication>> _new_apps; - std::string _panel_title; - nux::Geometry _last_geo; - - bool _overlay_showing; - bool _switcher_showing; - bool _launcher_keynav; - bool _show_now_activated; - bool _we_control_active; - bool _new_app_menu_shown; - - int _monitor; - Window _active_xid; - nux::Geometry _monitor_geo; - const std::string _desktop_name; - - int _menus_fadein; - int _menus_fadeout; - int _menus_discovery; - int _menus_discovery_fadein; - int _menus_discovery_fadeout; - - glib::Signal<void, BamfMatcher*, BamfView*> _view_opened_signal; - glib::Signal<void, BamfMatcher*, BamfView*> _view_closed_signal; - glib::Signal<void, BamfMatcher*, BamfView*, BamfView*> _active_win_changed_signal; - glib::Signal<void, BamfMatcher*, BamfApplication*, BamfApplication*> _active_app_changed_signal; - glib::Signal<void, BamfView*, gchar*, gchar*> _view_name_changed_signal; - sigc::connection _style_changed_connection; - - UBusManager _ubus_manager; - glib::SourceManager _sources; - - Animator _fade_in_animator; - Animator _fade_out_animator; + void StartFadeIn(int duration = -1); + void StartFadeOut(int duration = -1); + void OnFadeAnimatorUpdated(double opacity); + + glib::Object<BamfMatcher> matcher_; + + nux::TextureLayer* title_layer_; + nux::ObjectPtr<WindowButtons> window_buttons_; + nux::ObjectPtr<PanelTitlebarGrabArea> titlebar_grab_area_; + nux::ObjectPtr<nux::BaseTexture> title_texture_; + nux::ObjectPtr<nux::IOpenGLBaseTexture> gradient_texture_; + + bool is_inside_; + bool is_grabbed_; + bool is_maximized_; + + PanelIndicatorEntryView* last_active_view_; + glib::Object<BamfApplication> new_application_; + + std::map<Window, bool> decor_map_; + std::set<Window> maximized_set_; + std::list<glib::Object<BamfApplication>> new_apps_; + std::string panel_title_; + nux::Geometry last_geo_; + + bool overlay_showing_; + bool switcher_showing_; + bool launcher_keynav_; + bool show_now_activated_; + bool we_control_active_; + bool new_app_menu_shown_; + + int monitor_; + Window active_xid_; + nux::Geometry monitor_geo_; + const std::string desktop_name_; + + int menus_fadein_; + int menus_fadeout_; + int menus_discovery_; + int menus_discovery_fadein_; + int menus_discovery_fadeout_; + + glib::Signal<void, BamfMatcher*, BamfView*> view_opened_signal_; + glib::Signal<void, BamfMatcher*, BamfView*> view_closed_signal_; + glib::Signal<void, BamfMatcher*, BamfView*, BamfView*> active_win_changed_signal_; + glib::Signal<void, BamfMatcher*, BamfApplication*, BamfApplication*> active_app_changed_signal_; + glib::Signal<void, BamfView*, gchar*, gchar*> view_name_changed_signal_; + sigc::connection style_changed_connection_; + + UBusManager ubus_manager_; + glib::SourceManager sources_; + + nux::animation::AnimateValue<double> opacity_animator_; }; } diff --git a/panel/StandalonePanel.cpp b/panel/StandalonePanel.cpp index 5e2d362d5..ddea5172d 100644 --- a/panel/StandalonePanel.cpp +++ b/panel/StandalonePanel.cpp @@ -19,9 +19,11 @@ */ #include <Nux/Nux.h> +#include <Nux/NuxTimerTickSource.h> #include <Nux/VLayout.h> #include <Nux/HLayout.h> #include <Nux/WindowThread.h> +#include <NuxCore/AnimationController.h> #include <NuxGraphics/GraphicsEngine.h> #include <NuxCore/Logger.h> #include <gtk/gtk.h> @@ -30,33 +32,69 @@ #include "unity-shared/PanelStyle.h" #include "PanelView.h" -void ThreadWidgetInit(nux::NThread* thread, void* InitData) +using namespace unity; + +struct PanelWindow { - nux::VLayout* layout = new nux::VLayout(TEXT(""), NUX_TRACKER_LOCATION); - unity::PanelView* view = new unity::PanelView(); + PanelWindow() + : wt(nux::CreateGUIThread("Unity Panel", 1024, 24, 0, &PanelWindow::ThreadWidgetInit, this)) + , animation_controller(tick_source) + {} - //view->SetMinMaxSize(1024, 24); - view->SetPrimary(true); - layout->AddView(view, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); - layout->SetContentDistribution(nux::MAJOR_POSITION_CENTER); + void Show() + { + wt->Run(nullptr); + } - nux::GetWindowThread()->SetLayout(layout); -} +private: + class StandalonePanelView : public PanelView + { + // Used to sync menu geometries + std::string GetName() const { return "StandalonePanel"; } + }; + + void Init() + { + PanelView* panel = new StandalonePanelView(); + panel->SetPrimary(true); + + nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION); + layout->AddView(panel, 1); + layout->SetContentDistribution(nux::MAJOR_POSITION_START); + + panel_window = new nux::BaseWindow("StandalonePanel"); + panel_window->SetLayout(layout); + panel_window->SetBackgroundColor(nux::color::Transparent); + panel_window->ShowWindow(true); + panel_window->SetWidth(1024); + panel_window->SetXY(0, 0); + panel_window->SetMaximumHeight(panel_style.panel_height()); + + wt->window_configuration.connect([this] (int x, int y, int w, int h) { + panel_window->SetWidth(w); + }); + } + + static void ThreadWidgetInit(nux::NThread* thread, void* self) + { + static_cast<PanelWindow*>(self)->Init(); + } + + unity::Settings settings; + panel::Style panel_style; + std::shared_ptr<nux::WindowThread> wt; + nux::NuxTimerTickSource tick_source; + nux::animation::AnimationController animation_controller; + nux::ObjectPtr<nux::BaseWindow> panel_window; +}; int main(int argc, char** argv) { - g_type_init(); gtk_init(&argc, &argv); nux::NuxInitialize(0); nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); - - // The instances for the pseudo-singletons. - unity::Settings settings; - unity::panel::Style panel_style; - nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Unity Panel"), 1024, 24, 0, &ThreadWidgetInit, 0); + PanelWindow().Show(); - wt->Run(NULL); - delete wt; return 0; } diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index a13eae0f8..21534f42c 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -2639,7 +2639,7 @@ UnityWindow::focus () } bool -UnityWindow::minimized () +UnityWindow::minimized () const { return mMinimizeHandler.get () != nullptr; } @@ -2729,12 +2729,17 @@ void UnityWindow::windowNotify(CompWindowNotify n) { UnityScreen* us = UnityScreen::get(screen); - // can't rely on launcher->IsOverlayVisible on focus change (because ubus is async close on focus change.) - if (us && (us->dash_controller_->IsVisible() || us->hud_controller_->IsVisible())) + // If focus gets moved to an external program while the Dash/Hud is open, refocus key input. + if (us) { - CompWindow *lw; - lw = screen->findWindow(us->launcher_controller_->LauncherWindowId(0)); - lw->moveInputFocusTo(); + if (us->dash_controller_->IsVisible()) + { + us->dash_controller_->ReFocusKeyInput(); + } + else if (us->hud_controller_->IsVisible()) + { + us->hud_controller_->ReFocusKeyInput(); + } } } } diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index cb0286064..646d17c9d 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -369,7 +369,7 @@ public: void minimize(); void unminimize(); - bool minimized(); + bool minimized() const; bool focus(); void activate(); diff --git a/po/unity.pot b/po/unity.pot index db7d2be5f..b3b19d52a 100644 --- a/po/unity.pot +++ b/po/unity.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: ayatana-dev@lists.launchpad.net\n" -"POT-Creation-Date: 2012-11-08 12:05+0000\n" +"POT-Creation-Date: 2012-12-05 10:41+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/resources/lens-nav-app.svg b/resources/lens-nav-app.svg index b0bb63120..d886b1f56 100644 --- a/resources/lens-nav-app.svg +++ b/resources/lens-nav-app.svg @@ -1,17 +1,83 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill="#FFFFFF" d="M14,8v12c0,0.55-0.45,1-1,1h-2c-0.55,0-1-0.45-1-1V8H14z"/> -<path fill="#FFFFFF" d="M8,11H6v-1h2V8H6V7h2V4c0-0.55-0.45-1-1-1H5.001c-0.55,0-1,0.45-1,1L4,20c0,0.55,0.45,1,1,1h2 - c0.55,0,1-0.45,1-1v-3H6v-1h2v-2H6v-1h2V11z"/> -<path fill="#FFFFFF" d="M8,8L8,8V7l0,0V8z"/> -<path fill="#FFFFFF" d="M18.366,3v1.542C18.602,4.681,18.8,4.925,18.8,5.217c0,0.441-0.358,0.799-0.8,0.799s-0.8-0.358-0.8-0.799 - c0-0.292,0.198-0.537,0.433-0.675V3C17.16,3.578,16,5.26,16,6.005C16,7.106,17.116,8,18,8s2-0.894,2-1.995 - C20,5.26,18.84,3.578,18.366,3z"/> -<path fill="#FFFFFF" d="M20,9v11c0,0.55-0.45,1-1,1h-2c-0.55,0-1-0.45-1-1V9H20z"/> -<path fill="#FFFFFF" d="M12.552,3.991c0.191,0.349,0.378,0.7,0.56,1.056c0.182,0.355,0.349,0.701,0.502,1.038 - C13.766,6.42,13.895,6.726,14,7h-4c0.105-0.262,0.234-0.561,0.387-0.897c0.153-0.336,0.318-0.682,0.495-1.038 - c0.177-0.354,0.36-0.71,0.552-1.065c0.191-0.355,0.377-0.688,0.559-1C12.175,3.312,12.36,3.642,12.552,3.991z"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3416" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-apps.svg"> + <defs + id="defs3418" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:zoom="30.357661" + inkscape:cx="16.840889" + inkscape:cy="13.242127" + inkscape:document-units="px" + inkscape:current-layer="layer1-7" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid2986" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3421"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <g + style="display:inline" + transform="matrix(1.2495717,0,0,1.2495717,0.01542069,-262.63982)" + id="layer1-7" + inkscape:label="Layer 1" + inkscape:export-filename="PNG/app_lense_icon@18.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + style="font-size:15px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Sans Bold" + d="M 10.28125 4 C 9.7425234 5.1082451 9.2266818 6.2365259 8.71875 7.40625 C 8.2262008 8.5607293 7.7108254 9.8009431 7.1875 11.09375 C 7.0758879 11.377852 6.9568481 11.707718 6.84375 12 L 10.25 12 C 10.286928 11.898572 10.338458 11.787394 10.375 11.6875 C 10.621266 11.056466 10.831148 10.492071 11.03125 9.96875 C 11.231339 9.4454294 11.408572 8.9627378 11.5625 8.5625 C 11.716412 8.1622622 11.82929 7.8559209 11.90625 7.625 C 11.998594 7.8559209 12.127322 8.1622622 12.28125 8.5625 C 12.435162 8.9627378 12.612396 9.4454294 12.8125 9.96875 C 13.027979 10.492071 13.26911 11.056466 13.5 11.6875 C 13.53654 11.787394 13.588074 11.898572 13.625 12 L 17.125 12 C 17.009561 11.708482 16.895948 11.37713 16.78125 11.09375 C 16.273302 9.8009431 15.789173 8.5607293 15.28125 7.40625 C 14.773303 6.2365259 14.242067 5.1082451 13.71875 4 L 10.28125 4 z M 5 17 C 4.6470541 17.980077 4.2835139 18.916573 3.90625 20 L 7.65625 20 C 7.825559 19.445815 7.9874007 18.866175 8.1875 18.28125 C 8.3457001 17.85182 8.5063412 17.42938 8.65625 17 L 5 17 z M 15.21875 17 C 15.365342 17.428483 15.509646 17.852718 15.65625 18.28125 C 15.871725 18.866175 16.080676 19.445815 16.25 20 L 20.09375 20 C 19.716476 18.916573 19.352943 17.980077 19 17 L 15.21875 17 z " + transform="matrix(0.80027421,0,0,0.80027421,-0.01234078,1033.1556)" + id="path2993" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 4.5 13 C 3.669 13 3 13.669 3 14.5 C 3 15.331 3.669 16 4.5 16 L 19.5 16 C 20.331 16 21 15.331 21 14.5 C 21 13.669 20.331 13 19.5 13 L 4.5 13 z M 4.5 14 L 13.5 14 C 13.777 14 14 14.223 14 14.5 C 14 14.777 13.777 15 13.5 15 L 4.5 15 C 4.2229999 15 4 14.777 4 14.5 C 4 14.223 4.2229999 14 4.5 14 z " + transform="matrix(0.80027421,0,0,0.80027421,-0.01234078,1033.1556)" + id="rect2995" /> + </g> + </g> +</svg> diff --git a/resources/lens-nav-file.svg b/resources/lens-nav-file.svg index 48fb41c3b..3dc0536a0 100644 --- a/resources/lens-nav-file.svg +++ b/resources/lens-nav-file.svg @@ -1,8 +1,87 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill="#FFFFFF" d="M15,3v4h4V6l-3.031-3H15z"/> -<path fill="#FFFFFF" d="M18,21H6c-0.55,0-1-0.45-1-1V4c0-0.55,0.45-1,1-1h8v5.007h5V20C19,20.55,18.551,21,18,21z"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3140" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-file.svg"> + <defs + id="defs3142" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="24.286128" + inkscape:cx="16.407475" + inkscape:cy="15.002391" + inkscape:document-units="px" + inkscape:current-layer="g4978" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3178" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3145"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <rect + style="color:#000000;fill:none;stroke:none;stroke-width:7.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect4198" + width="35.999981" + height="35.999981" + x="0" + y="1016.3622" /> + <g + id="g4978" + transform="translate(-60,548.00002)"> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 9 3 C 5.00102 3 5 4 5 9 L 5 15 C 5 20 5.00102 21 9 21 L 15 21 C 18.99899 21 19 20 19 15 L 19 9 L 14 9 C 13.446 9 13 8.554 13 8 L 13 3 L 9 3 z " + transform="translate(60,480.36218)" + id="path3030" /> + <path + style="fill:#ffffff;stroke:none" + d="m 74,483.36218 5,5 -5,0 z" + id="path3032" + inkscape:connector-curvature="0" /> + </g> + </g> +</svg> diff --git a/resources/lens-nav-gwibber.svg b/resources/lens-nav-gwibber.svg index c0d95ad68..ddac548d7 100644 --- a/resources/lens-nav-gwibber.svg +++ b/resources/lens-nav-gwibber.svg @@ -1,12 +1,80 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill="#FFFFFF" d="M12.635,13.608c-0.849,0.836-2.011,1.265-3.272,1.204l0,0c-0.413-0.02-0.826-0.091-1.229-0.215 - c-0.368-0.112-0.665-0.404-0.778-0.769c-0.509-1.623-0.123-3.323,1.009-4.437c0.85-0.836,2.011-1.264,3.272-1.205 - c0.411,0.02,0.826,0.093,1.228,0.215c0.368,0.113,0.665,0.405,0.778,0.769C14.153,10.794,13.766,12.492,12.635,13.608z M15.5,7 - C15.224,7,15,6.775,15,6.499C15,6.224,15.224,6,15.5,6S16,6.224,16,6.499C16,6.775,15.776,7,15.5,7z M19.986,5.999 M20,6 - c0.552,0,1-0.447,1-1c0-0.552-0.449-1-1-1h-9c-4.418,0-8,3.582-8,8c0,4.418,3.582,8,8,8c4.417,0,8-3.576,8-7.994V7 - c0-0.01,0.001-0.019,0.001-0.028C19.001,6.436,19.448,6,20,6"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3289" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-gwibber.svg"> + <defs + id="defs3291" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="24.286129" + inkscape:cx="5.2087349" + inkscape:cy="11.142163" + inkscape:document-units="px" + inkscape:current-layer="g4451" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid3061" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3294"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <g + style="display:inline" + transform="translate(-789,604.3622)" + id="g4451"> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 7.3125 4 C 3.7714844 4.0683594 3 4.625 3 9 L 3 12 C 3 17 4 17 9 17 L 15 17 C 20 17 21 17 21 12 L 21 9 C 21 4 20 4 15 4 L 9 4 C 8.375 4 7.8183594 3.9902344 7.3125 4 z M 6 7 L 18 7 L 18 8 L 6 8 L 6 7 z M 6 9 L 18 9 L 18 10 L 6 10 L 6 9 z M 6 11 L 14 11 L 14 12 L 6 12 L 6 11 z " + transform="translate(789,424)" + id="rect2992" /> + <path + style="fill:#ffffff;stroke:none" + d="m 796,440 0,5 5,-5 z" + id="path3763" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccc" /> + </g> + </g> +</svg> diff --git a/resources/lens-nav-home.svg b/resources/lens-nav-home.svg index 0f30fda7c..8cad6d20a 100644 --- a/resources/lens-nav-home.svg +++ b/resources/lens-nav-home.svg @@ -1,9 +1,84 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M12.678,3.268C12.5,3.089,12.266,3,12.031,3 - c-0.235,0-0.47,0.089-0.647,0.268L3,12h2v8c0,0.553,0.447,1,1,1h12c0.553,0,1-0.447,1-1v-8h2L12.678,3.268z M14,20.998h-4v-5h4 - V20.998z"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3416" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens_home@18.svg"> + <defs + id="defs3418" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:zoom="15.543122" + inkscape:cx="27.11167" + inkscape:cy="7.4566742" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid2986" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3421"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <g + transform="translate(-338,-183.6378)" + style="display:inline" + id="g4180" + inkscape:export-filename="PNG/home_lense_icon@18.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <g + inkscape:label="Layer 1" + id="layer1-6" + transform="matrix(-0.50055933,0,0,0.50274125,359.02394,779.74862)" + style="fill:#ffffff"> + <path + sodipodi:nodetypes="ccccccccccccccssccccccssccccc" + inkscape:connector-curvature="0" + id="path4282" + d="m 17.779711,866.36001 c -0.72106,0.068 -1.41312,0.408 -1.90625,0.9375 l -15.03125011,15.0313 c -0.66238,0.7113 -0.93986,1.7728 -0.71875,2.7187 0.20547,0.8789 0.83816,1.6189 1.65625001,2 L 16.149198,871.89586 c 1.61681,-1.60979 2.152832,-1.6043 3.748053,-0.016 l 14.41371,15.1677 c 0.8098,-0.388 1.42596,-1.1554 1.625,-2.0313 0.21481,-0.945 -0.0549,-1.9803 -0.71875,-2.6874 l -15.03125,-15.0313 c -0.60766,-0.6498 -1.51835,-1.0046 -2.40625,-0.9375 z m -1.098725,7.72482 -12.6536496,13.35746 -0.00148,4.11574 c -0.00287,8.0057 -0.0162,10 7,10 l 3.043481,-0.0312 0,-10.38736 c 0,-1.59768 0.376851,-1.59768 1.977192,-1.5977 l 3.961618,0 c 1.629996,2e-5 2.052251,2e-5 2.052251,1.58624 l 0,10.39882 2.934208,0.0312 c 7.015839,0.0746 7.03125,-1.9943 7.03125,-10 l 0.0015,-4.11574 -12.653056,-13.36136 c -1.103387,-1.0986 -1.581101,-1.10346 -2.693295,0.004 z" + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + </g> + </g> + </g> +</svg> diff --git a/resources/lens-nav-music.svg b/resources/lens-nav-music.svg index ada6ce9e4..b2a163272 100644 --- a/resources/lens-nav-music.svg +++ b/resources/lens-nav-music.svg @@ -1,11 +1,119 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill="#FFFFFF" d="M19.964,14.964L20,15V3.849c0-0.55-0.444-0.926-0.986-0.835l-8.027,1.67C10.444,4.774,10,5.299,10,5.849 - v9.603c-0.984-0.633-2.52-0.61-3.892,0.172c-1.772,1.009-2.587,2.895-1.819,4.207c0.767,1.312,2.828,1.559,4.6,0.545 - c1.441-0.819,2.232-2.213,2.074-3.412L11,17V6.849c0-0.55,0.444-1.075,0.986-1.167l6.028-1.365C18.557,4.224,19,4.599,19,5.148 - v8.302c-0.984-0.632-2.521-0.609-3.891,0.174c-1.773,1.01-2.588,2.894-1.82,4.206c0.768,1.312,2.828,1.56,4.601,0.546 - C19.331,17.557,20.122,16.163,19.964,14.964z"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3416" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-music.svg"> + <defs + id="defs3418" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:zoom="30.357661" + inkscape:cx="26.928952" + inkscape:cy="14.091995" + inkscape:document-units="px" + inkscape:current-layer="g4363" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid2990" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3421"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <g + style="display:inline" + transform="matrix(1.2489157,0,0,1.2489157,0.01951965,-261.94947)" + id="g4363" + inkscape:label="Layer 1" + inkscape:export-filename="PNG/music_lense_icon@18.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + sodipodi:type="arc" + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="path4377" + sodipodi:cx="61.5" + sodipodi:cy="1497.3647" + sodipodi:rx="7.5" + sodipodi:ry="4.6352549" + d="m 69,1497.3647 a 7.5,4.6352549 0 1 1 -15,0 7.5,4.6352549 0 1 1 15,0 z" + transform="matrix(0.37365739,0,0,0.51822354,-17.791043,271.58835)" /> + <rect + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect4381" + width="0.80069476" + height="8.800458" + x="7.1906219" + y="1038.7504" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="m 9.2083717,1036.3483 c -1.4344769,0.03 -2.01775,0.2612 -2.01775,2.0017 l 0,0.4004 9.6083353,0 0,-0.4004 c 0,-2.0017 -0.768696,-2.0017 -2.690334,-2.0017 l -4.227668,0 c -0.2402051,0 -0.4676581,0 -0.6725833,0 z" + id="rect4385" + inkscape:connector-curvature="0" + sodipodi:nodetypes="csccsssc" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="m 7.1906232,1039.5511 9.2880558,0 0,0.8007 -9.2880558,0 z" + id="rect4391" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ccccc" /> + <path + transform="matrix(0.37365747,0,0,0.51822354,-8.9834092,271.58835)" + d="m 69,1497.3647 a 7.5,4.6352549 0 1 1 -15,0 7.5,4.6352549 0 1 1 15,0 z" + sodipodi:ry="4.6352549" + sodipodi:rx="7.5" + sodipodi:cy="1497.3647" + sodipodi:cx="61.5" + id="path4417" + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + sodipodi:type="arc" /> + <rect + y="1038.7504" + x="15.998261" + height="8.800458" + width="0.80069405" + id="rect4419" + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> + </g> + </g> +</svg> diff --git a/resources/lens-nav-people.svg b/resources/lens-nav-people.svg index acef9b538..f6cfe88c3 100644 --- a/resources/lens-nav-people.svg +++ b/resources/lens-nav-people.svg @@ -1,21 +1,97 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<g> - <g> - <path fill="#FFFFFF" d="M17.914,18.077c-1.999-0.991-2.911-2.703-2.911-3.514c0-0.544,0.363-1.382,0.713-1.788 - c0.341-0.399,0.849-0.598,1.091-1.041c0.393-0.725,0.602-2.17,0.48-2.807c-0.088-0.452-0.48-0.497-0.48-0.904 - c0-0.362,0.086-0.95,0.086-1.946c0-1.402-0.539-2.153-1.265-2.805c-0.656-0.589-1.965-1.223-3.625-1.223 - c-0.353,0-0.732,0.031-1.048,0.091c-0.72,0.135-1.206,0.473-1.452,0.738l-0.01-0.005L9.436,2.946 - C9.434,2.949,9.43,2.952,9.427,2.955c-0.306,0.046-0.8,0.116-1.223,0.452C7.636,3.86,7.113,4.675,7.113,6.077 - c0,0.996,0.087,1.584,0.087,1.946c0,0.407-0.393,0.452-0.48,0.904C6.597,9.564,6.807,11.01,7.2,11.734 - c0.241,0.443,0.75,0.642,1.091,1.041c0.35,0.406,0.713,1.244,0.713,1.788c0,0.811-0.919,2.522-2.919,3.514 - C3.346,19.435,2,20.059,2,21.95h20C22,20.059,20.655,19.435,17.914,18.077z M9.788,2.291L9.59,2.128 - C9.486,2.253,9.414,2.393,9.379,2.534C9.247,2.487,9.095,2.466,8.921,2.466v0.256c0.205,0,0.368,0.036,0.499,0.11l0.073,0.042 - l0.119-0.152C9.612,2.579,9.674,2.427,9.788,2.291z"/> - </g> -</g> -</svg> - \ No newline at end of file +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3416" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-people.svg"> + <defs + id="defs3418" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:zoom="24.286129" + inkscape:cx="18.664976" + inkscape:cy="15.39562" + inkscape:document-units="px" + inkscape:current-layer="g3441-4" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1" + inkscape:snap-global="false"> + <inkscape:grid + type="xygrid" + id="grid2988" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3421"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <g + style="display:inline" + inkscape:label="Layer 1" + id="g3441-4" + transform="matrix(1.25,0,0,1.25,0,-263.09055)"> + <path + inkscape:transform-center-y="4.1328031" + inkscape:transform-center-x="-0.0012930523" + id="path3447-0" + d="m 7.1978779,1036.3621 c -2.7985617,0 -3.1983559,1.1275 -3.1983559,3.3811 l 0,0.3758 c 0,1.6649 1.7896444,5.0457 3.2010249,5.0457 1.4113801,0 3.1956861,-3.3808 3.1956861,-5.0457 l 0,-0.3758 c 0,-2.2536 -0.399794,-3.3811 -3.1983551,-3.3811 z" + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + inkscape:connector-curvature="0" + sodipodi:nodetypes="ssszsss" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="m 4.85,1044.3622 c -1.9570873,0.045 -2.45,0.3901 -2.45,2.65 l 0,1.95 c 0,1.0006 0.3183616,1 1.275,1 l 7.05,0 c 0.95973,0 1.275,-0 1.275,-0.975 l 0,-1.325 0,-0.65 c 0,-2.2637 -0.50287,-2.5572 -2.475,-2.6 -0.2135576,0.2859 -0.4297224,0.5703 -0.675,0.8 -0.4488816,0.4204 -0.9707909,0.775 -1.65,0.775 -0.6792091,0 -1.2287434,-0.3537 -1.675,-0.775 -0.2565679,-0.2422 -0.459969,-0.5469 -0.675,-0.85 z" + id="rect3461-3" + inkscape:connector-curvature="0" /> + <path + sodipodi:nodetypes="ssszsss" + inkscape:connector-curvature="0" + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="m 13.579661,1038.7607 c -2.091866,0 -2.390704,0.7989 -2.390704,2.3955 l 0,0.2663 c 0,1.1796 1.337721,3.575 2.392699,3.575 1.054977,0 2.388709,-2.3954 2.388709,-3.575 l 0,-0.2663 c 0,-1.5966 -0.298838,-2.3955 -2.390704,-2.3955 z" + id="path2997" + inkscape:transform-center-x="4.4868569" + inkscape:transform-center-y="-8.1469625" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="m 15.575,1044.4622 c -0.191036,0.2653 -0.389138,0.5154 -0.625,0.725 -0.352063,0.3129 -0.792628,0.575 -1.35,0.575 -0.363059,0 -0.678286,-0.111 -0.95,-0.275 0.09289,0.4383 0.125,0.9495 0.125,1.525 l 0,0.65 0,0.7 3.125,0 c 0.673096,0 0.9,-0.01 0.9,-0.7 l 0,-0.925 0,-0.475 c 0,-1.3795 -0.27326,-1.7104 -1.225,-1.8 z" + id="path2999" + inkscape:connector-curvature="0" /> + </g> + </g> +</svg> diff --git a/resources/lens-nav-photo.svg b/resources/lens-nav-photo.svg index 7c91448a0..169b552be 100644 --- a/resources/lens-nav-photo.svg +++ b/resources/lens-nav-photo.svg @@ -1,11 +1,105 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill="#FFFFFF" d="M16,13.5c0,2.21-1.79,4-4,4s-4-1.79-4-4s1.79-4,4-4S16,11.29,16,13.5z"/> -<path fill="#FFFFFF" d="M20,7.5h-3c-0.55,0-1.162-0.433-1.336-0.956l-0.368-1.103C15.122,4.92,14.55,4.5,14,4.5h-4 - c-0.55,0-1.162,0.42-1.337,0.942L8.296,6.544C8.122,7.067,7.55,7.5,7,7.5H4c-0.55,0-1,0.45-1,1v10c0,0.551,0.45,1,1,1h16 - c0.55,0,1-0.449,1-1v-10C21,7.95,20.55,7.5,20,7.5z M12,18.5c-2.762,0-5-2.238-5-5c0-2.763,2.238-5,5-5c2.761,0,5,2.237,5,5 - C17,16.262,14.761,18.5,12,18.5z"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3140" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-photo.svg"> + <defs + id="defs3142" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="30.35766" + inkscape:cx="7.3844304" + inkscape:cy="13.704943" + inkscape:document-units="px" + inkscape:current-layer="g4978" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1" + showguides="true" + inkscape:guide-bbox="true"> + <inkscape:grid + type="xygrid" + id="grid3178" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3145"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <rect + style="color:#000000;fill:none;stroke:none;stroke-width:7.5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect4198" + width="35.999981" + height="35.999981" + x="0" + y="1016.3622" /> + <g + id="g4978" + transform="translate(-60,548.00002)"> + <path + style="fill:#ffffff;fill-opacity:1" + d="m 102,484.36218 c -1.05907,0 -1.2448,1.15201 -1.59375,1.62538 l -0.71875,0.875 -0.34375,0 c -5.295339,0 -6.34375,0.0294 -6.34375,4.28125 l 0,4.93712 c 0,4.25191 1.048411,4.25 6.34375,4.25 l 5.3125,0 c 5.29534,0 6.34375,0.002 6.34375,-4.25 l 0,-4.93712 c 0,-3.52483 -0.76508,-4.14636 -4.03125,-4.25 L 106.25,485.98756 c -0.36561,-0.461 -0.53468,-1.62538 -1.59375,-1.62538 z" + id="path3784" /> + <rect + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect2987" + width="3" + height="3" + x="95" + y="486.36218" + ry="0.5" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 7.3125 6 C 3.771484 6.0547 3 6.5 3 10 L 3 16 C 3 20 4 20 9 20 L 15 20 C 20 20 21 20 21 16 L 21 10 C 21 6 20 6 15 6 L 9 6 C 8.375 6 7.818359 5.992 7.3125 6 z M 13.5 7 C 16.537566 7 19 9.4624339 19 12.5 C 19 15.537566 16.537566 18 13.5 18 C 10.462434 18 8 15.537566 8 12.5 C 8 9.4624339 10.462434 7 13.5 7 z " + transform="translate(60,480.36218)" + id="path3802" /> + <path + style="fill:#ffffff;stroke:none" + d="m 71.1875,484.36218 c -0.235943,0.0501 -0.456305,0.17134 -0.625,0.34375 L 69,486.26843 c -0.281804,0.28031 -0.414534,0.70263 -0.34375,1.09375 l 9.6875,0 C 78.41453,486.97106 78.2818,486.54874 78,486.26843 l -1.5625,-1.5625 c -0.231824,-0.22276 -0.553544,-0.34915 -0.875,-0.34375 l -4.125,0 c -0.08305,-0.008 -0.166953,-0.008 -0.25,0 z" + id="path3776" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccccc" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 13.5 8.5 C 11.290861 8.5 9.5 10.290861 9.5 12.5 C 9.5 14.709139 11.290861 16.5 13.5 16.5 C 15.709139 16.5 17.5 14.709139 17.5 12.5 C 17.5 10.290861 15.709139 8.5 13.5 8.5 z M 12.5 10.5 C 13.052285 10.5 13.5 10.947715 13.5 11.5 C 13.5 12.052285 13.052285 12.5 12.5 12.5 C 11.947715 12.5 11.5 12.052285 11.5 11.5 C 11.5 10.947715 11.947715 10.5 12.5 10.5 z " + transform="translate(60,480.36218)" + id="path3806" /> + </g> + </g> +</svg> diff --git a/resources/lens-nav-video.svg b/resources/lens-nav-video.svg index 7c07198a9..cd597ad92 100644 --- a/resources/lens-nav-video.svg +++ b/resources/lens-nav-video.svg @@ -1,13 +1,83 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> -<path fill="#FFFFFF" d="M20,4.5H4c-0.532,0-1,0.467-1,1v13c0,0.533,0.468,1,1,1h16c0.533,0,1-0.467,1-1v-13 - C21,4.967,20.533,4.5,20,4.5z M5.5,18.5h-1v-1h1V18.5z M5.5,16.5h-1v-1h1V16.5z M5.5,14.5h-1v-1h1V14.5z M5.5,12.5h-1v-1h1V12.5z - M5.5,10.5h-1v-1h1V10.5z M5.5,8.5h-1v-1h1V8.5z M5.5,6.5h-1v-1h1V6.5z M14.267,13.241c-0.61,0.431-1.226,0.85-1.849,1.259 - c-0.621,0.408-1.226,0.785-1.815,1.129C10.015,15.973,9.479,16.263,9,16.5v-9c0.458,0.236,0.981,0.527,1.57,0.871 - c0.588,0.343,1.194,0.715,1.816,1.113c0.621,0.398,1.243,0.812,1.864,1.242c0.622,0.429,1.205,0.849,1.75,1.257 - C15.455,12.392,14.877,12.812,14.267,13.241z M19.5,18.5h-1v-1h1V18.5z M19.5,16.5h-1v-1h1V16.5z M19.5,14.5h-1v-1h1V14.5z - M19.5,12.5h-1v-1h1V12.5z M19.5,10.5h-1v-1h1V10.5z M19.5,8.5h-1v-1h1V8.5z M19.5,6.5h-1v-1h1V6.5z"/> -</svg> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="24" + height="24" + id="svg3416" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="lens-nav-video.svg"> + <defs + id="defs3418" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:zoom="30.357661" + inkscape:cx="18.097574" + inkscape:cy="11.611567" + inkscape:document-units="px" + inkscape:current-layer="layer1-44" + showgrid="true" + inkscape:window-width="1920" + inkscape:window-height="1029" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1"> + <inkscape:grid + type="xygrid" + id="grid2986" + empspacing="8" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata3421"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1028.3622)"> + <g + style="display:inline" + transform="matrix(1.2489156,0,0,1.2489156,0.01949292,-261.94937)" + id="layer1-44" + inkscape:label="Layer 1" + inkscape:export-filename="PNG/video_lense_icon@18.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="M 7 5 C 3.631252 5.0636947 3 5.5604642 3 9.40625 L 3 16 C 3 19.995531 3.7937498 20 8.59375 20 L 15.40625 20 C 20.206251 20 21 19.995531 21 16 L 21 9.40625 C 21 5.0111911 20.206251 5 15.40625 5 L 8.59375 5 C 7.9937498 5 7.481248 4.9875108 7 5 z M 9.21875 6 C 9.6345286 5.9931551 10.095767 6 10.625 6 L 13.375 6 C 17.62096 6 18.019042 5.9954179 18 9.5 L 18 15.9375 C 18 19.028191 17.62096 19.03125 13.375 19.03125 L 10.625 19.03125 C 6.391137 19.03125 6 19.028191 6 15.9375 L 6 9.5 C 6 6.4334907 6.3083 6.0479142 9.21875 6 z M 4 7.03125 L 5 7.03125 L 5 8 L 4 8 L 4 7.03125 z M 19 7.03125 L 20 7.03125 L 20 8 L 19 8 L 19 7.03125 z M 4 9.03125 L 5 9.03125 L 5 10 L 4 10 L 4 9.03125 z M 19 9.03125 L 20 9.03125 L 20 10 L 19 10 L 19 9.03125 z M 4 11.03125 L 5 11.03125 L 5 12 L 4 12 L 4 11.03125 z M 19 11.03125 L 20 11.03125 L 20 12 L 19 12 L 19 11.03125 z M 4 13.03125 L 5 13.03125 L 5 14 L 4 14 L 4 13.03125 z M 19 13.03125 L 20 13.03125 L 20 14 L 19 14 L 19 13.03125 z M 4 15.03125 L 5 15.03125 L 5 16 L 4 16 L 4 15.03125 z M 19 15.03125 L 20 15.03125 L 20 16 L 19 16 L 19 15.03125 z M 4 17.03125 L 5 17.03125 L 5 18 L 4 18 L 4 17.03125 z M 19 17.03125 L 20 17.03125 L 20 18 L 19 18 L 19 17.03125 z " + transform="matrix(0.80069462,0,0,0.80069462,-0.01560788,1033.1455)" + id="path3022" /> + <path + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + d="m 7.6772898,1040.3518 c 0.9157814,0.075 5.1182162,2.3379 5.1182162,2.8097 0,0.5031 -4.7857672,3.0467 -5.2590848,2.7951 -0.4733172,-0.2515 -0.4733172,-5.3388 0,-5.5904 0.029579,-0.016 0.079817,-0.019 0.1408686,-0.015 z" + id="path4219" + inkscape:connector-curvature="0" /> + </g> + </g> +</svg> diff --git a/shortcuts/ShortcutController.cpp b/shortcuts/ShortcutController.cpp index 62090604f..1be441640 100644 --- a/shortcuts/ShortcutController.cpp +++ b/shortcuts/ShortcutController.cpp @@ -20,6 +20,8 @@ #include "unity-shared/UBusMessages.h" +namespace na = nux::animation; + namespace unity { namespace shortcut @@ -37,8 +39,7 @@ Controller::Controller(std::list<AbstractHint::Ptr> const& hints, , visible_(false) , enabled_(true) , bg_color_(0.0, 0.0, 0.0, 0.5) - , fade_in_animator_(FADE_DURATION) - , fade_out_animator_(FADE_DURATION) + , fade_animator_(FADE_DURATION) { model_->Fill(); @@ -59,31 +60,9 @@ Controller::Controller(std::list<AbstractHint::Ptr> const& hints, ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT); - fade_in_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnFadeInUpdated)); - fade_in_animator_.animation_ended.connect(sigc::mem_fun(this, &Controller::OnFadeInEnded)); - fade_out_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnFadeOutUpdated)); - fade_out_animator_.animation_ended.connect(sigc::mem_fun(this, &Controller::OnFadeOutEnded)); -} - -void Controller::OnFadeInUpdated(double opacity) -{ - view_window_->SetOpacity(opacity); -} - -void Controller::OnFadeInEnded() -{ - view_window_->SetOpacity(1.0); -} - -void Controller::OnFadeOutUpdated(double progress) -{ - double opacity = CLAMP(1.0f - progress, 0.0f, 1.0f); - view_window_->SetOpacity(opacity); -} - -void Controller::OnFadeOutEnded() -{ - view_window_->SetOpacity(0.0); + fade_animator_.updated.connect([this] (double opacity) { + view_window_->SetOpacity(opacity); + }); } void Controller::OnBackgroundUpdate(GVariant* data) @@ -127,8 +106,16 @@ bool Controller::OnShowTimer() if (visible_) { view_->SetupBackground(true); - fade_out_animator_.Stop(); - fade_in_animator_.Start(view_window_->GetOpacity()); + + if (fade_animator_.CurrentState() == na::Animation::State::Running) + { + if (fade_animator_.GetFinishValue() == 0.0f) + fade_animator_.Reverse(); + } + else + { + fade_animator_.SetStartValue(0.0f).SetFinishValue(1.0f).Start(); + } } return false; @@ -184,8 +171,16 @@ void Controller::Hide() if (view_window_) { view_->SetupBackground(false); - fade_in_animator_.Stop(); - fade_out_animator_.Start(1.0 - view_window_->GetOpacity()); + + if (fade_animator_.CurrentState() == na::Animation::State::Running) + { + if (fade_animator_.GetFinishValue() == 1.0f) + fade_animator_.Reverse(); + } + else + { + fade_animator_.SetStartValue(1.0f).SetFinishValue(0.0f).Start(); + } } } @@ -214,11 +209,13 @@ std::string Controller::GetName() const void Controller::AddProperties(GVariantBuilder* builder) { + bool animating = (fade_animator_.CurrentState() == na::Animation::State::Running); + unity::variant::BuilderWrapper(builder) .add("timeout_duration", SUPER_TAP_DURATION + FADE_DURATION) .add("enabled", IsEnabled()) - .add("about_to_show", (Visible() && !fade_out_animator_.IsRunning() && view_window_ && view_window_->GetOpacity() != 1.0f)) - .add("about_to_hide", (Visible() && !fade_in_animator_.IsRunning() && view_window_ && view_window_->GetOpacity() != 1.0f)) + .add("about_to_show", (Visible() && animating && fade_animator_.GetFinishValue() == 1.0f)) + .add("about_to_hide", (Visible() && animating && fade_animator_.GetFinishValue() == 0.0f)) .add("visible", (Visible() && view_window_ && view_window_->GetOpacity() == 1.0f)); } diff --git a/shortcuts/ShortcutController.h b/shortcuts/ShortcutController.h index e4af3c954..cda24de50 100644 --- a/shortcuts/ShortcutController.h +++ b/shortcuts/ShortcutController.h @@ -25,13 +25,13 @@ #include <Nux/BaseWindow.h> #include <Nux/HLayout.h> #include <NuxCore/Color.h> +#include <NuxCore/Animation.h> #include <UnityCore/Variant.h> #include <UnityCore/GLibSource.h> #include "BaseWindowRaiser.h" #include "ShortcutModel.h" #include "ShortcutView.h" -#include "unity-shared/Animator.h" #include "unity-shared/Introspectable.h" #include "unity-shared/UBusWrapper.h" @@ -66,10 +66,6 @@ private: void ConstructView(); void EnsureView(); void OnBackgroundUpdate(GVariant* data); - void OnFadeInUpdated(double opacity); - void OnFadeInEnded(); - void OnFadeOutUpdated(double opacity); - void OnFadeOutEnded(); bool OnShowTimer(); View::Ptr view_; @@ -84,8 +80,7 @@ private: bool enabled_; nux::Color bg_color_; - Animator fade_in_animator_; - Animator fade_out_animator_; + nux::animation::AnimateValue<double> fade_animator_; glib::Source::UniquePtr show_timer_; UBusManager ubus_manager_; diff --git a/shortcuts/StandaloneShortcuts.cpp b/shortcuts/StandaloneShortcuts.cpp index 20c395f37..710757a62 100644 --- a/shortcuts/StandaloneShortcuts.cpp +++ b/shortcuts/StandaloneShortcuts.cpp @@ -21,7 +21,9 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include <Nux/Nux.h> +#include <Nux/NuxTimerTickSource.h> #include <Nux/WindowThread.h> +#include <NuxCore/AnimationController.h> #include "unity-shared/BackgroundEffectHelper.h" #include "BaseWindowRaiserImp.h" @@ -31,10 +33,36 @@ using namespace unity; -static shortcut::Controller::Ptr controller; +struct ShortcutsWindow +{ + ShortcutsWindow() + : wt(nux::CreateGUIThread("Unity Shortcut Hint Overlay", 1024, 768, 0, &ShortcutsWindow::ThreadWidgetInit, this)) + , animation_controller(tick_source) + {} + + void Show() + { + wt->Run(nullptr); + } + +private: + void Init(); + + static void ThreadWidgetInit(nux::NThread* thread, void* self) + { + static_cast<ShortcutsWindow*>(self)->Init(); + } + + unity::Settings settings; + std::shared_ptr<nux::WindowThread> wt; + nux::NuxTimerTickSource tick_source; + nux::animation::AnimationController animation_controller; + shortcut::Controller::Ptr controller; +}; -void ThreadWidgetInit(nux::NThread* thread, void* InitData) +void ShortcutsWindow::Init() { + BackgroundEffectHelper::blur_type = BLUR_NONE; std::list<std::shared_ptr<shortcut::AbstractHint>> hints; // Launcher... @@ -232,22 +260,16 @@ void ThreadWidgetInit(nux::NThread* thread, void* InitData) "initiate_key"))); auto base_window_raiser_ = std::make_shared<shortcut::BaseWindowRaiserImp>(); - controller.reset(new shortcut::Controller(hints, base_window_raiser_)); + controller = std::make_shared<shortcut::Controller>(hints, base_window_raiser_); controller->Show(); } int main(int argc, char** argv) { - g_type_init(); gtk_init(&argc, &argv); nux::NuxInitialize(0); - unity::Settings settings; - - BackgroundEffectHelper::blur_type = BLUR_NONE; - nux::WindowThread* wt = nux::CreateGUIThread(TEXT("Unity Shortcut Hint Overlay"), 1200, 720, 0, &ThreadWidgetInit, 0); + ShortcutsWindow().Show(); - wt->Run(NULL); - delete wt; return 0; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 83099eb54..bdd860a1b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -13,6 +13,9 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/bzr-handle-patch.d ${CMAKE_BINARY_DIR}/tests/data/applications/bzr-handle-patch.desktop) configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/no-icon.desktop ${CMAKE_BINARY_DIR}/tests/data/applications/no-icon.desktop) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/data/applications/kde4/afile.desktop + ${CMAKE_BINARY_DIR}/tests/data/applications/kde4/afile.desktop) + # # Unit tests # @@ -105,7 +108,6 @@ if (GTEST_SRC_DIR AND # The actual test executable (xless) - do not put anything that requires X in here set (GTEST_XLESS_SOURCES test_main_xless.cpp - #test_animator.cpp # XXX: disabled, to be removed completely soon test_launcher_model.cpp test_glib_object.cpp test_glib_object_utils.cpp @@ -239,7 +241,8 @@ if (ENABLE_X_SUPPORT) test_single_monitor_launcher_icon.cpp test_expo_launcher_icon.cpp test_showdesktop_handler.cpp - test_static_cairo_text.cpp + test_software_center_launcher_icon.cpp + test_static_cairo_text.cpp test_switcher_controller.cpp test_switcher_model.cpp test_texture_cache.cpp diff --git a/tests/autopilot/unity/tests/test_hud.py b/tests/autopilot/unity/tests/test_hud.py index d1f6d7a11..9d7ba21c2 100644 --- a/tests/autopilot/unity/tests/test_hud.py +++ b/tests/autopilot/unity/tests/test_hud.py @@ -329,7 +329,8 @@ class HudBehaviorTests(HudTestsBase): """Tests that Alt+ArrowKey events are correctly passed to the active window when Unity is not responding to them.""" - self.start_app_window("Terminal") + term_win = self.start_app_window("Terminal") + self.assertProperty(term_win, is_focused=True) #There's no easy way to read text from terminal, writing input #to a text file and then reading from there works. diff --git a/tests/autopilot/unity/tests/xim/test_gcin.py b/tests/autopilot/unity/tests/xim/test_gcin.py index 19de2c8a9..3a5adacbc 100644 --- a/tests/autopilot/unity/tests/xim/test_gcin.py +++ b/tests/autopilot/unity/tests/xim/test_gcin.py @@ -19,7 +19,6 @@ from unity.tests import UnityTestCase class GcinTestCase(UnityTestCase): """Tests the Input Method gcin.""" - @skip("Currenlty no XIM support in Nux") def setUp(self): super(GcinTestCase, self).setUp() @@ -44,17 +43,14 @@ class GcinTestHangul(GcinTestCase): ('national script', {'input': 'gug mun ', 'result': u'\uad6d\ubb38'}), ] - @skip("Currenlty no XIM support in Nux") def setUp(self): super(GcinTestHangul, self).setUp() - @skip("Currenlty no XIM support in Nux") def enter_hangul_mode(self): """Ctrl+Space turns gcin on, Ctrl+Alt+/ turns hangul on.""" self.keyboard.press_and_release("Ctrl+Space") self.keyboard.press_and_release("Ctrl+Alt+/") - @skip("Currenlty no XIM support in Nux") def test_dash_input(self): """Entering an input string through gcin will result in a Korean string result in the dash.""" @@ -65,7 +61,6 @@ class GcinTestHangul(GcinTestCase): self.keyboard.type(self.input) self.assertThat(self.dash.search_string, Eventually(Equals(self.result))) - @skip("Currenlty no XIM support in Nux") def test_hud_input(self): """Entering an input string through gcin will result in a Korean string result in the hud.""" diff --git a/tests/data/applications/kde4/afile.desktop b/tests/data/applications/kde4/afile.desktop new file mode 100644 index 000000000..fa07d53e5 --- /dev/null +++ b/tests/data/applications/kde4/afile.desktop @@ -0,0 +1,37 @@ +[Desktop Entry] +X-AppInstall-Package=gedit +X-AppInstall-Popcon=78622 +X-AppInstall-Section=main + +Name=gedit +GenericName=Text Editor +Comment=Edit text files +Exec=gedit %U +Terminal=false +Type=Application +StartupNotify=true +MimeType=text/plain; +Icon=accessories-text-editor +Categories=GNOME;GTK;Utility;TextEditor; +X-GNOME-DocPath=gedit/gedit.xml +X-GNOME-FullName=Text Editor +X-GNOME-Bugzilla-Bugzilla=GNOME +X-GNOME-Bugzilla-Product=gedit +X-GNOME-Bugzilla-Component=general +X-GNOME-Bugzilla-Version=3.6.0 +X-GNOME-Bugzilla-ExtraInfoScript=/usr/share/gedit/gedit-bugreport +Actions=Window;Document; +Keywords=Text;Plaintext;Write; + + +[Desktop Action Window] +Name=Open a New Window +Exec=gedit --new-window +OnlyShowIn=Unity; + +[Desktop Action Document] +Name=Open a New Document +Exec=gedit --new-document +OnlyShowIn=Unity; + +X-Ubuntu-Gettext-Domain=app-install-data diff --git a/tests/test_animator.cpp b/tests/test_animator.cpp deleted file mode 100644 index b0ec0adde..000000000 --- a/tests/test_animator.cpp +++ /dev/null @@ -1,277 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2011 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 (Treviño) <3v1n0@ubuntu.com> - */ - -#include <gtest/gtest.h> - -#include "Animator.h" -#include "test_utils.h" - -using namespace std; -using namespace unity; - -namespace -{ - -class TestAnimator : public ::testing::Test -{ -public: - TestAnimator() : - test_animator_(100), - n_steps_(0), - current_progress_(0.0f), - got_update_(false), - half_reached_(false), - started_(false), - stopped_(false), - ended_(false) - { - test_animator_.animation_started.connect([this]() { - started_ = true; - }); - - test_animator_.animation_ended.connect([this]() { - ended_ = true; - }); - - test_animator_.animation_stopped.connect([this](double progress) { - stopped_ = true; - }); - - test_animator_.animation_updated.connect([this](double progress) { - n_steps_++; - current_progress_ = progress; - got_update_ = true; - - if (progress >= 0.5f) - half_reached_ = true; - }); - } - -protected: - void ResetValues() - { - n_steps_ = 0; - current_progress_ = 0.0f; - started_ = false; - stopped_ = false; - ended_ = false; - got_update_ = false; - half_reached_ = false; - } - - Animator test_animator_; - unsigned int n_steps_; - double current_progress_; - bool got_update_; - bool half_reached_; - bool started_; - bool stopped_; - bool ended_; -}; - -TEST_F(TestAnimator, ConstructDestroy) -{ - bool stopped = false; - double progress = 0.0f; - - { - Animator tmp_animator(400, 20); - - EXPECT_EQ(tmp_animator.GetDuration(), 400); - EXPECT_EQ(tmp_animator.GetRate(), 20); - - bool got_update = false; - tmp_animator.animation_updated.connect([&progress, &got_update](double p) { - progress = p; - got_update = true; - }); - - tmp_animator.animation_stopped.connect([&stopped](double p) { - stopped = true; - }); - - tmp_animator.Start(); - - Utils::WaitUntil(got_update); - - EXPECT_EQ(tmp_animator.IsRunning(), true); - EXPECT_GT(progress, 0.0f); - EXPECT_EQ(stopped, false); - } - - EXPECT_EQ(stopped, true); -} - -TEST_F(TestAnimator, SetGetValues) -{ - test_animator_.SetRate(30); - EXPECT_EQ(test_animator_.GetRate(), 30); - - test_animator_.SetDuration(100); - EXPECT_EQ(test_animator_.GetDuration(), 100); - - EXPECT_EQ(test_animator_.GetProgress(), 0.0f); - EXPECT_EQ(test_animator_.IsRunning(), false); -} - -TEST_F(TestAnimator, SimulateStep) -{ - test_animator_.DoStep(); - EXPECT_EQ(test_animator_.IsRunning(), false); - EXPECT_EQ(n_steps_, 1); - EXPECT_GT(test_animator_.GetProgress(), 0.0f); - ResetValues(); -} - -TEST_F(TestAnimator, SimulateAnimation) -{ - test_animator_.SetRate(20); - test_animator_.SetDuration(400); - test_animator_.Start(); - - EXPECT_EQ(started_, true); - EXPECT_EQ(test_animator_.IsRunning(), true); - - Utils::WaitUntil(got_update_); - EXPECT_GT(test_animator_.GetProgress(), 0.0f); - EXPECT_EQ(test_animator_.GetProgress(), current_progress_); - EXPECT_GE(n_steps_, 1); - - Utils::WaitUntil(ended_); - EXPECT_EQ(stopped_, false); - EXPECT_EQ(ended_, true); - - ResetValues(); -} - -TEST_F(TestAnimator, SimulateStoppedAnimation) -{ - test_animator_.SetRate(20); - test_animator_.SetDuration(400); - test_animator_.Start(); - EXPECT_EQ(started_, true); - EXPECT_EQ(test_animator_.IsRunning(), true); - - Utils::WaitUntil(half_reached_); - EXPECT_GT(test_animator_.GetProgress(), 0.5f); - EXPECT_EQ(test_animator_.GetProgress(), current_progress_); - EXPECT_EQ(test_animator_.IsRunning(), true); - - test_animator_.Stop(); - EXPECT_EQ(test_animator_.IsRunning(), false); - EXPECT_LT(test_animator_.GetProgress(), 1.0f); - EXPECT_EQ(stopped_, true); - EXPECT_EQ(ended_, true); - - ResetValues(); -} - -TEST_F(TestAnimator, SimulateStoppedAndContinueAnimation) -{ - test_animator_.SetRate(20); - test_animator_.SetDuration(400); - test_animator_.Start(); - EXPECT_EQ(started_, true); - EXPECT_EQ(test_animator_.IsRunning(), true); - - Utils::WaitUntil(half_reached_); - test_animator_.Stop(); - - EXPECT_LT(test_animator_.GetProgress(), 1.0f); - EXPECT_EQ(stopped_, true); - EXPECT_EQ(ended_, true); - stopped_ = false; - ended_ = false; - - test_animator_.Start(test_animator_.GetProgress()); - Utils::WaitUntil(ended_); - EXPECT_EQ(stopped_, false); - EXPECT_EQ(ended_, true); - - ResetValues(); -} - -TEST_F(TestAnimator, SimulateOneTimeDurationStart) -{ - unsigned int default_duration = 100; - - test_animator_.SetRate(20); - test_animator_.SetDuration(default_duration); - - unsigned int one_time_duration = 200; - test_animator_.Start(one_time_duration); - EXPECT_EQ(started_, true); - EXPECT_EQ(test_animator_.IsRunning(), true); - - Utils::WaitUntil(half_reached_); - EXPECT_LT(test_animator_.GetProgress(), 1.0f); - EXPECT_EQ(test_animator_.GetDuration(), one_time_duration); - EXPECT_EQ(ended_, false); - - Utils::WaitUntil(ended_); - EXPECT_EQ(stopped_, false); - EXPECT_EQ(ended_, true); - - EXPECT_EQ(test_animator_.GetDuration(), default_duration); - - ResetValues(); -} - -TEST_F(TestAnimator, SimulateOneTimeDurationStartStop) -{ - unsigned int default_duration = 100; - - test_animator_.SetRate(20); - test_animator_.SetDuration(default_duration); - - unsigned int one_time_duration = 200; - test_animator_.Start(one_time_duration); - EXPECT_EQ(started_, true); - EXPECT_EQ(test_animator_.IsRunning(), true); - - Utils::WaitUntil(half_reached_); - EXPECT_EQ(test_animator_.GetDuration(), one_time_duration); - EXPECT_EQ(ended_, false); - - test_animator_.Stop(); - EXPECT_EQ(stopped_, true); - EXPECT_EQ(ended_, true); - EXPECT_EQ(test_animator_.GetDuration(), default_duration); - - ResetValues(); -} - -TEST_F(TestAnimator, SimulateZeroDuration) -{ - test_animator_.SetRate(20); - test_animator_.SetDuration(0); - - EXPECT_EQ(started_, false); - EXPECT_EQ(ended_, false); - EXPECT_EQ(test_animator_.IsRunning(), false); - - test_animator_.Start(); - EXPECT_EQ(started_, true); - - Utils::WaitUntil(ended_); - EXPECT_EQ(ended_, true); -} - - -} // Namespace diff --git a/tests/test_dash_controller.cpp b/tests/test_dash_controller.cpp index ccdf1c0d8..f2fed5945 100644 --- a/tests/test_dash_controller.cpp +++ b/tests/test_dash_controller.cpp @@ -23,6 +23,8 @@ #include "unity-shared/UnitySettings.h" #include "test_utils.h" +#include <NuxCore/AnimationController.h> + using namespace unity; using namespace testing; @@ -34,8 +36,9 @@ class TestDashController : public Test { public: TestDashController() - : base_window_(new testmocks::MockBaseWindow([](nux::Geometry const& geo) - { return geo; })) + : animation_controller(tick_source) + , base_window_(new testmocks::MockBaseWindow([](nux::Geometry const& geo) + { return geo; })) { } virtual void SetUp() @@ -50,6 +53,9 @@ public: } protected: + nux::animation::TickSource tick_source; + nux::animation::AnimationController animation_controller; + dash::Controller::Ptr controller_; testmocks::MockBaseWindow::Ptr base_window_; @@ -75,7 +81,7 @@ TEST_F(TestDashController, TestShowAndHideDash) } controller_->ShowDash(); - Utils::WaitForTimeout(1); + tick_source.tick.emit(1000*1000); Mock::VerifyAndClearExpectations(base_window_.GetPointer()); EXPECT_EQ(base_window_->GetOpacity(), 1.0); @@ -89,10 +95,11 @@ TEST_F(TestDashController, TestShowAndHideDash) } controller_->HideDash(); - Utils::WaitForTimeout(1); + tick_source.tick.emit(2000*1000); // Verify final conditions EXPECT_EQ(base_window_->GetOpacity(), 0.0); } } + diff --git a/tests/test_launcher_controller.cpp b/tests/test_launcher_controller.cpp index ebdb0f66f..b6df73206 100644 --- a/tests/test_launcher_controller.cpp +++ b/tests/test_launcher_controller.cpp @@ -929,6 +929,7 @@ TEST_F(TestLauncherController, GetLastIconPriorityUnStickyWithNoIconsAndUri) lc.Impl()->SetupIcons(); auto first_icon = lc.Impl()->GetIconByUri(FavoriteStore::URI_PREFIX_APP + app::SW_CENTER); + ASSERT_TRUE(first_icon); int last_priority = lc.Impl()->GetLastIconPriority<VolumeLauncherIcon>(places::DEVICES_URI); EXPECT_EQ(last_priority, first_icon->SortPriority() - 1); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 9e1289d37..cc5d3612f 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -3,12 +3,20 @@ #include <gtk/gtk.h> #include <NuxCore/Logger.h> #include <Nux/Nux.h> +#include <config.h> #include "logger_helper.h" int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); + + // init XDG_DATA_DIRS before GTK to point to the local test-dir as + // the environment is only read once by glib and then cached + const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data:/usr/share"; + g_setenv("XDG_DATA_DIRS", LOCAL_DATA_DIR.c_str(), TRUE); + + gtk_init(&argc, &argv); setlocale(LC_ALL, "C"); diff --git a/tests/test_overlay_scrollbar.cpp b/tests/test_overlay_scrollbar.cpp index d1c3cc13d..b6f3742ea 100644 --- a/tests/test_overlay_scrollbar.cpp +++ b/tests/test_overlay_scrollbar.cpp @@ -22,16 +22,20 @@ #include <gtest/gtest.h> #include <Nux/Nux.h> -#include <NuxCore/ObjectPtr.h> +#include <Nux/NuxTimerTickSource.h> #include <Nux/VLayout.h> +#include <NuxCore/ObjectPtr.h> +#include <NuxCore/AnimationController.h> + #include "unity-shared/VScrollBarOverlayWindow.h" #include "unity-shared/PlacesOverlayVScrollBar.h" #include "unity-shared/UScreen.h" +using namespace unity::dash; using namespace testing; -namespace +namespace unity { class TestOverlayWindow : public Test @@ -50,103 +54,179 @@ public: nux::ObjectPtr<VScrollBarOverlayWindow> overlay_window_; }; -class TestOverlayScrollBar : public Test +namespace dash +{ + +class MockScrollBar : public unity::dash::PlacesOverlayVScrollBar +{ + public: + MockScrollBar(NUX_FILE_LINE_DECL) + : PlacesOverlayVScrollBar(NUX_FILE_LINE_PARAM) + , scroll_tick_(1000 * 401) + , scroll_dy_(0) + , scroll_up_signal_(false) + , scroll_down_signal_(false) + { + OnScrollUp.connect([&] (float step, int dy) { + scroll_dy_ = dy; + scroll_up_signal_ = true; + }); + + OnScrollDown.connect([&] (float step, int dy) { + scroll_dy_ = dy; + scroll_down_signal_ = true; + }); + } + + // ScrollDown/Up moves the mouse over the overlay scroll bar, then + // moves it down/up by scroll_dy + void ScrollDown(int scroll_dy) + { + UpdateStepY(); + + auto geo = overlay_window_->GetThumbGeometry(); + int x = geo.x; + int y = geo.y; + + MoveMouse(x, y); + MoveDown(x, y); + + MoveMouse(x, y+scroll_dy); + MoveUp(x, y+scroll_dy); + } + + void ScrollUp(int scroll_dy) + { + UpdateStepY(); + + auto geo = overlay_window_->GetThumbGeometry(); + int x = geo.x; + int y = geo.y; + + MoveMouse(x, y); + MoveDown(x, y); + + MoveMouse(x, y-scroll_dy); + MoveUp(x, y-scroll_dy); + } + + void MoveDown(int x, int y) + { + nux::Event event; + event.type = nux::NUX_MOUSE_PRESSED; + event.x = x; + event.y = y; + nux::GetWindowCompositor().ProcessEvent(event); + } + + void MoveUp(int x, int y) + { + nux::Event event; + event.type = nux::NUX_MOUSE_RELEASED; + event.x = x; + event.y = y; + nux::GetWindowCompositor().ProcessEvent(event); + } + + void MoveMouse(int x, int y) + { + nux::Event event; + event.type = nux::NUX_MOUSE_MOVE; + event.x = x; + event.y = y; + nux::GetWindowCompositor().ProcessEvent(event); + } + + void MoveMouseNear() + { + auto geo = overlay_window_->GetThumbGeometry(); + MoveMouse(geo.x, geo.y); + } + + void ScrollUpAnimation(int scroll_dy) + { + nux::animation::AnimationController animation_controller(tick_source_); + + MoveMouseNear(); + UpdateStepY(); + + StartScrollAnimation(ScrollDir::UP, scroll_dy); + tick_source_.tick(scroll_tick_); + } + + void ScrollDownAnimation(int scroll_dy) + { + nux::animation::AnimationController animation_controller(tick_source_); + + MoveMouseNear(); + UpdateStepY(); + + StartScrollAnimation(ScrollDir::DOWN, scroll_dy); + tick_source_.tick(scroll_tick_); + } + + void SetThumbOffset(int y) + { + overlay_window_->SetThumbOffsetY(y); + UpdateConnectorPosition(); + } + + void StartScrollThenConnectorAnimation() + { + nux::animation::AnimationController animation_controller(tick_source_); + + StartScrollAnimation(ScrollDir::DOWN, 20); + MoveMouse(0,0); + StartConnectorAnimation(); + + tick_source_.tick(scroll_tick_); + } + + nux::NuxTimerTickSource tick_source_; + + using PlacesOverlayVScrollBar::connector_height_; + using VScrollBar::_slider; + + int scroll_tick_; + int scroll_dy_; + bool scroll_up_signal_; + bool scroll_down_signal_; +}; + +} + +class MockScrollView : public nux::ScrollView { public: - class MockScrollBar : public unity::dash::PlacesOverlayVScrollBar + MockScrollView(NUX_FILE_LINE_DECL) + : nux::ScrollView(NUX_FILE_LINE_PARAM) { - public: - MockScrollBar(NUX_FILE_LINE_DECL) - : unity::dash::PlacesOverlayVScrollBar(NUX_FILE_LINE_PARAM) - , scroll_dy(0) - , scroll_up_signal_(false) - , scroll_down_signal_(false) - { - SetGeometry(nux::Geometry(0,0,200,500)); - SetContainerSize(0,0,200,200); - SetContentSize(0,0,200,2000); - ComputeContentSize(); - - OnScrollUp.connect([&] (float step, int dy) { - scroll_dy = dy; - scroll_up_signal_ = true; - }); - - OnScrollDown.connect([&] (float step, int dy) { - scroll_dy = dy; - scroll_down_signal_ = true; - }); - } - - void ScrollDown(int scroll_dy) - { - // Shows we are over the Overlay Thumb - int x = _track->GetBaseX() + _track->GetBaseWidth() + 5; - int y = _track->GetBaseY(); - - MoveMouse(x,y); - MoveDown(x,y); - - MoveMouse(x,y+scroll_dy); - MoveUp(x,y+scroll_dy); - } - - void ScrollUp(int scroll_dy) - { - ScrollDown(scroll_dy); - - // Shows we are over the Overlay Thumb - int x = _track->GetBaseX() + _track->GetBaseWidth() + 5; - int y = _track->GetBaseY(); - - MoveMouse(x,y+scroll_dy); - MoveDown(x,y+scroll_dy); - - MoveMouse(x,y); - MoveUp(x,y); - } - - void MoveDown(int x, int y) - { - nux::Event event; - event.type = nux::NUX_MOUSE_PRESSED; - event.x = x; - event.y = y; - nux::GetWindowCompositor().ProcessEvent(event); - } - - void MoveUp(int x, int y) - { - nux::Event event; - event.type = nux::NUX_MOUSE_RELEASED; - event.x = x; - event.y = y; - nux::GetWindowCompositor().ProcessEvent(event); - } - - void MoveMouse(int x, int y) - { - nux::Event event; - event.type = nux::NUX_MOUSE_MOVE; - event.x = x; - event.y = y; - nux::GetWindowCompositor().ProcessEvent(event); - } - - using nux::VScrollBar::AtMinimum; - using nux::VScrollBar::GetBaseHeight; - - int scroll_dy; - bool scroll_up_signal_; - bool scroll_down_signal_; - }; - - TestOverlayScrollBar() + scroll_bar_ = new MockScrollBar(NUX_TRACKER_LOCATION); + SetVScrollBar(scroll_bar_.GetPointer()); + } + + nux::ObjectPtr<MockScrollBar> scroll_bar_; +}; + +class TestOverlayVScrollBar : public Test +{ +public: + TestOverlayVScrollBar() { - scroll_bar_ = std::make_shared<MockScrollBar>(NUX_TRACKER_LOCATION); + nux::VLayout* scroll_layout_ = new nux::VLayout(NUX_TRACKER_LOCATION); + scroll_layout_->SetGeometry(0,0,1000,5000); + scroll_layout_->SetScaleFactor(0); + + scroll_view_ = new MockScrollView(NUX_TRACKER_LOCATION); + scroll_view_->EnableVerticalScrollBar(true); + scroll_view_->EnableHorizontalScrollBar(false); + scroll_view_->SetLayout(scroll_layout_); + + scroll_view_->scroll_bar_->SetContentSize(0, 0, 201, 2000); + scroll_view_->scroll_bar_->SetContainerSize(0, 0, 202, 400); } - std::shared_ptr<MockScrollBar> scroll_bar_; + nux::ObjectPtr<MockScrollView> scroll_view_; }; TEST_F(TestOverlayWindow, TestOverlayShows) @@ -161,6 +241,7 @@ TEST_F(TestOverlayWindow, TestOverlayHides) EXPECT_TRUE(overlay_window_->IsVisible()); overlay_window_->MouseBeyond(); + overlay_window_->MouseLeave(); EXPECT_FALSE(overlay_window_->IsVisible()); } @@ -170,6 +251,7 @@ TEST_F(TestOverlayWindow, TestOverlayStaysOpenWhenMouseDown) overlay_window_->MouseDown(); overlay_window_->MouseBeyond(); + overlay_window_->MouseLeave(); EXPECT_TRUE(overlay_window_->IsVisible()); } @@ -241,40 +323,101 @@ TEST_F(TestOverlayWindow, TestOverlayMouseIsInsideOnOffsetChange) EXPECT_FALSE(overlay_window_->IsMouseInsideThumb(offset_y + thumb_height + 1)); } -TEST_F(TestOverlayScrollBar, TestScrollDownSignal) + +TEST_F(TestOverlayVScrollBar, TestScrollDownSignal) { - scroll_bar_->ScrollDown(10); - EXPECT_TRUE(scroll_bar_->scroll_down_signal_); + scroll_view_->scroll_bar_->ScrollDown(10); + EXPECT_TRUE(scroll_view_->scroll_bar_->scroll_down_signal_); } -TEST_F(TestOverlayScrollBar, TestScrollUpSignal) +TEST_F(TestOverlayVScrollBar, TestScrollUpSignal) { - scroll_bar_->ScrollUp(10); - EXPECT_TRUE(scroll_bar_->scroll_up_signal_); + scroll_view_->scroll_bar_->ScrollDown(10); + scroll_view_->scroll_bar_->ScrollUp(10); + EXPECT_TRUE(scroll_view_->scroll_bar_->scroll_up_signal_); } -TEST_F(TestOverlayScrollBar, TestScrollDownDeltaY) +TEST_F(TestOverlayVScrollBar, TestScrollDownDeltaY) { int scroll_down = 15; - scroll_bar_->ScrollDown(scroll_down); - EXPECT_EQ(scroll_bar_->scroll_dy, scroll_down); + scroll_view_->scroll_bar_->ScrollDown(scroll_down); + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, scroll_down); } -TEST_F(TestOverlayScrollBar, TestScrollUpDeltaY) +TEST_F(TestOverlayVScrollBar, TestScrollUpDeltaY) { int scroll_up = 7; - scroll_bar_->ScrollUp(scroll_up); - EXPECT_EQ(scroll_bar_->scroll_dy, scroll_up); + scroll_view_->scroll_bar_->ScrollDown(scroll_up+1); + scroll_view_->scroll_bar_->ScrollUp(scroll_up); + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, scroll_up); } -TEST_F(TestOverlayScrollBar, TestScrollsSlowlyDeltaY) +TEST_F(TestOverlayVScrollBar, TestScrollDownBaseYMoves) +{ + int slider_y = scroll_view_->scroll_bar_->_slider->GetBaseY(); + int scroll_down = 10; + scroll_view_->scroll_bar_->ScrollDown(scroll_down); + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, scroll_down); + EXPECT_GT(scroll_view_->scroll_bar_->_slider->GetBaseY(), slider_y); +} + +TEST_F(TestOverlayVScrollBar, TestScrollUpBaseYMoves) +{ + int scroll_up = 10; + scroll_view_->scroll_bar_->ScrollDown(scroll_up+1); + + int slider_y = scroll_view_->scroll_bar_->_slider->GetBaseY(); + scroll_view_->scroll_bar_->ScrollUp(scroll_up); + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, scroll_up); + EXPECT_LT(scroll_view_->scroll_bar_->_slider->GetBaseY(), slider_y); +} + +TEST_F(TestOverlayVScrollBar, TestScrollsSlowlyDeltaY) { int scroll_down = 10; for (int i = 0; i < scroll_down; i++) { - scroll_bar_->ScrollDown(1); - EXPECT_EQ(scroll_bar_->scroll_dy, 1); + scroll_view_->scroll_bar_->ScrollDown(1); + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, 1); } } +TEST_F(TestOverlayVScrollBar, TestScrollUpAnimationMovesSlider) +{ + int scroll_up = 10; + scroll_view_->scroll_bar_->ScrollDown(scroll_up+10); + + int slider_y = scroll_view_->scroll_bar_->_slider->GetBaseY(); + scroll_view_->scroll_bar_->ScrollUpAnimation(scroll_up); + + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, scroll_up); + EXPECT_LT(scroll_view_->scroll_bar_->_slider->GetBaseY(), slider_y); +} + +TEST_F(TestOverlayVScrollBar, TestScrollDownAnimationMovesSlider) +{ + int scroll_down = 10; + int slider_y = scroll_view_->scroll_bar_->_slider->GetBaseY(); + + scroll_view_->scroll_bar_->ScrollDownAnimation(scroll_down); + + EXPECT_EQ(scroll_view_->scroll_bar_->scroll_dy_, scroll_down); + EXPECT_GT(scroll_view_->scroll_bar_->_slider->GetBaseY(), slider_y); +} + +TEST_F(TestOverlayVScrollBar, TestConnectorResetsDuringScrollAnimation) +{ + scroll_view_->scroll_bar_->MoveMouseNear(); + scroll_view_->scroll_bar_->SetThumbOffset(100); + + int connector_height = scroll_view_->scroll_bar_->connector_height_; + EXPECT_GT(connector_height, 0); + + scroll_view_->scroll_bar_->StartScrollThenConnectorAnimation(); + + connector_height = scroll_view_->scroll_bar_->connector_height_; + EXPECT_EQ(connector_height, 0); } + +} + diff --git a/tests/test_software_center_launcher_icon.cpp b/tests/test_software_center_launcher_icon.cpp index 1ca700e67..a89e33bd7 100644 --- a/tests/test_software_center_launcher_icon.cpp +++ b/tests/test_software_center_launcher_icon.cpp @@ -15,11 +15,16 @@ * <http://www.gnu.org/licenses/> * * Authored by: Marco Trevisan (Treviño) <marco.trevisan@canonical.com> + * Michael Vogt <mvo@ubuntu.com> + * + * Run standalone with: + * cd build && make test-gtest && ./test-gtest --gtest_filter=TestSoftwareCenterLauncherIcon.* */ #include <config.h> #include <gmock/gmock.h> +#include "ApplicationManager.h" #include "SoftwareCenterLauncherIcon.h" #include "Launcher.h" #include "PanelStyle.h" @@ -29,28 +34,88 @@ using namespace unity; using namespace unity::launcher; -namespace +namespace unity +{ +namespace launcher +{ +const std::string LOCAL_DATA_DIR = BUILDDIR"/tests/data"; +const std::string USC_DESKTOP = LOCAL_DATA_DIR+"/applications/ubuntu-software-center.desktop"; + +class MockSoftwareCenterLauncherIcon : public SoftwareCenterLauncherIcon { -const std::string USC_DESKTOP = BUILDDIR"/tests/data/applications/ubuntu-software-center.desktop"; +public: + MockSoftwareCenterLauncherIcon(ApplicationPtr const& app, + std::string const& aptdaemon_trans_id, + std::string const& icon_path) + : SoftwareCenterLauncherIcon(app, aptdaemon_trans_id, icon_path) + {} + + using SoftwareCenterLauncherIcon::GetActualDesktopFileAfterInstall; + using SoftwareCenterLauncherIcon::_desktop_file; + using SoftwareCenterLauncherIcon::GetRemoteUri; + using SoftwareCenterLauncherIcon::OnFinished; + +}; struct TestSoftwareCenterLauncherIcon : testing::Test { +public: TestSoftwareCenterLauncherIcon() - : bamf_matcher(bamf_matcher_get_default()) - , usc(bamf_matcher_get_application_for_desktop_file(bamf_matcher, USC_DESKTOP.c_str(), TRUE), glib::AddRef()) - , icon(usc, "", "") + : usc(ApplicationManager::Default().GetApplicationForDesktopFile(USC_DESKTOP)) + , icon(usc, "", "") {} - glib::Object<BamfMatcher> bamf_matcher; - glib::Object<BamfApplication> usc; - SoftwareCenterLauncherIcon icon; + ApplicationPtr usc; + MockSoftwareCenterLauncherIcon icon; }; TEST_F(TestSoftwareCenterLauncherIcon, Construction) { EXPECT_FALSE(icon.IsVisible()); EXPECT_EQ(icon.position(), AbstractLauncherIcon::Position::FLOATING); - EXPECT_EQ(icon.tooltip_text(), bamf_view_get_name(glib::object_cast<BamfView>(usc))); + EXPECT_EQ(icon.tooltip_text(), usc->title()); +} + +TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformTrivial) +{ + // no transformation needed + EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP); +} + +TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformAppInstall) +{ + // ensure that tranformation from app-install data desktop files works + icon._desktop_file = "/usr/share/app-install/desktop/pkgname:kde4__afile.desktop"; + EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), + BUILDDIR"/tests/data/applications/kde4/afile.desktop"); +} + +TEST_F(TestSoftwareCenterLauncherIcon, DesktopFileTransformSCAgent) +{ + // now simualte data coming from the sc-agent + icon._desktop_file = "/tmp/software-center-agent:VP2W9M:ubuntu-software-center.desktop"; + EXPECT_EQ(icon.GetActualDesktopFileAfterInstall(), USC_DESKTOP); +} + +// simulate a OnFinished signal from a /usr/share/app-install location +// and ensure that the remote uri is updated from temp location to +// the real location +TEST_F(TestSoftwareCenterLauncherIcon, OnFinished) +{ + + // simulate desktop file from app-install-data + icon._desktop_file = "/usr/share/app-install/desktop/software-center:ubuntu-software-center.desktop"; + + // now simulate that the install was successful + GVariant *params = g_variant_new("(s)", "exit-success"); + icon.OnFinished(params); + + // and verify that both the desktop file and the remote uri gets updated + EXPECT_EQ(icon._desktop_file, USC_DESKTOP); + EXPECT_EQ(icon.GetRemoteUri(), + "application://ubuntu-software-center.desktop"); + + g_variant_unref(params); } TEST_F(TestSoftwareCenterLauncherIcon, Animate) @@ -60,8 +125,7 @@ TEST_F(TestSoftwareCenterLauncherIcon, Animate) Settings settings; panel::Style panel; nux::ObjectPtr<nux::BaseWindow> win(new nux::BaseWindow("")); - nux::ObjectPtr<DNDCollectionWindow> cwin(new DNDCollectionWindow); - nux::ObjectPtr<Launcher> launcher(new Launcher(win.GetPointer(), cwin)); + nux::ObjectPtr<Launcher> launcher(new Launcher(win.GetPointer())); launcher->options = Options::Ptr(new Options); launcher->SetModel(LauncherModel::Ptr(new LauncherModel)); @@ -72,3 +136,5 @@ TEST_F(TestSoftwareCenterLauncherIcon, Animate) } } + +} diff --git a/unity-shared/Animator.cpp b/unity-shared/Animator.cpp deleted file mode 100644 index 18ec7139b..000000000 --- a/unity-shared/Animator.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2011 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 (Treviño) <mail@3v1n0.net> - */ - -#include "Animator.h" - -namespace unity -{ - -Animator::Animator(unsigned int default_duration, unsigned int fps_rate) - : start_time_(0) - , rate_(1) - , duration_(0) - , one_time_duration_(0) - , start_progress_(0.0f) - , progress_(0.0f) -{ - SetDuration(default_duration); - SetRate(fps_rate); -} - -Animator::~Animator() -{ - Stop(); -} - -void Animator::SetRate(unsigned int fps_rate) -{ - if (fps_rate != 0) - rate_ = 1000 / fps_rate; -} - -void Animator::SetDuration(unsigned int duration) -{ - duration_ = duration * 1000; -} - -unsigned int Animator::GetRate() const -{ - if (rate_ != 0) - return 1000 / rate_; - - return rate_; -} - -unsigned int Animator::GetDuration() const -{ - return (one_time_duration_ > 0 ? one_time_duration_ : duration_) / 1000; -} - -bool Animator::IsRunning() const -{ - return bool(timeout_); -} - -double Animator::GetProgress() const -{ - return progress_; -} - -void Animator::Start(unsigned int one_time_duration, double start_progress) -{ - if (!timeout_ && start_progress < 1.0f) - { - if (start_progress < 0.0f) - start_progress = 0.0f; - - one_time_duration_ = one_time_duration * 1000; - start_progress_ = start_progress; - progress_ = start_progress_; - start_time_ = g_get_monotonic_time(); - timeout_.reset(new glib::Timeout(rate_, sigc::mem_fun(this, &Animator::DoStep))); - animation_started.emit(); - } -} - -void Animator::Start(double start_progress) -{ - Start(0, start_progress); -} - -void Animator::Stop() -{ - if (timeout_) - { - timeout_.reset(); - animation_updated.emit(progress_); - animation_ended.emit(); - animation_stopped.emit(progress_); - one_time_duration_ = 0; - } -} - -bool Animator::DoStep() -{ - const gint64 current_time = g_get_monotonic_time(); - const gint64 duration = one_time_duration_ > 0 ? one_time_duration_ : duration_; - const gint64 end_time = start_time_ + duration; - - if (current_time < end_time && progress_ < 1.0f && duration > 0) - { - const double diff_time = current_time - start_time_; - progress_ = CLAMP(start_progress_ + (diff_time / duration), 0.0f, 1.0f); - animation_updated.emit(progress_); - - return true; - } - else - { - progress_ = 1.0f; - animation_updated.emit(1.0f); - animation_ended.emit(); - one_time_duration_ = 0; - timeout_.reset(); - - return false; - } -} - -} //namespace diff --git a/unity-shared/Animator.h b/unity-shared/Animator.h deleted file mode 100644 index 50a544d19..000000000 --- a/unity-shared/Animator.h +++ /dev/null @@ -1,64 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2011 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 (Treviño) <mail@3v1n0.net> - */ - -#ifndef UNITY_ANIMATOR_H_ -#define UNITY_ANIMATOR_H_ - -#include <cstdint> -#include <UnityCore/GLibSource.h> - -namespace unity -{ -class Animator : boost::noncopyable -{ -public: - Animator(unsigned int default_duration, unsigned int fps_rate = 30); - ~Animator(); - - void SetRate(unsigned int fps_rate); - void SetDuration(unsigned int duration); - - unsigned int GetRate() const; - unsigned int GetDuration() const; - double GetProgress() const; - bool IsRunning() const; - - void Start(double start_progress = 0.0f); - void Start(unsigned int one_time_duration, double start_progress = 0.0f); - bool DoStep(); - void Stop(); - - sigc::signal<void> animation_started; - sigc::signal<void> animation_ended; - - sigc::signal<void, double> animation_updated; - sigc::signal<void, double> animation_stopped; - -private: - glib::Source::UniquePtr timeout_; - int64_t start_time_; - unsigned int rate_; - unsigned int duration_; - unsigned int one_time_duration_; - double start_progress_; - double progress_; -}; - -} -#endif diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 27cceddd2..bb5e98662 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -26,7 +26,6 @@ include_directories (.. ../services ../UnityCore ${UNITY_SRC} ${CMAKE_BINARY_DIR set (UNITY_SHARED_SOURCES AbstractSeparator.cpp ApplicationManager.cpp - Animator.cpp BGHash.cpp CoverArt.cpp BackgroundEffectHelper.cpp diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index 68c6ef6b2..7aedca53a 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -21,6 +21,7 @@ #include <iostream> #include <fstream> #include <sstream> +#include <iostream> #include <boost/algorithm/string.hpp> #include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/classification.hpp> diff --git a/unity-shared/GraphicsUtils.cpp b/unity-shared/GraphicsUtils.cpp index 1e1114cb6..ab4c7823c 100644 --- a/unity-shared/GraphicsUtils.cpp +++ b/unity-shared/GraphicsUtils.cpp @@ -67,5 +67,22 @@ void PopOffscreenRenderTarget() } } +void ClearGeometry(nux::Geometry const& geo, nux::Color const& color) +{ + nux::GraphicsEngine* graphics_engine = nux::GetGraphicsDisplay()->GetGraphicsEngine(); + + // This is necessary when doing redirected rendering. Clean the area below this view. + unsigned int current_alpha_blend; + unsigned int current_src_blend_factor; + unsigned int current_dest_blend_factor; + graphics_engine->GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + + graphics_engine->GetRenderStates().SetBlend(false); + graphics_engine->QRP_Color(geo.x, geo.y, geo.width, geo.height, color); + + graphics_engine->GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); +} + + } } diff --git a/unity-shared/GraphicsUtils.h b/unity-shared/GraphicsUtils.h index dd65d3b00..d4064b021 100644 --- a/unity-shared/GraphicsUtils.h +++ b/unity-shared/GraphicsUtils.h @@ -30,6 +30,8 @@ namespace graphics void PushOffscreenRenderTarget(nux::ObjectPtr<nux::IOpenGLBaseTexture> texture); void PopOffscreenRenderTarget(); +void ClearGeometry(nux::Geometry const& geo, nux::Color const& color = nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); + } } diff --git a/unity-shared/IconTexture.cpp b/unity-shared/IconTexture.cpp index 0b7393545..c78fd844d 100644 --- a/unity-shared/IconTexture.cpp +++ b/unity-shared/IconTexture.cpp @@ -181,6 +181,12 @@ void IconTexture::IconLoaded(std::string const& icon_name, void IconTexture::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { + unsigned int current_alpha_blend; + unsigned int current_src_blend_factor; + unsigned int current_dest_blend_factor; + GfxContext.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + nux::Geometry geo = GetGeometry(); GfxContext.PushClippingRectangle(geo); @@ -243,11 +249,11 @@ void IconTexture::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) texxform, col); } - - } GfxContext.PopClippingRectangle(); + + GfxContext.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); } void IconTexture::GetTextureSize(int* width, int* height) diff --git a/unity-shared/PlacesOverlayVScrollBar.cpp b/unity-shared/PlacesOverlayVScrollBar.cpp index e318cdf3c..6943176e6 100644 --- a/unity-shared/PlacesOverlayVScrollBar.cpp +++ b/unity-shared/PlacesOverlayVScrollBar.cpp @@ -37,7 +37,7 @@ namespace dash PlacesOverlayVScrollBar::PlacesOverlayVScrollBar(NUX_FILE_LINE_DECL) : PlacesVScrollBar(NUX_FILE_LINE_PARAM) , overlay_window_(new VScrollBarOverlayWindow(_track->GetAbsoluteGeometry())) - , area_prox_(overlay_window_.GetPointer(), PROXIMITY) + , area_prox_(this, PROXIMITY) , thumb_above_slider_(false) , connector_height_(0) , mouse_down_offset_(0) @@ -46,6 +46,8 @@ PlacesOverlayVScrollBar::PlacesOverlayVScrollBar(NUX_FILE_LINE_DECL) area_prox_.mouse_near.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseNear)); area_prox_.mouse_beyond.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseBeyond)); + 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)); overlay_window_->mouse_up.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseUp)); overlay_window_->mouse_click.connect(sigc::mem_fun(this, &PlacesOverlayVScrollBar::OnMouseClick)); @@ -77,12 +79,6 @@ void PlacesOverlayVScrollBar::OnVisibilityChanged(nux::Area* /*area*/, bool visi } } -void PlacesOverlayVScrollBar::StopAnimation() -{ - if (animation_.CurrentState() != nux::animation::Animation::State::Stopped) - animation_.Stop(); -} - void PlacesOverlayVScrollBar::SetupAnimation(int start, int stop, int milliseconds) { tweening_connection_.disconnect(); @@ -142,11 +138,23 @@ bool PlacesOverlayVScrollBar::IsScrollBarVisible() const return (content_height_ > container_height_); } +void PlacesOverlayVScrollBar::OnMouseEnter(int x, int y, unsigned int button_flags, unsigned int key_flags) +{ + overlay_window_->MouseEnter(); + UpdateConnectorPosition(); +} + +void PlacesOverlayVScrollBar::OnMouseLeave(int x, int y, unsigned int button_flags, unsigned int key_flags) +{ + overlay_window_->MouseLeave(); + UpdateConnectorPosition(); +} + void PlacesOverlayVScrollBar::OnMouseNear(nux::Point const& mouse_pos) { if (IsVisible() && IsScrollBarVisible()) { - StopAnimation(); + animation_.Stop(); overlay_window_->MouseNear(); AdjustThumbOffsetFromMouse(); @@ -230,7 +238,18 @@ void PlacesOverlayVScrollBar::UpdateConnectorPosition() void PlacesOverlayVScrollBar::ResetConnector() { - StartConnectorAnimation(); + if (animation_.CurrentState() == nux::animation::Animation::State::Stopped) + { + if (connector_height_ > 0) + { + StartConnectorAnimation(); + } + } + else + { + connector_height_ = 0; + } + QueueDraw(); } @@ -320,7 +339,7 @@ void PlacesOverlayVScrollBar::OnMouseMove(int /*x*/, int y, int /*dx*/, int /*dy void PlacesOverlayVScrollBar::OnMouseDrag(int /*x*/, int y, int /*dx*/, int dy, unsigned int /*button_flags*/, unsigned int /*key_flags*/) { - StopAnimation(); + animation_.Stop(); MouseDraggingOverlay(y, dy); } diff --git a/unity-shared/PlacesOverlayVScrollBar.h b/unity-shared/PlacesOverlayVScrollBar.h index f1b09403d..64945b944 100644 --- a/unity-shared/PlacesOverlayVScrollBar.h +++ b/unity-shared/PlacesOverlayVScrollBar.h @@ -51,6 +51,9 @@ private: void OnTrackGeometryChanged(nux::Area* area, nux::Geometry& geo); void OnVisibilityChanged(nux::Area* area, bool visible); + void OnMouseEnter(int x, int y, unsigned int button_flags, unsigned int key_flags); + void OnMouseLeave(int x, int y, unsigned int button_flags, unsigned int key_flags); + void OnMouseNear(nux::Point const& mouse_pos); void OnMouseBeyond(nux::Point const& mouse_pos); void AdjustThumbOffsetFromMouse(); @@ -78,7 +81,6 @@ private: void UpdateStepY(); void SetupAnimation(int start, int stop, int milliseconds); - void StopAnimation(); void StartScrollAnimation(ScrollDir dir, int stop); void OnScroll(ScrollDir dir, int mouse_dy); @@ -99,6 +101,8 @@ private: int connector_height_; int mouse_down_offset_; int delta_update_; + + friend class MockScrollBar; }; } // namespace dash diff --git a/unity-shared/PlacesVScrollBar.cpp b/unity-shared/PlacesVScrollBar.cpp index 2af828916..0058fb465 100644 --- a/unity-shared/PlacesVScrollBar.cpp +++ b/unity-shared/PlacesVScrollBar.cpp @@ -69,6 +69,24 @@ PlacesVScrollBar::PostLayoutManagement(long LayoutResult) void PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { + if(!RedirectedAncestor()) + { + DrawScrollbar(graphics_engine); + } +} + +void +PlacesVScrollBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) +{ + if(RedirectedAncestor()) + { + DrawScrollbar(graphics_engine); + } +} + +void +PlacesVScrollBar::DrawScrollbar(nux::GraphicsEngine& graphics_engine) +{ nux::Color color = nux::color::White; nux::Geometry const& base = GetGeometry(); nux::TexCoordXForm texxform; @@ -77,14 +95,6 @@ PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) unsigned int alpha = 0, src = 0, dest = 0; graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - if(RedirectedAncestor()) - { - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(GetX(), GetY(), GetWidth(), GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - } - // check if textures have been computed... if they haven't, exit function if (!_slider_texture) return; diff --git a/unity-shared/PlacesVScrollBar.h b/unity-shared/PlacesVScrollBar.h index de9a9dca7..87f793ea9 100644 --- a/unity-shared/PlacesVScrollBar.h +++ b/unity-shared/PlacesVScrollBar.h @@ -44,9 +44,12 @@ protected: void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw); + void DrawContent(nux::GraphicsEngine& gfxContext, + bool forceDraw); private: void UpdateTexture(); + void DrawScrollbar(nux::GraphicsEngine& graphics_engine); private: nux::BaseTexture* _slider_texture; diff --git a/unity-shared/SearchBar.cpp b/unity-shared/SearchBar.cpp index cdc33d44b..744f83ee2 100644 --- a/unity-shared/SearchBar.cpp +++ b/unity-shared/SearchBar.cpp @@ -30,7 +30,8 @@ #include "SearchBar.h" #include "CairoTexture.h" -#include "unity-shared/DashStyle.h" +#include "DashStyle.h" +#include "GraphicsUtils.h" namespace { @@ -362,21 +363,14 @@ void SearchBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) graphics_engine.PushClippingRectangle(base); if (RedirectedAncestor()) + graphics::ClearGeometry(base); + + if (bg_layer_) { - unsigned int alpha = 0, src = 0, dest = 0; - graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - // This is necessary when doing redirected rendering. - // Clean the area below this view before drawing anything. - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color(base.x, base.y, base.width, base.height, nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); + bg_layer_->SetGeometry(nux::Geometry(base.x, base.y, last_width_, last_height_)); + bg_layer_->Renderlayer(graphics_engine); } - bg_layer_->SetGeometry(nux::Geometry(base.x, base.y, last_width_, last_height_)); - nux::GetPainter().RenderSinglePaintLayer(graphics_engine, - bg_layer_->GetGeometry(), - bg_layer_.get()); - if (ShouldBeHighlighted()) { dash::Style& style = dash::Style::Instance(); @@ -398,56 +392,46 @@ void SearchBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) void SearchBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) { - nux::Geometry const& geo = GetGeometry(); - - graphics_engine.PushClippingRectangle(geo); + nux::Geometry const& base = GetGeometry(); - if (highlight_layer_ && ShouldBeHighlighted() && !IsFullRedraw()) - { - nux::GetPainter().PushLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get()); - } + graphics_engine.PushClippingRectangle(base); + int pushed_paint_layers = 0; if (!IsFullRedraw()) { - unsigned int current_alpha_blend; - unsigned int current_src_blend_factor; - unsigned int current_dest_blend_factor; - graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - - graphics_engine.GetRenderStates().SetBlend(false); - graphics_engine.QRP_Color( - pango_entry_->GetX(), - pango_entry_->GetY(), - pango_entry_->GetWidth(), - pango_entry_->GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); - - if (spinner_->IsRedrawNeeded()) + if (RedirectedAncestor()) { - graphics_engine.QRP_Color( - spinner_->GetX(), - spinner_->GetY(), - spinner_->GetWidth(), - spinner_->GetHeight(), nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); + graphics::ClearGeometry(pango_entry_->GetGeometry()); + if (spinner_->IsRedrawNeeded()) + graphics::ClearGeometry(spinner_->GetGeometry()); } - - graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - gPainter.PushLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + if (highlight_layer_ && ShouldBeHighlighted()) + { + pushed_paint_layers++; + nux::GetPainter().PushLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get()); + } + + if (bg_layer_) + { + pushed_paint_layers++; + nux::GetPainter().PushLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + } } else { - nux::GetPainter().PushPaintLayerStack(); + nux::GetPainter().PushPaintLayerStack(); } layout_->ProcessDraw(graphics_engine, force_draw); - if (!IsFullRedraw()) + if (IsFullRedraw()) { - gPainter.PopBackground(); + nux::GetPainter().PopPaintLayerStack(); } - else + else if (pushed_paint_layers > 0) { - nux::GetPainter().PopPaintLayerStack(); + nux::GetPainter().PopBackground(pushed_paint_layers); } graphics_engine.PopClippingRectangle(); @@ -505,7 +489,8 @@ void SearchBar::UpdateBackground(bool force) << layered_layout_->GetGeometry().height << " - " << pango_entry_->GetGeometry().height; - if (geo.width == last_width_ + if (!bg_layer_ && + geo.width == last_width_ && geo.height == last_height_ && force == false) return; diff --git a/unity-shared/SearchBarSpinner.cpp b/unity-shared/SearchBarSpinner.cpp index 240118785..39b62b523 100644 --- a/unity-shared/SearchBarSpinner.cpp +++ b/unity-shared/SearchBarSpinner.cpp @@ -60,6 +60,12 @@ SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) texxform.min_filter = nux::TEXFILTER_LINEAR; texxform.mag_filter = nux::TEXFILTER_LINEAR; + unsigned int current_alpha_blend; + unsigned int current_src_blend_factor; + unsigned int current_dest_blend_factor; + GfxContext.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + if (_state == STATE_READY) { GfxContext.QRP_1Tex(geo.x + ((geo.width - _magnify->GetWidth()) / 2), @@ -120,6 +126,8 @@ SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) } GfxContext.PopClippingRectangle(); + GfxContext.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + if (_state == STATE_SEARCHING && !_frame_timeout) { _frame_timeout.reset(new glib::Timeout(22, sigc::mem_fun(this, &SearchBarSpinner::OnFrameTimeout))); diff --git a/unity-shared/VScrollBarOverlayWindow.cpp b/unity-shared/VScrollBarOverlayWindow.cpp index 750feda63..71d490ad3 100644 --- a/unity-shared/VScrollBarOverlayWindow.cpp +++ b/unity-shared/VScrollBarOverlayWindow.cpp @@ -25,6 +25,9 @@ #include "DashStyle.h" #include "CairoTexture.h" +namespace unity +{ + namespace { int const THUMB_WIDTH = 21; @@ -38,9 +41,7 @@ VScrollBarOverlayWindow::VScrollBarOverlayWindow(nux::Geometry const& geo) , content_size_(geo) , content_offset_x_(0) , mouse_offset_y_(0) - , mouse_down_(false) - , mouse_near_(false) - , inside_slider_(false) + , current_state_(ThumbState::NONE) , current_action_(ThumbAction::NONE) { Area::SetGeometry(content_size_.x, content_size_.y, THUMB_WIDTH, content_size_.height); @@ -68,7 +69,7 @@ void VScrollBarOverlayWindow::SetThumbOffsetY(int y) if (new_offset != mouse_offset_y_) { - if (mouse_down_) + if (HasState(ThumbState::MOUSE_DOWN)) MouseDragging(); mouse_offset_y_ = new_offset; @@ -127,13 +128,13 @@ nux::Geometry VScrollBarOverlayWindow::GetThumbGeometry() const void VScrollBarOverlayWindow::MouseDown() { - mouse_down_ = true; + AddState(ThumbState::MOUSE_DOWN); UpdateTexture(); } void VScrollBarOverlayWindow::MouseUp() { - mouse_down_ = false; + RemoveState(ThumbState::MOUSE_DOWN); current_action_ = ThumbAction::NONE; UpdateTexture(); ShouldHide(); @@ -141,30 +142,42 @@ void VScrollBarOverlayWindow::MouseUp() void VScrollBarOverlayWindow::MouseNear() { - mouse_near_ = true; + AddState(ThumbState::MOUSE_NEAR); ShouldShow(); } void VScrollBarOverlayWindow::MouseBeyond() { - mouse_near_ = false; + RemoveState(ThumbState::MOUSE_NEAR); + ShouldHide(); +} + +void VScrollBarOverlayWindow::MouseEnter() +{ + AddState(ThumbState::MOUSE_INSIDE); + ShouldShow(); +} + +void VScrollBarOverlayWindow::MouseLeave() +{ + RemoveState(ThumbState::MOUSE_INSIDE); ShouldHide(); } void VScrollBarOverlayWindow::ThumbInsideSlider() { - if (!inside_slider_) + if (!HasState(ThumbState::INSIDE_SLIDER)) { - inside_slider_ = true; + AddState(ThumbState::INSIDE_SLIDER); UpdateTexture(); } } void VScrollBarOverlayWindow::ThumbOutsideSlider() { - if (inside_slider_) + if (HasState(ThumbState::INSIDE_SLIDER)) { - inside_slider_ = false; + RemoveState(ThumbState::INSIDE_SLIDER); UpdateTexture(); } } @@ -194,7 +207,8 @@ void VScrollBarOverlayWindow::ShouldShow() { if (!IsVisible()) { - if (mouse_down_ || mouse_near_) + if (HasState(ThumbState::MOUSE_DOWN) || + HasState(ThumbState::MOUSE_NEAR)) { ShowWindow(true); PushToFront(); @@ -207,7 +221,9 @@ void VScrollBarOverlayWindow::ShouldHide() { if (IsVisible()) { - if (!mouse_down_ && !mouse_near_) + if (!(HasState(ThumbState::MOUSE_DOWN)) && + !(HasState(ThumbState::MOUSE_NEAR)) && + !(HasState(ThumbState::MOUSE_INSIDE))) { ShowWindow(false); QueueDraw(); @@ -217,12 +233,26 @@ void VScrollBarOverlayWindow::ShouldHide() void VScrollBarOverlayWindow::ResetStates() { - mouse_down_ = false; - mouse_near_ = false; + current_state_ = ThumbState::NONE; current_action_ = ThumbAction::NONE; ShouldHide(); } +void VScrollBarOverlayWindow::AddState(ThumbState const& state) +{ + current_state_ |= state; +} + +void VScrollBarOverlayWindow::RemoveState(ThumbState const& state) +{ + current_state_ &= ~(state); +} + +bool VScrollBarOverlayWindow::HasState(ThumbState const& state) const +{ + return (current_state_ & state); +} + void VScrollBarOverlayWindow::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) { if (!thumb_texture_) @@ -465,7 +495,7 @@ void VScrollBarOverlayWindow::UpdateTexture() current_y += 0.5; cairoGraphics.DrawRoundedRectangle(cr, aspect, current_x, current_y, radius - 1, width - 1, height - 1); - if (inside_slider_) + if (HasState(ThumbState::INSIDE_SLIDER)) SetSourceRGB(cr, bg_selected, 1.0); else SetSourceRGB(cr, bg_active, 0.9); @@ -524,3 +554,5 @@ void VScrollBarOverlayWindow::UpdateTexture() QueueDraw(); } + +} // namespace unity diff --git a/unity-shared/VScrollBarOverlayWindow.h b/unity-shared/VScrollBarOverlayWindow.h index abcf6db25..5ac11db16 100644 --- a/unity-shared/VScrollBarOverlayWindow.h +++ b/unity-shared/VScrollBarOverlayWindow.h @@ -24,6 +24,8 @@ #include <Nux/Nux.h> #include <Nux/BaseWindow.h> +namespace unity +{ class VScrollBarOverlayWindow : public nux::BaseWindow { @@ -39,6 +41,9 @@ public: void MouseNear(); void MouseBeyond(); + void MouseEnter(); + void MouseLeave(); + void ThumbInsideSlider(); void ThumbOutsideSlider(); @@ -67,6 +72,15 @@ private: PAGE_DOWN }; + enum ThumbState + { + NONE = 1 << 0, + MOUSE_DOWN = 1 << 1, + MOUSE_NEAR = 1 << 2, + MOUSE_INSIDE = 1 << 3, + INSIDE_SLIDER = 1 << 4 + }; + void MouseDragging(); void UpdateMouseOffsetX(); int GetValidOffsetYValue(int y) const; @@ -82,11 +96,14 @@ private: int content_offset_x_; int mouse_offset_y_; - bool mouse_down_; - bool mouse_near_; - bool inside_slider_; - + void AddState(ThumbState const& state); + void RemoveState(ThumbState const& state); + bool HasState(ThumbState const& state) const; + + unsigned int current_state_; ThumbAction current_action_; }; -#endif +} // namespace unity + +#endif // VSCROLLBAR_OVERLAY_WINDOW_H |
