summaryrefslogtreecommitdiff
path: root/src
diff options
authorNeil Jagdish Patel <neil.patel@canonical.com>2011-02-27 13:50:25 +0000
committerNeil Jagdish Patel <neil.patel@canonical.com>2011-02-27 13:50:25 +0000
commit6633a2a6db9d1f56e9b0fcfc52d891b37bcf5234 (patch)
treebb99a536345af57c46d918fa1fa72c86ec218bca /src
parent20dbf125a887f515f15832e077ff4dbdc9e21cd1 (diff)
Lots more clean up and first bits of making PlacesResultsController use the new stuff
(bzr r894.1.9)
Diffstat (limited to 'src')
-rw-r--r--src/PlacesResultsController.cpp174
-rw-r--r--src/PlacesResultsController.h40
-rw-r--r--src/PlacesResultsView.cpp6
-rw-r--r--src/PlacesResultsView.h3
-rw-r--r--src/PlacesSimpleTile.cpp35
-rw-r--r--src/PlacesSimpleTile.h43
-rw-r--r--src/PlacesTile.cpp137
-rw-r--r--src/PlacesTile.h73
-rw-r--r--src/PlacesView.cpp31
-rw-r--r--src/PlacesView.h7
-rw-r--r--src/StaticCairoText.cpp2
-rw-r--r--src/UBusMessages.h4
12 files changed, 217 insertions, 338 deletions
diff --git a/src/PlacesResultsController.cpp b/src/PlacesResultsController.cpp
index f7e64ec3c..0661e01b3 100644
--- a/src/PlacesResultsController.cpp
+++ b/src/PlacesResultsController.cpp
@@ -60,131 +60,102 @@ PlacesResultsController::GetView ()
}
void
-PlacesResultsController::AddResultToGroup (const char *groupname,
- PlacesTile *tile,
- void *_id)
+PlacesResultsController::AddGroup (PlaceEntryGroup& group)
{
- PlacesGroup *group = _groups[groupname];
-
- if (!group)
- {
- group = CreateGroup (groupname);
- }
+ PlacesSettings *settings = PlacesSettings::GetDefault ();
- group->GetChildLayout ()->AddView (tile, 1, nux::eLeft, nux::eFull);
- _tiles[_id] = tile;
- _tile_group_relations[_id] = groupname;
+ PlacesGroup *new_group = new PlacesGroup (NUX_TRACKER_LOCATION);
+ new_group->SetTitle (group.GetName ());
+ new_group->SetEmblem (group.GetIcon ());
- // Should also catch the onclick signal here on each tile,
- // so we can activate or do whatever it is we need to do
+ nux::GridHLayout *layout = new nux::GridHLayout (NUX_TRACKER_LOCATION);
+ layout->ForceChildrenSize (true);
+ layout->SetChildrenSize (settings->GetDefaultTileWidth (), 100);
+ layout->EnablePartialVisibility (false);
- if (group->IsVisible () == false)
- {
- group->SetVisible (true);
- group->Relayout ();
- }
+ layout->SetVerticalExternalMargin (4);
+ layout->SetHorizontalExternalMargin (4);
+ layout->SetVerticalInternalMargin (4);
+ layout->SetHorizontalInternalMargin (4);
+ layout->SetHeightMatchContent (true);
+
+ new_group->SetChildLayout (layout);
+ new_group->SetVisible (false);
- tile->QueueDraw ();
+ _id_to_group[group.GetId ()] = new_group;
+ _results_view->AddGroup (new_group);
+ _results_view->QueueRelayout ();
}
void
-PlacesResultsController::RemoveResultFromGroup (const char *groupname,
- void *_id)
+PlacesResultsController::AddResult (PlaceEntryGroup& group, PlaceEntryResult& result)
{
- PlacesTile *tile = _tiles[_id];
- PlacesGroup *group = _groups[groupname];
+ PlacesGroup *pgroup;
+ gchar *result_name;
+ const gchar *result_icon;
+ PlacesSimpleTile *tile;
- if (group)
+ pgroup = _id_to_group[group.GetId ()];
+ if (!pgroup)
{
- if (tile)
- {
- group->GetChildLayout ()->RemoveChildObject (tile);
-
- if (group->GetChildLayout ()->GetChildren ().empty ())
- {
- group->SetVisible (false);
- }
- else
- {
- group->Relayout ();
- }
- }
- else
- {
- g_warning ("Unable to remove '%p' from group '%s': Unable to find tile",
- _id, groupname);
- }
- }
- else
- {
- g_warning ("Unable to remove '%p' from group '%s': Unable to find group",
- _id, groupname);
+ g_warning ("Unable find group %s for result %s", group.GetName (), result.GetName ());
+ return;
}
- _tiles.erase (_id);
- _tile_group_relations.erase (_id);
-}
+ result_name = g_markup_escape_text (result.GetName (), -1);
+ result_icon = result.GetIcon ();
-void
-PlacesResultsController::RemoveResult (void *_id)
-{
- RemoveResultFromGroup (_tile_group_relations [_id].c_str (), _id);
+ tile = new PlacesSimpleTile (result_icon, result_name, 48);
+ tile->SetURI (result.GetURI ());
+
+ _id_to_tile[result.GetId ()] = tile;
+
+ pgroup->GetChildLayout ()->AddView (tile);
+ pgroup->Relayout ();
+ tile->QueueRelayout ();
+
+ pgroup->SetVisible (pgroup->GetChildLayout ()->GetChildren ().size ());
+ g_free (result_name);
}
void
-PlacesResultsController::Clear ()
+PlacesResultsController::RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& result)
{
- std::map<std::string, PlacesGroup *>::iterator it;
+ PlacesTile *tile;
+ PlacesGroup *pgroup;
- for (it = _groups.begin (); it != _groups.end (); ++it)
+ pgroup = _id_to_group[group.GetId ()];
+ if (!pgroup)
+ {
+ g_warning ("Unable find group %s for result %s", group.GetName (), result.GetName ());
+ return;
+ }
+
+ tile = _id_to_tile[result.GetId ()];
+ if (!tile)
{
- PlacesGroup *group = dynamic_cast <PlacesGroup *> (it->second);
-
- if (group)
- {
- _results_view->RemoveGroup (group);
- group->UnReference ();
- }
+ g_warning ("Unable to find result %s for group %s", result.GetName (), group.GetName ());
+ return;
}
- _groups.erase (_groups.begin (), _groups.end ());
- _tiles.erase (_tiles.begin (), _tiles.end ());
- _tile_group_relations.erase (_tile_group_relations.begin (), _tile_group_relations.end ());
+ pgroup->GetChildLayout ()->RemoveChildObject (tile);
+ pgroup->SetVisible (pgroup->GetChildLayout ()->GetChildren ().size ());
+ pgroup->Relayout ();
}
-PlacesGroup *
-PlacesResultsController::CreateGroup (const char *groupname, const char *icon)
+void
+PlacesResultsController::Clear ()
{
- PlacesSettings *settings = PlacesSettings::GetDefault ();
-
- PlacesGroup *newgroup = new PlacesGroup (NUX_TRACKER_LOCATION);
- newgroup->SinkReference ();
- newgroup->SetTitle (groupname);
- newgroup->SetEmblem (icon);
-
- nux::GridHLayout *layout = new nux::GridHLayout (NUX_TRACKER_LOCATION);
- layout->ForceChildrenSize (true);
- layout->SetChildrenSize (settings->GetDefaultTileWidth (), 100);
- layout->EnablePartialVisibility (false);
-
- layout->SetVerticalExternalMargin (4);
- layout->SetHorizontalExternalMargin (4);
- layout->SetVerticalInternalMargin (4);
- layout->SetHorizontalInternalMargin (4);
- layout->SetHeightMatchContent (true);
-
- newgroup->SetChildLayout (layout);
- newgroup->SetVisible (false);
-
- _groups[groupname] = newgroup;
- _results_view->AddGroup (newgroup);
-
- return newgroup;
+ _results_view->Clear ();
+ _id_to_group.erase (_id_to_group.begin (), _id_to_group.end ());
+ _id_to_tile.erase (_id_to_tile.begin (), _id_to_tile.end ());
}
-/* Introspection */
-const gchar *
+//
+// Introspection
+//
+const gchar*
PlacesResultsController::GetName ()
{
return "PlacesResultsController";
@@ -193,12 +164,5 @@ PlacesResultsController::GetName ()
void
PlacesResultsController::AddProperties (GVariantBuilder *builder)
{
-}
-
-
-
-
-
-
-
+}
diff --git a/src/PlacesResultsController.h b/src/PlacesResultsController.h
index 5ff9a692b..0d007bf8e 100644
--- a/src/PlacesResultsController.h
+++ b/src/PlacesResultsController.h
@@ -19,44 +19,40 @@
#ifndef PLACES_RESULTS_CONTROLLER_H
#define PLACES_RESULTS_CONTROLLER_H
-#include <Nux/TextureArea.h>
-#include <Nux/View.h>
-#include "Nux/Layout.h"
-#include <NuxImage/CairoGraphics.h>
-#include <NuxGraphics/GraphicsEngine.h>
+#include <Nux/Nux.h>
+#include "Introspectable.h"
+#include "PlaceEntry.h"
#include "PlacesResultsView.h"
+
+//FIXME
#include "PlacesTile.h"
-#include "Introspectable.h"
+#include "PlacesGroup.h"
class PlacesResultsController : public nux::Object, public Introspectable
{
public:
- PlacesResultsController ();
+ PlacesResultsController ();
~PlacesResultsController ();
- void SetView (PlacesResultsView *_results_view);
- PlacesResultsView *GetView ();
+ void SetView (PlacesResultsView *view);
+ PlacesResultsView * GetView ();
+
+ void AddGroup (PlaceEntryGroup& group);
+ void AddResult (PlaceEntryGroup& group, PlaceEntryResult& result);
+ void RemoveResult (PlaceEntryGroup& group, PlaceEntryResult& result);
+ // Clears all the current groups and results
+ void Clear ();
- void AddResultToGroup (const char *groupname,
- PlacesTile *tile,
- void *id);
- void RemoveResult (void *id);
- void RemoveResultFromGroup (const char *groupname,
- void *_id);
- void Clear ();
- PlacesGroup *CreateGroup (const char *groupname,
- const char *icon="");
protected:
const gchar* GetName ();
- void AddProperties (GVariantBuilder *builder);
+ void AddProperties (GVariantBuilder *builder);
private:
PlacesResultsView *_results_view;
- std::map<std::string, PlacesGroup *> _groups;
- std::map<void *, PlacesTile *> _tiles;
- std::map<void *, std::string> _tile_group_relations;
+ std::map<const void *, PlacesGroup *> _id_to_group;
+ std::map<const void *, PlacesTile *> _id_to_tile;
};
#endif // PLACES_RESULTS_CONTROLLER_H
diff --git a/src/PlacesResultsView.cpp b/src/PlacesResultsView.cpp
index b43cd9602..ac301c554 100644
--- a/src/PlacesResultsView.cpp
+++ b/src/PlacesResultsView.cpp
@@ -61,3 +61,9 @@ PlacesResultsView::RemoveGroup (PlacesGroup *group)
_groups.remove (group);
_layout->RemoveChildObject (group);
}
+
+void
+PlacesResultsView::Clear ()
+{
+ _layout->Clear ();
+}
diff --git a/src/PlacesResultsView.h b/src/PlacesResultsView.h
index 666081291..4aa91bf9d 100644
--- a/src/PlacesResultsView.h
+++ b/src/PlacesResultsView.h
@@ -42,8 +42,9 @@ public:
PlacesResultsView (NUX_FILE_LINE_PROTO);
~PlacesResultsView ();
- void AddGroup (PlacesGroup *group);
+ void AddGroup (PlacesGroup *group);
void RemoveGroup (PlacesGroup *group);
+ void Clear ();
private:
nux::Layout *_layout;
diff --git a/src/PlacesSimpleTile.cpp b/src/PlacesSimpleTile.cpp
index d7e924bb1..70d166cfb 100644
--- a/src/PlacesSimpleTile.cpp
+++ b/src/PlacesSimpleTile.cpp
@@ -16,17 +16,15 @@
* <http://www.gnu.org/licenses/>
*
* Authored by: Gordon Allott <gord.allott@canonical.com>
+ * Neil Jagdish Patel <neil.patel@canonical.com>
*
*/
-#include "Nux/Nux.h"
-#include "PlacesSimpleTile.h"
-
-#include "IconTexture.h"
-
#include "PlacesSettings.h"
+#include "ubus-server.h"
+#include "UBusMessages.h"
-#define ICON_HEIGHT 48
+#include "PlacesSimpleTile.h"
PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, int icon_size)
: PlacesTile (NUX_TRACKER_LOCATION),
@@ -34,7 +32,7 @@ PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, in
_icon (NULL),
_uri (NULL)
{
- _layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
+ nux::VLayout *layout = new nux::VLayout ("", NUX_TRACKER_LOCATION);
_label = g_strdup (label);
_icon = g_strdup (icon_name);
@@ -42,6 +40,7 @@ PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, in
_icontex = new IconTexture (_icon, icon_size);
_icontex->SetMinMaxSize (PlacesSettings::GetDefault ()->GetDefaultTileWidth (), icon_size);
_icontex->SinkReference ();
+ AddChild (_icontex);
_cairotext = new nux::StaticCairoText (_label);
_cairotext->SinkReference ();
@@ -50,16 +49,16 @@ PlacesSimpleTile::PlacesSimpleTile (const char *icon_name, const char *label, in
_cairotext->SetTextAlignment (nux::StaticCairoText::NUX_ALIGN_CENTRE);
_cairotext->SetMaximumWidth (140);
- _layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));
- _layout->AddView (_icontex, 0, nux::eCenter, nux::eFull);
- _layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));
- _layout->AddView (_cairotext, 0, nux::eCenter, nux::eFull);
+ layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));
+ layout->AddView (_icontex, 0, nux::eCenter, nux::eFull);
+ layout->AddLayout (new nux::SpaceLayout (0, 0, 12, 12));
+ layout->AddView (_cairotext, 0, nux::eCenter, nux::eFull);
SetMinMaxSize (160, 128);
- AddChild (_icontex);
+ SetLayout (layout);
- SetLayout (_layout);
+ OnMouseClick.connect (sigc::mem_fun (this, &PlacesSimpleTile::Clicked));
}
@@ -142,3 +141,13 @@ PlacesSimpleTile::AddProperties (GVariantBuilder *builder)
g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
}
+void
+PlacesSimpleTile::Clicked (int x, int y, unsigned long button_flags, unsigned long key_flags)
+{
+ if (_uri)
+ {
+ ubus_server_send_message (ubus_server_get_default (),
+ UBUS_PLACE_TILE_ACTIVATE_REQUEST,
+ g_variant_new_string (_uri));
+ }
+}
diff --git a/src/PlacesSimpleTile.h b/src/PlacesSimpleTile.h
index 5835cf13c..efc1e8d3b 100644
--- a/src/PlacesSimpleTile.h
+++ b/src/PlacesSimpleTile.h
@@ -22,27 +22,10 @@
#include <sigc++/sigc++.h>
-#include <Nux/Nux.h>
-#include <Nux/VLayout.h>
-#include <Nux/BaseWindow.h>
-#include <NuxCore/Math/MathInc.h>
-#include <NuxImage/CairoGraphics.h>
-#include <NuxGraphics/GraphicsEngine.h>
-
-#include "PlacesTile.h"
-
+#include "IconTexture.h"
#include "Introspectable.h"
-
-#include <sigc++/trackable.h>
-#include <sigc++/signal.h>
-#include <sigc++/functors/ptr_fun.h>
-#include <sigc++/functors/mem_fun.h>
-
-class IconTexture;
-namespace nux
-{
- class StaticCairoText;
-}
+#include "PlacesTile.h"
+#include "StaticCairoText.h"
class PlacesSimpleTile : public Introspectable, public PlacesTile
{
@@ -52,25 +35,27 @@ public:
~PlacesSimpleTile ();
const char * GetLabel ();
- const char * GetIcon ();
- const char * GetURI ();
-
- void SetURI (const char *uri);
+ const char * GetIcon ();
+ const char * GetURI ();
+ void SetURI (const char *uri);
protected:
nux::Geometry GetHighlightGeometry ();
- nux::Geometry _highlight_geometry;
- const gchar* GetName ();
- const gchar *GetChildsName ();
- void AddProperties (GVariantBuilder *builder);
+
+ const gchar * GetName ();
+ const gchar * GetChildsName ();
+ void AddProperties (GVariantBuilder *builder);
private:
+ void Clicked (int x, int y, unsigned long button_flags, unsigned long key_flags);
+
+private:
+ nux::Geometry _highlight_geometry;
char* _label;
char* _icon;
char* _uri;
IconTexture *_icontex;
nux::StaticCairoText *_cairotext;
-
};
diff --git a/src/PlacesTile.cpp b/src/PlacesTile.cpp
index 645280bf4..b63ecd5ec 100644
--- a/src/PlacesTile.cpp
+++ b/src/PlacesTile.cpp
@@ -25,6 +25,8 @@
#include "Nux/Nux.h"
#include "PlacesTile.h"
+#define PADDING 8
+
PlacesTile::PlacesTile (NUX_FILE_LINE_DECL) :
View (NUX_FILE_LINE_PARAM),
_hilight_background (NULL),
@@ -32,17 +34,12 @@ PlacesTile::PlacesTile (NUX_FILE_LINE_DECL) :
_last_width (0),
_last_height (0)
{
- _state = STATE_DEFAULT;
-
OnMouseDown.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseDown));
OnMouseUp.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseUp));
OnMouseClick.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseClick));
- OnMouseMove.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseMove));
- //OnMouseDrag.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseDrag));
OnMouseEnter.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseEnter));
OnMouseLeave.connect (sigc::mem_fun (this, &PlacesTile::RecvMouseLeave));
_hilight_view = this;
-
}
PlacesTile::~PlacesTile ()
@@ -68,7 +65,9 @@ PlacesTile::DrawHighlight (const char *texid, int width, int height, nux::BaseTe
{
nux::Geometry base = GetGeometry ();
nux::Geometry highlight_geo = GetHighlightGeometry ();
- nux::CairoGraphics *cairo_graphics = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, highlight_geo.width + 6, highlight_geo.height + 6);
+ nux::CairoGraphics *cairo_graphics = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32,
+ highlight_geo.width + PADDING,
+ highlight_geo.height + PADDING);
cairo_t *cr = cairo_graphics->GetContext();
cairo_scale (cr, 1.0f, 1.0f);
@@ -80,7 +79,7 @@ PlacesTile::DrawHighlight (const char *texid, int width, int height, nux::BaseTe
// draw tiled background
// set up clip path
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- DrawRoundedRectangle (cr, 1.0, 0, 0, 5.0, highlight_geo.width + 6, highlight_geo.height + 6);
+ DrawRoundedRectangle (cr, 1.0, 0, 0, 5.0, highlight_geo.width + PADDING, highlight_geo.height + PADDING);
cairo_clip (cr);
int w, h;
@@ -107,7 +106,7 @@ PlacesTile::DrawHighlight (const char *texid, int width, int height, nux::BaseTe
// draw the outline
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- DrawRoundedRectangle (cr, 1.0, 0, 0, 5.0, highlight_geo.width + 6, highlight_geo.height + 6);
+ DrawRoundedRectangle (cr, 1.0, 0, 0, 5.0, highlight_geo.width + PADDING, highlight_geo.height + PADDING);
cairo_set_source_rgba (cr, 0.66, 0.66, 0.66, 1.0);
cairo_set_line_width (cr, 1.0);
cairo_stroke (cr);
@@ -122,8 +121,6 @@ PlacesTile::DrawHighlight (const char *texid, int width, int height, nux::BaseTe
delete bitmap;
}
-//texture->OnDestroyed.connect (sigc::mem_fun (this, &TextureCache::OnDestroyNotify));
-
void
PlacesTile::OnDestroyNotify (nux::Trackable *Object)
{
@@ -161,8 +158,7 @@ PlacesTile::UpdateBackground ()
_hilight_background = hilight_tex;
_hilight_background->Reference ();
- //g_debug ("_hilight_backgrounds reference count %i", _hilight_background->GetReferenceCount ());
-
+
nux::ROPConfig rop;
rop.Blend = true;
rop.SrcBlend = GL_ONE;
@@ -248,121 +244,94 @@ PlacesTile::DrawRoundedRectangle (cairo_t* cr,
270.0f * G_PI / 180.0f);
}
-long PlacesTile::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
+long
+PlacesTile::ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
{
- long ret = TraverseInfo;
- ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo);
- return ret;
+ return PostProcessEvent2 (ievent, TraverseInfo, ProcessEventInfo);
}
-void PlacesTile::Draw (nux::GraphicsEngine& gfxContext,
+void
+PlacesTile::Draw (nux::GraphicsEngine& gfxContext,
bool forceDraw)
{
nux::Geometry base = GetGeometry ();
- nux::GetPainter ().PaintBackground (gfxContext, GetGeometry ());
+ nux::GetPainter ().PaintBackground (gfxContext, base);
gfxContext.PushClippingRectangle (base);
- if (_state == STATE_HOVER)
+ if (IsMouseInside ())
{
UpdateBackground ();
nux::Geometry hl_geo = GetHighlightGeometry ();
-
- nux::Geometry total_highlight_geo = nux::Geometry (base.x + hl_geo.x - 3, base.y + hl_geo.y - 3,
- hl_geo.width + 7, hl_geo.height + 7);
+ nux::Geometry total_highlight_geo = nux::Geometry (base.x + hl_geo.x - (PADDING)/2 -1,
+ base.y + hl_geo.y - (PADDING)/2 -1,
+ hl_geo.width + PADDING + 1,
+ hl_geo.height + PADDING + 1);
- gPainter.PushDrawLayer (gfxContext, total_highlight_geo, _hilight_layer);
- gPainter.PopBackground ();
+ _hilight_layer->SetGeometry (total_highlight_geo);
+ nux::GetPainter ().RenderSinglePaintLayer (gfxContext, total_highlight_geo, _hilight_layer);
}
gfxContext.PopClippingRectangle ();
}
-void PlacesTile::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
+void
+PlacesTile::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
{
- GfxContext.PushClippingRectangle (GetGeometry() );
+ nux::Geometry base = GetGeometry ();
- if (_state == STATE_HOVER)
+ GfxContext.PushClippingRectangle (base);
+
+ if (IsMouseInside ())
{
UpdateBackground ();
- nux::GetPainter ().PushLayer (GfxContext, GetGeometry (), _hilight_layer);
+
+ nux::Geometry hl_geo = GetHighlightGeometry ();
+ nux::Geometry total_highlight_geo = nux::Geometry (base.x + hl_geo.x - (PADDING)/2 - 1,
+ base.y + hl_geo.y - (PADDING)/2 - 1,
+ hl_geo.width + PADDING + 1,
+ hl_geo.height + PADDING + 1);
+
+ nux::GetPainter ().PushLayer (GfxContext, total_highlight_geo, _hilight_layer);
}
- _layout->ProcessDraw (GfxContext, force_draw);
+ if (GetCompositionLayout ())
+ GetCompositionLayout ()->ProcessDraw (GfxContext, force_draw);
- if (_state == STATE_HOVER)
+ if (IsMouseInside ())
nux::GetPainter ().PopBackground ();
GfxContext.PopClippingRectangle();
}
-void PlacesTile::PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
-{
-
-}
-
void
-PlacesTile::PreLayoutManagement ()
+PlacesTile::RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- nux::View::PreLayoutManagement ();
+ sigClick.emit (this);
+ QueueDraw ();
}
-long
-PlacesTile::PostLayoutManagement (long LayoutResult)
-{
- return nux::View::PostLayoutManagement (LayoutResult);
-}
-
-void PlacesTile::SetState (TileState state)
-{
- _state = state;
- NeedRedraw ();
-}
-
-PlacesTile::TileState PlacesTile::GetState ()
-{
- return _state;
-}
-
-void PlacesTile::RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags)
-{
- sigClick.emit(this);
-
- NeedRedraw();
- _layout->NeedRedraw ();
-}
-
-void PlacesTile::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
-{
- NeedRedraw();
- _layout->NeedRedraw ();
-}
-
-void PlacesTile::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
+void
+PlacesTile::RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- _state = STATE_PRESSED;
- NeedRedraw();
- _layout->NeedRedraw ();
+ QueueDraw ();
}
-void PlacesTile::RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
+void
+PlacesTile::RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags)
{
-
+ QueueDraw ();
}
-void PlacesTile::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
+void
+PlacesTile::RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- SetState (STATE_HOVER);
- NeedRedraw();
- _layout->NeedRedraw ();
+ QueueDraw ();
}
-void PlacesTile::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
+void
+PlacesTile::RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags)
{
- SetState (STATE_DEFAULT);
- NeedRedraw();
- _layout->NeedRedraw ();
+ QueueDraw ();
}
-
-
diff --git a/src/PlacesTile.h b/src/PlacesTile.h
index 2927e8254..9c4b78fac 100644
--- a/src/PlacesTile.h
+++ b/src/PlacesTile.h
@@ -24,84 +24,33 @@
#include <Nux/Nux.h>
#include <Nux/VLayout.h>
-#include <Nux/BaseWindow.h>
-#include <NuxCore/Math/MathInc.h>
-
-#include "StaticCairoText.h"
+#include <NuxImage/CairoGraphics.h>
#include "Introspectable.h"
-#include <sigc++/trackable.h>
-#include <sigc++/signal.h>
-#include <sigc++/functors/ptr_fun.h>
-#include <sigc++/functors/mem_fun.h>
-
class PlacesTile : public nux::View
{
public:
- typedef enum
- {
- STATE_DEFAULT,
- STATE_HOVER,
- STATE_PRESSED,
- STATE_ACTIVATED,
- } TileState;
-
PlacesTile (NUX_FILE_LINE_PROTO);
~PlacesTile ();
- // mainly for testing
- virtual void SetState (TileState state);
- virtual TileState GetState ();
-
- sigc::signal<void, PlacesTile *> sigClick;
- sigc::signal<void> sigToggled;
- sigc::signal<void, bool> sigStateChanged;
-
- sigc::signal<void, int> MouseDown;
- sigc::signal<void, int> MouseUp;
- sigc::signal<void> MouseEnter;
- sigc::signal<void> MouseLeave;
- sigc::signal<void, int> MouseClick;
+ sigc::signal<void, PlacesTile*> sigClick;
protected:
-
- virtual long ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
- virtual void Draw (nux::GraphicsEngine &GfxContext, bool force_draw);
- virtual void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
- virtual void PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw);
-
- virtual void PreLayoutManagement ();
- virtual long PostLayoutManagement (long LayoutResult);
-
virtual nux::Geometry GetHighlightGeometry ();
- void DrawHighlight (const char *texid, int width, int height, nux::BaseTexture **texture);
-
+private:
+ void Draw (nux::GraphicsEngine &GfxContext, bool force_draw);
+ void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw);
+ long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
void RecvMouseClick (int x, int y, unsigned long button_flags, unsigned long key_flags);
- void RecvMouseMove (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
- //void RecvMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
-
- sigc::signal<void, PlacesTile*> sigMouseEnter;
- sigc::signal<void, PlacesTile*> sigMouseLeave;
- sigc::signal<void, PlacesTile*, int, int> sigMouseReleased;
- sigc::signal<void, PlacesTile*, int, int> sigMouseClick;
- sigc::signal<void, PlacesTile*, int, int> sigMouseDrag;
-
- sigc::connection con_obj;
void OnDestroyNotify (nux::Trackable *Object);
- TileState _state;
- nux::Layout *_layout;
- nux::BaseTexture *_hilight_background;
- nux::View *_hilight_view;
- nux::TextureLayer *_hilight_layer;
-
void UpdateBackground ();
void DrawRoundedRectangle (cairo_t* cr,
double aspect,
@@ -110,11 +59,17 @@ protected:
double cornerRadius,
double width,
double height);
-
-
+ void DrawHighlight (const char *texid, int width, int height, nux::BaseTexture **texture);
+
private:
+ nux::BaseTexture *_hilight_background;
+ nux::View *_hilight_view;
+ nux::TextureLayer *_hilight_layer;
+
int _last_width;
int _last_height;
+
+ sigc::connection con_obj;
};
#endif // PLACE_TILE_H
diff --git a/src/PlacesView.cpp b/src/PlacesView.cpp
index 4108bb53a..598bed365 100644
--- a/src/PlacesView.cpp
+++ b/src/PlacesView.cpp
@@ -74,6 +74,9 @@ PlacesView::PlacesView (PlaceFactory *factory)
ubus_server_register_interest (ubus, UBUS_PLACE_VIEW_CLOSE_REQUEST,
(UBusCallback)&PlacesView::CloseRequest,
this);
+ ubus_server_register_interest (ubus, UBUS_PLACE_TILE_ACTIVATE_REQUEST,
+ (UBusCallback)&PlacesView::OnResultClicked,
+ this);
_icon_loader = IconLoader::GetDefault ();
@@ -198,30 +201,17 @@ PlacesView::GetResultsController ()
void
PlacesView::OnGroupAdded (PlaceEntry *entry, PlaceEntryGroup& group)
{
- _results_controller->CreateGroup (group.GetName (), group.GetIcon ());
+ _results_controller->AddGroup (group);
}
void
PlacesView::OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result)
{
- gchar *result_name;
- const gchar *result_icon;
- PlacesSimpleTile *tile;
-
//FIXME: We can't do anything with these do just ignore
if (g_str_has_prefix (result.GetURI (), "unity-install"))
return;
-
- result_name = g_markup_escape_text (result.GetName (), -1);
- result_icon = result.GetIcon ();
- tile = new PlacesSimpleTile (result_icon, result_name, 48);
- tile->SetURI (result.GetURI ());
- tile->sigClick.connect (sigc::mem_fun (this, &PlacesView::OnResultClicked));
- _results_controller->AddResultToGroup (group.GetName (), tile,
- const_cast<void*> (result.GetId ()));
-
- g_free (result_name);
+ _results_controller->AddResult (group, result);
}
void
@@ -231,18 +221,19 @@ PlacesView::OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEnt
if (g_str_has_prefix (result.GetURI (), "unity-install"))
return;
- _results_controller->RemoveResult (const_cast<void*> (result.GetId ()));
+ _results_controller->RemoveResult (group, result);
}
void
-PlacesView::OnResultClicked (PlacesTile *tile)
+PlacesView::OnResultClicked (GVariant *data, PlacesView *self)
{
- PlacesSimpleTile *simple_tile = static_cast<PlacesSimpleTile *> (tile);
const char *uri;
- if (!(uri = simple_tile->GetURI ()))
+ uri = g_variant_get_string (data, NULL);
+
+ if (!uri)
{
- g_warning ("Unable to launch %s: does not have a URI", simple_tile->GetLabel ());
+ g_warning ("Unable to launch tile does not have a URI");
return;
}
diff --git a/src/PlacesView.h b/src/PlacesView.h
index 83e0069e6..11a8c736d 100644
--- a/src/PlacesView.h
+++ b/src/PlacesView.h
@@ -51,10 +51,6 @@ public:
PlacesView (PlaceFactory *factory);
~PlacesView ();
- // Return the TextEntry View. This is required to enable the keyboard focus on the text entry when the
- // dahs is shown.
- nux::TextEntry* GetTextEntryView ();
-
// nux::View overrides
long ProcessEvent(nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
@@ -70,6 +66,7 @@ public:
PlacesResultsController * GetResultsController ();
+ nux::TextEntry* GetTextEntryView ();
// UBus handlers
void PlaceEntryActivateRequest (const char *entry_id, guint section, const gchar *search);
@@ -89,7 +86,7 @@ private:
void OnResultAdded (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
void OnResultRemoved (PlaceEntry *entry, PlaceEntryGroup& group, PlaceEntryResult& result);
- void OnResultClicked (PlacesTile *tile);
+ static void OnResultClicked (GVariant *data, PlacesView *self);
void OnSearchChanged (const char *search_string);
private:
diff --git a/src/StaticCairoText.cpp b/src/StaticCairoText.cpp
index b10cc6776..3ab8b4a04 100644
--- a/src/StaticCairoText.cpp
+++ b/src/StaticCairoText.cpp
@@ -153,6 +153,8 @@ StaticCairoText::Draw (GraphicsEngine& gfxContext,
gfxContext.PushClippingRectangle (base);
+ gPainter.PaintBackground (gfxContext, base);
+
TexCoordXForm texxform;
texxform.SetWrap (TEXWRAP_REPEAT, TEXWRAP_REPEAT);
texxform.SetTexCoordType (TexCoordXForm::OFFSET_COORD);
diff --git a/src/UBusMessages.h b/src/UBusMessages.h
index 5cf1211ac..1471cbe49 100644
--- a/src/UBusMessages.h
+++ b/src/UBusMessages.h
@@ -33,6 +33,10 @@
// id = entry->GetId(), search_string can be ""
#define UBUS_PLACE_ENTRY_ACTIVATE_REQUEST "PLACE_ENTRY_ACTIVATE_REQUEST"
+// When a result wants to activate in a place
+// Payload should be: (s) = (uri)
+#define UBUS_PLACE_TILE_ACTIVATE_REQUEST "PLACE_TILE_ACTIVATE_REQUEST"
+
// Signal send when places are shown or hidden
#define UBUS_PLACE_VIEW_HIDDEN "PLACE_VIEW_HIDDEN"
#define UBUS_PLACE_VIEW_SHOWN "PLACE_VIEW_SHOWN"