=== added file 'plugins/unityshell/src/CoverflowResultView.cpp'
--- plugins/unityshell/src/CoverflowResultView.cpp 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/CoverflowResultView.cpp 2012-02-24 17:53:50 +0000
@@ -0,0 +1,207 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2012 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 .
+ *
+ * Authored by: Jason Smith
+ */
+
+#include "CoverflowResultView.h"
+#include "IconLoader.h"
+#include "IconTexture.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+namespace unity
+{
+namespace dash
+{
+
+NUX_IMPLEMENT_OBJECT_TYPE(CoverflowResultView);
+
+class CoverflowResultItem : public nux::CoverflowItem
+{
+public:
+ CoverflowResultItem(Result& result, CoverflowResultView *parent);
+ ~CoverflowResultItem();
+
+ nux::ObjectPtr GetTexture() const;
+ void Activate();
+
+ Result result_;
+ CoverflowResultView* parent_;
+ IconTexture *icon_texture_;
+};
+
+class CoverflowResultView::Impl : public sigc::trackable
+{
+public:
+ Impl(CoverflowResultView *parent);
+ ~Impl();
+
+ void ComputeFlatIcons();
+
+ CoverflowResultView *parent_;
+ nux::Coverflow *coverflow_;
+ nux::HLayout* layout_;
+};
+
+CoverflowResultItem::CoverflowResultItem(Result& result, CoverflowResultView *parent)
+ : CoverflowItem(result.name())
+ , result_(result)
+ , parent_(parent)
+{
+ std::string const& icon_hint = result.icon_hint;
+ std::string icon_name = !icon_hint.empty() ? icon_hint : ". GThemedIcon text-x-preview";
+ static const int element_size = 128;
+
+ icon_texture_ = new IconTexture(icon_name.c_str(), element_size, true);
+ icon_texture_->add_border = true;
+ icon_texture_->LoadIcon();
+
+ icon_texture_->texture_updated.connect([&] (nux::BaseTexture *texture)
+ {
+ if (parent_)
+ parent_->NeedRedraw();
+ });
+}
+
+CoverflowResultItem::~CoverflowResultItem()
+{
+
+}
+
+nux::ObjectPtr CoverflowResultItem::GetTexture() const
+{
+ return nux::ObjectPtr(icon_texture_->texture());
+}
+
+void CoverflowResultItem::Activate()
+{
+ parent_->UriActivated.emit(result_.uri);
+}
+
+CoverflowResultView::Impl::Impl(CoverflowResultView *parent)
+ : parent_(parent)
+ , coverflow_(new nux::Coverflow)
+ , layout_(new nux::HLayout())
+{
+ layout_->AddView(coverflow_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+ parent_->SetLayout(layout_);
+
+ coverflow_->SetCameraDistance(1.44);
+ coverflow_->fov = 60;
+ coverflow_->folding_angle = 45;
+ coverflow_->true_perspective = false;
+ coverflow_->camera_motion_drift_enabled = false;
+ coverflow_->show_reflection = true;
+ coverflow_->folding_depth = .25;
+ coverflow_->reflection_strength = .2f;
+ //coverflow_->folding_rate = 3.5;
+ coverflow_->kinetic_scroll_rate = 0.05f;
+ coverflow_->mouse_drag_rate = 1.5f;
+ coverflow_->pinching = 0.2f;
+ coverflow_->y_offset = 0.15f;
+ coverflow_->reflection_size = .5f;
+}
+
+CoverflowResultView::Impl::~Impl()
+{
+
+}
+
+CoverflowResultView::CoverflowResultView(NUX_FILE_LINE_DECL)
+ : ResultView(NUX_FILE_LINE_PARAM)
+ , pimpl(new CoverflowResultView::Impl(this))
+{
+ SetMinimumHeight(180);
+}
+
+CoverflowResultView::~CoverflowResultView()
+{
+
+}
+
+void CoverflowResultView::SetModelRenderer(ResultRenderer* renderer)
+{
+ return; // abstracting breaks down here. Needs to be reworked.
+}
+
+void CoverflowResultView::AddResult(Result& result)
+{
+ results_.push_back (result);
+
+ nux::CoverflowItem::Ptr result_item(new CoverflowResultItem(result, this));
+ pimpl->coverflow_->model()->AddItem(result_item);
+}
+
+void CoverflowResultView::RemoveResult(Result& result)
+{
+ ResultView::RemoveResult(result);
+ // Ineffecient, API needs to be improved in Coverflow?
+ for (nux::CoverflowItem::Ptr item : pimpl->coverflow_->model()->Items())
+ {
+ CoverflowResultItem *result_item = static_cast(item.GetPointer());
+
+ if (result_item->result_.uri == result.uri) // maybe?
+ {
+ pimpl->coverflow_->model()->RemoveItem(item);
+ break;
+ }
+ }
+}
+
+void CoverflowResultView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
+{
+ // do nothing here
+}
+
+void CoverflowResultView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
+{
+ nux::Geometry base = GetGeometry();
+ GfxContext.PushClippingRectangle(base);
+
+ if (GetCompositionLayout())
+ {
+ nux::Geometry geo = GetCompositionLayout()->GetGeometry();
+ GetCompositionLayout()->ProcessDraw(GfxContext, force_draw);
+ }
+
+ GfxContext.PopClippingRectangle();
+}
+
+void CoverflowResultView::Impl::ComputeFlatIcons()
+{
+ float width = coverflow_->ViewportWidthAtDepth(0);
+ width /= coverflow_->space_between_icons();
+
+ int flat_icons = static_cast(std::floor((width - 2.0f) / 2.0f));
+ coverflow_->flat_icons = flat_icons;
+}
+
+long CoverflowResultView::ComputeContentSize()
+{
+ pimpl->ComputeFlatIcons();
+ long ret = ResultView::ComputeContentSize();
+ return ret;
+}
+
+
+}
+}
=== added file 'plugins/unityshell/src/CoverflowResultView.h'
--- plugins/unityshell/src/CoverflowResultView.h 1970-01-01 00:00:00 +0000
+++ plugins/unityshell/src/CoverflowResultView.h 2012-02-24 17:53:50 +0000
@@ -0,0 +1,56 @@
+// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
+/*
+ * Copyright (C) 2012 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 .
+ *
+ * Authored by: Jason Smith
+ */
+
+#ifndef UNITY_COVERFLOWRESULTVIEW_H
+#define UNITY_COVERFLOWRESULTVIEW_H
+
+#include "ResultView.h"
+
+namespace unity
+{
+namespace dash
+{
+
+class CoverflowResultView : public ResultView
+{
+ NUX_DECLARE_OBJECT_TYPE(CoverflowResultView, ResultView);
+
+public:
+ CoverflowResultView(NUX_FILE_LINE_DECL);
+ ~CoverflowResultView();
+
+ virtual void SetModelRenderer(ResultRenderer* renderer);
+
+ virtual void AddResult(Result& result);
+ virtual void RemoveResult(Result& result);
+
+protected:
+ virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
+ virtual long ComputeContentSize();
+
+private:
+ struct Impl;
+ Impl* pimpl;
+};
+
+}
+}
+
+#endif
\ No newline at end of file
=== modified file 'plugins/unityshell/src/DashStyle.cpp'
--- plugins/unityshell/src/DashStyle.cpp 2012-02-20 11:59:12 +0000
+++ plugins/unityshell/src/DashStyle.cpp 2012-02-24 17:53:50 +0000
@@ -212,6 +212,9 @@
LazyLoadTexture group_unexpand_texture_;
LazyLoadTexture group_expand_texture_;
+
+ LazyLoadTexture group_grid_texture_;
+ LazyLoadTexture group_coverflow_texture_;
LazyLoadTexture star_deselected_texture_;
LazyLoadTexture star_selected_texture_;
@@ -248,6 +251,8 @@
, search_spin_glow_texture_("/search_spin_glow.png")
, 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")
@@ -2139,6 +2144,16 @@
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();
=== modified file 'plugins/unityshell/src/DashStyle.h'
--- plugins/unityshell/src/DashStyle.h 2012-02-20 11:59:12 +0000
+++ plugins/unityshell/src/DashStyle.h 2012-02-24 17:53:50 +0000
@@ -185,6 +185,9 @@
nux::BaseTexture* GetGroupUnexpandIcon();
nux::BaseTexture* GetGroupExpandIcon();
+
+ nux::BaseTexture* GetGroupGridIcon();
+ nux::BaseTexture* GetGroupCoverflowIcon();
nux::BaseTexture* GetStarDeselectedIcon();
nux::BaseTexture* GetStarSelectedIcon();
=== modified file 'plugins/unityshell/src/IconTexture.cpp'
--- plugins/unityshell/src/IconTexture.cpp 2012-02-07 22:04:45 +0000
+++ plugins/unityshell/src/IconTexture.cpp 2012-02-24 17:53:50 +0000
@@ -46,6 +46,7 @@
IconTexture::IconTexture(nux::BaseTexture* texture, guint width, guint height)
: TextureArea(NUX_TRACKER_LOCATION),
_accept_key_nav_focus(false),
+ _pixbuf_cached(NULL),
_icon_name(NULL),
_size(height),
_texture_cached(texture),
@@ -60,6 +61,7 @@
IconTexture::IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading)
: TextureArea(NUX_TRACKER_LOCATION),
_accept_key_nav_focus(false),
+ _pixbuf_cached(NULL),
_icon_name(NULL),
_size(size),
_texture_width(0),
@@ -76,6 +78,8 @@
IconTexture::~IconTexture()
{
g_free(_icon_name);
+ if (_pixbuf_cached)
+ g_object_unref(_pixbuf_cached);
}
void IconTexture::SetByIconName(const char* icon_name, unsigned int size)
@@ -134,7 +138,12 @@
void IconTexture::Refresh(GdkPixbuf* pixbuf)
{
+ if (pixbuf == _pixbuf_cached)
+ return;
+
TextureCache& cache = TextureCache::GetDefault();
+ if (_pixbuf_cached)
+ g_object_unref(_pixbuf_cached);
_pixbuf_cached = pixbuf;
// Cache the pixbuf dimensions so we scale correctly
@@ -152,12 +161,38 @@
_loading = false;
}
+GdkPixbuf* IconTexture::AddBorderToPixbuf(GdkPixbuf* pixbuf)
+{
+ int width = gdk_pixbuf_get_width(pixbuf);
+ int height = gdk_pixbuf_get_height(pixbuf);
+ GdkPixbuf* result = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf),
+ TRUE,
+ gdk_pixbuf_get_bits_per_sample(pixbuf),
+ width + 2, height + 2);
+
+ guchar* pixels = gdk_pixbuf_get_pixels(result);
+ memset(pixels, 0, gdk_pixbuf_get_byte_length(result));
+
+ gdk_pixbuf_copy_area(pixbuf, 0, 0, width, height, result, 1, 1);
+ return result;
+}
+
void IconTexture::IconLoaded(std::string const& icon_name, unsigned size,
GdkPixbuf* pixbuf)
{
if (GDK_IS_PIXBUF(pixbuf))
{
- Refresh(pixbuf);
+ if (add_border)
+ {
+ // Dont ref this, we already own a ref
+ GdkPixbuf* result = AddBorderToPixbuf(pixbuf);
+ Refresh(result);
+ }
+ else
+ {
+ g_object_ref(pixbuf);
+ Refresh(pixbuf);
+ }
}
else
{
=== modified file 'plugins/unityshell/src/IconTexture.h'
--- plugins/unityshell/src/IconTexture.h 2012-02-07 07:42:12 +0000
+++ plugins/unityshell/src/IconTexture.h 2012-02-24 17:53:50 +0000
@@ -40,6 +40,8 @@
IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading = false);
~IconTexture();
+ nux::Property add_border;
+
void SetByIconName(const char* icon_name, unsigned int size);
void SetByFilePath(const char* file_path, unsigned int size);
void GetTextureSize(int* width, int* height);
@@ -72,6 +74,7 @@
nux::BaseTexture* CreateTextureCallback(std::string const& texid, int width, int height);
void Refresh(GdkPixbuf* pixbuf);
void IconLoaded(std::string const& icon_name, unsigned size, GdkPixbuf* pixbuf);
+ GdkPixbuf* AddBorderToPixbuf(GdkPixbuf* pixbuf);
// FIXME: make _icon_name a std::string.
char* _icon_name;
=== modified file 'plugins/unityshell/src/LensView.cpp'
--- plugins/unityshell/src/LensView.cpp 2012-02-21 20:10:05 +0000
+++ plugins/unityshell/src/LensView.cpp 2012-02-24 17:53:50 +0000
@@ -24,6 +24,7 @@
#include
#include "DashStyle.h"
+#include "CoverflowResultView.h"
#include "ResultRendererTile.h"
#include "ResultRendererHorizontalTile.h"
#include "UBusMessages.h"
@@ -268,15 +269,9 @@
/* Reset result count */
counts_[group] = 0;
- ResultViewGrid* grid = new ResultViewGrid(NUX_TRACKER_LOCATION);
- grid->expanded = false;
- if (renderer_name == "tile-horizontal")
- grid->SetModelRenderer(new ResultRendererHorizontalTile(NUX_TRACKER_LOCATION));
- 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 */
@@ -289,7 +284,7 @@
{
try {
PlacesGroup* group = categories_.at(result.category_index);
- ResultViewGrid* grid = static_cast(group->GetChildView());
+ ResultView* grid = static_cast(group->GetChildView());
std::string uri = result.uri;
LOG_TRACE(logger) << "Result added: " << uri;
@@ -308,7 +303,7 @@
{
try {
PlacesGroup* group = categories_.at(result.category_index);
- ResultViewGrid* grid = static_cast(group->GetChildView());
+ ResultView* grid = static_cast(group->GetChildView());
std::string uri = result.uri;
LOG_TRACE(logger) << "Result removed: " << uri;
@@ -364,7 +359,7 @@
void LensView::OnGroupExpanded(PlacesGroup* group)
{
- ResultViewGrid* grid = static_cast(group->GetChildView());
+ ResultView* grid = static_cast(group->GetChildView());
grid->expanded = group->GetExpanded();
ubus_manager_.SendMessage(UBUS_PLACE_VIEW_QUEUE_DRAW);
}
=== modified file 'plugins/unityshell/src/PlacesGroup.cpp'
--- plugins/unityshell/src/PlacesGroup.cpp 2012-02-21 20:10:05 +0000
+++ plugins/unityshell/src/PlacesGroup.cpp 2012-02-24 17:53:50 +0000
@@ -44,6 +44,14 @@
#include "ubus-server.h"
#include "UBusMessages.h"
+#include "ResultView.h"
+#include "ResultViewGrid.h"
+#include "ResultRendererTile.h"
+#include "ResultRendererHorizontalTile.h"
+#include "CoverflowResultView.h"
+#include "FilterBasicButton.h"
+
+
namespace unity
{
namespace
@@ -112,7 +120,9 @@
_is_expanded(true),
_n_visible_items_in_unexpand_mode(0),
_n_total_items(0),
- _draw_sep(true)
+ _draw_sep(true),
+ _coverflow_enabled(false),
+ _coverflow_button(nullptr)
{
SetAcceptKeyNavFocusOnMouseDown(false);
SetAcceptKeyNavFocusOnMouseEnter(false);
@@ -127,7 +137,7 @@
_group_layout->AddLayout(new nux::SpaceLayout(15,15,15,15), 0);
_header_view = new HeaderView(NUX_TRACKER_LOCATION);
- _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FIX);
+ _group_layout->AddView(_header_view, 0, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL);
_header_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
_header_layout->SetHorizontalInternalMargin(10);
@@ -166,14 +176,40 @@
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);
+
+ nux::BaseTexture *grid_texture = dash::Style::Instance().GetGroupCoverflowIcon();
+ _coverflow_button = new IconTexture(grid_texture, 32, 32);
+
+ _coverflow_button->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::CoverflowButtonClicked));
key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
{
if (!has_focus)
@@ -184,6 +220,15 @@
else
nux::GetWindowCompositor().SetKeyFocusArea(GetHeaderFocusableView(), direction);
});
+ nux::HLayout *toggle_layout = new nux::HLayout();
+ toggle_layout->SetHorizontalInternalMargin(8);
+ toggle_layout->SetHorizontalExternalMargin(6);
+ nux::Layout *toggle_space = new nux::SpaceLayout(1, 10000, 0, 1);
+ toggle_layout->AddLayout(toggle_space, 1);
+ toggle_layout->AddView(_coverflow_button, 0, nux::MINOR_POSITION_CENTER);
+
+ _header_layout->AddLayout(toggle_layout, 1);
+
}
PlacesGroup::~PlacesGroup()
@@ -216,6 +261,48 @@
}
void
+PlacesGroup::CoverflowButtonClicked(int x, int y, unsigned long button_flags, unsigned long key_flags)
+{
+ dash::ResultView *new_view, *old_view;
+
+ old_view = _child_view;
+
+ if (_coverflow_enabled == false)
+ {
+ new_view = new dash::CoverflowResultView(NUX_TRACKER_LOCATION);
+ _coverflow_enabled = true;
+
+ _coverflow_button->SetTexture(dash::Style::Instance().GetGroupGridIcon());
+ }
+ else
+ {
+ new_view = new dash::ResultViewGrid (NUX_TRACKER_LOCATION);
+ _coverflow_enabled = false;
+
+ _coverflow_button->SetTexture(dash::Style::Instance().GetGroupCoverflowIcon());
+
+ if (_renderer_name == "tile-horizontal")
+ new_view->SetModelRenderer(new dash::ResultRendererHorizontalTile(NUX_TRACKER_LOCATION));
+ else
+ new_view->SetModelRenderer(new dash::ResultRendererTile(NUX_TRACKER_LOCATION));
+
+
+ }
+
+ for (dash::Result result: old_view->GetResultList())
+ {
+ new_view->AddResult(result);
+ }
+
+ new_view->expanded = (bool)(old_view)->expanded;
+
+ SetChildView (new_view);
+
+ SetExpanded (new_view->expanded);
+ QueueRelayout();
+}
+
+void
PlacesGroup::SetName(const char* name)
{
gchar* final = NULL;
@@ -234,6 +321,17 @@
g_free(final);
}
+void
+PlacesGroup::SetRendererName(const char *renderer_name)
+{
+ _renderer_name = renderer_name;
+
+ if (g_strcmp0(renderer_name, "tile-horizontal") == 0)
+ _child_view->SetModelRenderer(new dash::ResultRendererHorizontalTile(NUX_TRACKER_LOCATION));
+ else
+ _child_view->SetModelRenderer(new dash::ResultRendererTile(NUX_TRACKER_LOCATION));
+}
+
nux::StaticCairoText*
PlacesGroup::GetLabel()
{
@@ -253,14 +351,23 @@
}
void
-PlacesGroup::SetChildView(nux::View* view)
+PlacesGroup::SetChildView(dash::ResultView *view)
{
+ if (_child_view != NULL)
+ {
+ _group_layout->RemoveChildObject(_child_view);
+ }
_child_view = view;
_group_layout->AddView(_child_view, 1);
QueueDraw();
+
+ view->UriActivated.connect([&] (std::string const& uri)
+ {
+ UriActivated.emit(uri);
+ });
}
-nux::View*
+dash::ResultView *
PlacesGroup::GetChildView()
{
return _child_view;
@@ -307,6 +414,20 @@
_expand_label->SetText(final);
_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);
+
+ 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);
+
QueueDraw();
g_free((result_string));
@@ -441,11 +562,11 @@
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;
=== modified file 'plugins/unityshell/src/PlacesGroup.h'
--- plugins/unityshell/src/PlacesGroup.h 2012-02-13 17:09:05 +0000
+++ plugins/unityshell/src/PlacesGroup.h 2012-02-24 17:53:50 +0000
@@ -31,6 +31,7 @@
#include "Introspectable.h"
#include "StaticCairoText.h"
#include "UBusWrapper.h"
+#include "ResultView.h"
namespace nux
{
@@ -50,12 +51,13 @@
void SetIcon(const char* icon);
void SetName(const char* name);
+ void SetRendererName(const char *renderer_name);
nux::StaticCairoText* GetLabel();
nux::StaticCairoText* GetExpandLabel();
- void SetChildView(nux::View* view);
- nux::View* GetChildView();
+ void SetChildView(dash::ResultView* view);
+ dash::ResultView* GetChildView();
void SetChildLayout(nux::Layout* layout);
@@ -73,6 +75,7 @@
void SetDrawSeparator(bool draw_it);
sigc::signal expanded;
+ sigc::signal UriActivated;
protected:
long ComputeContentSize();
@@ -100,6 +103,8 @@
void OnLabelActivated(nux::Area* label);
void OnLabelFocusChanged(nux::Area* label, bool has_focus, nux::KeyNavDirection direction);
void RefreshLabel();
+
+ void CoverflowButtonClicked(int x, int y, unsigned long button_flags, unsigned long key_flags);
private:
nux::VLayout* _group_layout;
@@ -107,7 +112,7 @@
nux::HLayout* _header_layout;
nux::HLayout* _text_layout;
nux::HLayout* _expand_layout;
- nux::View* _child_view;
+ dash::ResultView *_child_view;
nux::AbstractPaintLayer* _focus_layer;
IconTexture* _icon;
@@ -123,6 +128,11 @@
char* _cached_name;
bool _draw_sep;
nux::Geometry _cached_geometry;
+
+ std::string _renderer_name;
+ bool _coverflow_enabled;
+
+ IconTexture *_coverflow_button;
UBusManager _ubus;
};
=== modified file 'plugins/unityshell/src/ResultView.cpp'
--- plugins/unityshell/src/ResultView.cpp 2012-02-21 23:19:50 +0000
+++ plugins/unityshell/src/ResultView.cpp 2012-02-24 17:53:50 +0000
@@ -68,6 +68,10 @@
ResultView::~ResultView()
{
+ if (renderer_ == NULL)
+ {
+ return;
+ }
ClearIntrospectableWrappers();
for (auto result : results_)
@@ -100,7 +104,9 @@
void ResultView::AddResult(Result& result)
{
results_.push_back(result);
- renderer_->Preload(result);
+
+ if (renderer_ != NULL)
+ renderer_->Preload(result);
NeedRedraw();
}
@@ -118,7 +124,9 @@
break;
}
}
- renderer_->Unload(result);
+
+ if (renderer_ != NULL)
+ renderer_->Unload(result);
}
ResultView::ResultList ResultView::GetResultList()
=== modified file 'plugins/unityshell/src/ResultView.h'
--- plugins/unityshell/src/ResultView.h 2012-02-21 23:19:50 +0000
+++ plugins/unityshell/src/ResultView.h 2012-02-24 17:53:50 +0000
@@ -48,14 +48,14 @@
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 ();
- void SetPreview(PreviewBase* preview, Result& related_result);
+ virtual void SetPreview(PreviewBase* preview, Result& related_result);
nux::Property expanded;
sigc::signal UriActivated;
=== modified file 'standalone-clients/CMakeLists.txt'
--- standalone-clients/CMakeLists.txt 2012-02-21 00:11:20 +0000
+++ standalone-clients/CMakeLists.txt 2012-02-24 17:53:50 +0000
@@ -47,6 +47,8 @@
${UNITY_SRC}/BackgroundEffectHelper.h
${UNITY_SRC}/BGHash.cpp
${UNITY_SRC}/BGHash.h
+ ${UNITY_SRC}/CoverflowResultView.cpp
+ ${UNITY_SRC}/CoverflowResultView.h
${UNITY_SRC}/SearchBar.cpp
${UNITY_SRC}/SearchBar.h
${UNITY_SRC}/SearchBarSpinner.cpp