summaryrefslogtreecommitdiffstats
path: root/src/sp-guide.cpp
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc@jeanmougin.fr>2015-12-05 11:33:26 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2015-12-05 11:33:26 +0000
commit151733327589217e84c5ac7006b9076f428c53a0 (patch)
tree795008ca0e01c65760a1dea3258c5d0ae89522ed /src/sp-guide.cpp
parentadded comment + simpler rounding (diff)
downloadinkscape-151733327589217e84c5ac7006b9076f428c53a0.tar.gz
inkscape-151733327589217e84c5ac7006b9076f428c53a0.zip
cppification: GSList replaced by vectors (mostly related to guides and grids)
(bzr r14504.1.1)
Diffstat (limited to 'src/sp-guide.cpp')
-rw-r--r--src/sp-guide.cpp56
1 files changed, 27 insertions, 29 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index bbdf5f260..06eaee001 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -51,7 +51,6 @@ using std::vector;
SPGuide::SPGuide()
: SPObject()
, label(NULL)
- , views(NULL)
, normal_to_line(Geom::Point(0.,1.))
, point_on_line(Geom::Point(0.,0.))
, color(0x0000ff7f)
@@ -62,8 +61,8 @@ void SPGuide::setColor(guint32 c)
{
color = c;
- for (GSList *l = this->views; l != NULL; l = l->next) {
- sp_guideline_set_color(SP_GUIDELINE(l->data), this->color);
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ sp_guideline_set_color(*it, this->color);
}
}
@@ -82,10 +81,10 @@ void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr)
void SPGuide::release()
{
- while (this->views) {
- sp_guideline_delete(SP_GUIDELINE(this->views->data));
- this->views = g_slist_remove(this->views, this->views->data);
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ sp_guideline_delete(*it);
}
+ this->views.clear();
if (this->document) {
// Unregister ourselves
@@ -272,14 +271,14 @@ void SPGuide::showSPGuide(SPCanvasGroup *group, GCallback handler)
g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this);
- views = g_slist_prepend(views, item);
+ views.push_back(SP_GUIDELINE(item));
}
void SPGuide::showSPGuide()
{
- for (GSList *v = views; v != NULL; v = v->next) {
- sp_canvas_item_show(SP_CANVAS_ITEM(v->data));
- sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin));
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ sp_canvas_item_show(SP_CANVAS_ITEM(*it));
+ sp_canvas_item_show(SP_CANVAS_ITEM((*it)->origin));
}
}
@@ -287,11 +286,10 @@ void SPGuide::hideSPGuide(SPCanvas *canvas)
{
g_assert(canvas != NULL);
g_assert(SP_IS_CANVAS(canvas));
-
- for (GSList *l = views; l != NULL; l = l->next) {
- if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
- sp_guideline_delete(SP_GUIDELINE(l->data));
- views = g_slist_remove(views, l->data);
+ for(std::vector<SPGuideLine *>::iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ if (canvas == SP_CANVAS_ITEM(*it)->canvas) {
+ sp_guideline_delete(*it);
+ views.erase(it);
return;
}
}
@@ -301,9 +299,9 @@ void SPGuide::hideSPGuide(SPCanvas *canvas)
void SPGuide::hideSPGuide()
{
- for (GSList *v = views; v != NULL; v = v->next) {
- sp_canvas_item_hide(SP_CANVAS_ITEM(v->data));
- sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin));
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ sp_canvas_item_hide(SP_CANVAS_ITEM(*it));
+ sp_canvas_item_hide(SP_CANVAS_ITEM((*it)->origin));
}
}
@@ -312,9 +310,9 @@ void SPGuide::sensitize(SPCanvas *canvas, bool sensitive)
g_assert(canvas != NULL);
g_assert(SP_IS_CANVAS(canvas));
- for (GSList *l = views; l != NULL; l = l->next) {
- if (canvas == SP_CANVAS_ITEM(l->data)->canvas) {
- sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive);
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ if (canvas == SP_CANVAS_ITEM(*it)->canvas) {
+ sp_guideline_set_sensitive(*it, sensitive);
return;
}
}
@@ -339,8 +337,8 @@ double SPGuide::getDistanceFrom(Geom::Point const &pt) const
*/
void SPGuide::moveto(Geom::Point const point_on_line, bool const commit)
{
- for (GSList *l = views; l != NULL; l = l->next) {
- sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line);
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ sp_guideline_set_position(*it, point_on_line);
}
/* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit
@@ -385,8 +383,8 @@ void SPGuide::moveto(Geom::Point const point_on_line, bool const commit)
*/
void SPGuide::set_normal(Geom::Point const normal_to_line, bool const commit)
{
- for (GSList *l = this->views; l != NULL; l = l->next) {
- sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line);
+ for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) {
+ sp_guideline_set_normal(*it, normal_to_line);
}
/* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit
@@ -411,8 +409,8 @@ void SPGuide::set_color(const unsigned r, const unsigned g, const unsigned b, bo
{
this->color = (r << 24) | (g << 16) | (b << 8) | 0x7f;
- if (views) {
- sp_guideline_set_color(SP_GUIDELINE(views->data), this->color);
+ if (! views.empty()) {
+ sp_guideline_set_color(views[0], this->color);
}
if (commit) {
@@ -425,8 +423,8 @@ void SPGuide::set_color(const unsigned r, const unsigned g, const unsigned b, bo
void SPGuide::set_label(const char* label, bool const commit)
{
- if (views) {
- sp_guideline_set_label(SP_GUIDELINE(views->data), label);
+ if (!views.empty()) {
+ sp_guideline_set_label(views[0], label);
}
if (commit) {