summaryrefslogtreecommitdiff
diff options
authorJason Smith <jason.smith@canonical.com>2012-08-09 12:50:43 -0400
committerJason Smith <jason.smith@canonical.com>2012-08-09 12:50:43 -0400
commitcf5ed4ac69557cbe022079f3b2f572abb4016772 (patch)
treeb1c675d60b3fb01f8565b5e4ea7037e22ee2056e
parentaf68ce14e5e1516563e57d6db950df570cc5d39f (diff)
Recreate coverflow branch without background and alignment tweaks.
(bzr r2542.1.1)
-rw-r--r--dash/CMakeLists.txt1
-rw-r--r--dash/LensView.cpp13
-rw-r--r--dash/PlacesGroup.cpp80
-rw-r--r--dash/PlacesGroup.h15
-rw-r--r--dash/ResultView.cpp12
-rw-r--r--dash/ResultView.h6
-rw-r--r--unity-shared/DashStyle.cpp15
-rw-r--r--unity-shared/DashStyle.h3
8 files changed, 129 insertions, 16 deletions
diff --git a/dash/CMakeLists.txt b/dash/CMakeLists.txt
index 7aee3ce68..7b4dc8c28 100644
--- a/dash/CMakeLists.txt
+++ b/dash/CMakeLists.txt
@@ -30,6 +30,7 @@ include_directories (. .. ../services ../UnityCore ${UNITY_SRC} ${CMAKE_BINARY_D
#
set (DASH_SOURCES
AbstractPlacesGroup.cpp
+ CoverflowResultView.cpp
DashController.cpp
DashView.cpp
DashViewPrivate.cpp
diff --git a/dash/LensView.cpp b/dash/LensView.cpp
index 9e8c7ac08..4fdfd3a9e 100644
--- a/dash/LensView.cpp
+++ b/dash/LensView.cpp
@@ -25,6 +25,8 @@
#include <NuxCore/Logger.h>
#include "unity-shared/DashStyle.h"
+#include "CoverflowResultView.h"
+
#include "ResultRendererTile.h"
#include "ResultRendererHorizontalTile.h"
#include "unity-shared/UBusMessages.h"
@@ -278,6 +280,7 @@ void LensView::OnCategoryAdded(Category const& category)
/* Reset result count */
counts_[group] = 0;
+
ResultViewGrid* grid = new ResultViewGrid(NUX_TRACKER_LOCATION);
grid->expanded = false;
if (renderer_name == "tile-horizontal")
@@ -289,8 +292,8 @@ void LensView::OnCategoryAdded(Category const& category)
else
grid->SetModelRenderer(new ResultRendererTile(NUX_TRACKER_LOCATION));
- grid->UriActivated.connect([&] (std::string const& uri) { uri_activated.emit(uri); lens_->Activate(uri); });
- group->SetChildView(grid);
+ group->SetRendererName(renderer_name.c_str());
+ group->UriActivated.connect([&] (std::string const& uri) { uri_activated.emit(uri); lens_->Activate(uri); });
/* We need the full range of method args so we can specify the offset
* of the group into the layout */
@@ -303,7 +306,7 @@ void LensView::OnResultAdded(Result const& result)
{
try {
PlacesGroup* group = categories_.at(result.category_index);
- ResultViewGrid* grid = static_cast<ResultViewGrid*>(group->GetChildView());
+ ResultView* grid = static_cast<ResultView*>(group->GetChildView());
std::string uri = result.uri;
LOG_TRACE(logger) << "Result added: " << uri;
@@ -327,7 +330,7 @@ void LensView::OnResultRemoved(Result const& result)
{
try {
PlacesGroup* group = categories_.at(result.category_index);
- ResultViewGrid* grid = static_cast<ResultViewGrid*>(group->GetChildView());
+ ResultView* grid = static_cast<ResultView*>(group->GetChildView());
std::string uri = result.uri;
LOG_TRACE(logger) << "Result removed: " << uri;
@@ -444,7 +447,7 @@ std::string LensView::get_search_string() const
void LensView::OnGroupExpanded(PlacesGroup* group)
{
- ResultViewGrid* grid = static_cast<ResultViewGrid*>(group->GetChildView());
+ ResultView* grid = static_cast<ResultView*>(group->GetChildView());
grid->expanded = group->GetExpanded();
ubus_manager_.SendMessage(UBUS_PLACE_VIEW_QUEUE_DRAW);
}
diff --git a/dash/PlacesGroup.cpp b/dash/PlacesGroup.cpp
index 3d9aee07e..c036a1e6c 100644
--- a/dash/PlacesGroup.cpp
+++ b/dash/PlacesGroup.cpp
@@ -42,6 +42,14 @@ namespace
nux::logging::Logger logger("unity.dash.placesgroup");
}
+#include "ResultView.h"
+#include "ResultViewGrid.h"
+#include "ResultRendererTile.h"
+#include "ResultRendererHorizontalTile.h"
+#include "CoverflowResultView.h"
+#include "FilterBasicButton.h"
+
+
namespace unity
{
namespace
@@ -108,7 +116,9 @@ PlacesGroup::PlacesGroup()
_child_view(nullptr),
_is_expanded(true),
_n_visible_items_in_unexpand_mode(0),
- _n_total_items(0)
+ _n_total_items(0),
+ _draw_sep(true),
+ _coverflow_enabled(false)
{
dash::Style& style = dash::Style::Instance();
@@ -177,14 +187,36 @@ PlacesGroup::PlacesGroup()
SetLayout(_group_layout);
// don't need to disconnect these signals as they are disconnected when this object destroys the contents
+ _header_view->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
+ _header_view->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
_header_view->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
_header_view->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
_header_view->key_nav_focus_activate.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelActivated));
_icon->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
+ _icon->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
+ _icon->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
+ _icon->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
_name->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
+ _name->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
+ _name->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
+ _name->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
_expand_label->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
+ _expand_label->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
+ _expand_label->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
+ _expand_label->key_nav_focus_activate.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelActivated));
+ _expand_label->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
_expand_icon->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick));
-
+ _expand_icon->mouse_enter.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseEnter));
+ _expand_icon->mouse_leave.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseLeave));
+ _expand_icon->key_nav_focus_change.connect(sigc::mem_fun(this, &PlacesGroup::OnLabelFocusChanged));
+
+ dash::ResultView *grid = new dash::CoverflowResultView(NUX_TRACKER_LOCATION);
+ grid->expanded = false;
+
+ grid->SetModelRenderer(new dash::ResultRendererTile(NUX_TRACKER_LOCATION));
+
+ SetChildView(grid);
+
key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
{
if (!has_focus)
@@ -234,6 +266,17 @@ PlacesGroup::SetName(std::string const& name)
}
}
+void
+PlacesGroup::SetRendererName(const char *renderer_name)
+{
+ _renderer_name = renderer_name;
+
+ if (g_strcmp0(renderer_name, "tile-horizontal") == 0)
+ (static_cast<dash::ResultView*>(_child_view))->SetModelRenderer(new dash::ResultRendererHorizontalTile(NUX_TRACKER_LOCATION));
+ else
+ (static_cast<dash::ResultView*>(_child_view))->SetModelRenderer(new dash::ResultRendererTile(NUX_TRACKER_LOCATION));
+}
+
nux::StaticCairoText*
PlacesGroup::GetLabel()
{
@@ -255,9 +298,15 @@ PlacesGroup::SetIcon(std::string const& path_to_emblem)
void
PlacesGroup::SetChildView(dash::ResultView* view)
{
+ if (_child_view != NULL)
+ {
+ _group_layout->RemoveChildObject(_child_view);
+ }
+
debug::Introspectable *i = dynamic_cast<debug::Introspectable*>(view);
if (i)
AddChild(i);
+
_child_view = view;
nux::VLayout* layout = new nux::VLayout();
@@ -274,6 +323,11 @@ PlacesGroup::SetChildView(dash::ResultView* view)
});
QueueDraw();
+
+ view->UriActivated.connect([&] (std::string const& uri)
+ {
+ UriActivated.emit(uri);
+ });
}
nux::View*
@@ -316,6 +370,12 @@ PlacesGroup::RefreshLabel()
_expand_label->SetText(result_string);
_expand_label->SetVisible(_n_visible_items_in_unexpand_mode < _n_total_items);
+
+ _icon->SetAcceptKeyNavFocus(false);
+ _name->SetAcceptKeyNavFocus(false);
+ _expand_label->SetAcceptKeyNavFocus(false);
+ _expand_icon->SetAcceptKeyNavFocus(false);
+
// See bug #748101 ("Dash - "See more..." line should be base-aligned with section header")
// We're making two assumptions here:
// [a] The font size _name is bigger than the font size of _expand_label
@@ -323,8 +383,20 @@ PlacesGroup::RefreshLabel()
int bottom_padding = _name->GetBaseHeight() - _name->GetBaseline() -
(_expand_label->GetBaseHeight() - _expand_label->GetBaseline());
+
+
+ if (_expand_label->IsVisible())
+ _expand_label->SetAcceptKeyNavFocus(true);
+ else if (_expand_icon->IsVisible())
+ _expand_icon->SetAcceptKeyNavFocus(true);
+ else if (_name->IsVisible())
+ _name->SetAcceptKeyNavFocus(true);
+ else if (_icon->IsVisible())
+ _icon->SetAcceptKeyNavFocus(true);
+
_expand_label_layout->SetTopAndBottomPadding(0, bottom_padding);
+
QueueDraw();
}
@@ -437,11 +509,11 @@ PlacesGroup::GetExpanded() const
void
PlacesGroup::SetExpanded(bool is_expanded)
{
- if (_is_expanded == is_expanded)
+ /* if (_is_expanded == is_expanded)
return;
if (is_expanded && _n_total_items <= _n_visible_items_in_unexpand_mode)
- return;
+ return;*/
_is_expanded = is_expanded;
diff --git a/dash/PlacesGroup.h b/dash/PlacesGroup.h
index 8e9bab92d..8d406135c 100644
--- a/dash/PlacesGroup.h
+++ b/dash/PlacesGroup.h
@@ -24,13 +24,18 @@
#include <Nux/VLayout.h>
#include <Nux/HLayout.h>
#include <Nux/TextureArea.h>
-#include <UnityCore/GLibSource.h>
-#include "AbstractPlacesGroup.h"
+#include <sigc++/sigc++.h>
+
#include "unity-shared/IconTexture.h"
#include "unity-shared/Introspectable.h"
#include "unity-shared/StaticCairoText.h"
#include "unity-shared/UBusWrapper.h"
+
+#include <UnityCore/GLibSource.h>
+
+#include "AbstractPlacesGroup.h"
+
#include "ResultView.h"
namespace nux
@@ -53,6 +58,7 @@ public:
void SetIcon(std::string const& icon);
void SetName(std::string const& name);
+ void SetRendererName(const char *renderer_name);
nux::StaticCairoText* GetLabel();
nux::StaticCairoText* GetExpandLabel();
@@ -74,6 +80,7 @@ public:
nux::View* GetHeaderFocusableView() const;
sigc::signal<void, PlacesGroup*> expanded;
+ sigc::signal<void, std::string const&> UriActivated;
protected:
long ComputeContentSize();
@@ -124,7 +131,11 @@ private:
guint _n_visible_items_in_unexpand_mode;
guint _n_total_items;
std::string _cached_name;
+ bool _draw_sep;
nux::Geometry _cached_geometry;
+
+ std::string _renderer_name;
+ bool _coverflow_enabled;
glib::Source::UniquePtr _relayout_idle;
UBusManager _ubus;
diff --git a/dash/ResultView.cpp b/dash/ResultView.cpp
index c25c9810f..e4d6959b7 100644
--- a/dash/ResultView.cpp
+++ b/dash/ResultView.cpp
@@ -54,6 +54,10 @@ ResultView::ResultView(NUX_FILE_LINE_DECL)
ResultView::~ResultView()
{
+ if (renderer_ == NULL)
+ {
+ return;
+ }
ClearIntrospectableWrappers();
for (auto result : results_)
@@ -87,7 +91,9 @@ void ResultView::SetModelRenderer(ResultRenderer* renderer)
void ResultView::AddResult(Result& result)
{
results_.push_back(result);
- renderer_->Preload(result);
+
+ if (renderer_ != NULL)
+ renderer_->Preload(result);
NeedRedraw();
}
@@ -105,7 +111,9 @@ void ResultView::RemoveResult(Result& result)
break;
}
}
- renderer_->Unload(result);
+
+ if (renderer_ != NULL)
+ renderer_->Unload(result);
}
ResultView::ResultList ResultView::GetResultList()
diff --git a/dash/ResultView.h b/dash/ResultView.h
index 224d11637..898e6b805 100644
--- a/dash/ResultView.h
+++ b/dash/ResultView.h
@@ -47,10 +47,10 @@ public:
ResultView(NUX_FILE_LINE_DECL);
virtual ~ResultView();
- void SetModelRenderer(ResultRenderer* renderer);
+ virtual void SetModelRenderer(ResultRenderer* renderer);
- void AddResult(Result& result);
- void RemoveResult(Result& result);
+ virtual void AddResult(Result& result);
+ virtual void RemoveResult(Result& result);
ResultList GetResultList ();
diff --git a/unity-shared/DashStyle.cpp b/unity-shared/DashStyle.cpp
index 31d997f0f..a8f197375 100644
--- a/unity-shared/DashStyle.cpp
+++ b/unity-shared/DashStyle.cpp
@@ -220,6 +220,9 @@ public:
LazyLoadTexture group_unexpand_texture_;
LazyLoadTexture group_expand_texture_;
+
+ LazyLoadTexture group_grid_texture_;
+ LazyLoadTexture group_coverflow_texture_;
LazyLoadTexture star_deselected_texture_;
LazyLoadTexture star_selected_texture_;
@@ -260,6 +263,8 @@ Style::Impl::Impl(Style* owner)
, search_spin_texture_("/search_spin.svg", 32)
, group_unexpand_texture_("/dash_group_unexpand.png")
, group_expand_texture_("/dash_group_expand.png")
+ , group_grid_texture_("/grid-view.svg")
+ , group_coverflow_texture_ ("/flow-view.svg")
, star_deselected_texture_("/star_deselected.png")
, star_selected_texture_("/star_selected.png")
, star_highlight_texture_("/star_highlight.png")
@@ -2178,6 +2183,16 @@ nux::BaseTexture* Style::GetGroupExpandIcon()
return pimpl->group_expand_texture_.texture();
}
+nux::BaseTexture* Style::GetGroupGridIcon()
+{
+ return pimpl->group_grid_texture_.texture();
+}
+
+nux::BaseTexture* Style::GetGroupCoverflowIcon()
+{
+ return pimpl->group_coverflow_texture_.texture();
+}
+
nux::BaseTexture* Style::GetStarDeselectedIcon()
{
return pimpl->star_deselected_texture_.texture();
diff --git a/unity-shared/DashStyle.h b/unity-shared/DashStyle.h
index 440914d7d..8d639aa02 100644
--- a/unity-shared/DashStyle.h
+++ b/unity-shared/DashStyle.h
@@ -192,6 +192,9 @@ public:
nux::BaseTexture* GetGroupUnexpandIcon();
nux::BaseTexture* GetGroupExpandIcon();
+
+ nux::BaseTexture* GetGroupGridIcon();
+ nux::BaseTexture* GetGroupCoverflowIcon();
nux::BaseTexture* GetStarDeselectedIcon();
nux::BaseTexture* GetStarSelectedIcon();