diff options
Diffstat (limited to 'src/ui/tools/freehand-base.cpp')
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 32f2bdde1..064a83a5a 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -81,13 +81,10 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape) , red_curve(NULL) , blue_bpath(NULL) , blue_curve(NULL) - , green_bpaths(NULL) , green_curve(NULL) , green_anchor(NULL) , green_closed(false) , white_item(NULL) - , white_curves(NULL) - , white_anchors(NULL) , overwrite_curve(NULL) , sa(NULL) , ea(NULL) @@ -178,7 +175,7 @@ bool FreehandBase::root_handler(GdkEvent* event) { switch (event->type) { case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_KP_Up: @@ -619,22 +616,20 @@ static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/ SPCurve *norm = SP_PATH(item)->get_curve_for_edit(); norm->transform((dc->white_item)->i2dt_affine()); g_return_if_fail( norm != NULL ); - dc->white_curves = g_slist_reverse(norm->split()); + dc->white_curves = norm->split(); norm->unref(); // Anchor list - for (GSList *l = dc->white_curves; l != NULL; l = l->next) { - SPCurve *c; - c = static_cast<SPCurve*>(l->data); + for (auto c:dc->white_curves) { g_return_if_fail( c->get_segment_count() > 0 ); if ( !c->is_closed() ) { SPDrawAnchor *a; a = sp_draw_anchor_new(dc, c, TRUE, *(c->first_point())); if (a) - dc->white_anchors = g_slist_prepend(dc->white_anchors, a); + dc->white_anchors.push_back(a); a = sp_draw_anchor_new(dc, c, FALSE, *(c->last_point())); if (a) - dc->white_anchors = g_slist_prepend(dc->white_anchors, a); + dc->white_anchors.push_back(a); } } // fixme: recalculate active anchor? @@ -706,10 +701,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Green dc->green_curve = new SPCurve(); - while (dc->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); - dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data); - } + for (auto i : dc->green_bpaths) + sp_canvas_item_destroy(i); + dc->green_bpaths.clear(); // Blue c->append_continuous(dc->blue_curve, 0.0625); @@ -759,8 +753,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->unref(); dc->overwrite_curve->closepath_current(); if(dc->sa){ - dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); - dc->white_curves = g_slist_append(dc->white_curves, dc->overwrite_curve); + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve)); + dc->white_curves.push_back(dc->overwrite_curve); } }else{ dc->sa->curve->append_continuous(c, 0.0625); @@ -774,7 +768,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) // Step C - test start if (dc->sa) { SPCurve *s = dc->sa->curve; - dc->white_curves = g_slist_remove(dc->white_curves, s); + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), s)); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ s = dc->overwrite_curve; @@ -787,7 +781,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c = s; } else /* Step D - test end */ if (dc->ea) { SPCurve *e = dc->ea->curve; - dc->white_curves = g_slist_remove(dc->white_curves, e); + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), e)); if (!dc->ea->start) { e = reverse_then_unref(e); } @@ -827,11 +821,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) { SPCurve *c; - if (dc->white_curves) { + if (! dc->white_curves.empty()) { g_assert(dc->white_item); c = SPCurve::concat(dc->white_curves); - g_slist_free(dc->white_curves); - dc->white_curves = NULL; + dc->white_curves.clear(); if (gc) { c->append(gc, FALSE); } @@ -883,7 +876,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) Inkscape::GC::release(repr); item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); - item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + item->doWriteTransform(item->transform, NULL, true); spdc_check_for_and_apply_waiting_LPE(dc, item, c, false); dc->selection->set(repr); if(previous_shape_type == BEND_CLIPBOARD){ @@ -917,8 +910,8 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) active = sp_draw_anchor_test(dc->green_anchor, p, TRUE); } - for (GSList *l = dc->white_anchors; l != NULL; l = l->next) { - SPDrawAnchor *na = sp_draw_anchor_test(static_cast<SPDrawAnchor*>(l->data), p, !active); + for (auto i:dc->white_anchors) { + SPDrawAnchor *na = sp_draw_anchor_test(i, p, !active); if ( !active && na ) { active = na; } @@ -932,14 +925,12 @@ static void spdc_reset_white(FreehandBase *dc) // We do not hold refcount dc->white_item = NULL; } - while (dc->white_curves) { - reinterpret_cast<SPCurve *>(dc->white_curves->data)->unref(); - dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data); - } - while (dc->white_anchors) { - sp_draw_anchor_destroy(static_cast<SPDrawAnchor*>(dc->white_anchors->data)); - dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data); - } + for (auto i: dc->white_curves) + i->unref(); + dc->white_curves.clear(); + for (auto i:dc->white_anchors) + sp_draw_anchor_destroy(i); + dc->white_anchors.clear(); } static void spdc_free_colors(FreehandBase *dc) @@ -963,10 +954,9 @@ static void spdc_free_colors(FreehandBase *dc) } // Green - while (dc->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); - dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data); - } + for (auto i : dc->green_bpaths) + sp_canvas_item_destroy(i); + dc->green_bpaths.clear(); if (dc->green_curve) { dc->green_curve = dc->green_curve->unref(); } @@ -979,14 +969,12 @@ static void spdc_free_colors(FreehandBase *dc) // We do not hold refcount dc->white_item = NULL; } - while (dc->white_curves) { - reinterpret_cast<SPCurve *>(dc->white_curves->data)->unref(); - dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data); - } - while (dc->white_anchors) { - sp_draw_anchor_destroy(static_cast<SPDrawAnchor *>(dc->white_anchors->data)); - dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data); - } + for (auto i: dc->white_curves) + i->unref(); + dc->white_curves.clear(); + for (auto i:dc->white_anchors) + sp_draw_anchor_destroy(i); + dc->white_anchors.clear(); } void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) { |
