paperbox r121 - in trunk: . src
- From: markoa svn gnome org
- To: svn-commits-list gnome org
- Subject: paperbox r121 - in trunk: . src
- Date: Sat, 15 Mar 2008 17:59:06 +0000 (GMT)
Author: markoa
Date: Sat Mar 15 17:59:05 2008
New Revision: 121
URL: http://svn.gnome.org/viewvc/paperbox?rev=121&view=rev
Log:
Fixed marker invalidation issue after cloud redraw
Modified:
trunk/ChangeLog
trunk/src/tag-cloud.cc
trunk/src/tag-cloud.hh
trunk/src/tag-item.cc
Modified: trunk/src/tag-cloud.cc
==============================================================================
--- trunk/src/tag-cloud.cc (original)
+++ trunk/src/tag-cloud.cc Sat Mar 15 17:59:05 2008
@@ -96,15 +96,7 @@
TagCloud::~TagCloud()
{
- list<shared_ptr<TagItem> >::iterator item_it(text_items_.begin());
- list<shared_ptr<TagItem> >::iterator item_end(text_items_.end());
-
- for ( ; item_it != item_end; ++item_it) {
- goo_canvas_item_remove ((*item_it)->get_canvas_item());
- GooCanvasItem* marker = (*item_it)->get_marker();
- if (marker) goo_canvas_item_remove (marker);
- }
-
+ remove_canvas_items();
delete canvas_;
g_rand_free (grand_);
}
@@ -280,15 +272,26 @@
}
void
-TagCloud::redraw_tags()
+TagCloud::remove_canvas_items()
{
list<shared_ptr<TagItem> >::iterator item_it(text_items_.begin());
list<shared_ptr<TagItem> >::iterator item_end(text_items_.end());
for ( ; item_it != item_end; ++item_it) {
goo_canvas_item_remove ((*item_it)->get_canvas_item());
+ GooCanvasItem* marker = (*item_it)->get_marker();
+ if (marker) {
+ goo_canvas_item_remove (marker);
+ marker = 0;
+ }
}
+}
+void
+TagCloud::redraw_tags()
+{
+ reset_selection(true); // we need to invalidate the marker
+ remove_canvas_items();
text_items_.clear();
canvas_->set_size_request(alloc_width_ - 30,
@@ -302,6 +305,15 @@
model_->get_font_sizes(tags);
set_tags(tags);
+
+ if (selection_string_.size()) {
+ list<shared_ptr<TagItem> >::iterator it(text_items_.begin());
+ list<shared_ptr<TagItem> >::iterator end(text_items_.end());
+
+ for ( ; it != end; ++it)
+ if ((*it)->get_tag() == selection_string_)
+ update_marker(it->get());
+ }
}
void
@@ -319,15 +331,22 @@
}
selection_ = new_selection;
+ selection_string_ = selection_->get_tag();
}
+/// Set keep_old_selection to true to keep the selection_string_ variable
+/// unchanged - useful when we need to redraw a selection marker around a tag
+/// which had been selected before the cloud redraw.
void
-TagCloud::reset_selection()
+TagCloud::reset_selection(bool keep_old_selection)
{
if (! selection_) return;
selection_->marker_off();
selection_ = 0;
+
+ if (! keep_old_selection)
+ selection_string_ = "";
}
// Finds a TagItem by string and causes its' rectangle marker to be drawn.
@@ -343,6 +362,7 @@
if ((*item_it)->get_tag() == tag) {
(*item_it)->marker_on();
selection_ = item_it->get();
+ selection_string_ = tag;
break;
}
}
Modified: trunk/src/tag-cloud.hh
==============================================================================
--- trunk/src/tag-cloud.hh (original)
+++ trunk/src/tag-cloud.hh Sat Mar 15 17:59:05 2008
@@ -66,13 +66,15 @@
void update_marker(TagItem* new_selection);
- void reset_selection();
+ void reset_selection(bool keep_old_selection = false);
void select_tag(const Glib::ustring& tag);
protected:
virtual void on_size_allocate(Gdk::Rectangle& allocation);
+ virtual void remove_canvas_items();
+
virtual void redraw_tags();
virtual void on_model_changed();
@@ -85,6 +87,7 @@
std::list<boost::shared_ptr<TagItem> > text_items_;
boost::shared_ptr<TagCloudModel> model_;
TagItem* selection_;
+ Glib::ustring selection_string_;
GRand* grand_;
bool randomize_borders_;
Modified: trunk/src/tag-item.cc
==============================================================================
--- trunk/src/tag-item.cc (original)
+++ trunk/src/tag-item.cc Sat Mar 15 17:59:05 2008
@@ -52,6 +52,7 @@
void
TagItem::marker_off()
{
+ if (! rect_marker_) return;
g_object_set (rect_marker_,
"visibility", GOO_CANVAS_ITEM_INVISIBLE,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]