X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fshape-editor.cpp;h=d7cafaed2ab12864d502e2e2f3a7c58d8f26593c;hb=c4b828ca1807524249c2793e18be249cf2a7660d;hp=32c20ace698a6fd1f751b71207563ed266b5f5d7;hpb=6bd282f1511dc25162bbc6c63f42aa218f40ef17;p=inkscape.git diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index 32c20ace6..d7cafaed2 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -22,10 +22,10 @@ #include "desktop.h" #include "desktop-handles.h" #include "knotholder.h" -#include "live_effects/parameter/pointparam-knotholder.h" +#include "live_effects/parameter/point.h" #include "nodepath.h" #include "xml/node-event-vector.h" -#include "prefs-utils.h" +#include "preferences.h" #include "object-edit.h" #include "style.h" #include "display/curve.h" @@ -75,7 +75,7 @@ void ShapeEditor::unset_item(SubType type, bool keep_knotholder) { } this->grab_node = -1; - sp_nodepath_destroy(this->nodepath); + delete this->nodepath; this->nodepath = NULL; } break; @@ -241,7 +241,8 @@ void ShapeEditor::set_item(SPItem *item, SubType type, bool keep_knotholder) { switch(type) { case SH_NODEPATH: if (SP_IS_LPE_ITEM(item)) { - this->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + this->nodepath = sp_nodepath_new(desktop, item, (prefs->getBool("/tools/nodes/show_handles", true))); } if (this->nodepath) { this->nodepath->shape_editor = this; @@ -286,8 +287,9 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, this->grab_node = -1; if (lpeobject) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); this->nodepath = sp_nodepath_new( desktop, lpeobject, - (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0), + (prefs->getInt("/tools/nodes/show_handles", true)), key, item); if (this->nodepath) { this->nodepath->shape_editor = this; @@ -354,7 +356,7 @@ void ShapeEditor::update_statusbar () { sp_nodepath_update_statusbar(this->nodepath); } -bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) { +bool ShapeEditor::is_over_stroke (Geom::Point event_p, bool remember) { if (!this->nodepath) return false; // no stroke in knotholder @@ -372,19 +374,20 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) { return false; } - NR::Point nearest = pathv[pvpos->path_nr].pointAt(pvpos->t); - NR::Point delta = nearest - this->curvepoint_doc; + Geom::Point nearest = pathv[pvpos->path_nr].pointAt(pvpos->t); + Geom::Point delta = nearest - this->curvepoint_doc; delta = desktop->d2w(delta); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double stroke_tolerance = (( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 * - NR::expansion(sp_item_i2d_affine(item)) + to_2geom(sp_item_i2d_affine(item)).descrim() : 0.0) - + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item)); - bool close = (NR::L2 (delta) < stroke_tolerance); + + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100)) / to_2geom(sp_item_i2d_affine(item)).descrim(); + bool close = (Geom::L2 (delta) < stroke_tolerance); if (remember && close) { // calculate index for nodepath's representation. @@ -397,8 +400,8 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) { segment_index += 1; } - this->curvepoint_event[NR::X] = (gint) event_p [NR::X]; - this->curvepoint_event[NR::Y] = (gint) event_p [NR::Y]; + this->curvepoint_event[Geom::X] = (gint) event_p [Geom::X]; + this->curvepoint_event[Geom::Y] = (gint) event_p [Geom::Y]; this->hit = true; this->grab_t = t; this->grab_node = segment_index; @@ -450,17 +453,17 @@ void ShapeEditor::curve_drag(gdouble eventx, gdouble eventy) { // The coordinates hasn't changed since the last motion event, abort - if (this->curvepoint_event[NR::X] == x && - this->curvepoint_event[NR::Y] == y) + if (this->curvepoint_event[Geom::X] == x && + this->curvepoint_event[Geom::Y] == y) return; - NR::Point const delta_w(eventx - this->curvepoint_event[NR::X], - eventy - this->curvepoint_event[NR::Y]); - NR::Point const delta_dt(this->desktop->w2d(delta_w)); + Geom::Point const delta_w(eventx - this->curvepoint_event[Geom::X], + eventy - this->curvepoint_event[Geom::Y]); + Geom::Point const delta_dt(this->desktop->w2d(delta_w)); sp_nodepath_curve_drag (this->nodepath, this->grab_node, this->grab_t, delta_dt); - this->curvepoint_event[NR::X] = x; - this->curvepoint_event[NR::Y] = y; + this->curvepoint_event[Geom::X] = x; + this->curvepoint_event[Geom::Y] = y; } if (this->knotholder) { @@ -475,7 +478,7 @@ void ShapeEditor::finish_drag() { } } -void ShapeEditor::select_rect(NR::Rect const &rect, bool add) { +void ShapeEditor::select_rect(Geom::Rect const &rect, bool add) { if (this->nodepath) { sp_nodepath_select_rect(this->nodepath, rect, add); } @@ -565,7 +568,7 @@ void ShapeEditor::select_next () { if (this->nodepath) { sp_nodepath_select_next (this->nodepath); if (this->nodepath->numSelected() >= 1) { - this->desktop->scroll_to_point(&(this->nodepath->singleSelectedCoords()), 1.0); + this->desktop->scroll_to_point(this->nodepath->singleSelectedCoords(), 1.0); } } } @@ -573,7 +576,7 @@ void ShapeEditor::select_prev () { if (this->nodepath) { sp_nodepath_select_prev (this->nodepath); if (this->nodepath->numSelected() >= 1) { - this->desktop->scroll_to_point(&(this->nodepath->singleSelectedCoords()), 1.0); + this->desktop->scroll_to_point(this->nodepath->singleSelectedCoords(), 1.0); } } } @@ -588,16 +591,16 @@ void ShapeEditor::show_helperpath (bool show) { sp_nodepath_show_helperpath (this->nodepath, show); } -void ShapeEditor::flip (NR::Dim2 axis, boost::optional center) { +void ShapeEditor::flip (Geom::Dim2 axis, boost::optional center) { if (this->nodepath) sp_nodepath_flip (this->nodepath, axis, center); } -void ShapeEditor::distribute (NR::Dim2 axis) { +void ShapeEditor::distribute (Geom::Dim2 axis) { if (this->nodepath) sp_nodepath_selected_distribute (this->nodepath, axis); } -void ShapeEditor::align (NR::Dim2 axis) { +void ShapeEditor::align (Geom::Dim2 axis) { if (this->nodepath) sp_nodepath_selected_align (this->nodepath, axis); }