diff options
| author | Neil Jagdish Patel <njpatel@gmail.com> | 2012-09-19 09:58:01 -0400 | 
|---|---|---|
| committer | Tarmac <> | 2012-09-19 09:58:01 -0400 | 
| commit | 1c60a7adfafd0639475a341e63122f3cb64f346c (patch) | |
| tree | 3c80691d8b500239cb2c38b2d800c7127068f52c | |
| parent | dcc4b455dea789c439805d02396478a6e0d191c1 (diff) | |
| parent | b94ef1ee477b7b0c67f687780dbc204c8e405a90 (diff) | |
This branch introduces dash to preview transitions. I relies on this nux branch: https://code.launchpad.net/~unity-team/nux/nux.redirected-views/+merge/124661
Animation from Dash to Preview slides out elements of the dash to make room for the previews. The process happens in 250ms. Many changes were necessary to create this effects. It has to be said that the changes have an impact on the rendering engine and the way elements are drawn in the dash. Efforts are being made to reduce this impact.. Fixes: https://bugs.launchpad.net/bugs/1049593. Approved by Neil J. Patel. Original authors: - Neil Jagdish Patel <njpatel@gmail.com> - Jay Taoko <jay.taoko@canonical.com> - Neil Jagdish Patel <neil.patel@canonical.com> (bzr r2719)
| -rwxr-xr-x | dash/CoverflowResultView.cpp | 18 | ||||
| -rw-r--r-- | dash/DashView.cpp | 372 | ||||
| -rw-r--r-- | dash/DashView.h | 29 | ||||
| -rw-r--r-- | dash/FilterAllButton.cpp | 4 | ||||
| -rw-r--r-- | dash/FilterBar.cpp | 15 | ||||
| -rw-r--r-- | dash/FilterBasicButton.cpp | 29 | ||||
| -rw-r--r-- | dash/FilterBasicButton.h | 2 | ||||
| -rw-r--r-- | dash/FilterExpanderLabel.cpp | 55 | ||||
| -rw-r--r-- | dash/FilterMultiRangeButton.cpp | 7 | ||||
| -rw-r--r-- | dash/FilterRatingsButton.cpp | 7 | ||||
| -rw-r--r-- | dash/LensBar.cpp | 45 | ||||
| -rw-r--r-- | dash/LensBarIcon.cpp | 14 | ||||
| -rwxr-xr-x | dash/LensView.cpp | 1 | ||||
| -rwxr-xr-x | dash/PlacesGroup.cpp | 53 | ||||
| -rw-r--r-- | dash/ResultViewGrid.cpp | 38 | ||||
| -rw-r--r-- | manual-tests/DashToPreviewTransition.txt | 38 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 22 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 6 | ||||
| -rwxr-xr-x | unity-shared/DashStyle.h | 2 | ||||
| -rw-r--r-- | unity-shared/PlacesVScrollBar.cpp | 25 | ||||
| -rw-r--r-- | unity-shared/SearchBar.cpp | 75 | ||||
| -rw-r--r-- | unity-shared/UBusMessages.h | 4 | 
22 files changed, 722 insertions, 139 deletions
| diff --git a/dash/CoverflowResultView.cpp b/dash/CoverflowResultView.cpp index 257db0dda..4441651c8 100755 --- a/dash/CoverflowResultView.cpp +++ b/dash/CoverflowResultView.cpp @@ -135,7 +135,7 @@ void CoverflowResultItem::Activate(int button)  int size = model_->Items().size();  ubus_.SendMessage(UBUS_DASH_PREVIEW_INFO_PAYLOAD,  - g_variant_new("(iii)", 0, index, size - index)); + g_variant_new("(iiii)", 0, 0, index, size - index));  }  CoverflowResultView::Impl::Impl(CoverflowResultView *parent) @@ -193,7 +193,7 @@ CoverflowResultView::Impl::Impl(CoverflowResultView *parent)  int right_results = num_results ? (num_results - current_index) - 1 : 0;  parent_->UriActivated.emit(GetUriForIndex(current_index), ActivateType::PREVIEW);  ubus_.SendMessage(UBUS_DASH_PREVIEW_INFO_PAYLOAD,  - g_variant_new("(iii)", 0, left_results, right_results)); + g_variant_new("(iiii)", 0, 0, left_results, right_results));  }  });  } @@ -269,6 +269,20 @@ void CoverflowResultView::DrawContent(nux::GraphicsEngine& GfxContext, bool forc  nux::Geometry base = GetGeometry();  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); + } +   if (GetCompositionLayout())  {  nux::Geometry geo = GetCompositionLayout()->GetGeometry(); diff --git a/dash/DashView.cpp b/dash/DashView.cpp index c29bf6568..b0713b7be 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -16,6 +16,7 @@  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>  */ +  #include "DashView.h"  #include "DashViewPrivate.h" @@ -36,6 +37,7 @@  #include "unity-shared/UBusMessages.h"  #include "unity-shared/PreviewStyle.h" +#include "Nux/NuxTimerTickSource.h"  namespace unity  { @@ -89,7 +91,14 @@ DashView::DashView()  , search_in_progress_(false)  , activate_on_finish_(false)  , visible_(false) + , fade_out_value_(0.0f) + , fade_in_value_(0.0f) + , opening_row_y_(-1) + , opening_row_height_(0)  { + //tick_source_.reset(new nux::NuxTimerTickSource); + //animation_controller_.reset(new na::AnimationController(*tick_source_)); +  renderer_.SetOwner(this);  renderer_.need_redraw.connect([this] () {  QueueDraw(); @@ -110,6 +119,13 @@ DashView::DashView()  home_lens_->AddLenses(lenses_);  home_lens_->search_finished.connect(sigc::mem_fun(this, &DashView::OnGlobalSearchFinished));  lens_bar_->Activate("home.lens"); + + // We are interested in the color of the desktop background. + ubus_manager_.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &DashView::OnBGColorChanged)); + + // request the latest colour from bghash + ubus_manager_.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT); +  }  DashView::~DashView() @@ -119,6 +135,15 @@ DashView::~DashView()  RemoveLayout();  } +void DashView::OnBGColorChanged(GVariant *data) +{ + double red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f; + + g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha); + background_color_ = nux::Color(red, green, blue, alpha); + QueueDraw(); +} +  void DashView::SetMonitorOffset(int x, int y)  {  renderer_.x_offset = x; @@ -127,25 +152,87 @@ void DashView::SetMonitorOffset(int x, int y)  void DashView::ClosePreview()  { - preview_displaying_ = false; + if (preview_displaying_) + { + layout_->SetPresentRedirectedView(true); + animation_.Stop(); + fade_out_connection_.disconnect(); + fade_in_connection_.disconnect(); + // Set fade animation + animation_.SetDuration(250); + animation_.SetEasingCurve(na::EasingCurve(na::EasingCurve::Type::ExpoEaseIn)); + fade_in_connection_ = animation_.updated.connect(sigc::mem_fun(this, &DashView::FadeInCallBack)); + + fade_in_value_ = 1.0f; + animation_.SetStartValue(fade_in_value_); + animation_.SetFinishValue(0.0f); + animation_.Start(); + } - // sanity check - if (!preview_container_) - return; - RemoveChild(preview_container_.GetPointer()); - preview_container_->UnParentObject(); - preview_container_.Release(); // free resources - preview_state_machine_.ClosePreview(); + preview_displaying_ = false;  // re-focus dash view component.  nux::GetWindowCompositor().SetKeyFocusArea(default_focus());  QueueDraw();  } +void DashView::FadeOutCallBack(float const& fade_out_value) +{ + fade_out_value_ = fade_out_value; + QueueDraw(); +} + +void DashView::FadeInCallBack(float const& fade_in_value) +{ + fade_in_value_ = fade_in_value; + QueueDraw(); + + if (fade_in_value_ == 0.0f) + { + // sanity check + if (!preview_container_) + { + return; + } + RemoveChild(preview_container_.GetPointer()); + preview_container_->UnParentObject(); + preview_container_.Release(); // free resources + preview_state_machine_.ClosePreview(); + + // Closing the preview. Set opening_row_y_ to -1; + // opening_row_y_ is updated once when the preview + opening_row_y_ = -1; + } +} +  void DashView::BuildPreview(Preview::Ptr model)  {  if (!preview_displaying_)  { + // Make a copy of this DashView backup texture. + if (layout_->RedirectRenderingToTexture()) + { + nux::TexCoordXForm texxform; + nux::ObjectPtr<nux::IOpenGLBaseTexture> src_texture; + + layout_copy_ = src_texture = layout_->BackupTexture(); + + animation_.Stop(); + fade_out_connection_.disconnect(); + fade_in_connection_.disconnect(); + // Set fade animation + animation_.SetDuration(250); + animation_.SetEasingCurve(na::EasingCurve(na::EasingCurve::Type::ExpoEaseIn)); + fade_out_connection_ = animation_.updated.connect(sigc::mem_fun(this, &DashView::FadeOutCallBack)); + + fade_out_value_ = 1.0f; + animation_.SetStartValue(fade_out_value_); + animation_.SetFinishValue(0.0f); + animation_.Start(); + + layout_->SetPresentRedirectedView(false); + } +  preview_container_ = previews::PreviewContainer::Ptr(new previews::PreviewContainer());  AddChild(preview_container_.GetPointer());  preview_container_->SetParentObject(this); @@ -264,6 +351,7 @@ void DashView::SetupViews()  layout_->SetLeftAndRightPadding(style.GetVSeparatorSize(), 0);  layout_->SetTopAndBottomPadding(style.GetHSeparatorSize(), 0);  SetLayout(layout_); + layout_->SetRedirectRenderingToTexture(true);  content_layout_ = new DashLayout(NUX_TRACKER_LOCATION);  content_layout_->SetTopAndBottomPadding(style.GetDashViewTopPadding(), 0); @@ -313,12 +401,21 @@ void DashView::SetupUBusConnections()  ubus_manager_.RegisterInterest(UBUS_DASH_PREVIEW_INFO_PAYLOAD, [&] (GVariant *data)   {  int position = -1; + int row_height = 0;  int results_to_the_left = 0;  int results_to_the_right = 0; - g_variant_get(data, "(iii)", &position, &results_to_the_left, &results_to_the_right); + g_variant_get(data, "(iiii)", &position, &row_height, &results_to_the_left, &results_to_the_right);  preview_state_machine_.SetSplitPosition(SplitPosition::CONTENT_AREA, position);  preview_state_machine_.left_results = results_to_the_left;  preview_state_machine_.right_results = results_to_the_right; + + if (opening_row_y_ == -1) + { + // Update only when opening the previews + opening_row_y_ = position; + } + opening_row_height_ = row_height; +  });  } @@ -396,27 +493,268 @@ nux::Geometry DashView::GetBestFitGeometry(nux::Geometry const& for_geo)  return nux::Geometry(0, 0, width, height);  } -void DashView::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) +void DashView::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  { - renderer_.DrawFull(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + renderer_.DrawFull(graphics_engine, content_geo_, GetAbsoluteGeometry(), GetGeometry());  } -void DashView::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) +void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)  { - renderer_.DrawInner(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + renderer_.DrawInner(graphics_engine, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + + bool display_ghost = false; + bool preview_redraw = false; + if (preview_container_) + { + 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(); + } +  if (preview_displaying_) - preview_container_->ProcessDraw(gfx_context, (!force_draw) ? IsFullRedraw() : force_draw); - else - layout_->ProcessDraw(gfx_context, force_draw); + { + // Progressively reveal the preview. + nux::Geometry preview_clip_geo = preview_container_->GetGeometry(); + preview_clip_geo.y = (preview_clip_geo.y + preview_clip_geo.height)/2.0f -  + (1.0f - fade_out_value_) * (preview_clip_geo.height)/2.0f; + preview_clip_geo.height = (1.0f - fade_out_value_) * (preview_clip_geo.height); + + graphics_engine.PushModelViewMatrix(nux::Matrix4::TRANSLATE(-preview_container_->GetWidth()/2.0f, -preview_container_->GetHeight()/2.0f, 0)); + graphics_engine.PushModelViewMatrix(nux::Matrix4::SCALE(1.0f - fade_out_value_, 1.0f - fade_out_value_, 1.0f)); + graphics_engine.PushModelViewMatrix(nux::Matrix4::TRANSLATE(preview_container_->GetWidth()/2.0f, preview_container_->GetHeight()/2.0f, 0)); + + preview_container_->ProcessDraw(graphics_engine, (!force_draw) ? IsFullRedraw() : force_draw); + + graphics_engine.PopModelViewMatrix(); + graphics_engine.PopModelViewMatrix(); + graphics_engine.PopModelViewMatrix(); + } + else if (fade_in_value_ > 0.0f && preview_container_ && preview_container_.IsValid()) + { + graphics_engine.PushModelViewMatrix(nux::Matrix4::TRANSLATE(-preview_container_->GetWidth()/2.0f, -preview_container_->GetHeight()/2.0f, 0)); + graphics_engine.PushModelViewMatrix(nux::Matrix4::SCALE(fade_in_value_, fade_in_value_, 1.0f)); + graphics_engine.PushModelViewMatrix(nux::Matrix4::TRANSLATE(preview_container_->GetWidth()/2.0f, preview_container_->GetHeight()/2.0f, 0)); + + preview_container_->ProcessDraw(graphics_engine, (!force_draw) ? IsFullRedraw() : force_draw); + + graphics_engine.PopModelViewMatrix(); + graphics_engine.PopModelViewMatrix(); + graphics_engine.PopModelViewMatrix(); + } + else if (fade_in_value_ == 0.0f) + { + layout_->ProcessDraw(graphics_engine, force_draw); + } +  + // Animation effect rendering + if (display_ghost || 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); + + float ghost_opacity = 0.25f;  + float tint_factor = 1.2f; + float saturation_ref = 0.4f; + nux::Color bg_color = background_color_; + + int position_offset = 40; + + if (preview_displaying_ && layout_ && layout_->RedirectRenderingToTexture()) + { + if (layout_copy_.IsValid()) + { + graphics_engine.PushClippingRectangle(layout_->GetGeometry()); + graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + nux::TexCoordXForm texxform; + + texxform.FlipVCoord(true); + + int filter_width = 10; + if (active_lens_view_ && active_lens_view_->filters_expanded) + { + texxform.uoffset = (active_lens_view_->filter_bar()->GetX() -layout_->GetX())/(float)layout_->GetWidth(); + texxform.voffset = (active_lens_view_->filter_bar()->GetY() -layout_->GetY())/(float)layout_->GetHeight(); + + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + + graphics_engine.QRP_1Tex( + active_lens_view_->filter_bar()->GetX() + (1.0f - fade_out_value_)*(active_lens_view_->filter_bar()->GetWidth() + 10), + active_lens_view_->filter_bar()->GetY(), + active_lens_view_->filter_bar()->GetWidth(), + active_lens_view_->filter_bar()->GetHeight(), + layout_copy_, texxform, + nux::Color(fade_out_value_, fade_out_value_, fade_out_value_, fade_out_value_) + ); + filter_width += active_lens_view_->filter_bar()->GetWidth(); + }  + + float saturation = fade_out_value_ + (1.0f - fade_out_value_) * saturation_ref; + float opacity = fade_out_value_ < ghost_opacity ? ghost_opacity : fade_out_value_; + nux::Color tint = nux::Color( + fade_out_value_ + (1.0f - fade_out_value_) * tint_factor*bg_color.red, + fade_out_value_ + (1.0f - fade_out_value_) * tint_factor*bg_color.green, + fade_out_value_ + (1.0f - fade_out_value_) * tint_factor*bg_color.blue, + 1.0f); + + // Ghost row of items above the preview + { + int final_x = layout_->GetX(); + int final_y = layout_->GetY() - (opening_row_y_) - position_offset ; + + texxform.uoffset = 0.0f; + texxform.voffset = 0.0f; + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + + graphics_engine.QRP_TexDesaturate( + fade_out_value_ * layout_->GetX() + (1.0f - fade_out_value_) * final_x, + fade_out_value_ * layout_->GetY() + (1.0f - fade_out_value_) * final_y, + layout_->GetWidth() - filter_width, + opening_row_y_ + opening_row_height_, + layout_copy_, texxform, + nux::Color(tint.red, tint.green, tint.blue, opacity), + saturation + ); + } + + // Ghost row of items below the preview + { + int final_x = layout_->GetX(); + int final_y = layout_->GetY() + layout_->GetHeight() - (position_offset*1.9); + + texxform.uoffset = (layout_->GetX() - layout_->GetX())/(float)layout_->GetWidth(); + texxform.voffset = (opening_row_y_ + opening_row_height_ - layout_->GetY())/(float)layout_->GetHeight(); + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + + graphics_engine.QRP_TexDesaturate( + fade_out_value_ * layout_->GetX() + (1 - fade_out_value_) * final_x, + fade_out_value_ * (opening_row_y_ + opening_row_height_) + (1 - fade_out_value_) * final_y, + layout_->GetWidth() - filter_width, + layout_->GetHeight() - opening_row_y_ - opening_row_height_, + layout_copy_, texxform, + nux::Color(tint.red, tint.green, tint.blue, opacity), + saturation + ); + } + + graphics_engine.GetRenderStates().SetBlend(false); + graphics_engine.PopClippingRectangle(); + } + + + } + else if (layout_ && layout_->RedirectRenderingToTexture() && fade_in_value_ != 0.0f) + { + if (layout_copy_.IsValid()) + { + graphics_engine.PushClippingRectangle(layout_->GetGeometry()); + graphics_engine.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + nux::TexCoordXForm texxform; + + texxform.FlipVCoord(true); + + int filter_width = 10; + if (active_lens_view_ && active_lens_view_->filters_expanded) + { + texxform.uoffset = (active_lens_view_->filter_bar()->GetX() -layout_->GetX())/(float)layout_->GetWidth(); + texxform.voffset = (active_lens_view_->filter_bar()->GetY() -layout_->GetY())/(float)layout_->GetHeight(); + + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + + graphics_engine.QRP_1Tex( + active_lens_view_->filter_bar()->GetX() + (fade_in_value_)*(active_lens_view_->filter_bar()->GetWidth() + 10), + active_lens_view_->filter_bar()->GetY(), + active_lens_view_->filter_bar()->GetWidth(), + active_lens_view_->filter_bar()->GetHeight(), + layout_copy_, texxform, + nux::Color(1.0f - fade_in_value_, 1.0f - fade_in_value_, 1.0f - fade_in_value_, 1.0f - fade_in_value_) + ); + filter_width += active_lens_view_->filter_bar()->GetWidth(); + } + + float saturation = fade_in_value_ * saturation_ref + (1.0f - fade_in_value_); + float opacity = (1.0f - fade_in_value_) < ghost_opacity ? ghost_opacity : (1.0f - fade_in_value_); + nux::Color tint = nux::Color( + fade_in_value_ * tint_factor*bg_color.red + (1.0f - fade_in_value_), + fade_in_value_ * tint_factor*bg_color.green + (1.0f - fade_in_value_), + fade_in_value_ * tint_factor*bg_color.blue + (1.0f - fade_in_value_), + 1.0f); + + // Ghost row of items above the preview + { + int final_x = layout_->GetX(); + int final_y = layout_->GetY() - (opening_row_y_) - position_offset; + + texxform.uoffset = 0.0f; + texxform.voffset = 0.0f; + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + + graphics_engine.QRP_TexDesaturate( + (1.0f - fade_in_value_) * layout_->GetX() + (fade_in_value_) * final_x, + (1.0f - fade_in_value_) * layout_->GetY() + (fade_in_value_) * final_y, + layout_->GetWidth() - filter_width, + opening_row_y_ + opening_row_height_, + layout_copy_, texxform, + nux::Color(tint.red, tint.green, tint.blue, opacity), + saturation + ); + } + + // Ghost row of items below the preview + { + int final_x = layout_->GetX(); + int final_y = layout_->GetY() + layout_->GetHeight() -(position_offset*1.9); + + texxform.uoffset = (layout_->GetX() - layout_->GetX())/(float)layout_->GetWidth(); + texxform.voffset = (opening_row_y_ + opening_row_height_ - layout_->GetY())/(float)layout_->GetHeight(); + texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD); + + graphics_engine.QRP_TexDesaturate( + (1.0f - fade_in_value_) * layout_->GetX() + (fade_in_value_) * final_x, + (1.0f - fade_in_value_) * (opening_row_y_ + opening_row_height_) + (fade_in_value_) * final_y, + layout_->GetWidth() - filter_width, + layout_->GetHeight() - opening_row_y_ - opening_row_height_, + layout_copy_, texxform, + nux::Color(tint.red, tint.green, tint.blue, opacity), + saturation + ); + } + graphics_engine.GetRenderStates().SetBlend(false); + graphics_engine.PopClippingRectangle(); + } + } + + graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); + }  if (IsFullRedraw()) + {  nux::GetPainter().PopBackgroundStack(); + } - renderer_.DrawInnerCleanup(gfx_context, content_geo_, GetAbsoluteGeometry(), GetGeometry()); + renderer_.DrawInnerCleanup(graphics_engine, content_geo_, GetAbsoluteGeometry(), GetGeometry());  }  void DashView::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) diff --git a/dash/DashView.h b/dash/DashView.h index 25019f8fc..de3b487ab 100644 --- a/dash/DashView.h +++ b/dash/DashView.h @@ -23,6 +23,8 @@  #include <Nux/PaintLayer.h>  #include <Nux/View.h>  #include <Nux/VLayout.h> +#include <Nux/NuxTimerTickSource.h> +  #include <UnityCore/FilesystemLenses.h>  #include <UnityCore/HomeLens.h>  #include <UnityCore/GLibSource.h> @@ -30,6 +32,7 @@  #include "unity-shared/BackgroundEffectHelper.h"  #include "unity-shared/SearchBar.h"  #include "unity-shared/Introspectable.h" +#include "unity-shared/BGHash.h"  #include "LensBar.h"  #include "LensView.h"  #include "unity-shared/UBusWrapper.h" @@ -38,6 +41,8 @@  #include "previews/PreviewContainer.h"  #include "PreviewStateMachine.h" +namespace na = nux::animation; +  namespace unity  {  namespace dash @@ -81,7 +86,7 @@ protected:  private:  void SetupViews();  void SetupUBusConnections(); - + void OnBGColorChanged(GVariant *data);  nux::Geometry GetBestFitGeometry(nux::Geometry const& for_geo);  void Draw(nux::GraphicsEngine& gfx_context, bool force_draw); @@ -152,6 +157,28 @@ private:  glib::Source::UniquePtr searching_timeout_;  glib::Source::UniquePtr hide_message_delay_; + + nux::ObjectPtr<nux::IOpenGLBaseTexture> dash_view_copy_; + nux::ObjectPtr<nux::IOpenGLBaseTexture> search_view_copy_; + nux::ObjectPtr<nux::IOpenGLBaseTexture> filter_view_copy_; + nux::ObjectPtr<nux::IOpenGLBaseTexture> layout_copy_; + + float fade_out_value_; + float fade_in_value_; + std::unique_ptr<nux::NuxTimerTickSource> tick_source_; + std::unique_ptr<na::AnimationController> animation_controller_; + na::AnimateValue<float> animation_; + + void FadeOutCallBack(float const& fade_out_value); + void FadeInCallBack(float const& fade_out_value); + + int opening_row_y_; + int opening_row_height_; + + sigc::connection fade_in_connection_; + sigc::connection fade_out_connection_; + + nux::Color background_color_;  }; diff --git a/dash/FilterAllButton.cpp b/dash/FilterAllButton.cpp index dc42e94f2..013be5690 100644 --- a/dash/FilterAllButton.cpp +++ b/dash/FilterAllButton.cpp @@ -38,6 +38,10 @@ 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 8493fb772..6d8164d0f 100644 --- a/dash/FilterBar.cpp +++ b/dash/FilterBar.cpp @@ -99,21 +99,16 @@ void FilterBar::RemoveFilter(Filter::Ptr const& filter)  }  } -void FilterBar::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) +void FilterBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  { - nux::Geometry const& geo = GetGeometry(); - GfxContext.PushClippingRectangle(geo); - nux::GetPainter().PaintBackground(GfxContext, geo); - GfxContext.PopClippingRectangle();  } -void FilterBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) +void FilterBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)  { - GfxContext.PushClippingRectangle(GetGeometry()); - GetLayout()->ProcessDraw(GfxContext, force_draw); - - GfxContext.PopClippingRectangle(); + graphics_engine.PushClippingRectangle(GetGeometry()); + GetLayout()->ProcessDraw(graphics_engine, force_draw); + graphics_engine.PopClippingRectangle();  }  // diff --git a/dash/FilterBasicButton.cpp b/dash/FilterBasicButton.cpp index a0fc5b8fa..766432d6a 100644 --- a/dash/FilterBasicButton.cpp +++ b/dash/FilterBasicButton.cpp @@ -71,6 +71,8 @@ void FilterBasicButton::Init()  SetAcceptKeyNavFocusOnMouseDown(false);  SetAcceptKeyNavFocusOnMouseEnter(true); + clear_before_draw_ = true; +  key_nav_focus_change.connect([&] (nux::Area*, bool, nux::KeyNavDirection)  {  QueueDraw(); @@ -128,11 +130,15 @@ long FilterBasicButton::ComputeContentSize()  return ret;  } -void FilterBasicButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) +void FilterBasicButton::SetClearBeforeDraw(bool clear_before_draw) +{ + clear_before_draw_ = clear_before_draw; +} + +void FilterBasicButton::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& geo = GetGeometry(); - gPainter.PaintBackground(GfxContext, geo);  // set up our texture mode  nux::TexCoordXForm texxform;  texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT); @@ -140,12 +146,19 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)  // clear what is behind us  unsigned int alpha = 0, src = 0, dest = 0; - GfxContext.GetRenderStates().GetBlend(alpha, src, dest); - GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + 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;  col.alpha = 0; - GfxContext.QRP_Color(geo.x, + graphics_engine.QRP_Color(geo.x,  geo.y,  geo.width,  geo.height, @@ -159,7 +172,7 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)  else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)  texture = active_->GetTexture(); - GfxContext.QRP_1Tex(geo.x, + graphics_engine.QRP_1Tex(geo.x,  geo.y,  geo.width,  geo.height, @@ -169,7 +182,7 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)  if (HasKeyboardFocus())  { - GfxContext.QRP_1Tex(geo.x, + graphics_engine.QRP_1Tex(geo.x,  geo.y,  geo.width,  geo.height, @@ -178,7 +191,7 @@ void FilterBasicButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)  nux::Color(1.0f, 1.0f, 1.0f, 1.0f));  } - GfxContext.GetRenderStates().SetBlend(alpha, src, dest); + graphics_engine.GetRenderStates().SetBlend(alpha, src, dest);  }  } // namespace dash diff --git a/dash/FilterBasicButton.h b/dash/FilterBasicButton.h index 8216938f2..db7991ee4 100644 --- a/dash/FilterBasicButton.h +++ b/dash/FilterBasicButton.h @@ -40,6 +40,7 @@ public:  FilterBasicButton(NUX_FILE_LINE_PROTO);  virtual ~FilterBasicButton(); + void SetClearBeforeDraw(bool clear_before_draw);  protected:  virtual long ComputeContentSize();  virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); @@ -60,6 +61,7 @@ protected:  private:  std::string label_; + bool clear_before_draw_;  };  } // namespace dash diff --git a/dash/FilterExpanderLabel.cpp b/dash/FilterExpanderLabel.cpp index 7f26e8d8b..5954d01b9 100644 --- a/dash/FilterExpanderLabel.cpp +++ b/dash/FilterExpanderLabel.cpp @@ -257,12 +257,22 @@ bool FilterExpanderLabel::ShouldBeHighlighted()  return ((expander_view_ && expander_view_->HasKeyFocus()));  } -void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) +void FilterExpanderLabel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& base = GetGeometry(); - GfxContext.PushClippingRectangle(base); - nux::GetPainter().PaintBackground(GfxContext, base); + 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())  { @@ -274,23 +284,46 @@ void FilterExpanderLabel::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)  highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height));  highlight_layer_->SetGeometry(geo); - highlight_layer_->Renderlayer(GfxContext); + highlight_layer_->Renderlayer(graphics_engine);  } - GfxContext.PopClippingRectangle(); + graphics_engine.PopClippingRectangle();  } -void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) +void FilterExpanderLabel::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)  { - GfxContext.PushClippingRectangle(GetGeometry()); + graphics_engine.PushClippingRectangle(GetGeometry()); - if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw()) + if (RedirectedAncestor() && !IsFullRedraw())  { - nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get()); + 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);  } - GetLayout()->ProcessDraw(GfxContext, force_draw); - GfxContext.PopClippingRectangle(); + int pushed_paint_layers = 0; + if (RedirectedAncestor()) + { + if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw()) + nux::GetPainter().RenderSinglePaintLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get()); + } + else if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw()) + { + ++pushed_paint_layers; + nux::GetPainter().PushLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get()); + } + + GetLayout()->ProcessDraw(graphics_engine, true); + graphics_engine.PopClippingRectangle(); + + if (pushed_paint_layers) + { + nux::GetPainter().PopBackground(pushed_paint_layers); + }  }  // diff --git a/dash/FilterMultiRangeButton.cpp b/dash/FilterMultiRangeButton.cpp index 5fd1701bb..9aef960ad 100644 --- a/dash/FilterMultiRangeButton.cpp +++ b/dash/FilterMultiRangeButton.cpp @@ -226,6 +226,13 @@ 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/FilterRatingsButton.cpp b/dash/FilterRatingsButton.cpp index 503e8eeb1..e472051f4 100644 --- a/dash/FilterRatingsButton.cpp +++ b/dash/FilterRatingsButton.cpp @@ -107,6 +107,13 @@ 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/LensBar.cpp b/dash/LensBar.cpp index 7b0bb1f99..80a612c7e 100644 --- a/dash/LensBar.cpp +++ b/dash/LensBar.cpp @@ -104,32 +104,49 @@ void LensBar::Activate(std::string id)  }  } -void LensBar::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) +void LensBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& base = GetGeometry(); - gfx_context.PushClippingRectangle(base); - nux::GetPainter().PaintBackground(gfx_context, base); + graphics_engine.PushClippingRectangle(base);  bg_layer_->SetGeometry(base); - nux::GetPainter().RenderSinglePaintLayer(gfx_context, base, bg_layer_.get()); + nux::GetPainter().RenderSinglePaintLayer(graphics_engine, base, bg_layer_.get()); - gfx_context.PopClippingRectangle(); + graphics_engine.PopClippingRectangle();  } -void LensBar::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) +void LensBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& base = GetGeometry(); - gfx_context.PushClippingRectangle(base); + graphics_engine.PushClippingRectangle(base); - if (!IsFullRedraw()) - nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_.get()); + int pushed_paint_layers = 0; + 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); + } + + nux::GetPainter().RenderSinglePaintLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + } + else if (!IsFullRedraw()) + { + ++pushed_paint_layers; + nux::GetPainter().PushLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get()); + } - layout_->ProcessDraw(gfx_context, force_draw); + layout_->ProcessDraw(graphics_engine, true); - if (!IsFullRedraw()) - nux::GetPainter().PopBackground(); + if (pushed_paint_layers) + nux::GetPainter().PopBackground(pushed_paint_layers);  for (auto icon: icons_)  { @@ -142,7 +159,7 @@ void LensBar::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw)  // bigger one and clip part of them using the "-1".  int y = base.y - 1; - nux::GetPainter().Draw2DTriangleColor(gfx_context, + nux::GetPainter().Draw2DTriangleColor(graphics_engine,  middle - size, y,  middle, y + size,  middle + size, y, @@ -152,7 +169,7 @@ void LensBar::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw)  }  } - gfx_context.PopClippingRectangle(); + graphics_engine.PopClippingRectangle();  }  void LensBar::SetActive(LensBarIcon* activated) diff --git a/dash/LensBarIcon.cpp b/dash/LensBarIcon.cpp index e891220a4..cfb71c4da 100644 --- a/dash/LensBarIcon.cpp +++ b/dash/LensBarIcon.cpp @@ -58,21 +58,21 @@ 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()  {} -void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw) +void LensBarIcon::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& geo = GetGeometry(); - gfx_context.PushClippingRectangle(geo); - nux::GetPainter().PaintBackground(gfx_context, geo); + graphics_engine.PushClippingRectangle(geo);  if (!texture())  { - gfx_context.PopClippingRectangle(); + graphics_engine.PopClippingRectangle();  return;  } @@ -82,7 +82,7 @@ void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)  nux::AbstractPaintLayer* layer = focus_layer_.get();  layer->SetGeometry(geo); - layer->Renderlayer(gfx_context); + layer->Renderlayer(graphics_engine);  }  float opacity = active ? 1.0f : inactive_opacity_; @@ -94,7 +94,7 @@ void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)  texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);  texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER); - gfx_context.QRP_1Tex(geo.x + ((geo.width - width) / 2), + graphics_engine.QRP_1Tex(geo.x + ((geo.width - width) / 2),  geo.y + ((geo.height - height) / 2),  width,  height, @@ -102,7 +102,7 @@ void LensBarIcon::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)  texxform,  col); - gfx_context.PopClippingRectangle(); + graphics_engine.PopClippingRectangle();  }  void LensBarIcon::OnActiveChanged(bool is_active) diff --git a/dash/LensView.cpp b/dash/LensView.cpp index bb7332d82..1537499d0 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -174,7 +174,6 @@ LensView::LensView(Lens::Ptr lens, nux::Area* show_filters)  if ((child && child->HasKeyFocus()) ||  (expand_label && expand_label->HasKeyFocus()))  { -  focused_pos.x += child->GetGeometry().x;  focused_pos.y += child->GetGeometry().y - 30;  focused_pos.height += 30; diff --git a/dash/PlacesGroup.cpp b/dash/PlacesGroup.cpp index 76de3fd48..12d11a905 100755 --- a/dash/PlacesGroup.cpp +++ b/dash/PlacesGroup.cpp @@ -458,10 +458,29 @@ long PlacesGroup::ComputeContentSize()  void PlacesGroup::Draw(nux::GraphicsEngine& graphics_engine,  bool forceDraw)  { + +} + +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())  {  nux::Geometry geo(_header_layout->GetGeometry()); @@ -486,41 +505,11 @@ void PlacesGroup::Draw(nux::GraphicsEngine& graphics_engine,  _background_layer->SetGeometry(bg_geo);  _background_layer->Renderlayer(graphics_engine); - graphics_engine.PopClippingRectangle(); -} - -void -PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) -{ - nux::Geometry const& base = GetGeometry(); - - graphics_engine.PushClippingRectangle(base); - nux::Geometry bg_geo = GetGeometry(); -  - int bg_width = 0; - if (_using_nofilters_background) - bg_width = _background_nofilters->GetWidth(); - else - bg_width = _background->GetWidth(); -  - // if the dash is smaller, resize to fit, otherwise move to the right edge - 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(); - if (!IsFullRedraw()) - { - nux::GetPainter().PushLayer(graphics_engine, bg_geo, _background_layer.get()); - } - if (ShouldBeHighlighted() && !IsFullRedraw() && _focus_layer) - { - nux::GetPainter().PushLayer(graphics_engine, _focus_layer->GetGeometry(), _focus_layer.get()); - } - - _group_layout->ProcessDraw(graphics_engine, force_draw); + _group_layout->ProcessDraw(graphics_engine, true);  graphics_engine.PopClippingRectangle(); +  }  void PlacesGroup::PostDraw(nux::GraphicsEngine& graphics_engine, diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp index fc9c2fcfa..e70a8ab0f 100644 --- a/dash/ResultViewGrid.cpp +++ b/dash/ResultViewGrid.cpp @@ -143,10 +143,28 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL)  << " " << activated_uri_;  int left_results = current_index;  int right_results = num_results ? (num_results - current_index) - 1 : 0; + + int row_y = padding + GetRootGeometry().y; + int row_size = renderer_->height + vertical_spacing; + int row_height = row_size; + + if (GetItemsPerRow()) + { + int num_row = GetNumResults() / GetItemsPerRow(); + if (GetNumResults() % GetItemsPerRow()) + { + ++num_row; + } + int row_index = current_index / GetItemsPerRow(); + + row_y += row_index * row_size; + } +   ubus_.SendMessage(UBUS_DASH_PREVIEW_INFO_PAYLOAD,  - g_variant_new("(iii)", 0, left_results, right_results)); + g_variant_new("(iiii)", row_y, row_height, left_results, right_results));  UriActivated.emit(activated_uri_, ActivateType::PREVIEW);  } +  }  g_free(uri); @@ -691,8 +709,24 @@ void ResultViewGrid::MouseClick(int x, int y, unsigned long button_flags, unsign  int left_results = index;  int right_results = (num_results - index) - 1;  //FIXME - just uses y right now, needs to use the absolute position of the bottom of the result  + // (jay) Here is the fix: Compute the y position of the row where the item is located. + int row_y = padding + GetRootGeometry().y; + int row_size = renderer_->height + vertical_spacing; + int row_height = row_size; + + if (GetItemsPerRow()) + { + int num_row = GetNumResults() / GetItemsPerRow(); + if (GetNumResults() % GetItemsPerRow()) + { + ++num_row; + } + int row_index = index / GetItemsPerRow(); + + row_y += row_index * row_size; + }  ubus_.SendMessage(UBUS_DASH_PREVIEW_INFO_PAYLOAD,  - g_variant_new("(iii)", y, left_results, right_results)); + g_variant_new("(iiii)", row_y, row_height, left_results, right_results));  }  else  { diff --git a/manual-tests/DashToPreviewTransition.txt b/manual-tests/DashToPreviewTransition.txt new file mode 100644 index 000000000..ecc1fb06a --- /dev/null +++ b/manual-tests/DashToPreviewTransition.txt @@ -0,0 +1,38 @@ +Preview Open Animation +---------------------- +This tests the dash animation transition to the preview + +Setup: +#. Open dash super +#. Open a lens which supports previewing (e.g. Application, Music, File) + +Actions: +#. Right click on an icon in the dash + +Expected Result: + The central part of the dash split itself up just below the icon that was clicked, to reveal the preview window. It fades out but does not become fully transparent. + The Search Entry slides up and fades out. + If opened, the Filter Bar slides away to the right and fades. + Above the Preview, there is a faded out row of icons that include the icon that was right clicked. + + +Preview Close Animation +----------------------- +This tests the preview close animation + +Setup: +#. Open dash super +#. Open a lens which supports previewing (e.g. Application, Music, File) +#. Right-click the mouse on an icon to open its preview. +#. Wait for the preview window to open and finish animating. + +Actions: +#. Press Escape. + +Expected Result: + The Preview is progressively scaled down and disapears. + The search bar slides in from the top. + If the Filter Bar was opened when the Preview started, it will slide in from the right  + to its normal position. + The splitted and faded out dash appears to close itself and regain it full opacity. + diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 36c8d6cfe..45cd3c00e 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -24,6 +24,7 @@  #include <Nux/HLayout.h>  #include <Nux/BaseWindow.h>  #include <Nux/WindowCompositor.h> +#include <Nux/NuxTimerTickSource.h>  #include "BaseWindowRaiserImp.h"  #include "IconRenderer.h" @@ -113,7 +114,6 @@ UnityScreen::UnityScreen(CompScreen* screen)  , screen(screen)  , cScreen(CompositeScreen::get(screen))  , gScreen(GLScreen::get(screen)) - , animation_controller_(tick_source_)  , debugger_(this)  , enable_shortcut_overlay_(true)  , needsRelayout(false) @@ -125,6 +125,7 @@ UnityScreen::UnityScreen(CompScreen* screen)  , allowWindowPaint(false)  , _key_nav_mode_requested(false)  , _last_output(nullptr) + , _bghash(NULL)  , grab_index_ (0)  , painting_tray_ (false)  , last_scroll_event_(0) @@ -235,8 +236,16 @@ UnityScreen::UnityScreen(CompScreen* screen)  this));  #endif + tick_source_.reset(new nux::NuxTimerTickSource); + animation_controller_.reset(new na::AnimationController(*tick_source_)); +  wt->RedrawRequested.connect(sigc::mem_fun(this, &UnityScreen::onRedrawRequested)); + // _bghash is a pointer. We don't want it to be created before Nux system has had a chance + // to start. BGHash relies on animations. Nux animation system starts after the WindowThread + // has been created. + _bghash = new BGHash(); +  unity_a11y_init(wt.get());  /* i18n init */ @@ -382,6 +391,7 @@ UnityScreen::~UnityScreen()  unity_a11y_finalize();  ::unity::ui::IconRenderer::DestroyTextures();  QuicklistManager::Destroy(); + delete _bghash;  reset_glib_logging();  } @@ -1260,10 +1270,6 @@ void UnityScreen::preparePaint(int ms)  {  cScreen->preparePaint(ms); - // Emit the current time throught the tick_source. This moves any running - // animations along their path. - tick_source_.tick(g_get_monotonic_time()); -  for (ShowdesktopHandlerWindowInterface *wi : ShowdesktopHandler::animating_windows)  wi->HandleAnimations (ms); @@ -1572,7 +1578,8 @@ void UnityScreen::handleEvent(XEvent* event)  if (event->xproperty.window == GDK_ROOT_WINDOW() &&  event->xproperty.atom == gdk_x11_get_xatom_by_name("_GNOME_BACKGROUND_REPRESENTATIVE_COLORS"))  { - _bghash.RefreshColor(); + if (_bghash) + _bghash->RefreshColor();  }  break;  default: @@ -2785,7 +2792,8 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num)  override_color.red = override_color.red / override_color.alpha;  override_color.green = override_color.green / override_color.alpha;  override_color.blue = override_color.blue / override_color.alpha; - _bghash.OverrideColor(override_color); + if (_bghash) + _bghash->OverrideColor(override_color);  break;  }  case UnityshellOptions::LauncherHideMode: diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 0e5392cb8..dabc386fe 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -247,8 +247,8 @@ private:  bool TopPanelBackgroundTextureNeedsUpdate() const;  void UpdateTopPanelBackgroundTexture(); - nux::animation::TickSource tick_source_; - nux::animation::AnimationController animation_controller_; + std::unique_ptr<nux::NuxTimerTickSource> tick_source_; + std::unique_ptr<na::AnimationController> animation_controller_;  Settings dash_settings_;  dash::Style dash_style_; @@ -308,7 +308,7 @@ private:  nux::Property<nux::Geometry> primary_monitor_; - BGHash _bghash; + BGHash* _bghash;  ::GLFramebufferObject *oldFbo; diff --git a/unity-shared/DashStyle.h b/unity-shared/DashStyle.h index 0592fdbe2..76d54dc19 100755 --- a/unity-shared/DashStyle.h +++ b/unity-shared/DashStyle.h @@ -246,9 +246,11 @@ public:  int GetCategorySeparatorLeftPadding() const;  int GetCategorySeparatorRightPadding() const; +  sigc::signal<void> changed;  nux::Property<bool> always_maximised; + nux::Property<bool> preview_mode;  private:  class Impl; diff --git a/unity-shared/PlacesVScrollBar.cpp b/unity-shared/PlacesVScrollBar.cpp index 0f8619fcc..2af828916 100644 --- a/unity-shared/PlacesVScrollBar.cpp +++ b/unity-shared/PlacesVScrollBar.cpp @@ -67,15 +67,23 @@ PlacesVScrollBar::PostLayoutManagement(long LayoutResult)  }  void -PlacesVScrollBar::Draw(nux::GraphicsEngine& gfxContext, bool force_draw) +PlacesVScrollBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Color color = nux::color::White;  nux::Geometry const& base = GetGeometry();  nux::TexCoordXForm texxform; - gfxContext.PushClippingRectangle(base); + graphics_engine.PushClippingRectangle(base); + unsigned int alpha = 0, src = 0, dest = 0; + graphics_engine.GetRenderStates().GetBlend(alpha, src, dest); - nux::GetPainter().PaintBackground(gfxContext, base); + 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) @@ -83,14 +91,14 @@ PlacesVScrollBar::Draw(nux::GraphicsEngine& gfxContext, bool force_draw)  texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD); - gfxContext.GetRenderStates().SetBlend(true); - gfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER); + graphics_engine.GetRenderStates().SetBlend(true); + graphics_engine.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);  if (content_height_ > container_height_)  {  nux::Geometry const& slider_geo = _slider->GetGeometry(); - gfxContext.QRP_1Tex(slider_geo.x, + graphics_engine.QRP_1Tex(slider_geo.x,  slider_geo.y,  slider_geo.width,  slider_geo.height, @@ -99,9 +107,8 @@ PlacesVScrollBar::Draw(nux::GraphicsEngine& gfxContext, bool force_draw)  color);  } - gfxContext.GetRenderStates().SetBlend(false); - gfxContext.PopClippingRectangle(); - gfxContext.GetRenderStates().SetBlend(true); + graphics_engine.PopClippingRectangle(); + graphics_engine.GetRenderStates().SetBlend(alpha, src, dest);  }  void PlacesVScrollBar::UpdateTexture() diff --git a/unity-shared/SearchBar.cpp b/unity-shared/SearchBar.cpp index 8f1b9175f..11060e804 100644 --- a/unity-shared/SearchBar.cpp +++ b/unity-shared/SearchBar.cpp @@ -355,17 +355,16 @@ void SearchBar::OnShowingFiltersChanged(bool is_showing)  }  } -void SearchBar::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) +void SearchBar::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& base = GetGeometry();  UpdateBackground(false); - GfxContext.PushClippingRectangle(base); - nux::GetPainter().PaintBackground(GfxContext, base); + graphics_engine.PushClippingRectangle(base);  bg_layer_->SetGeometry(nux::Geometry(base.x, base.y, last_width_, last_height_)); - nux::GetPainter().RenderSinglePaintLayer(GfxContext, + nux::GetPainter().RenderSinglePaintLayer(graphics_engine,  bg_layer_->GetGeometry(),  bg_layer_.get()); @@ -381,35 +380,85 @@ void SearchBar::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)  if (!highlight_layer_)  highlight_layer_.reset(style.FocusOverlay(geo.width, geo.height)); + 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(geo.x, geo.y, geo.width, geo.height, nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); + graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); + } +  highlight_layer_->SetGeometry(geo); - highlight_layer_->Renderlayer(GfxContext); + highlight_layer_->Renderlayer(graphics_engine);  } + else if (expander_view_ && expander_view_->IsVisible()) + { + nux::Geometry geo(expander_view_->GetGeometry()); + + geo.y -= (HIGHLIGHT_HEIGHT- geo.height) / 2; + geo.height = HIGHLIGHT_HEIGHT; - GfxContext.PopClippingRectangle(); + 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(geo.x, geo.y, geo.width, geo.height, nux::Color(0.0f, 0.0f, 0.0f, 0.0f)); + graphics_engine.GetRenderStates().SetBlend(alpha, src, dest); + } + } + graphics_engine.PopClippingRectangle();  } -void SearchBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) +void SearchBar::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)  {  nux::Geometry const& geo = GetGeometry(); - GfxContext.PushClippingRectangle(geo); + graphics_engine.PushClippingRectangle(geo);  if (highlight_layer_ && ShouldBeHighlighted() && !IsFullRedraw())  { - nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get()); + nux::GetPainter().PushLayer(graphics_engine, highlight_layer_->GetGeometry(), highlight_layer_.get());  } -  if (!IsFullRedraw())  { - gPainter.PushLayer(GfxContext, bg_layer_->GetGeometry(), bg_layer_.get()); + 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()) + { + graphics_engine.QRP_Color( + spinner_->GetX(), + spinner_->GetY(), + spinner_->GetWidth(), + spinner_->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); + + gPainter.PushLayer(graphics_engine, bg_layer_->GetGeometry(), bg_layer_.get());  }  else  {  nux::GetPainter().PushPaintLayerStack();  } - layout_->ProcessDraw(GfxContext, force_draw); + layout_->ProcessDraw(graphics_engine, force_draw);  if (!IsFullRedraw())  { @@ -420,7 +469,7 @@ void SearchBar::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)  nux::GetPainter().PopPaintLayerStack();  } - GfxContext.PopClippingRectangle(); + graphics_engine.PopClippingRectangle();  }  void SearchBar::OnClearClicked(int x, int y, unsigned long button_fags, diff --git a/unity-shared/UBusMessages.h b/unity-shared/UBusMessages.h index 7330a70e6..95612d249 100644 --- a/unity-shared/UBusMessages.h +++ b/unity-shared/UBusMessages.h @@ -82,8 +82,8 @@  // FIXME - fix the nux focus api so we don't need this  #define UBUS_RESULT_VIEW_KEYNAV_CHANGED "RESULT_VIEW_KEYNAV_CHANGED" -// for communicating positions to the preview state machine (iii) -// (split y coord in absolute geometry, results to the left, results to the right) +// for communicating positions to the preview state machine (iiii) +// (split y coord in absolute geometry, height of row where icon resides, results to the left, results to the right)  #define UBUS_DASH_PREVIEW_INFO_PAYLOAD "DASH_PREVIEW_INFO_PAYLOAD"  // called when previews wish to navigate left/right or close (is) | 
