From 3103b99b4cf6c1048c89f75e280761d8cd0ca1c2 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 15 Apr 2017 00:20:13 +0200 Subject: Allow set and reset default values of LPE parameters (bzr r15620.1.1) --- src/live_effects/effect.cpp | 175 ++++++++---- src/live_effects/effect.h | 7 +- src/live_effects/lpe-bendpath.cpp | 8 +- src/live_effects/lpe-bounding-box.cpp | 4 +- src/live_effects/lpe-bspline.cpp | 16 ++ src/live_effects/lpe-clone-original.cpp | 15 + src/live_effects/lpe-constructgrid.cpp | 4 +- src/live_effects/lpe-copy_rotate.cpp | 15 + src/live_effects/lpe-curvestitch.cpp | 16 +- src/live_effects/lpe-dynastroke.cpp | 22 +- src/live_effects/lpe-envelope.cpp | 12 +- src/live_effects/lpe-extrude.cpp | 2 +- src/live_effects/lpe-fill-between-many.cpp | 10 +- src/live_effects/lpe-fill-between-strokes.cpp | 14 +- src/live_effects/lpe-fillet-chamfer.cpp | 16 +- src/live_effects/lpe-interpolate.cpp | 6 +- src/live_effects/lpe-knot.cpp | 12 +- src/live_effects/lpe-lattice.cpp | 32 +-- src/live_effects/lpe-lattice2.cpp | 17 +- src/live_effects/lpe-line_segment.cpp | 2 +- src/live_effects/lpe-measure-line.cpp | 167 +++++------ src/live_effects/lpe-measure-line.h | 1 - src/live_effects/lpe-mirror_symmetry.cpp | 15 + src/live_effects/lpe-offset.cpp | 2 +- src/live_effects/lpe-parallel.cpp | 6 +- src/live_effects/lpe-path_length.cpp | 8 +- src/live_effects/lpe-patternalongpath.cpp | 20 +- src/live_effects/lpe-perp_bisector.cpp | 4 +- src/live_effects/lpe-perspective-envelope.cpp | 15 + src/live_effects/lpe-perspective_path.cpp | 10 +- src/live_effects/lpe-powerstroke.cpp | 16 +- src/live_effects/lpe-recursiveskeleton.cpp | 2 +- src/live_effects/lpe-rough-hatches.cpp | 40 +-- src/live_effects/lpe-roughen.cpp | 15 + src/live_effects/lpe-ruler.cpp | 18 +- src/live_effects/lpe-simplify.cpp | 15 + src/live_effects/lpe-skeleton.cpp | 2 +- src/live_effects/lpe-sketch.cpp | 34 +-- src/live_effects/lpe-tangent_to_curve.cpp | 8 +- src/live_effects/lpe-test-doEffect-stack.cpp | 8 +- src/live_effects/lpe-text_label.cpp | 2 +- src/live_effects/lpe-transform_2pts.cpp | 15 + src/live_effects/lpe-vonkoch.cpp | 18 +- src/live_effects/parameter/array.h | 2 +- src/live_effects/parameter/bool.cpp | 8 +- src/live_effects/parameter/bool.h | 4 +- src/live_effects/parameter/enum.h | 10 +- .../parameter/filletchamferpointarray.h | 1 + src/live_effects/parameter/fontbutton.cpp | 11 +- src/live_effects/parameter/fontbutton.h | 6 +- src/live_effects/parameter/item.cpp | 4 + src/live_effects/parameter/item.h | 1 + src/live_effects/parameter/originalitem.h | 1 - src/live_effects/parameter/originalpatharray.h | 3 +- src/live_effects/parameter/parameter.cpp | 10 + src/live_effects/parameter/parameter.h | 4 +- src/live_effects/parameter/path.cpp | 4 + src/live_effects/parameter/path.h | 1 + src/live_effects/parameter/point.cpp | 15 +- src/live_effects/parameter/point.h | 4 +- src/live_effects/parameter/powerstrokepointarray.h | 2 +- src/live_effects/parameter/random.cpp | 14 + src/live_effects/parameter/random.h | 4 +- src/live_effects/parameter/text.cpp | 6 +- src/live_effects/parameter/text.h | 6 +- src/live_effects/parameter/togglebutton.cpp | 12 + src/live_effects/parameter/togglebutton.h | 2 + src/live_effects/parameter/transformedpoint.cpp | 19 ++ src/live_effects/parameter/transformedpoint.h | 4 +- src/live_effects/parameter/unit.cpp | 4 +- src/live_effects/parameter/unit.h | 5 +- src/live_effects/parameter/vector.cpp | 19 ++ src/live_effects/parameter/vector.h | 3 +- src/preferences-skeleton.h | 310 +++++++++++++++++++++ 74 files changed, 980 insertions(+), 365 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 017947cda..23af55cb3 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -74,72 +74,73 @@ #include "xml/sp-css-attr.h" #include "live_effects/lpeobject.h" #include "display/curve.h" - +#include +#include namespace Inkscape { namespace LivePathEffect { - +const Glib::ustring DEFAULT_PREF_VALUE = "--default"; const Util::EnumData LPETypeData[] = { // {constant defined in effect-enum.h, N_("name of your effect"), "name of your effect in SVG"} #ifdef LPE_ENABLE_TEST_EFFECTS - {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, - {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, + {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, + {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, {CIRCLE_WITH_RADIUS, N_("Circle (by center and radius)"), "circle_with_radius"}, - {CIRCLE_3PTS, N_("Circle by 3 points"), "circle_3pts"}, - {DYNASTROKE, N_("Dynamic stroke"), "dynastroke"}, - {EXTRUDE, N_("Extrude"), "extrude"}, - {LATTICE, N_("Lattice Deformation"), "lattice"}, - {LINE_SEGMENT, N_("Line Segment"), "line_segment"}, - {OFFSET, N_("Offset"), "offset"}, - {PARALLEL, N_("Parallel"), "parallel"}, - {PATH_LENGTH, N_("Path length"), "path_length"}, - {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"}, - {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"}, - {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, - {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, - {TEXT_LABEL, N_("Text label"), "text_label"}, - {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, + {CIRCLE_3PTS, N_("Circle by 3 points"), "circle_3pts"}, + {DYNASTROKE, N_("Dynamic stroke"), "dynastroke"}, + {EXTRUDE, N_("Extrude"), "extrude"}, + {LATTICE, N_("Lattice Deformation"), "lattice"}, + {LINE_SEGMENT, N_("Line Segment"), "line_segment"}, + {OFFSET, N_("Offset"), "offset"}, + {PARALLEL, N_("Parallel"), "parallel"}, + {PATH_LENGTH, N_("Path length"), "path_length"}, + {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"}, + {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"}, + {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, + {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, + {TEXT_LABEL, N_("Text label"), "text_label"}, + {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, #endif /* 0.46 */ - {BEND_PATH, N_("Bend"), "bend_path"}, - {GEARS, N_("Gears"), "gears"}, - {PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG - {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"}, + {BEND_PATH, N_("Bend"), "bend_path"}, + {GEARS, N_("Gears"), "gears"}, + {PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG + {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"}, /* 0.47 */ - {VONKOCH, N_("VonKoch"), "vonkoch"}, - {KNOT, N_("Knot"), "knot"}, - {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"}, - {SPIRO, N_("Spiro spline"), "spiro"}, - {ENVELOPE, N_("Envelope Deformation"), "envelope"}, - {INTERPOLATE, N_("Interpolate Sub-Paths"), "interpolate"}, - {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, - {SKETCH, N_("Sketch"), "sketch"}, - {RULER, N_("Ruler"), "ruler"}, + {VONKOCH, N_("VonKoch"), "vonkoch"}, + {KNOT, N_("Knot"), "knot"}, + {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"}, + {SPIRO, N_("Spiro spline"), "spiro"}, + {ENVELOPE, N_("Envelope Deformation"), "envelope"}, + {INTERPOLATE, N_("Interpolate Sub-Paths"), "interpolate"}, + {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, + {SKETCH, N_("Sketch"), "sketch"}, + {RULER, N_("Ruler"), "ruler"}, /* 0.91 */ - {POWERSTROKE, N_("Power stroke"), "powerstroke"}, - {CLONE_ORIGINAL, N_("Clone original"), "clone_original"}, + {POWERSTROKE, N_("Power stroke"), "powerstroke"}, + {CLONE_ORIGINAL, N_("Clone original"), "clone_original"}, /* 0.92 */ - {SIMPLIFY, N_("Simplify"), "simplify"}, - {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, - {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, - {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, - {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, - {SHOW_HANDLES, N_("Show handles"), "show_handles"}, - {ROUGHEN, N_("Roughen"), "roughen"}, - {BSPLINE, N_("BSpline"), "bspline"}, - {JOIN_TYPE, N_("Join type"), "join_type"}, - {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, - {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, - {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, + {SIMPLIFY, N_("Simplify"), "simplify"}, + {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, + {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, //TODO:Wrong name with "-" + {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, + {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, + {SHOW_HANDLES, N_("Show handles"), "show_handles"}, + {ROUGHEN, N_("Roughen"), "roughen"}, + {BSPLINE, N_("BSpline"), "bspline"}, + {JOIN_TYPE, N_("Join type"), "join_type"}, + {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, + {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, + {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, /* Ponyscape -> Inkscape 0.92*/ - {ATTACH_PATH, N_("Attach path"), "attach_path"}, - {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, - {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"}, - {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, - {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, + {ATTACH_PATH, N_("Attach path"), "attach_path"}, + {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, + {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"}, + {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, + {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, /* 9.93 */ - {MEASURE_LINE, N_("Measure Line"), "measure-line"}, + {MEASURE_LINE, N_("Measure Line"), "measure_line"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -350,6 +351,7 @@ Effect::Effect(LivePathEffectObject *lpeobject) : apply_to_clippath_and_mask(false), _provides_knotholder_entities(false), oncanvasedit_it(0), + show_default_widgets(true), is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true), show_orig_path(false), erase_extra_objects(true), @@ -644,6 +646,7 @@ void Effect::readallParameters(Inkscape::XML::Node const* repr) { std::vector::iterator it = param_vector.begin(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); while (it != param_vector.end()) { Parameter * param = *it; const gchar * key = param->param_key.c_str(); @@ -654,10 +657,18 @@ Effect::readallParameters(Inkscape::XML::Node const* repr) g_warning("Effect::readallParameters - '%s' not accepted for %s", value, key); } } else { - // set default value - param->param_set_default(); + Glib::ustring prefs_path = (Glib::ustring)"/live_effects/" + + (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(prefs_path).isValid(); + //add to preferences-skeleton the parameters you want reseteable + if(valid && prefs->getString(prefs_path) != DEFAULT_PREF_VALUE){ + param->param_update_default(prefs->getString(prefs_path).c_str()); + } else { + param->param_set_default(); + } } - ++it; } } @@ -667,6 +678,7 @@ void Effect::setParameter(const gchar * key, const gchar * new_value) { Parameter * param = getParameter(key); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (param) { if (new_value) { bool accepted = param->param_readSVGValue(new_value); @@ -674,7 +686,6 @@ Effect::setParameter(const gchar * key, const gchar * new_value) g_warning("Effect::setParameter - '%s' not accepted for %s", new_value, key); } } else { - // set default value param->param_set_default(); } } @@ -773,6 +784,21 @@ Effect::newWidget() ++it; } upd_params = false; + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &Effect::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &Effect::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } @@ -866,6 +892,45 @@ Effect::resetDefaults(SPItem const* /*item*/) } } +void +Effect::setDefaultParams() +{ + std::vector::iterator it = param_vector.begin(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + while (it != param_vector.end()) { + Parameter * param = *it; + const gchar * key = param->param_key.c_str(); + Glib::ustring prefs_path = (Glib::ustring)"/live_effects/" + + (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(prefs_path).isValid(); + if (valid){ + prefs->setString(prefs_path, (Glib::ustring)param->param_getSVGValue()); + } + ++it; + } +} + +void +Effect::resetDefaultParams(){ + std::vector::iterator it = param_vector.begin(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + while (it != param_vector.end()) { + Parameter * param = *it; + const gchar * key = param->param_key.c_str(); + Glib::ustring prefs_path = (Glib::ustring)"/live_effects/" + + (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(prefs_path).isValid(); + if (valid){ + prefs->setString(prefs_path, DEFAULT_PREF_VALUE); + } + ++it; + } +} + void Effect::transform_multiply(Geom::Affine const& postmul, bool set) { diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index f5e41d50e..c509db387 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -136,6 +136,7 @@ public: bool upd_params; BoolParam is_visible; SPCurve * sp_curve; + Geom::PathVector pathvector_before_effect; protected: Effect(LivePathEffectObject *lpeobject); @@ -156,12 +157,14 @@ protected: virtual void addKnotHolderEntities(KnotHolder * /*knotholder*/, SPItem * /*item*/) {}; virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); - std::vector param_vector; + void setDefaultParams(); + void resetDefaultParams(); + bool _provides_knotholder_entities; int oncanvasedit_it; - + bool show_default_widgets; bool show_orig_path; // set this to true in derived effects to automatically have the original // path displayed as helperpath diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index b1e133292..363356cac 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -57,10 +57,10 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : scale_y_rel(_("W_idth in units of length"), _("Scale the width of the path in units of its length"), "scale_y_rel", &wr, this, false), vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false) { - registerParameter( dynamic_cast(&bend_path) ); - registerParameter( dynamic_cast(&prop_scale) ); - registerParameter( dynamic_cast(&scale_y_rel) ); - registerParameter( dynamic_cast(&vertical_pattern) ); + registerParameter( &bend_path ); + registerParameter( &prop_scale); + registerParameter( &scale_y_rel); + registerParameter( &vertical_pattern); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); diff --git a/src/live_effects/lpe-bounding-box.cpp b/src/live_effects/lpe-bounding-box.cpp index 11fb34e04..c83d7e3bc 100644 --- a/src/live_effects/lpe-bounding-box.cpp +++ b/src/live_effects/lpe-bounding-box.cpp @@ -20,8 +20,8 @@ LPEBoundingBox::LPEBoundingBox(LivePathEffectObject *lpeobject) : linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this), visual_bounds(_("Visual Bounds"), _("Uses the visual bounding box"), "visualbounds", &wr, this) { - registerParameter( dynamic_cast(&linked_path) ); - registerParameter( dynamic_cast(&visual_bounds) ); + registerParameter(&linked_path); + registerParameter(&visual_bounds); //perceived_path = true; } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 1423e670a..fb803b770 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -139,6 +139,22 @@ Gtk::Widget *LPEBSpline::newWidget() ++it; } + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEBSpline::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEBSpline::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index c41b1ef95..74f93eddc 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -323,6 +323,21 @@ LPECloneOriginal::newWidget() expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPECloneOriginal::onExpanderChanged) ); vbox->pack_start(*expander, true, true, 2); + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECloneOriginal::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECloneOriginal::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } this->upd_params = false; return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp index 8d24f9f47..db620fa95 100644 --- a/src/live_effects/lpe-constructgrid.cpp +++ b/src/live_effects/lpe-constructgrid.cpp @@ -24,8 +24,8 @@ LPEConstructGrid::LPEConstructGrid(LivePathEffectObject *lpeobject) : nr_x(_("Size _X:"), _("The size of the grid in X direction."), "nr_x", &wr, this, 5), nr_y(_("Size _Y:"), _("The size of the grid in Y direction."), "nr_y", &wr, this, 5) { - registerParameter( dynamic_cast(&nr_x) ); - registerParameter( dynamic_cast(&nr_y) ); + registerParameter(&nr_x); + registerParameter(&nr_y); nr_x.param_make_integer(); nr_y.param_make_integer(); diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index bf82b5deb..a462c76a6 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -332,6 +332,21 @@ Gtk::Widget * LPECopyRotate::newWidget() ++it; } + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECopyRotate::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECopyRotate::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index f2fc00aeb..f8d2e56ca 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -40,14 +40,14 @@ LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : prop_scale(_("Scale _width:"), _("Scale the width of the stitch path"), "prop_scale", &wr, this, 1), scale_y_rel(_("Scale _width relative to length"), _("Scale the width of the stitch path relative to its length"), "scale_y_rel", &wr, this, false) { - registerParameter( dynamic_cast(&nrofpaths) ); - registerParameter( dynamic_cast(&startpoint_edge_variation) ); - registerParameter( dynamic_cast(&startpoint_spacing_variation) ); - registerParameter( dynamic_cast(&endpoint_edge_variation) ); - registerParameter( dynamic_cast(&endpoint_spacing_variation) ); - registerParameter( dynamic_cast(&strokepath) ); - registerParameter( dynamic_cast(&prop_scale) ); - registerParameter( dynamic_cast(&scale_y_rel) ); + registerParameter(&nrofpaths); + registerParameter(&startpoint_edge_variation); + registerParameter(&startpoint_spacing_variation); + registerParameter(&endpoint_edge_variation); + registerParameter(&endpoint_spacing_variation); + registerParameter(&strokepath ); + registerParameter(&prop_scale); + registerParameter(&scale_y_rel); nrofpaths.param_make_integer(); nrofpaths.param_set_range(2, Geom::infinity()); diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 50bbe6451..33e754a8a 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -55,17 +55,17 @@ LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : capping(_("Capping:"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") { - registerParameter( dynamic_cast(& method) ); - registerParameter( dynamic_cast(& width) ); - registerParameter( dynamic_cast(& roundness) ); - registerParameter( dynamic_cast(& angle) ); - //registerParameter( dynamic_cast(& modulo_pi) ); - registerParameter( dynamic_cast(& start_cap) ); - registerParameter( dynamic_cast(& growfor) ); - registerParameter( dynamic_cast(& end_cap) ); - registerParameter( dynamic_cast(& fadefor) ); - registerParameter( dynamic_cast(& round_ends) ); - registerParameter( dynamic_cast(& capping) ); + registerParameter(&method); + registerParameter(&width); + registerParameter(&roundness); + registerParameter(&angle); + //registerParameter(&modulo_pi) ); + registerParameter(&start_cap); + registerParameter(&growfor); + registerParameter(&end_cap); + registerParameter(&fadefor); + registerParameter(&round_ends); + registerParameter(&capping); width.param_set_range(0, Geom::infinity()); roundness.param_set_range(0.01, 1); diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 61a696435..8528ab14d 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -23,12 +23,12 @@ LPEEnvelope::LPEEnvelope(LivePathEffectObject *lpeobject) : xx(_("_Enable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true), yy(_("_Enable top & bottom paths"), _("Enable the top and bottom deformation paths"), "yy", &wr, this, true) { - registerParameter( dynamic_cast(&yy) ); - registerParameter( dynamic_cast(&xx) ); - registerParameter( dynamic_cast(&bend_path1) ); - registerParameter( dynamic_cast(&bend_path2) ); - registerParameter( dynamic_cast(&bend_path3) ); - registerParameter( dynamic_cast(&bend_path4) ); + registerParameter(&yy); + registerParameter(&xx); + registerParameter(&bend_path1); + registerParameter(&bend_path2); + registerParameter(&bend_path3); + registerParameter(&bend_path4); concatenate_before_pwd2 = true; apply_to_clippath_and_mask = true; } diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index daa30d45a..4a3ad7508 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -27,7 +27,7 @@ LPEExtrude::LPEExtrude(LivePathEffectObject *lpeobject) : show_orig_path = true; concatenate_before_pwd2 = false; - registerParameter( dynamic_cast(&extrude_vector) ); + registerParameter(&extrude_vector); } LPEExtrude::~LPEExtrude() diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 2e1fe0dc1..40fa91c68 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -25,11 +25,11 @@ LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) : join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true), close(_("Close"), _("Close path"), "close", &wr, this, true) { - registerParameter( dynamic_cast(&linked_paths) ); - registerParameter( dynamic_cast(&fuse) ); - registerParameter( dynamic_cast(&allow_transforms) ); - registerParameter( dynamic_cast(&join) ); - registerParameter( dynamic_cast(&close) ); + registerParameter(&linked_paths); + registerParameter(&fuse); + registerParameter(&allow_transforms); + registerParameter(&join); + registerParameter(&close); transformmultiply = false; } diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp index 43fef4288..f8d86ae99 100644 --- a/src/live_effects/lpe-fill-between-strokes.cpp +++ b/src/live_effects/lpe-fill-between-strokes.cpp @@ -25,13 +25,13 @@ LPEFillBetweenStrokes::LPEFillBetweenStrokes(LivePathEffectObject *lpeobject) : join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true), close(_("Close"), _("Close path"), "close", &wr, this, true) { - registerParameter( dynamic_cast(&linked_path) ); - registerParameter( dynamic_cast(&second_path) ); - registerParameter( dynamic_cast(&reverse_second) ); - registerParameter( dynamic_cast(&fuse) ); - registerParameter( dynamic_cast(&allow_transforms) ); - registerParameter( dynamic_cast(&join) ); - registerParameter( dynamic_cast(&close) ); + registerParameter(&linked_path); + registerParameter(&second_path); + registerParameter(&reverse_second); + registerParameter(&fuse); + registerParameter(&allow_transforms); + registerParameter(&join); + registerParameter(&close); transformmultiply = false; } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 1e2df7dc8..f21b53f90 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -176,7 +176,21 @@ Gtk::Widget *LPEFilletChamfer::newWidget() vbox->pack_start(*filletContainer, true, true, 2); vbox->pack_start(*chamferContainer, true, true, 2); - + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return vbox; } diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index e95dc5f38..db3faa307 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -30,9 +30,9 @@ LPEInterpolate::LPEInterpolate(LivePathEffectObject *lpeobject) : { show_orig_path = true; - registerParameter( dynamic_cast(&trajectory_path) ); - registerParameter( dynamic_cast(&equidistant_spacing) ); - registerParameter( dynamic_cast(&number_of_steps) ); + registerParameter(&trajectory_path); + registerParameter(&equidistant_spacing); + registerParameter(&number_of_steps); number_of_steps.param_make_integer(); number_of_steps.param_set_range(2, Geom::infinity()); diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 2defecb77..261612fdb 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -356,12 +356,12 @@ LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) : switcher(0.,0.) { // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( dynamic_cast(&interruption_width) ); - registerParameter( dynamic_cast(&prop_to_stroke_width) ); - registerParameter( dynamic_cast(&add_stroke_width) ); - registerParameter( dynamic_cast(&add_other_stroke_width) ); - registerParameter( dynamic_cast(&switcher_size) ); - registerParameter( dynamic_cast(&crossing_points_vector) ); + registerParameter(&interruption_width); + registerParameter(&prop_to_stroke_width); + registerParameter(&add_stroke_width); + registerParameter(&add_other_stroke_width); + registerParameter(&switcher_size); + registerParameter(&crossing_points_vector); _provides_knotholder_entities = true; } diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index acffed000..124a7a9c6 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -50,22 +50,22 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) : { // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( dynamic_cast(&grid_point0) ); - registerParameter( dynamic_cast(&grid_point1) ); - registerParameter( dynamic_cast(&grid_point2) ); - registerParameter( dynamic_cast(&grid_point3) ); - registerParameter( dynamic_cast(&grid_point4) ); - registerParameter( dynamic_cast(&grid_point5) ); - registerParameter( dynamic_cast(&grid_point6) ); - registerParameter( dynamic_cast(&grid_point7) ); - registerParameter( dynamic_cast(&grid_point8) ); - registerParameter( dynamic_cast(&grid_point9) ); - registerParameter( dynamic_cast(&grid_point10) ); - registerParameter( dynamic_cast(&grid_point11) ); - registerParameter( dynamic_cast(&grid_point12) ); - registerParameter( dynamic_cast(&grid_point13) ); - registerParameter( dynamic_cast(&grid_point14) ); - registerParameter( dynamic_cast(&grid_point15) ); + registerParameter(&grid_point0); + registerParameter(&grid_point1); + registerParameter(&grid_point2); + registerParameter(&grid_point3); + registerParameter(&grid_point4); + registerParameter(&grid_point5); + registerParameter(&grid_point6); + registerParameter(&grid_point7); + registerParameter(&grid_point8); + registerParameter(&grid_point9); + registerParameter(&grid_point10); + registerParameter(&grid_point11); + registerParameter(&grid_point12); + registerParameter(&grid_point13); + registerParameter(&grid_point14); + registerParameter(&grid_point15); apply_to_clippath_and_mask = true; } diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index e827491c0..fe01ef9ee 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -256,12 +256,27 @@ LPELattice2::newWidget() ++it; } - + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPELattice2::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPELattice2::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show Points")))); expander->add(*vbox_expander); expander->set_expanded(expanded); vbox->pack_start(*expander, true, true, 2); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPELattice2::onExpanderChanged) ); + return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp index cc024fb92..fd23da804 100644 --- a/src/live_effects/lpe-line_segment.cpp +++ b/src/live_effects/lpe-line_segment.cpp @@ -32,7 +32,7 @@ LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) : end_type(_("End type:"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH) { /* register all your parameters here, so Inkscape knows which parameters this effect has: */ - registerParameter( dynamic_cast(&end_type) ); + registerParameter(&end_type); } LPELineSegment::~LPELineSegment() diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index 86d72615c..1095cfc0d 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -49,32 +49,33 @@ static const Util::EnumDataConverter OMConverter(OrientationM LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : Effect(lpeobject), - unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"), - fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this), + unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"), + fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this), orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false), curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1), - precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2), - position(_("Position*"), _("Position"), "position", &wr, this, 5), - text_top_bottom(_("Text top/bottom*"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), - text_right_left(_("Text right/left*"), _("Text right/left"), "text_right_left", &wr, this, 0), - helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), - helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), - scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0), - format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), + precision(_("Precision"), _("Precision"), "precision", &wr, this, 2), + position(_("Position"), _("Position"), "position", &wr, this, 5), + text_top_bottom(_("Text top/bottom"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), + text_right_left(_("Text right/left"), _("Text right/left"), "text_right_left", &wr, this, 0), + helpline_distance(_("Helpline distance"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), + helpline_overlap(_("Helpline overlap"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), + scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0), + format(_("Format"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), id_origin("id_origin", "id_origin", "id_origin", &wr, this,""), arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false), - flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false), - scale_sensitive(_("Scale sensitive*"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), - local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true), - line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), - rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), - hide_back(_("Hide if label over*"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), - dimline_format(_("CSS DIN line*"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), - helperlines_format(_("CSS helpers*"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), - anotation_format(_("CSS anotation*"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), - arrows_format(_("CSS arrows*"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), + flip_side(_("Flip side"), _("Flip side"), "flip_side", &wr, this, false), + scale_sensitive(_("Scale sensitive"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), + local_locale(_("Local Number Format"), _("Local number format"), "local_locale", &wr, this, true), + line_group_05(_("Line Group 0.5"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), + rotate_anotation(_("Rotate Anotation"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), + hide_back(_("Hide if label over"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), + dimline_format(_("CSS DIN line"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), + helperlines_format(_("CSS helpers"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), + anotation_format(_("CSS anotation"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), + arrows_format(_("CSS arrows"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), expanded(false) { + //set to true the parameters you want to be changed his default values registerParameter(&unit); registerParameter(&fontbutton); registerParameter(&orientation); @@ -99,39 +100,16 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : registerParameter(&anotation_format); registerParameter(&arrows_format); registerParameter(&id_origin); + id_origin.param_hide_canvas_text(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton"); - if(fontbutton_value.empty()){ - fontbutton_value = "Sans 10"; - } - fontbutton.param_update_default(fontbutton_value); - scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0)); - precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2)); - position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0)); - text_top_bottom.param_update_default(prefs->getDouble("/live_effects/measure-line/text_top_bottom", 5.0)); - helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0)); - helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0)); - Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit"); - if(unit_value.empty()){ - unit_value = "px"; - } - unit.param_update_default(unit_value); + Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format"); if(format_value.empty()){ format_value = "{measure}{unit}"; } - format.param_update_default(format_value); - dimline_format.param_update_default(prefs->getString("/live_effects/measure-line/dimline_format")); - helperlines_format.param_update_default(prefs->getString("/live_effects/measure-line/helperlines_format")); - anotation_format.param_update_default(prefs->getString("/live_effects/measure-line/anotation_format")); - arrows_format.param_update_default(prefs->getString("/live_effects/measure-line/arrows_format")); - flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side")); - scale_sensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_sensitive")); - local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale")); - line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05")); - rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation")); - hide_back.param_update_default(prefs->getBool("/live_effects/measure-line/hide_back")); + format.param_update_default(format_value.c_str()); + format.param_hide_canvas_text(); dimline_format.param_hide_canvas_text(); helperlines_format.param_hide_canvas_text(); @@ -375,7 +353,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl items.push_back(id); Geom::OptRect bounds = SP_ITEM(elemref)->bounds(SPItem::GEOMETRIC_BBOX); if (bounds) { - anotation_width = bounds->width() * 1.4; + anotation_width = bounds->width() * 1.15; } } @@ -405,8 +383,14 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, const char * id, b k = (Geom::distance(start,end)/2.0) - arrow_gap - (anotation_width/2.0); } if (Geom::distance(start,end) < anotation_width){ - return; + if ((elemref = document->getObjectById(id))) { + if (remove) { + elemref->deleteObject(); + } + return; + } } + //k = std::max(k , arrow_gap -1); Geom::Ray ray(end, start); Geom::Coord angle = ray.angle(); line_path.start(start); @@ -622,6 +606,9 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } bool overflow = false; const char * downline = g_strdup(Glib::ustring("downline-").append(this->getRepr()->attribute("id")).c_str()); + //delete residual lines if exist + createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); + //Create it if ((anotation_width/2) + std::abs(text_right_left) > Geom::distance(start,end)/2.0) { Geom::Point sstart = end - Point::polar(angle_cross, position); Geom::Point send = end - Point::polar(angle_cross, position); @@ -645,9 +632,6 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } overflow = true; createLine(sstart, prog_end, downline, true, overflow, false, false); - } else { - //erase it - createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); } //LINE arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str()); @@ -708,44 +692,56 @@ Gtk::Widget *LPEMeasureLine::newWidget() vbox->set_spacing(2); std::vector::iterator it = param_vector.begin(); - Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0)); Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); vbox_expander->set_border_width(0); vbox_expander->set_spacing(2); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; - Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - if (param->param_key != "dimline_format" && - param->param_key != "helperlines_format" && - param->param_key != "arrows_format" && - param->param_key != "anotation_format") { - vbox->pack_start(*widg, true, true, 2); - } else { - vbox_expander->pack_start(*widg, true, true, 2); - } - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); + if (param->param_key != "id_origin") { + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + if (param->param_key != "dimline_format" && + param->param_key != "helperlines_format" && + param->param_key != "arrows_format" && + param->param_key != "anotation_format") { + vbox->pack_start(*widg, true, true, 2); + } else { + vbox_expander->pack_start(*widg, true, true, 2); + } + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } } } } ++it; } - Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default")))); - save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault)); - button1->pack_start(*save_default, true, true, 2); expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override")))); expander->add(*vbox_expander); expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureLine::onExpanderChanged) ); vbox->pack_start(*expander, true, true, 2); - vbox->pack_start(*button1, true, true, 2); + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } @@ -766,31 +762,6 @@ LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in) return path_in; } -void -LPEMeasureLine::saveDefault() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString("/live_effects/measure-line/fontbutton", Glib::ustring(fontbutton.param_getSVGValue())); - prefs->setDouble("/live_effects/measure-line/scale", scale); - prefs->setInt("/live_effects/measure-line/precision", precision); - prefs->setDouble("/live_effects/measure-line/position", position); - prefs->setDouble("/live_effects/measure-line/text_top_bottom", text_top_bottom); - prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance); - prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap); - prefs->setString("/live_effects/measure-line/unit", Glib::ustring(unit.get_abbreviation())); - prefs->setString("/live_effects/measure-line/format", Glib::ustring(format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/dimline_format", Glib::ustring(dimline_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/helperlines_format", Glib::ustring(helperlines_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/anotation_format", Glib::ustring(anotation_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/arrows_format", Glib::ustring(arrows_format.param_getSVGValue())); - prefs->setBool("/live_effects/measure-line/flip_side", flip_side); - prefs->setBool("/live_effects/measure-line/scale_sensitive", scale_sensitive); - prefs->setBool("/live_effects/measure-line/local_locale", local_locale); - prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05); - prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation); - prefs->setBool("/live_effects/measure-line/hide_back", hide_back); -} - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h index 724c0d924..b42f7cfd5 100644 --- a/src/live_effects/lpe-measure-line.h +++ b/src/live_effects/lpe-measure-line.h @@ -49,7 +49,6 @@ public: void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove, bool valid); void onExpanderChanged(); void createArrowMarker(const char * mode); - void saveDefault(); virtual Gtk::Widget *newWidget(); private: UnitParam unit; diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 97015c34d..a00aac3be 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -336,6 +336,21 @@ LPEMirrorSymmetry::newWidget() ++it; } this->upd_params = false; + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameterss")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMirrorSymmetry::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMirrorSymmetry::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index 057f404e0..c853e4afa 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -27,7 +27,7 @@ LPEOffset::LPEOffset(LivePathEffectObject *lpeobject) : { show_orig_path = true; apply_to_clippath_and_mask = true; - registerParameter(dynamic_cast(&offset_pt)); + registerParameter(&offset_pt); } LPEOffset::~LPEOffset() diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 276749c43..271442c7d 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -51,9 +51,9 @@ LPEParallel::LPEParallel(LivePathEffectObject *lpeobject) : show_orig_path = true; _provides_knotholder_entities = true; - registerParameter(dynamic_cast(&offset_pt)); - registerParameter( dynamic_cast(&length_left) ); - registerParameter( dynamic_cast(&length_right) ); + registerParameter(&offset_pt); + registerParameter(&length_left); + registerParameter(&length_right); } LPEParallel::~LPEParallel() diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp index a06dbde98..61818a73b 100644 --- a/src/live_effects/lpe-path_length.cpp +++ b/src/live_effects/lpe-path_length.cpp @@ -26,10 +26,10 @@ LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) : unit(_("Unit:"), _("Unit"), "unit", &wr, this), display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true) { - registerParameter(dynamic_cast(&scale)); - registerParameter(dynamic_cast(&info_text)); - registerParameter(dynamic_cast(&unit)); - registerParameter(dynamic_cast(&display_unit)); + registerParameter(&scale); + registerParameter(&info_text); + registerParameter(&unit); + registerParameter(&display_unit); } LPEPathLength::~LPEPathLength() diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 966e9020e..b026bbc22 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -85,16 +85,16 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : fuse_tolerance(_("_Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), "fuse_tolerance", &wr, this, 0) { - registerParameter( dynamic_cast(&pattern) ); - registerParameter( dynamic_cast(©type) ); - registerParameter( dynamic_cast(&prop_scale) ); - registerParameter( dynamic_cast(&scale_y_rel) ); - registerParameter( dynamic_cast(&spacing) ); - registerParameter( dynamic_cast(&normal_offset) ); - registerParameter( dynamic_cast(&tang_offset) ); - registerParameter( dynamic_cast(&prop_units) ); - registerParameter( dynamic_cast(&vertical_pattern) ); - registerParameter( dynamic_cast(&fuse_tolerance) ); + registerParameter(&pattern); + registerParameter(©type); + registerParameter(&prop_scale); + registerParameter(&scale_y_rel); + registerParameter(&spacing); + registerParameter(&normal_offset); + registerParameter(&tang_offset); + registerParameter(&prop_units); + registerParameter(&vertical_pattern); + registerParameter(&fuse_tolerance); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index bce22250a..dab169cfe 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -99,8 +99,8 @@ LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) : _provides_knotholder_entities = true; // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( dynamic_cast(&length_left) ); - registerParameter( dynamic_cast(&length_right) ); + registerParameter(&length_left); + registerParameter(&length_right); } LPEPerpBisector::~LPEPerpBisector() diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index 365ff5389..e967a01aa 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -414,6 +414,21 @@ LPEPerspectiveEnvelope::newWidget() reset_button->set_size_request(140,30); vbox->pack_start(*hbox, true,true,2); hbox->pack_start(*reset_button, false, false,2); + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEPerspectiveEnvelope::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEPerspectiveEnvelope::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index b83fb67d7..435c91c2d 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -51,11 +51,11 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : uses_plane_xy(_("Uses XY plane?"), _("If true, put the path on the left side of an imaginary box, otherwise on the right side"), "uses_plane_xy", &wr, this, true) { // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( dynamic_cast(&scalex) ); - registerParameter( dynamic_cast(&scaley) ); - registerParameter( dynamic_cast(&offsetx) ); - registerParameter( dynamic_cast(&offsety) ); - registerParameter( dynamic_cast(&uses_plane_xy) ); + registerParameter( &scalex); + registerParameter( &scaley); + registerParameter( &offsetx); + registerParameter( &offsety); + registerParameter( &uses_plane_xy); concatenate_before_pwd2 = true; // don't split the path into its subpaths _provides_knotholder_entities = true; diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index e9f3975c7..d87f92fcc 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -179,14 +179,14 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : interpolator_beta.addSlider(true); interpolator_beta.param_set_range(0.,1.); - registerParameter( dynamic_cast(&offset_points) ); - registerParameter( dynamic_cast(&sort_points) ); - registerParameter( dynamic_cast(&interpolator_type) ); - registerParameter( dynamic_cast(&interpolator_beta) ); - registerParameter( dynamic_cast(&start_linecap_type) ); - registerParameter( dynamic_cast(&linejoin_type) ); - registerParameter( dynamic_cast(&miter_limit) ); - registerParameter( dynamic_cast(&end_linecap_type) ); + registerParameter(&offset_points); + registerParameter(&sort_points); + registerParameter(&interpolator_type); + registerParameter(&interpolator_beta); + registerParameter(&start_linecap_type); + registerParameter(&linejoin_type); + registerParameter(&miter_limit); + registerParameter(&end_linecap_type); } LPEPowerStroke::~LPEPowerStroke() diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index aa0db920b..47613f58e 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -28,7 +28,7 @@ LPERecursiveSkeleton::LPERecursiveSkeleton(LivePathEffectObject *lpeobject) : concatenate_before_pwd2 = true; iterations.param_make_integer(true); iterations.param_set_range(1, 15); - registerParameter( dynamic_cast(&iterations) ); + registerParameter(&iterations); } diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 3cc8658ea..d832b3615 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -241,26 +241,26 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : // bender(_("Global bending"), _("Relative position to a reference point defines global bending direction and amount"), "bender", &wr, this, Geom::Point(-5,0)) { - registerParameter( dynamic_cast(&direction) ); - registerParameter( dynamic_cast(&dist_rdm) ); - registerParameter( dynamic_cast(&growth) ); - registerParameter( dynamic_cast(&do_bend) ); - registerParameter( dynamic_cast(&bender) ); - registerParameter( dynamic_cast(&top_edge_variation) ); - registerParameter( dynamic_cast(&bot_edge_variation) ); - registerParameter( dynamic_cast(&top_tgt_variation) ); - registerParameter( dynamic_cast(&bot_tgt_variation) ); - registerParameter( dynamic_cast(&scale_tf) ); - registerParameter( dynamic_cast(&scale_tb) ); - registerParameter( dynamic_cast(&scale_bf) ); - registerParameter( dynamic_cast(&scale_bb) ); - registerParameter( dynamic_cast(&top_smth_variation) ); - registerParameter( dynamic_cast(&bot_smth_variation) ); - registerParameter( dynamic_cast(&fat_output) ); - registerParameter( dynamic_cast(&stroke_width_top) ); - registerParameter( dynamic_cast(&stroke_width_bot) ); - registerParameter( dynamic_cast(&front_thickness) ); - registerParameter( dynamic_cast(&back_thickness) ); + registerParameter(&direction); + registerParameter(&dist_rdm); + registerParameter(&growth); + registerParameter(&do_bend); + registerParameter(&bender); + registerParameter(&top_edge_variation); + registerParameter(&bot_edge_variation); + registerParameter(&top_tgt_variation); + registerParameter(&bot_tgt_variation); + registerParameter(&scale_tf); + registerParameter(&scale_tb); + registerParameter(&scale_bf); + registerParameter(&scale_bb); + registerParameter(&top_smth_variation); + registerParameter(&bot_smth_variation); + registerParameter(&fat_output); + registerParameter(&stroke_width_top); + registerParameter(&stroke_width_bot); + registerParameter(&front_thickness); + registerParameter(&back_thickness); //hatch_dist.param_set_range(0.1, Geom::infinity()); growth.param_set_range(0, Geom::infinity()); diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index e847494a2..8b2a07d59 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -163,6 +163,21 @@ Gtk::Widget *LPERoughen::newWidget() } ++it; } + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPERoughen::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPERoughen::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 60c2a3e1c..852592219 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -45,15 +45,15 @@ LPERuler::LPERuler(LivePathEffectObject *lpeobject) : offset(_("_Offset:"), _("Offset of first mark"), "offset", &wr, this, 0.0), border_marks(_("Border marks:"), _("Choose whether to draw marks at the beginning and end of the path"), "border_marks", BorderMarkTypeConverter, &wr, this, BORDERMARK_BOTH) { - registerParameter(dynamic_cast(&unit)); - registerParameter(dynamic_cast(&mark_distance)); - registerParameter(dynamic_cast(&mark_length)); - registerParameter(dynamic_cast(&minor_mark_length)); - registerParameter(dynamic_cast(&major_mark_steps)); - registerParameter(dynamic_cast(&shift)); - registerParameter(dynamic_cast(&offset)); - registerParameter(dynamic_cast(&mark_dir)); - registerParameter(dynamic_cast(&border_marks)); + registerParameter(&unit); + registerParameter(&mark_distance); + registerParameter(&mark_length); + registerParameter(&minor_mark_length); + registerParameter(&major_mark_steps); + registerParameter(&shift); + registerParameter(&offset); + registerParameter(&mark_dir); + registerParameter(&border_marks); major_mark_steps.param_make_integer(); major_mark_steps.param_set_range(1, 1000); diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 5de9816bb..5b5bbea6c 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -115,6 +115,21 @@ LPESimplify::newWidget() ++it; } vbox->pack_start(*buttons,true, true, 2); + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPESimplify::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPESimplify::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index 4fc18cee2..d3c94269a 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -37,7 +37,7 @@ LPESkeleton::LPESkeleton(LivePathEffectObject *lpeobject) : //_provides_knotholder_entities /* register all your parameters here, so Inkscape knows which parameters this effect has: */ - registerParameter( dynamic_cast(&number) ); + registerParameter(&number); } LPESkeleton::~LPESkeleton() diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e01516f2e..e3376b7e5 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -62,25 +62,25 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : // register all your parameters here, so Inkscape knows which parameters this effect has: //Add some comment in the UI: *warning* the precise output of this effect might change in future releases! //convert to path if you want to keep exact output unchanged in future releases... - //registerParameter( dynamic_cast(&testpointA) ); - registerParameter( dynamic_cast(&nbiter_approxstrokes) ); - registerParameter( dynamic_cast(&strokelength) ); - registerParameter( dynamic_cast(&strokelength_rdm) ); - registerParameter( dynamic_cast(&strokeoverlap) ); - registerParameter( dynamic_cast(&strokeoverlap_rdm) ); - registerParameter( dynamic_cast(&ends_tolerance) ); - registerParameter( dynamic_cast(¶llel_offset) ); - registerParameter( dynamic_cast(&tremble_size) ); - registerParameter( dynamic_cast(&tremble_frequency) ); + //registerParameter(&testpointA) ); + registerParameter(&nbiter_approxstrokes); + registerParameter(&strokelength); + registerParameter(&strokelength_rdm); + registerParameter(&strokeoverlap); + registerParameter(&strokeoverlap_rdm); + registerParameter(&ends_tolerance); + registerParameter(¶llel_offset); + registerParameter(&tremble_size); + registerParameter(&tremble_frequency); #ifdef LPE_SKETCH_USE_CONSTRUCTION_LINES - registerParameter( dynamic_cast(&nbtangents) ); - registerParameter( dynamic_cast(&tgt_places_rdmness) ); - registerParameter( dynamic_cast(&tgtscale) ); - registerParameter( dynamic_cast(&tgtlength) ); - registerParameter( dynamic_cast(&tgtlength_rdm) ); + registerParameter(&nbtangents); + registerParameter(&tgt_places_rdmness); + registerParameter(&tgtscale); + registerParameter(&tgtlength); + registerParameter(&tgtlength_rdm); #ifdef LPE_SKETCH_USE_CURVATURE - registerParameter( dynamic_cast(&min_curvature) ); - registerParameter( dynamic_cast(&max_curvature) ); + registerParameter(&min_curvature); + registerParameter(&max_curvature); #endif #endif diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 5f63e1ee9..69a4dfad9 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -60,10 +60,10 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) : show_orig_path = true; _provides_knotholder_entities = true; - registerParameter( dynamic_cast(&angle) ); - registerParameter( dynamic_cast(&t_attach) ); - registerParameter( dynamic_cast(&length_left) ); - registerParameter( dynamic_cast(&length_right) ); + registerParameter(&angle); + registerParameter(&t_attach); + registerParameter(&length_left); + registerParameter(&length_right); } LPETangentToCurve::~LPETangentToCurve() diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index 324893706..c484c88a2 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -21,12 +21,12 @@ LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) : point(_("Point param:"), "tooltip of point parameter", "point_param", &wr, this), path(_("Path param:"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0") { - registerParameter( dynamic_cast(&step) ); - registerParameter( dynamic_cast(&point) ); - registerParameter( dynamic_cast(&path) ); + registerParameter(&step); + registerParameter(&point); + registerParameter(&path); point.set_oncanvas_looks(SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR, 0x00ff0000); - point.param_setValue(point,true); + point.param_setValue(point); } LPEdoEffectStackTest::~LPEdoEffectStackTest() diff --git a/src/live_effects/lpe-text_label.cpp b/src/live_effects/lpe-text_label.cpp index 709d05e18..0c1db2f04 100644 --- a/src/live_effects/lpe-text_label.cpp +++ b/src/live_effects/lpe-text_label.cpp @@ -23,7 +23,7 @@ LPETextLabel::LPETextLabel(LivePathEffectObject *lpeobject) : Effect(lpeobject), label(_("Label:"), _("Text label attached to the path"), "label", &wr, this, "This is a label") { - registerParameter( dynamic_cast(&label) ); + registerParameter(&label); } LPETextLabel::~LPETextLabel() diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index ef2900775..e5bc8657d 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -350,6 +350,21 @@ Gtk::Widget *LPETransform2Pts::newWidget() vbox->pack_start(*button2, true, true, 2); vbox->pack_start(*button3, true, true, 2); vbox->pack_start(*button4, true, true, 2); + if (show_default_widgets) { + Gtk::Label *default_label = Gtk::manage(new Gtk::Label( + Glib::ustring(_("Defaults set defaultable parameters")), + Gtk::ALIGN_START)); + default_label->set_use_markup(true); + vbox->pack_start(*default_label, true, true, 2); + Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); + set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::setDefaultParams)); + Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::resetDefaultParams)); + defaultBox->pack_start(*set_default, true, true, 2); + defaultBox->pack_start(*reset_default, true, true, 2); + vbox->pack_start(*defaultBox, true, true, 2); + } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 47e2a1cec..b9fd8908a 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -53,15 +53,15 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) : maxComplexity(_("_Max complexity:"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000) { //FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug. - registerParameter( dynamic_cast(&ref_path) ); - //registerParameter( dynamic_cast(&refA) ); - //registerParameter( dynamic_cast(&refB) ); - registerParameter( dynamic_cast(&generator) ); - registerParameter( dynamic_cast(&similar_only) ); - registerParameter( dynamic_cast(&nbgenerations) ); - registerParameter( dynamic_cast(&drawall) ); - registerParameter( dynamic_cast(&maxComplexity) ); - //registerParameter( dynamic_cast(&draw_boxes) ); + registerParameter(&ref_path); + //registerParameter(&refA) ); + //registerParameter(&refB) ); + registerParameter(&generator); + registerParameter(&similar_only); + registerParameter(&nbgenerations); + registerParameter(&drawall); + registerParameter(&maxComplexity); + //registerParameter(&draw_boxes) ); apply_to_clippath_and_mask = true; nbgenerations.param_make_integer(); nbgenerations.param_set_range(0, Geom::infinity()); diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index a600f0257..fa08e1f91 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -59,7 +59,7 @@ public: g_strfreev (strarray); return true; } - + virtual void param_update_default(const gchar * default_value){}; virtual gchar * param_getSVGValue() const { Inkscape::SVGOStringStream os; writesvg(os, _vector); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 813c06b4e..cdc988ab2 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -37,11 +37,17 @@ BoolParam::param_set_default() } void -BoolParam::param_update_default(bool const default_value) +BoolParam::param_update_default(bool default_value) { defvalue = default_value; } +void +BoolParam::param_update_default(const gchar * default_value) +{ + param_update_default(helperfns_read_bool(default_value, defvalue)); +} + bool BoolParam::param_readSVGValue(const gchar * strvalue) { diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 7ad8a9368..a96966c46 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -36,9 +36,9 @@ public: void param_setValue(bool newvalue); virtual void param_set_default(); - void param_update_default(bool const default_value); + void param_update_default(bool default_value); + virtual void param_update_default(const gchar * default_value); bool get_value() const { return value; }; - inline operator bool() const { return value; }; private: diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index dbfc68623..0bb2d89b2 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -76,7 +76,15 @@ public: void param_set_default() { param_set_value(defvalue); } - + + void param_update_default(E default_value) { + defvalue = default_value; + } + + virtual void param_update_default(const gchar * default_value) { + param_update_default(enumdataconv->get_id_from_key(Glib::ustring(default_value))); + } + void param_set_value(E val) { value = val; } diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h index b81339a69..4e4268703 100644 --- a/src/live_effects/parameter/filletchamferpointarray.h +++ b/src/live_effects/parameter/filletchamferpointarray.h @@ -55,6 +55,7 @@ public: virtual void set_chamfer_steps(int value_chamfer_steps); virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); + virtual void param_update_default(const gchar * default_value){}; virtual bool providesKnotHolderEntities() const { return true; } diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp index 64c203093..53b8c0612 100644 --- a/src/live_effects/parameter/fontbutton.cpp +++ b/src/live_effects/parameter/fontbutton.cpp @@ -33,9 +33,11 @@ FontButtonParam::param_set_default() { param_setValue(defvalue); } + void -FontButtonParam::param_update_default(const Glib::ustring default_value){ - defvalue = default_value; +FontButtonParam::param_update_default(const gchar * default_value) +{ + defvalue = (Glib::ustring)strdup(default_value); } bool @@ -63,7 +65,7 @@ FontButtonParam::param_newWidget() *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - Glib::ustring fontspec = param_getSVGValue(); + Glib::ustring fontspec = (Glib::ustring)param_getSVGValue(); fontbuttonwdg->setValue( fontspec); fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter")); param_effect->upd_params = false; @@ -71,11 +73,12 @@ FontButtonParam::param_newWidget() } void -FontButtonParam::param_setValue(const Glib::ustring newvalue) +FontButtonParam::param_setValue(Glib::ustring newvalue) { value = newvalue; } + } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/fontbutton.h b/src/live_effects/parameter/fontbutton.h index df47251a2..60e1aa46e 100644 --- a/src/live_effects/parameter/fontbutton.h +++ b/src/live_effects/parameter/fontbutton.h @@ -21,15 +21,15 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const Glib::ustring default_value = ""); + const Glib::ustring default_value = "Sans 10"); virtual ~FontButtonParam() {} virtual Gtk::Widget * param_newWidget(); virtual bool param_readSVGValue(const gchar * strvalue); - void param_update_default(const Glib::ustring defvalue); + void param_update_default(const gchar * default_value); virtual gchar * param_getSVGValue() const; - void param_setValue(const Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue); virtual void param_set_default(); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 93cf2b15f..7b40f4540 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -60,6 +60,10 @@ ItemParam::param_set_default() param_readSVGValue(defvalue); } +void +ItemParam::param_update_default(const gchar * default_value){ + defvalue = strdup(default_value); +} void ItemParam::param_set_and_write_default() diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h index 6c719d451..89c32f9bd 100644 --- a/src/live_effects/parameter/item.h +++ b/src/live_effects/parameter/item.h @@ -36,6 +36,7 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); + virtual void param_update_default(const gchar * default_value); void param_set_and_write_default(); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/parameter/originalitem.h b/src/live_effects/parameter/originalitem.h index 58d04e05a..de1a6ac25 100644 --- a/src/live_effects/parameter/originalitem.h +++ b/src/live_effects/parameter/originalitem.h @@ -26,7 +26,6 @@ public: void setInverse(bool inversed) { inverse = inversed; } bool linksToItem() const { return (href != NULL); } SPItem * getObject() const { return ref.getObject(); } - virtual Gtk::Widget * param_newWidget(); protected: diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index 296c0f7f7..fe9371644 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -65,12 +65,11 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - + virtual void param_update_default(const gchar * default_value){}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector & /*hp_vec*/) {}; - std::vector _vector; protected: diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index befac4df1..15c81d543 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -107,6 +107,16 @@ ScalarParam::param_update_default(gdouble default_value) defvalue = default_value; } +void +ScalarParam::param_update_default(const gchar * default_value) +{ + double newval; + unsigned int success = sp_svg_number_read_d(default_value, &newval); + if (success == 1) { + param_update_default(newval); + } +} + void ScalarParam::param_set_value(gdouble val) { diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 6cf10710c..e94737a6f 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -60,7 +60,7 @@ public: void write_to_SVG(); virtual void param_set_default() = 0; - + virtual void param_update_default(const gchar * default_value) = 0; // This creates a new widget (newed with Gtk::manage(new ...);) virtual Gtk::Widget * param_newWidget() = 0; @@ -112,6 +112,7 @@ public: virtual void param_set_default(); void param_update_default(gdouble default_value); + virtual void param_update_default(const gchar * default_value); void param_set_value(gdouble val); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); @@ -120,7 +121,6 @@ public: void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; double param_get_max() { return max; }; double param_get_min() { return min; }; - void param_overwrite_widget(bool overwrite_widget); virtual Gtk::Widget * param_newWidget(); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index dafc6d406..aa87508ab 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -439,6 +439,10 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); } +void +PathParam::param_update_default(const gchar * default_value){ + defvalue = strdup(default_value); +} /* CALLBACK FUNCTIONS FOR THE BUTTONS */ void diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index d2dddbe97..5381a6b36 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -40,6 +40,7 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); + virtual void param_update_default(const gchar * default_value); void param_set_and_write_default(); void set_new_value (Geom::PathVector const &newpath, bool write_to_svg); void set_new_value (Geom::Piecewise > const &newpath, bool write_to_svg); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index c87b1e299..683cadc1f 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -59,11 +59,24 @@ PointParam::param_get_default() const{ } void -PointParam::param_update_default(const Geom::Point default_point) +PointParam::param_update_default(Geom::Point default_point) { defvalue = default_point; } +void +PointParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + void PointParam::param_setValue(Geom::Point newpoint, bool write) { diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index e8cb66225..a3797aea5 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -43,14 +43,14 @@ public: void param_set_default(); Geom::Point param_get_default() const; void param_set_liveupdate(bool live_update); - void param_update_default(const Geom::Point default_point); + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); - friend class PointParamKnotHolderEntity; private: PointParam(const PointParam&); diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index 56a609fa8..a34163ca1 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -39,13 +39,13 @@ public: virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); + virtual void param_update_default(const gchar * default_value){}; void set_pwd2(Geom::Piecewise > const & pwd2_in, Geom::Piecewise > const & pwd2_normal_in); Geom::Piecewise > const & get_pwd2() const { return last_pwd2; } Geom::Piecewise > const & get_pwd2_normal() const { return last_pwd2_normal; } void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise > const & pwd2_in); - friend class PowerStrokePointArrayParamKnotHolderEntity; private: diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 075e85ee1..90e53ca0e 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -77,6 +77,20 @@ RandomParam::param_set_default() param_set_value(defvalue, defseed); } +void +RandomParam::param_update_default(gdouble default_value){ + defvalue = default_value; +} + +void +RandomParam::param_update_default(const gchar * default_value){ + double newval; + unsigned int success = sp_svg_number_read_d(default_value, &newval); + if (success == 1) { + param_update_default(newval); + } +} + void RandomParam::param_set_value(gdouble val, long newseed) { diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index ca4440336..5fb6027ac 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -38,9 +38,9 @@ public: void param_set_value(gdouble val, long newseed); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); - + void param_update_default(gdouble default_value); + virtual void param_update_default(const gchar * default_value); void resetRandomizer(); - operator gdouble(); inline gdouble get_value() { return value; } ; diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 5c4cdf4c6..8d526e4cc 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -50,9 +50,9 @@ TextParam::param_set_default() } void -TextParam::param_update_default(Glib::ustring default_value) +TextParam::param_update_default(const gchar * default_value) { - defvalue = default_value; + defvalue = (Glib::ustring)default_value; } void @@ -130,7 +130,7 @@ TextParam::param_newWidget() } void -TextParam::param_setValue(const Glib::ustring newvalue) +TextParam::param_setValue(Glib::ustring newvalue) { param_effect->upd_params = true; value = newvalue; diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 553c84c0a..137f3ee02 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -39,16 +39,16 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(const Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue); void param_hide_canvas_text(); virtual void param_set_default(); - void param_update_default(Glib::ustring default_value); + virtual void param_update_default(const gchar * default_value); void setPos(Geom::Point pos); void setPosAndAnchor(const Geom::Piecewise > &pwd2, const double t, const double length, bool use_curvature = false); void setAnchor(double x_value, double y_value); - const Glib::ustring get_value() const { return defvalue; }; + const Glib::ustring get_value() const { return value; }; private: TextParam(const TextParam&); diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index b3f6442bb..4eaa1aeb2 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -60,6 +60,18 @@ ToggleButtonParam::param_getSVGValue() const return str; } +void +ToggleButtonParam::param_update_default(bool default_value) +{ + defvalue = default_value; +} + +void +ToggleButtonParam::param_update_default(const gchar * default_value) +{ + param_update_default(helperfns_read_bool(default_value, defvalue)); +} + Gtk::Widget * ToggleButtonParam::param_newWidget() { diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h index 8390fec86..d6ca15e75 100644 --- a/src/live_effects/parameter/togglebutton.h +++ b/src/live_effects/parameter/togglebutton.h @@ -51,6 +51,8 @@ public: sigc::signal& signal_toggled() { return _signal_toggled; } virtual void toggled(); + void param_update_default(bool default_value); + virtual void param_update_default(const gchar * default_value); private: ToggleButtonParam(const ToggleButtonParam&); diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp index 0d03432c3..22d5ba3a4 100644 --- a/src/live_effects/parameter/transformedpoint.cpp +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -82,6 +82,25 @@ TransformedPointParam::param_getSVGValue() const return str; } +void +TransformedPointParam::param_update_default(Geom::Point default_point) +{ + defvalue = default_point; +} + +void +TransformedPointParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + Gtk::Widget * TransformedPointParam::param_newWidget() { diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h index c96bedb53..269cc508e 100644 --- a/src/live_effects/parameter/transformedpoint.h +++ b/src/live_effects/parameter/transformedpoint.h @@ -51,7 +51,9 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - + Geom::Point param_get_default() { return defvalue; } + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index b6ea99bfe..b78b75dbf 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -55,9 +55,9 @@ UnitParam::param_set_default() } void -UnitParam::param_update_default(const Glib::ustring default_unit) +UnitParam::param_update_default(const gchar * default_unit) { - defunit = unit_table.getUnit(default_unit); + defunit = unit_table.getUnit((Glib::ustring)default_unit); } void diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index ae58cf956..c662b6edc 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -33,11 +33,10 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); void param_set_value(Inkscape::Util::Unit const &val); - void param_update_default(const Glib::ustring default_unit); + virtual void param_update_default(const gchar * default_unit); const gchar *get_abbreviation() const; - virtual Gtk::Widget * param_newWidget(); - + operator Inkscape::Util::Unit const *() const { return unit; } private: diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 55b4d4b32..470fa9c2d 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -48,6 +48,25 @@ VectorParam::param_set_default() setVector(defvalue); } +void +VectorParam::param_update_default(Geom::Point default_point) +{ + defvalue = default_point; +} + +void +VectorParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + bool VectorParam::param_readSVGValue(const gchar * strvalue) { diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index edee4ff4d..d270e9f43 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -51,7 +51,8 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index ed00092b2..44775988c 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -72,6 +72,316 @@ static char const preferences_skeleton[] = " inkscape:window-width=\"640\"\n" " inkscape:window-height=\"480\" />\n" " \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" "\n" " \n" -- cgit v1.2.3 From abda18047008ae28d9711729521fef7bbff8a241 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 26 Apr 2017 21:00:04 +0200 Subject: Start adding GUI to prefs (bzr r15620.1.3) --- src/live_effects/effect.h | 3 ++- src/ui/dialog/inkscape-preferences.cpp | 40 ++++++++++++++++++++++++++++++++-- src/ui/dialog/inkscape-preferences.h | 2 ++ 3 files changed, 42 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index c509db387..d7f9ab2e7 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -136,7 +136,8 @@ public: bool upd_params; BoolParam is_visible; SPCurve * sp_curve; - + std::vector getParamVector() { return param_vector; } + Geom::PathVector pathvector_before_effect; protected: Effect(LivePathEffectObject *lpeobject); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 646439613..2f962a7ac 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -27,7 +27,10 @@ #include "preferences.h" #include "verbs.h" #include "selcue.h" - +#include "live_effects/effect-enum.h" +#include "live_effects/effect.h" +#include "live_effects/lpeobject.h" +#include "sp-defs.h" #include "extension/internal/gdkpixbuf-input.h" #include "message-stack.h" #include "style.h" @@ -820,6 +823,39 @@ void InkscapePreferences::initPageUI() this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS); initKeyboardShortcuts(iter_ui); + + _page_le.add_group_header( _("Live Effects")); + SPDocument * doc = SP_ACTIVE_DOCUMENT; + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect"); + lpe_repr->setAttribute("id", "deleteme"); + SPObject *lpeo = SP_OBJECT(doc->getDefs()->appendChildRepr(lpe_repr)); + Inkscape::GC::release(lpe_repr); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + for ( int le = Inkscape::LivePathEffect::EffectType::BEND_PATH; le != Inkscape::LivePathEffect::EffectType::INVALID_LPE; le++ ){ + Inkscape::LivePathEffect::EffectType lpenr = static_cast(le); + Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(lpenr); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(lpenr); + bool is_text_label_lpe = effectkey == (Glib::ustring)"text_label"; + if (!effectname.empty() && !is_text_label_lpe){ + lpeo->setAttribute("effect", effectkey.c_str()); + LivePathEffectObject * lpeobj = dynamic_cast(lpeo); + Glib::ustring liveeffect = effectname +(Glib::ustring)_(":"); + _page_le.add_group_header(liveeffect.c_str()); + Inkscape::LivePathEffect::Effect* effect = Inkscape::LivePathEffect::Effect::New(lpenr, lpeobj); + std::vector param_vector = effect->getParamVector(); + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + Inkscape::LivePathEffect::Parameter * param = *it; + const gchar * key = param->param_key.c_str(); + const gchar * value = param->param_label.c_str(); + _page_le.add_group_header(value); + ++it; + } + } + } + lpeo->deleteObject(); + this->AddPage(_page_le, _("Live Effects"), iter_ui, PREFS_PAGE_UI_LE); } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -2042,7 +2078,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) _page_list.expand_row(_path_tools, false); if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL) _page_list.expand_row(_path_shapes, false); - if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_KEYBOARD_SHORTCUTS) + if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_LE) _page_list.expand_row(_path_ui, false); if (desired_page >= PREFS_PAGE_BEHAVIOR && desired_page <= PREFS_PAGE_BEHAVIOR_MASKS) _page_list.expand_row(_path_behavior, false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index e6ba4e4b2..2e42252d9 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -73,6 +73,7 @@ enum { PREFS_PAGE_UI_WINDOWS, PREFS_PAGE_UI_GRIDS, PREFS_PAGE_UI_KEYBOARD_SHORTCUTS, + PREFS_PAGE_UI_LE, PREFS_PAGE_BEHAVIOR, PREFS_PAGE_BEHAVIOR_SELECTING, PREFS_PAGE_BEHAVIOR_TRANSFORMS, @@ -187,6 +188,7 @@ protected: UI::Widget::DialogPage _page_spellcheck; UI::Widget::DialogPage _page_keyshortcuts; + UI::Widget::DialogPage _page_le; UI::Widget::PrefSpinButton _mouse_sens; UI::Widget::PrefSpinButton _mouse_thres; -- cgit v1.2.3 From af42d5456d7f523d6cb259d0e2921234aa887146 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Thu, 27 Apr 2017 01:06:31 +0200 Subject: Add LPE prefs dialog (bzr r15620.1.4) --- src/live_effects/effect.cpp | 8 ++--- src/live_effects/parameter/bool.cpp | 12 ++++++- src/live_effects/parameter/fontbutton.cpp | 12 ++++++- src/live_effects/parameter/parameter.h | 2 +- src/ui/dialog/inkscape-preferences.cpp | 54 ++++++++++++++++++++++++++++--- src/ui/dialog/inkscape-preferences.h | 8 +++-- 6 files changed, 81 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 23af55cb3..5246dbf89 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -657,14 +657,14 @@ Effect::readallParameters(Inkscape::XML::Node const* repr) g_warning("Effect::readallParameters - '%s' not accepted for %s", value, key); } } else { - Glib::ustring prefs_path = (Glib::ustring)"/live_effects/" + + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + (Glib::ustring)"/" + (Glib::ustring)key; - bool valid = prefs->getEntry(prefs_path).isValid(); + bool valid = prefs->getEntry(pref_path).isValid(); //add to preferences-skeleton the parameters you want reseteable - if(valid && prefs->getString(prefs_path) != DEFAULT_PREF_VALUE){ - param->param_update_default(prefs->getString(prefs_path).c_str()); + if(valid && prefs->getString(pref_path) != DEFAULT_PREF_VALUE){ + param->param_update_default(prefs->getString(pref_path).c_str()); } else { param->param_set_default(); } diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index cdc988ab2..a031b5ced 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -66,8 +66,18 @@ Gtk::Widget * BoolParam::param_newWidget() { if(!hide_widget){ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredCheckButton( param_label, + new Inkscape::UI::Widget::RegisteredCheckButton( label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp index 53b8c0612..ee76c4ab9 100644 --- a/src/live_effects/parameter/fontbutton.cpp +++ b/src/live_effects/parameter/fontbutton.cpp @@ -58,8 +58,18 @@ FontButtonParam::param_getSVGValue() const Gtk::Widget * FontButtonParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredFontButton( param_label, + new Inkscape::UI::Widget::RegisteredFontButton( label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index e94737a6f..ee1d2d547 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -77,6 +77,7 @@ public: virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) {}; Glib::ustring param_key; + Glib::ustring param_tooltip; Inkscape::UI::Widget::Registry * param_wr; Glib::ustring param_label; @@ -84,7 +85,6 @@ public: bool widget_is_visible; protected: - Glib::ustring param_tooltip; Effect* param_effect; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2f962a7ac..93cf5eb42 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -824,14 +824,16 @@ void InkscapePreferences::initPageUI() initKeyboardShortcuts(iter_ui); - _page_le.add_group_header( _("Live Effects")); + _page_lpe.add_group_header( _("Allow set default to this parameters:")); SPDocument * doc = SP_ACTIVE_DOCUMENT; Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect"); lpe_repr->setAttribute("id", "deleteme"); SPObject *lpeo = SP_OBJECT(doc->getDefs()->appendChildRepr(lpe_repr)); Inkscape::GC::release(lpe_repr); + Inkscape::UI::Widget::Registry * wr; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + for ( int le = Inkscape::LivePathEffect::EffectType::BEND_PATH; le != Inkscape::LivePathEffect::EffectType::INVALID_LPE; le++ ){ Inkscape::LivePathEffect::EffectType lpenr = static_cast(le); Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(lpenr); @@ -841,21 +843,63 @@ void InkscapePreferences::initPageUI() lpeo->setAttribute("effect", effectkey.c_str()); LivePathEffectObject * lpeobj = dynamic_cast(lpeo); Glib::ustring liveeffect = effectname +(Glib::ustring)_(":"); - _page_le.add_group_header(liveeffect.c_str()); Inkscape::LivePathEffect::Effect* effect = Inkscape::LivePathEffect::Effect::New(lpenr, lpeobj); std::vector param_vector = effect->getParamVector(); std::vector::iterator it = param_vector.begin(); + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); + vbox_expander->set_border_width(10); + vbox_expander->set_spacing(2); while (it != param_vector.end()) { Inkscape::LivePathEffect::Parameter * param = *it; const gchar * key = param->param_key.c_str(); const gchar * value = param->param_label.c_str(); - _page_le.add_group_header(value); + const gchar * tooltip = (param->param_tooltip + (Glib::ustring)_(". Toogling this widget in preferences reset custom values for this parameter")).c_str(); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(pref_path).isValid(); + bool set = false; + if(valid){ + set = true; + } + Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredCheckButton( param->param_label, + param->param_tooltip, + param->param_key, + *wr, + false, + NULL, + NULL) ); + checkwdg->setActive(set); + checkwdg->setProgrammatically = false; + checkwdg->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &InkscapePreferences::defaultLpeUpdater), pref_path, checkwdg)); + vbox_expander->pack_start(*dynamic_cast (checkwdg), true, true, 2); ++it; } + + Gtk::Expander * expander = Gtk::manage(new Gtk::Expander(liveeffect)); + expander->add(*vbox_expander); + expander->set_expanded(false); + Glib::ustring tip = (Glib::ustring)_("Set defaultables parameters for ") + liveeffect; + _page_lpe.add_line( true, "", *dynamic_cast(expander), "", tip.c_str() ); } } lpeo->deleteObject(); - this->AddPage(_page_le, _("Live Effects"), iter_ui, PREFS_PAGE_UI_LE); + this->AddPage(_page_lpe, _("Live Effects"), iter_ui, PREFS_PAGE_UI_LPE); +} + +void +InkscapePreferences::defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Widget::RegisteredCheckButton * checkwdg) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (checkwdg->get_active()) + { + prefs->setString(pref_path, "--default"); + + } else { + prefs->remove(pref_path); + } } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -2078,7 +2122,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) _page_list.expand_row(_path_tools, false); if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL) _page_list.expand_row(_path_shapes, false); - if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_LE) + if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_LPE) _page_list.expand_row(_path_ui, false); if (desired_page >= PREFS_PAGE_BEHAVIOR && desired_page <= PREFS_PAGE_BEHAVIOR_MASKS) _page_list.expand_row(_path_behavior, false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 2e42252d9..6320ff49c 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -22,6 +22,7 @@ #include #include #include "ui/widget/preferences-widget.h" +#include "ui/widget/registered-widget.h" #include "ui/widget/button.h" #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +75,7 @@ enum { PREFS_PAGE_UI_WINDOWS, PREFS_PAGE_UI_GRIDS, PREFS_PAGE_UI_KEYBOARD_SHORTCUTS, - PREFS_PAGE_UI_LE, + PREFS_PAGE_UI_LPE, PREFS_PAGE_BEHAVIOR, PREFS_PAGE_BEHAVIOR_SELECTING, PREFS_PAGE_BEHAVIOR_TRANSFORMS, @@ -188,7 +190,7 @@ protected: UI::Widget::DialogPage _page_spellcheck; UI::Widget::DialogPage _page_keyshortcuts; - UI::Widget::DialogPage _page_le; + UI::Widget::DialogPage _page_lpe; UI::Widget::PrefSpinButton _mouse_sens; UI::Widget::PrefSpinButton _mouse_thres; @@ -492,7 +494,7 @@ protected: Gtk::TreeModel::iterator AddPage(UI::Widget::DialogPage& p, Glib::ustring title, Gtk::TreeModel::iterator parent, int id); bool SetMaxDialogSize(const Gtk::TreeModel::iterator& iter); bool PresentPage(const Gtk::TreeModel::iterator& iter); - + void defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Widget::RegisteredCheckButton * checkwdg); static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); -- cgit v1.2.3 From 18e032118bbb1718778c6f2e5e55cdb1723dc1ce Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 27 Apr 2017 12:05:03 +0200 Subject: Add end of preferences GUI (bzr r15620.1.6) --- src/live_effects/effect.cpp | 2 +- src/live_effects/lpe-bspline.cpp | 2 +- src/live_effects/lpe-clone-original.cpp | 2 +- src/live_effects/lpe-copy_rotate.cpp | 2 +- src/live_effects/lpe-fillet-chamfer.cpp | 2 +- src/live_effects/lpe-lattice2.cpp | 2 +- src/live_effects/lpe-measure-line.cpp | 2 +- src/live_effects/lpe-mirror_symmetry.cpp | 2 +- src/live_effects/lpe-perspective-envelope.cpp | 2 +- src/live_effects/lpe-simplify.cpp | 2 +- src/live_effects/lpe-transform_2pts.cpp | 2 +- src/live_effects/parameter/item.cpp | 12 +++++++++++- src/live_effects/parameter/originalitem.cpp | 12 +++++++++++- src/live_effects/parameter/originalpath.cpp | 12 +++++++++++- src/live_effects/parameter/parameter.cpp | 12 +++++++++++- src/live_effects/parameter/path.cpp | 12 +++++++++++- src/live_effects/parameter/point.cpp | 12 +++++++++++- src/live_effects/parameter/random.cpp | 12 +++++++++++- src/live_effects/parameter/text.cpp | 12 +++++++++++- src/live_effects/parameter/togglebutton.cpp | 12 +++++++++++- src/live_effects/parameter/transformedpoint.cpp | 12 +++++++++++- src/live_effects/parameter/unit.cpp | 12 +++++++++++- src/live_effects/parameter/vector.cpp | 12 +++++++++++- src/ui/dialog/inkscape-preferences.cpp | 14 +++++++++++--- 24 files changed, 154 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 5246dbf89..a7315b37f 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -786,7 +786,7 @@ Effect::newWidget() upd_params = false; if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index fb803b770..eb6fb5d0a 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -142,7 +142,7 @@ Gtk::Widget *LPEBSpline::newWidget() Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index ae20b582a..93ea4aa9d 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -320,7 +320,7 @@ LPECloneOriginal::newWidget() vbox->pack_start(*expander, true, true, 2); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 1fd0e466f..3a1925366 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -330,7 +330,7 @@ Gtk::Widget * LPECopyRotate::newWidget() if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index f21b53f90..585972fee 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -178,7 +178,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget() vbox->pack_start(*chamferContainer, true, true, 2); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index fe01ef9ee..88cb815f9 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -258,7 +258,7 @@ LPELattice2::newWidget() } if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index 1095cfc0d..64b970e7b 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -729,7 +729,7 @@ Gtk::Widget *LPEMeasureLine::newWidget() vbox->pack_start(*expander, true, true, 2); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index a00aac3be..87107f914 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -338,7 +338,7 @@ LPEMirrorSymmetry::newWidget() this->upd_params = false; if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameterss")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index e967a01aa..88998aa49 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -416,7 +416,7 @@ LPEPerspectiveEnvelope::newWidget() hbox->pack_start(*reset_button, false, false,2); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 5b5bbea6c..49d869cff 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -117,7 +117,7 @@ LPESimplify::newWidget() vbox->pack_start(*buttons,true, true, 2); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index e5bc8657d..6927ee13d 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -352,7 +352,7 @@ Gtk::Widget *LPETransform2Pts::newWidget() vbox->pack_start(*button4, true, true, 2); if (show_default_widgets) { Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), + Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), Gtk::ALIGN_START)); default_label->set_use_markup(true); vbox->pack_start(*default_label, true, true, 2); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 7b40f4540..aba61b96a 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -108,10 +108,20 @@ ItemParam::param_getSVGValue() const Gtk::Widget * ItemParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Gtk::HBox * _widget = Gtk::manage(new Gtk::HBox()); Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); - Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); + Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); pButton->set_relief(Gtk::RELIEF_NONE); diff --git a/src/live_effects/parameter/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp index 053062128..8db8851bf 100644 --- a/src/live_effects/parameter/originalitem.cpp +++ b/src/live_effects/parameter/originalitem.cpp @@ -46,10 +46,20 @@ OriginalItemParam::~OriginalItemParam() Gtk::Widget * OriginalItemParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Gtk::HBox *_widget = Gtk::manage(new Gtk::HBox()); { // Label - Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label)); + Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); } diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index 1e78f7fe1..388a3b5e6 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -47,10 +47,20 @@ OriginalPathParam::~OriginalPathParam() Gtk::Widget * OriginalPathParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Gtk::HBox *_widget = Gtk::manage(new Gtk::HBox()); { // Label - Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label)); + Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); } diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 15c81d543..359a51913 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -172,8 +172,18 @@ Gtk::Widget * ScalarParam::param_newWidget() { if(!hide_widget){ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( - param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); rsu->setValue(value); rsu->setDigits(digits); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index aa87508ab..9bdebaf47 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -170,9 +170,19 @@ PathParam::param_getSVGValue() const Gtk::Widget * PathParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Gtk::HBox * _widget = Gtk::manage(new Gtk::HBox()); - Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); + Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 561f1b34c..2fbe4b3b4 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -126,8 +126,18 @@ PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) Gtk::Widget * PointParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, + new Inkscape::UI::Widget::RegisteredTransformedPoint( label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 90e53ca0e..bcba05399 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -129,8 +129,18 @@ RandomParam::resetRandomizer() Gtk::Widget * RandomParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredRandom* regrandom = Gtk::manage( - new Inkscape::UI::Widget::RegisteredRandom( param_label, + new Inkscape::UI::Widget::RegisteredRandom( label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 8d526e4cc..5c56e8447 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -119,8 +119,18 @@ TextParam::param_getSVGValue() const Gtk::Widget * TextParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( - param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); + label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); rsu->setText(value); rsu->setProgrammatically = false; diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 4eaa1aeb2..1d1bc82a6 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -75,12 +75,22 @@ ToggleButtonParam::param_update_default(const gchar * default_value) Gtk::Widget * ToggleButtonParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } if (_toggled_connection.connected()) { _toggled_connection.disconnect(); } checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredToggleButton( param_label, + new Inkscape::UI::Widget::RegisteredToggleButton( label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp index 22d5ba3a4..2081a8c0c 100644 --- a/src/live_effects/parameter/transformedpoint.cpp +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -104,8 +104,18 @@ TransformedPointParam::param_update_default(const gchar * default_point) Gtk::Widget * TransformedPointParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredVector( param_label, + new Inkscape::UI::Widget::RegisteredVector( label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index b78b75dbf..684f29555 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -75,8 +75,18 @@ UnitParam::get_abbreviation() const Gtk::Widget * UnitParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredUnitMenu* unit_menu = Gtk::manage( - new Inkscape::UI::Widget::RegisteredUnitMenu(param_label, + new Inkscape::UI::Widget::RegisteredUnitMenu(label, param_key, *param_wr, param_effect->getRepr(), diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 470fa9c2d..d6593871d 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -104,8 +104,18 @@ VectorParam::param_getSVGValue() const Gtk::Widget * VectorParam::param_newWidget() { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)param_key; + Glib::ustring label = param_label; + if(prefs->getEntry(pref_path).isValid()){ + label = (Glib::ustring)"* " + param_label; + } Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredVector( param_label, + new Inkscape::UI::Widget::RegisteredVector( label, param_tooltip, param_key, *param_wr, diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 93cf5eb42..2f83a08e9 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -834,7 +834,7 @@ void InkscapePreferences::initPageUI() Inkscape::UI::Widget::Registry * wr; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - for ( int le = Inkscape::LivePathEffect::EffectType::BEND_PATH; le != Inkscape::LivePathEffect::EffectType::INVALID_LPE; le++ ){ + for ( int le = Inkscape::LivePathEffect::EffectType::BEND_PATH; le != Inkscape::LivePathEffect::EffectType::INVALID_LPE; ++le){ Inkscape::LivePathEffect::EffectType lpenr = static_cast(le); Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(lpenr); Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(lpenr); @@ -845,6 +845,9 @@ void InkscapePreferences::initPageUI() Glib::ustring liveeffect = effectname +(Glib::ustring)_(":"); Inkscape::LivePathEffect::Effect* effect = Inkscape::LivePathEffect::Effect::New(lpenr, lpeobj); std::vector param_vector = effect->getParamVector(); + if (param_vector.size() == 1) { + continue; + } std::vector::iterator it = param_vector.begin(); Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); vbox_expander->set_border_width(10); @@ -852,8 +855,13 @@ void InkscapePreferences::initPageUI() while (it != param_vector.end()) { Inkscape::LivePathEffect::Parameter * param = *it; const gchar * key = param->param_key.c_str(); + if (strcmp(key,"is_visible") == 0 ){ + ++it; + continue; + } const gchar * value = param->param_label.c_str(); - const gchar * tooltip = (param->param_tooltip + (Glib::ustring)_(". Toogling this widget in preferences reset custom values for this parameter")).c_str(); + const gchar * tooltip_extra = _(". Toogling this check in preferences reset to default custom values for this parameter"); + Glib::ustring tooltip = param->param_tooltip + (Glib::ustring)tooltip_extra; Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + effectkey + (Glib::ustring)"/" + @@ -865,7 +873,7 @@ void InkscapePreferences::initPageUI() } Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( new Inkscape::UI::Widget::RegisteredCheckButton( param->param_label, - param->param_tooltip, + tooltip, param->param_key, *wr, false, -- cgit v1.2.3 From 7139c8a3275224df37c3e59628355f6b3e3398b4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 27 Apr 2017 15:49:12 +0200 Subject: Fixing remove prefs (bzr r15620.1.7) --- src/preferences-skeleton.h | 310 --------------------------------- src/preferences.cpp | 29 +++ src/ui/dialog/inkscape-preferences.cpp | 2 + 3 files changed, 31 insertions(+), 310 deletions(-) (limited to 'src') diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 44775988c..ed00092b2 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -72,316 +72,6 @@ static char const preferences_skeleton[] = " inkscape:window-width=\"640\"\n" " inkscape:window-height=\"480\" />\n" " \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" "\n" " \n" diff --git a/src/preferences.cpp b/src/preferences.cpp index 4d522a1d8..2849fe068 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -512,6 +512,35 @@ void Preferences::remove(Glib::ustring const &pref_path) Inkscape::XML::Node *node = _getNode(pref_path, false); if (node && node->parent()) { node->parent()->removeChild(node); + } else { //Handle to remove also attributes in path not only the container node + // verify path + g_assert( pref_path.at(0) == '/' ); + if (_prefs_doc == NULL){ + return; + } + node = _prefs_doc->root(); + Inkscape::XML::Node *child = NULL; + gchar **splits = g_strsplit(pref_path.c_str(), "/", 0); + if ( splits ) { + for (int part_i = 0; splits[part_i]; ++part_i) { + // skip empty path segments + if (!splits[part_i][0]) { + continue; + } + if (!node->firstChild()) { + node->setAttribute(splits[part_i], NULL); + g_strfreev(splits); + return; + } + for (child = node->firstChild(); child; child = child->next()) { + if (!strcmp(splits[part_i], child->attribute("id"))) { + break; + } + } + node = child; + } + } + g_strfreev(splits); } } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 2f83a08e9..6e12104f0 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -907,6 +907,8 @@ InkscapePreferences::defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Wi } else { prefs->remove(pref_path); + prefs->remove((Glib::ustring)"/live_effects/gdsgddssdggdsgdsgdsgs"); + prefs->remove((Glib::ustring)"/ddsdsdsgdsg"); } } -- cgit v1.2.3 From 52054e24f8b98c07753588c726a1e777bad7245b Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Fri, 28 Apr 2017 21:42:36 +0200 Subject: Reset (bzr r15620.1.9) --- src/live_effects/effect.cpp | 175 +++++++-------------- src/live_effects/effect.h | 8 +- src/live_effects/lpe-bendpath.cpp | 8 +- src/live_effects/lpe-bounding-box.cpp | 4 +- src/live_effects/lpe-bspline.cpp | 16 -- src/live_effects/lpe-clone-original.cpp | 15 -- src/live_effects/lpe-constructgrid.cpp | 4 +- src/live_effects/lpe-copy_rotate.cpp | 17 -- src/live_effects/lpe-curvestitch.cpp | 16 +- src/live_effects/lpe-dynastroke.cpp | 22 +-- src/live_effects/lpe-envelope.cpp | 12 +- src/live_effects/lpe-extrude.cpp | 2 +- src/live_effects/lpe-fill-between-many.cpp | 10 +- src/live_effects/lpe-fill-between-strokes.cpp | 14 +- src/live_effects/lpe-fillet-chamfer.cpp | 16 +- src/live_effects/lpe-interpolate.cpp | 6 +- src/live_effects/lpe-knot.cpp | 12 +- src/live_effects/lpe-lattice.cpp | 32 ++-- src/live_effects/lpe-lattice2.cpp | 17 +- src/live_effects/lpe-line_segment.cpp | 2 +- src/live_effects/lpe-measure-line.cpp | 167 ++++++++++++-------- src/live_effects/lpe-measure-line.h | 1 + src/live_effects/lpe-mirror_symmetry.cpp | 15 -- src/live_effects/lpe-offset.cpp | 2 +- src/live_effects/lpe-parallel.cpp | 6 +- src/live_effects/lpe-path_length.cpp | 8 +- src/live_effects/lpe-patternalongpath.cpp | 20 +-- src/live_effects/lpe-perp_bisector.cpp | 4 +- src/live_effects/lpe-perspective-envelope.cpp | 15 -- src/live_effects/lpe-perspective_path.cpp | 10 +- src/live_effects/lpe-powerstroke.cpp | 16 +- src/live_effects/lpe-recursiveskeleton.cpp | 2 +- src/live_effects/lpe-rough-hatches.cpp | 40 ++--- src/live_effects/lpe-roughen.cpp | 15 -- src/live_effects/lpe-ruler.cpp | 18 +-- src/live_effects/lpe-simplify.cpp | 15 -- src/live_effects/lpe-skeleton.cpp | 2 +- src/live_effects/lpe-sketch.cpp | 34 ++-- src/live_effects/lpe-tangent_to_curve.cpp | 8 +- src/live_effects/lpe-test-doEffect-stack.cpp | 8 +- src/live_effects/lpe-text_label.cpp | 2 +- src/live_effects/lpe-transform_2pts.cpp | 15 -- src/live_effects/lpe-vonkoch.cpp | 18 +-- src/live_effects/parameter/array.h | 2 +- src/live_effects/parameter/bool.cpp | 20 +-- src/live_effects/parameter/bool.h | 4 +- src/live_effects/parameter/enum.h | 10 +- .../parameter/filletchamferpointarray.h | 1 - src/live_effects/parameter/fontbutton.cpp | 23 +-- src/live_effects/parameter/fontbutton.h | 6 +- src/live_effects/parameter/item.cpp | 16 +- src/live_effects/parameter/item.h | 1 - src/live_effects/parameter/originalitem.cpp | 12 +- src/live_effects/parameter/originalitem.h | 1 + src/live_effects/parameter/originalpath.cpp | 12 +- src/live_effects/parameter/originalpatharray.h | 3 +- src/live_effects/parameter/parameter.cpp | 22 +-- src/live_effects/parameter/parameter.h | 6 +- src/live_effects/parameter/path.cpp | 16 +- src/live_effects/parameter/path.h | 1 - src/live_effects/parameter/point.cpp | 25 +-- src/live_effects/parameter/point.h | 2 - src/live_effects/parameter/powerstrokepointarray.h | 2 +- src/live_effects/parameter/random.cpp | 26 +-- src/live_effects/parameter/random.h | 4 +- src/live_effects/parameter/text.cpp | 18 +-- src/live_effects/parameter/text.h | 6 +- src/live_effects/parameter/togglebutton.cpp | 24 +-- src/live_effects/parameter/togglebutton.h | 2 - src/live_effects/parameter/transformedpoint.cpp | 31 +--- src/live_effects/parameter/transformedpoint.h | 4 +- src/live_effects/parameter/unit.cpp | 16 +- src/live_effects/parameter/unit.h | 5 +- src/live_effects/parameter/vector.cpp | 31 +--- src/live_effects/parameter/vector.h | 3 +- src/preferences.cpp | 29 ---- src/ui/dialog/inkscape-preferences.cpp | 94 +---------- src/ui/dialog/inkscape-preferences.h | 6 +- 78 files changed, 380 insertions(+), 953 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a7315b37f..017947cda 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -74,73 +74,72 @@ #include "xml/sp-css-attr.h" #include "live_effects/lpeobject.h" #include "display/curve.h" -#include -#include + namespace Inkscape { namespace LivePathEffect { -const Glib::ustring DEFAULT_PREF_VALUE = "--default"; + const Util::EnumData LPETypeData[] = { // {constant defined in effect-enum.h, N_("name of your effect"), "name of your effect in SVG"} #ifdef LPE_ENABLE_TEST_EFFECTS - {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, - {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, + {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"}, + {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"}, {CIRCLE_WITH_RADIUS, N_("Circle (by center and radius)"), "circle_with_radius"}, - {CIRCLE_3PTS, N_("Circle by 3 points"), "circle_3pts"}, - {DYNASTROKE, N_("Dynamic stroke"), "dynastroke"}, - {EXTRUDE, N_("Extrude"), "extrude"}, - {LATTICE, N_("Lattice Deformation"), "lattice"}, - {LINE_SEGMENT, N_("Line Segment"), "line_segment"}, - {OFFSET, N_("Offset"), "offset"}, - {PARALLEL, N_("Parallel"), "parallel"}, - {PATH_LENGTH, N_("Path length"), "path_length"}, - {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"}, - {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"}, - {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, - {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, - {TEXT_LABEL, N_("Text label"), "text_label"}, - {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, + {CIRCLE_3PTS, N_("Circle by 3 points"), "circle_3pts"}, + {DYNASTROKE, N_("Dynamic stroke"), "dynastroke"}, + {EXTRUDE, N_("Extrude"), "extrude"}, + {LATTICE, N_("Lattice Deformation"), "lattice"}, + {LINE_SEGMENT, N_("Line Segment"), "line_segment"}, + {OFFSET, N_("Offset"), "offset"}, + {PARALLEL, N_("Parallel"), "parallel"}, + {PATH_LENGTH, N_("Path length"), "path_length"}, + {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"}, + {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"}, + {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"}, + {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}, + {TEXT_LABEL, N_("Text label"), "text_label"}, + {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, #endif /* 0.46 */ - {BEND_PATH, N_("Bend"), "bend_path"}, - {GEARS, N_("Gears"), "gears"}, - {PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG - {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"}, + {BEND_PATH, N_("Bend"), "bend_path"}, + {GEARS, N_("Gears"), "gears"}, + {PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG + {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"}, /* 0.47 */ - {VONKOCH, N_("VonKoch"), "vonkoch"}, - {KNOT, N_("Knot"), "knot"}, - {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"}, - {SPIRO, N_("Spiro spline"), "spiro"}, - {ENVELOPE, N_("Envelope Deformation"), "envelope"}, - {INTERPOLATE, N_("Interpolate Sub-Paths"), "interpolate"}, - {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, - {SKETCH, N_("Sketch"), "sketch"}, - {RULER, N_("Ruler"), "ruler"}, + {VONKOCH, N_("VonKoch"), "vonkoch"}, + {KNOT, N_("Knot"), "knot"}, + {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"}, + {SPIRO, N_("Spiro spline"), "spiro"}, + {ENVELOPE, N_("Envelope Deformation"), "envelope"}, + {INTERPOLATE, N_("Interpolate Sub-Paths"), "interpolate"}, + {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"}, + {SKETCH, N_("Sketch"), "sketch"}, + {RULER, N_("Ruler"), "ruler"}, /* 0.91 */ - {POWERSTROKE, N_("Power stroke"), "powerstroke"}, - {CLONE_ORIGINAL, N_("Clone original"), "clone_original"}, + {POWERSTROKE, N_("Power stroke"), "powerstroke"}, + {CLONE_ORIGINAL, N_("Clone original"), "clone_original"}, /* 0.92 */ - {SIMPLIFY, N_("Simplify"), "simplify"}, - {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, - {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, //TODO:Wrong name with "-" - {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, - {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, - {SHOW_HANDLES, N_("Show handles"), "show_handles"}, - {ROUGHEN, N_("Roughen"), "roughen"}, - {BSPLINE, N_("BSpline"), "bspline"}, - {JOIN_TYPE, N_("Join type"), "join_type"}, - {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, - {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, - {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, + {SIMPLIFY, N_("Simplify"), "simplify"}, + {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, + {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, + {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, + {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, + {SHOW_HANDLES, N_("Show handles"), "show_handles"}, + {ROUGHEN, N_("Roughen"), "roughen"}, + {BSPLINE, N_("BSpline"), "bspline"}, + {JOIN_TYPE, N_("Join type"), "join_type"}, + {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, + {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, + {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, /* Ponyscape -> Inkscape 0.92*/ - {ATTACH_PATH, N_("Attach path"), "attach_path"}, - {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, - {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"}, - {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, - {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, + {ATTACH_PATH, N_("Attach path"), "attach_path"}, + {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, + {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"}, + {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, + {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, /* 9.93 */ - {MEASURE_LINE, N_("Measure Line"), "measure_line"}, + {MEASURE_LINE, N_("Measure Line"), "measure-line"}, }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -351,7 +350,6 @@ Effect::Effect(LivePathEffectObject *lpeobject) : apply_to_clippath_and_mask(false), _provides_knotholder_entities(false), oncanvasedit_it(0), - show_default_widgets(true), is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true), show_orig_path(false), erase_extra_objects(true), @@ -646,7 +644,6 @@ void Effect::readallParameters(Inkscape::XML::Node const* repr) { std::vector::iterator it = param_vector.begin(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); while (it != param_vector.end()) { Parameter * param = *it; const gchar * key = param->param_key.c_str(); @@ -657,18 +654,10 @@ Effect::readallParameters(Inkscape::XML::Node const* repr) g_warning("Effect::readallParameters - '%s' not accepted for %s", value, key); } } else { - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + - (Glib::ustring)"/" + - (Glib::ustring)key; - bool valid = prefs->getEntry(pref_path).isValid(); - //add to preferences-skeleton the parameters you want reseteable - if(valid && prefs->getString(pref_path) != DEFAULT_PREF_VALUE){ - param->param_update_default(prefs->getString(pref_path).c_str()); - } else { - param->param_set_default(); - } + // set default value + param->param_set_default(); } + ++it; } } @@ -678,7 +667,6 @@ void Effect::setParameter(const gchar * key, const gchar * new_value) { Parameter * param = getParameter(key); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (param) { if (new_value) { bool accepted = param->param_readSVGValue(new_value); @@ -686,6 +674,7 @@ Effect::setParameter(const gchar * key, const gchar * new_value) g_warning("Effect::setParameter - '%s' not accepted for %s", new_value, key); } } else { + // set default value param->param_set_default(); } } @@ -784,21 +773,6 @@ Effect::newWidget() ++it; } upd_params = false; - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &Effect::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &Effect::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } @@ -892,45 +866,6 @@ Effect::resetDefaults(SPItem const* /*item*/) } } -void -Effect::setDefaultParams() -{ - std::vector::iterator it = param_vector.begin(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - while (it != param_vector.end()) { - Parameter * param = *it; - const gchar * key = param->param_key.c_str(); - Glib::ustring prefs_path = (Glib::ustring)"/live_effects/" + - (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + - (Glib::ustring)"/" + - (Glib::ustring)key; - bool valid = prefs->getEntry(prefs_path).isValid(); - if (valid){ - prefs->setString(prefs_path, (Glib::ustring)param->param_getSVGValue()); - } - ++it; - } -} - -void -Effect::resetDefaultParams(){ - std::vector::iterator it = param_vector.begin(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - while (it != param_vector.end()) { - Parameter * param = *it; - const gchar * key = param->param_key.c_str(); - Glib::ustring prefs_path = (Glib::ustring)"/live_effects/" + - (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + - (Glib::ustring)"/" + - (Glib::ustring)key; - bool valid = prefs->getEntry(prefs_path).isValid(); - if (valid){ - prefs->setString(prefs_path, DEFAULT_PREF_VALUE); - } - ++it; - } -} - void Effect::transform_multiply(Geom::Affine const& postmul, bool set) { diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index d7f9ab2e7..f5e41d50e 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -136,8 +136,6 @@ public: bool upd_params; BoolParam is_visible; SPCurve * sp_curve; - std::vector getParamVector() { return param_vector; } - Geom::PathVector pathvector_before_effect; protected: Effect(LivePathEffectObject *lpeobject); @@ -158,14 +156,12 @@ protected: virtual void addKnotHolderEntities(KnotHolder * /*knotholder*/, SPItem * /*item*/) {}; virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); - std::vector param_vector; - void setDefaultParams(); - void resetDefaultParams(); + std::vector param_vector; bool _provides_knotholder_entities; int oncanvasedit_it; - bool show_default_widgets; + bool show_orig_path; // set this to true in derived effects to automatically have the original // path displayed as helperpath diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 363356cac..b1e133292 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -57,10 +57,10 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) : scale_y_rel(_("W_idth in units of length"), _("Scale the width of the path in units of its length"), "scale_y_rel", &wr, this, false), vertical_pattern(_("_Original path is vertical"), _("Rotates the original 90 degrees, before bending it along the bend path"), "vertical", &wr, this, false) { - registerParameter( &bend_path ); - registerParameter( &prop_scale); - registerParameter( &scale_y_rel); - registerParameter( &vertical_pattern); + registerParameter( dynamic_cast(&bend_path) ); + registerParameter( dynamic_cast(&prop_scale) ); + registerParameter( dynamic_cast(&scale_y_rel) ); + registerParameter( dynamic_cast(&vertical_pattern) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); diff --git a/src/live_effects/lpe-bounding-box.cpp b/src/live_effects/lpe-bounding-box.cpp index c83d7e3bc..11fb34e04 100644 --- a/src/live_effects/lpe-bounding-box.cpp +++ b/src/live_effects/lpe-bounding-box.cpp @@ -20,8 +20,8 @@ LPEBoundingBox::LPEBoundingBox(LivePathEffectObject *lpeobject) : linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this), visual_bounds(_("Visual Bounds"), _("Uses the visual bounding box"), "visualbounds", &wr, this) { - registerParameter(&linked_path); - registerParameter(&visual_bounds); + registerParameter( dynamic_cast(&linked_path) ); + registerParameter( dynamic_cast(&visual_bounds) ); //perceived_path = true; } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index eb6fb5d0a..1423e670a 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -139,22 +139,6 @@ Gtk::Widget *LPEBSpline::newWidget() ++it; } - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEBSpline::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEBSpline::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index 93ea4aa9d..47fb6a04e 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -318,21 +318,6 @@ LPECloneOriginal::newWidget() expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPECloneOriginal::onExpanderChanged) ); vbox->pack_start(*expander, true, true, 2); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECloneOriginal::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECloneOriginal::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } this->upd_params = false; return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp index db620fa95..8d24f9f47 100644 --- a/src/live_effects/lpe-constructgrid.cpp +++ b/src/live_effects/lpe-constructgrid.cpp @@ -24,8 +24,8 @@ LPEConstructGrid::LPEConstructGrid(LivePathEffectObject *lpeobject) : nr_x(_("Size _X:"), _("The size of the grid in X direction."), "nr_x", &wr, this, 5), nr_y(_("Size _Y:"), _("The size of the grid in Y direction."), "nr_y", &wr, this, 5) { - registerParameter(&nr_x); - registerParameter(&nr_y); + registerParameter( dynamic_cast(&nr_x) ); + registerParameter( dynamic_cast(&nr_y) ); nr_x.param_make_integer(); nr_y.param_make_integer(); diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 3a1925366..4869e8279 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -327,23 +327,6 @@ Gtk::Widget * LPECopyRotate::newWidget() reset_button->set_size_request(110,20); vbox->pack_start(*hbox, true,true,2); hbox->pack_start(*reset_button, false, false,2); - - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECopyRotate::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPECopyRotate::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } - return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index f8d2e56ca..f2fc00aeb 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -40,14 +40,14 @@ LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : prop_scale(_("Scale _width:"), _("Scale the width of the stitch path"), "prop_scale", &wr, this, 1), scale_y_rel(_("Scale _width relative to length"), _("Scale the width of the stitch path relative to its length"), "scale_y_rel", &wr, this, false) { - registerParameter(&nrofpaths); - registerParameter(&startpoint_edge_variation); - registerParameter(&startpoint_spacing_variation); - registerParameter(&endpoint_edge_variation); - registerParameter(&endpoint_spacing_variation); - registerParameter(&strokepath ); - registerParameter(&prop_scale); - registerParameter(&scale_y_rel); + registerParameter( dynamic_cast(&nrofpaths) ); + registerParameter( dynamic_cast(&startpoint_edge_variation) ); + registerParameter( dynamic_cast(&startpoint_spacing_variation) ); + registerParameter( dynamic_cast(&endpoint_edge_variation) ); + registerParameter( dynamic_cast(&endpoint_spacing_variation) ); + registerParameter( dynamic_cast(&strokepath) ); + registerParameter( dynamic_cast(&prop_scale) ); + registerParameter( dynamic_cast(&scale_y_rel) ); nrofpaths.param_make_integer(); nrofpaths.param_set_range(2, Geom::infinity()); diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 33e754a8a..50bbe6451 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -55,17 +55,17 @@ LPEDynastroke::LPEDynastroke(LivePathEffectObject *lpeobject) : capping(_("Capping:"), _("left capping"), "capping", &wr, this, "M 100,5 C 50,5 0,0 0,0 0,0 50,-5 100,-5") { - registerParameter(&method); - registerParameter(&width); - registerParameter(&roundness); - registerParameter(&angle); - //registerParameter(&modulo_pi) ); - registerParameter(&start_cap); - registerParameter(&growfor); - registerParameter(&end_cap); - registerParameter(&fadefor); - registerParameter(&round_ends); - registerParameter(&capping); + registerParameter( dynamic_cast(& method) ); + registerParameter( dynamic_cast(& width) ); + registerParameter( dynamic_cast(& roundness) ); + registerParameter( dynamic_cast(& angle) ); + //registerParameter( dynamic_cast(& modulo_pi) ); + registerParameter( dynamic_cast(& start_cap) ); + registerParameter( dynamic_cast(& growfor) ); + registerParameter( dynamic_cast(& end_cap) ); + registerParameter( dynamic_cast(& fadefor) ); + registerParameter( dynamic_cast(& round_ends) ); + registerParameter( dynamic_cast(& capping) ); width.param_set_range(0, Geom::infinity()); roundness.param_set_range(0.01, 1); diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 8528ab14d..61a696435 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -23,12 +23,12 @@ LPEEnvelope::LPEEnvelope(LivePathEffectObject *lpeobject) : xx(_("_Enable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true), yy(_("_Enable top & bottom paths"), _("Enable the top and bottom deformation paths"), "yy", &wr, this, true) { - registerParameter(&yy); - registerParameter(&xx); - registerParameter(&bend_path1); - registerParameter(&bend_path2); - registerParameter(&bend_path3); - registerParameter(&bend_path4); + registerParameter( dynamic_cast(&yy) ); + registerParameter( dynamic_cast(&xx) ); + registerParameter( dynamic_cast(&bend_path1) ); + registerParameter( dynamic_cast(&bend_path2) ); + registerParameter( dynamic_cast(&bend_path3) ); + registerParameter( dynamic_cast(&bend_path4) ); concatenate_before_pwd2 = true; apply_to_clippath_and_mask = true; } diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index 4a3ad7508..daa30d45a 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -27,7 +27,7 @@ LPEExtrude::LPEExtrude(LivePathEffectObject *lpeobject) : show_orig_path = true; concatenate_before_pwd2 = false; - registerParameter(&extrude_vector); + registerParameter( dynamic_cast(&extrude_vector) ); } LPEExtrude::~LPEExtrude() diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 40fa91c68..2e1fe0dc1 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -25,11 +25,11 @@ LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) : join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true), close(_("Close"), _("Close path"), "close", &wr, this, true) { - registerParameter(&linked_paths); - registerParameter(&fuse); - registerParameter(&allow_transforms); - registerParameter(&join); - registerParameter(&close); + registerParameter( dynamic_cast(&linked_paths) ); + registerParameter( dynamic_cast(&fuse) ); + registerParameter( dynamic_cast(&allow_transforms) ); + registerParameter( dynamic_cast(&join) ); + registerParameter( dynamic_cast(&close) ); transformmultiply = false; } diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp index f8d86ae99..43fef4288 100644 --- a/src/live_effects/lpe-fill-between-strokes.cpp +++ b/src/live_effects/lpe-fill-between-strokes.cpp @@ -25,13 +25,13 @@ LPEFillBetweenStrokes::LPEFillBetweenStrokes(LivePathEffectObject *lpeobject) : join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true), close(_("Close"), _("Close path"), "close", &wr, this, true) { - registerParameter(&linked_path); - registerParameter(&second_path); - registerParameter(&reverse_second); - registerParameter(&fuse); - registerParameter(&allow_transforms); - registerParameter(&join); - registerParameter(&close); + registerParameter( dynamic_cast(&linked_path) ); + registerParameter( dynamic_cast(&second_path) ); + registerParameter( dynamic_cast(&reverse_second) ); + registerParameter( dynamic_cast(&fuse) ); + registerParameter( dynamic_cast(&allow_transforms) ); + registerParameter( dynamic_cast(&join) ); + registerParameter( dynamic_cast(&close) ); transformmultiply = false; } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 585972fee..1e2df7dc8 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -176,21 +176,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget() vbox->pack_start(*filletContainer, true, true, 2); vbox->pack_start(*chamferContainer, true, true, 2); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } + return vbox; } diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index db3faa307..e95dc5f38 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -30,9 +30,9 @@ LPEInterpolate::LPEInterpolate(LivePathEffectObject *lpeobject) : { show_orig_path = true; - registerParameter(&trajectory_path); - registerParameter(&equidistant_spacing); - registerParameter(&number_of_steps); + registerParameter( dynamic_cast(&trajectory_path) ); + registerParameter( dynamic_cast(&equidistant_spacing) ); + registerParameter( dynamic_cast(&number_of_steps) ); number_of_steps.param_make_integer(); number_of_steps.param_set_range(2, Geom::infinity()); diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 261612fdb..2defecb77 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -356,12 +356,12 @@ LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) : switcher(0.,0.) { // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter(&interruption_width); - registerParameter(&prop_to_stroke_width); - registerParameter(&add_stroke_width); - registerParameter(&add_other_stroke_width); - registerParameter(&switcher_size); - registerParameter(&crossing_points_vector); + registerParameter( dynamic_cast(&interruption_width) ); + registerParameter( dynamic_cast(&prop_to_stroke_width) ); + registerParameter( dynamic_cast(&add_stroke_width) ); + registerParameter( dynamic_cast(&add_other_stroke_width) ); + registerParameter( dynamic_cast(&switcher_size) ); + registerParameter( dynamic_cast(&crossing_points_vector) ); _provides_knotholder_entities = true; } diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 124a7a9c6..acffed000 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -50,22 +50,22 @@ LPELattice::LPELattice(LivePathEffectObject *lpeobject) : { // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter(&grid_point0); - registerParameter(&grid_point1); - registerParameter(&grid_point2); - registerParameter(&grid_point3); - registerParameter(&grid_point4); - registerParameter(&grid_point5); - registerParameter(&grid_point6); - registerParameter(&grid_point7); - registerParameter(&grid_point8); - registerParameter(&grid_point9); - registerParameter(&grid_point10); - registerParameter(&grid_point11); - registerParameter(&grid_point12); - registerParameter(&grid_point13); - registerParameter(&grid_point14); - registerParameter(&grid_point15); + registerParameter( dynamic_cast(&grid_point0) ); + registerParameter( dynamic_cast(&grid_point1) ); + registerParameter( dynamic_cast(&grid_point2) ); + registerParameter( dynamic_cast(&grid_point3) ); + registerParameter( dynamic_cast(&grid_point4) ); + registerParameter( dynamic_cast(&grid_point5) ); + registerParameter( dynamic_cast(&grid_point6) ); + registerParameter( dynamic_cast(&grid_point7) ); + registerParameter( dynamic_cast(&grid_point8) ); + registerParameter( dynamic_cast(&grid_point9) ); + registerParameter( dynamic_cast(&grid_point10) ); + registerParameter( dynamic_cast(&grid_point11) ); + registerParameter( dynamic_cast(&grid_point12) ); + registerParameter( dynamic_cast(&grid_point13) ); + registerParameter( dynamic_cast(&grid_point14) ); + registerParameter( dynamic_cast(&grid_point15) ); apply_to_clippath_and_mask = true; } diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index 88cb815f9..e827491c0 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -256,27 +256,12 @@ LPELattice2::newWidget() ++it; } - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPELattice2::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPELattice2::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } + expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show Points")))); expander->add(*vbox_expander); expander->set_expanded(expanded); vbox->pack_start(*expander, true, true, 2); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPELattice2::onExpanderChanged) ); - return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp index fd23da804..cc024fb92 100644 --- a/src/live_effects/lpe-line_segment.cpp +++ b/src/live_effects/lpe-line_segment.cpp @@ -32,7 +32,7 @@ LPELineSegment::LPELineSegment(LivePathEffectObject *lpeobject) : end_type(_("End type:"), _("Determines on which side the line or line segment is infinite."), "end_type", EndTypeConverter, &wr, this, END_OPEN_BOTH) { /* register all your parameters here, so Inkscape knows which parameters this effect has: */ - registerParameter(&end_type); + registerParameter( dynamic_cast(&end_type) ); } LPELineSegment::~LPELineSegment() diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index 64b970e7b..86d72615c 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -49,33 +49,32 @@ static const Util::EnumDataConverter OMConverter(OrientationM LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : Effect(lpeobject), - unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"), - fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this), + unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"), + fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this), orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false), curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1), - precision(_("Precision"), _("Precision"), "precision", &wr, this, 2), - position(_("Position"), _("Position"), "position", &wr, this, 5), - text_top_bottom(_("Text top/bottom"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), - text_right_left(_("Text right/left"), _("Text right/left"), "text_right_left", &wr, this, 0), - helpline_distance(_("Helpline distance"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), - helpline_overlap(_("Helpline overlap"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), - scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0), - format(_("Format"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), + precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2), + position(_("Position*"), _("Position"), "position", &wr, this, 5), + text_top_bottom(_("Text top/bottom*"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), + text_right_left(_("Text right/left*"), _("Text right/left"), "text_right_left", &wr, this, 0), + helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), + helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), + scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0), + format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), id_origin("id_origin", "id_origin", "id_origin", &wr, this,""), arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false), - flip_side(_("Flip side"), _("Flip side"), "flip_side", &wr, this, false), - scale_sensitive(_("Scale sensitive"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), - local_locale(_("Local Number Format"), _("Local number format"), "local_locale", &wr, this, true), - line_group_05(_("Line Group 0.5"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), - rotate_anotation(_("Rotate Anotation"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), - hide_back(_("Hide if label over"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), - dimline_format(_("CSS DIN line"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), - helperlines_format(_("CSS helpers"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), - anotation_format(_("CSS anotation"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), - arrows_format(_("CSS arrows"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), + flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false), + scale_sensitive(_("Scale sensitive*"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), + local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true), + line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), + rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), + hide_back(_("Hide if label over*"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), + dimline_format(_("CSS DIN line*"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), + helperlines_format(_("CSS helpers*"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), + anotation_format(_("CSS anotation*"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), + arrows_format(_("CSS arrows*"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), expanded(false) { - //set to true the parameters you want to be changed his default values registerParameter(&unit); registerParameter(&fontbutton); registerParameter(&orientation); @@ -100,16 +99,39 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : registerParameter(&anotation_format); registerParameter(&arrows_format); registerParameter(&id_origin); - id_origin.param_hide_canvas_text(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - + Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton"); + if(fontbutton_value.empty()){ + fontbutton_value = "Sans 10"; + } + fontbutton.param_update_default(fontbutton_value); + scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0)); + precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2)); + position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0)); + text_top_bottom.param_update_default(prefs->getDouble("/live_effects/measure-line/text_top_bottom", 5.0)); + helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0)); + helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0)); + Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit"); + if(unit_value.empty()){ + unit_value = "px"; + } + unit.param_update_default(unit_value); Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format"); if(format_value.empty()){ format_value = "{measure}{unit}"; } - format.param_update_default(format_value.c_str()); - + format.param_update_default(format_value); + dimline_format.param_update_default(prefs->getString("/live_effects/measure-line/dimline_format")); + helperlines_format.param_update_default(prefs->getString("/live_effects/measure-line/helperlines_format")); + anotation_format.param_update_default(prefs->getString("/live_effects/measure-line/anotation_format")); + arrows_format.param_update_default(prefs->getString("/live_effects/measure-line/arrows_format")); + flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side")); + scale_sensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_sensitive")); + local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale")); + line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05")); + rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation")); + hide_back.param_update_default(prefs->getBool("/live_effects/measure-line/hide_back")); format.param_hide_canvas_text(); dimline_format.param_hide_canvas_text(); helperlines_format.param_hide_canvas_text(); @@ -353,7 +375,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl items.push_back(id); Geom::OptRect bounds = SP_ITEM(elemref)->bounds(SPItem::GEOMETRIC_BBOX); if (bounds) { - anotation_width = bounds->width() * 1.15; + anotation_width = bounds->width() * 1.4; } } @@ -383,14 +405,8 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, const char * id, b k = (Geom::distance(start,end)/2.0) - arrow_gap - (anotation_width/2.0); } if (Geom::distance(start,end) < anotation_width){ - if ((elemref = document->getObjectById(id))) { - if (remove) { - elemref->deleteObject(); - } - return; - } + return; } - //k = std::max(k , arrow_gap -1); Geom::Ray ray(end, start); Geom::Coord angle = ray.angle(); line_path.start(start); @@ -606,9 +622,6 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } bool overflow = false; const char * downline = g_strdup(Glib::ustring("downline-").append(this->getRepr()->attribute("id")).c_str()); - //delete residual lines if exist - createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); - //Create it if ((anotation_width/2) + std::abs(text_right_left) > Geom::distance(start,end)/2.0) { Geom::Point sstart = end - Point::polar(angle_cross, position); Geom::Point send = end - Point::polar(angle_cross, position); @@ -632,6 +645,9 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } overflow = true; createLine(sstart, prog_end, downline, true, overflow, false, false); + } else { + //erase it + createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); } //LINE arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str()); @@ -692,56 +708,44 @@ Gtk::Widget *LPEMeasureLine::newWidget() vbox->set_spacing(2); std::vector::iterator it = param_vector.begin(); + Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0)); Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); vbox_expander->set_border_width(0); vbox_expander->set_spacing(2); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; - if (param->param_key != "id_origin") { - Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - if (param->param_key != "dimline_format" && - param->param_key != "helperlines_format" && - param->param_key != "arrows_format" && - param->param_key != "anotation_format") { - vbox->pack_start(*widg, true, true, 2); - } else { - vbox_expander->pack_start(*widg, true, true, 2); - } - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + if (param->param_key != "dimline_format" && + param->param_key != "helperlines_format" && + param->param_key != "arrows_format" && + param->param_key != "anotation_format") { + vbox->pack_start(*widg, true, true, 2); + } else { + vbox_expander->pack_start(*widg, true, true, 2); + } + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); } } } ++it; } + Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default")))); + save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault)); + button1->pack_start(*save_default, true, true, 2); expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override")))); expander->add(*vbox_expander); expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureLine::onExpanderChanged) ); vbox->pack_start(*expander, true, true, 2); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } + vbox->pack_start(*button1, true, true, 2); return dynamic_cast(vbox); } @@ -762,6 +766,31 @@ LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in) return path_in; } +void +LPEMeasureLine::saveDefault() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString("/live_effects/measure-line/fontbutton", Glib::ustring(fontbutton.param_getSVGValue())); + prefs->setDouble("/live_effects/measure-line/scale", scale); + prefs->setInt("/live_effects/measure-line/precision", precision); + prefs->setDouble("/live_effects/measure-line/position", position); + prefs->setDouble("/live_effects/measure-line/text_top_bottom", text_top_bottom); + prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance); + prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap); + prefs->setString("/live_effects/measure-line/unit", Glib::ustring(unit.get_abbreviation())); + prefs->setString("/live_effects/measure-line/format", Glib::ustring(format.param_getSVGValue())); + prefs->setString("/live_effects/measure-line/dimline_format", Glib::ustring(dimline_format.param_getSVGValue())); + prefs->setString("/live_effects/measure-line/helperlines_format", Glib::ustring(helperlines_format.param_getSVGValue())); + prefs->setString("/live_effects/measure-line/anotation_format", Glib::ustring(anotation_format.param_getSVGValue())); + prefs->setString("/live_effects/measure-line/arrows_format", Glib::ustring(arrows_format.param_getSVGValue())); + prefs->setBool("/live_effects/measure-line/flip_side", flip_side); + prefs->setBool("/live_effects/measure-line/scale_sensitive", scale_sensitive); + prefs->setBool("/live_effects/measure-line/local_locale", local_locale); + prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05); + prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation); + prefs->setBool("/live_effects/measure-line/hide_back", hide_back); +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h index b42f7cfd5..724c0d924 100644 --- a/src/live_effects/lpe-measure-line.h +++ b/src/live_effects/lpe-measure-line.h @@ -49,6 +49,7 @@ public: void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove, bool valid); void onExpanderChanged(); void createArrowMarker(const char * mode); + void saveDefault(); virtual Gtk::Widget *newWidget(); private: UnitParam unit; diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 87107f914..97015c34d 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -336,21 +336,6 @@ LPEMirrorSymmetry::newWidget() ++it; } this->upd_params = false; - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMirrorSymmetry::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMirrorSymmetry::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index c853e4afa..057f404e0 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -27,7 +27,7 @@ LPEOffset::LPEOffset(LivePathEffectObject *lpeobject) : { show_orig_path = true; apply_to_clippath_and_mask = true; - registerParameter(&offset_pt); + registerParameter(dynamic_cast(&offset_pt)); } LPEOffset::~LPEOffset() diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 271442c7d..276749c43 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -51,9 +51,9 @@ LPEParallel::LPEParallel(LivePathEffectObject *lpeobject) : show_orig_path = true; _provides_knotholder_entities = true; - registerParameter(&offset_pt); - registerParameter(&length_left); - registerParameter(&length_right); + registerParameter(dynamic_cast(&offset_pt)); + registerParameter( dynamic_cast(&length_left) ); + registerParameter( dynamic_cast(&length_right) ); } LPEParallel::~LPEParallel() diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp index 61818a73b..a06dbde98 100644 --- a/src/live_effects/lpe-path_length.cpp +++ b/src/live_effects/lpe-path_length.cpp @@ -26,10 +26,10 @@ LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) : unit(_("Unit:"), _("Unit"), "unit", &wr, this), display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true) { - registerParameter(&scale); - registerParameter(&info_text); - registerParameter(&unit); - registerParameter(&display_unit); + registerParameter(dynamic_cast(&scale)); + registerParameter(dynamic_cast(&info_text)); + registerParameter(dynamic_cast(&unit)); + registerParameter(dynamic_cast(&display_unit)); } LPEPathLength::~LPEPathLength() diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index b026bbc22..966e9020e 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -85,16 +85,16 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : fuse_tolerance(_("_Fuse nearby ends:"), _("Fuse ends closer than this number. 0 means don't fuse."), "fuse_tolerance", &wr, this, 0) { - registerParameter(&pattern); - registerParameter(©type); - registerParameter(&prop_scale); - registerParameter(&scale_y_rel); - registerParameter(&spacing); - registerParameter(&normal_offset); - registerParameter(&tang_offset); - registerParameter(&prop_units); - registerParameter(&vertical_pattern); - registerParameter(&fuse_tolerance); + registerParameter( dynamic_cast(&pattern) ); + registerParameter( dynamic_cast(©type) ); + registerParameter( dynamic_cast(&prop_scale) ); + registerParameter( dynamic_cast(&scale_y_rel) ); + registerParameter( dynamic_cast(&spacing) ); + registerParameter( dynamic_cast(&normal_offset) ); + registerParameter( dynamic_cast(&tang_offset) ); + registerParameter( dynamic_cast(&prop_units) ); + registerParameter( dynamic_cast(&vertical_pattern) ); + registerParameter( dynamic_cast(&fuse_tolerance) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index dab169cfe..bce22250a 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -99,8 +99,8 @@ LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) : _provides_knotholder_entities = true; // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter(&length_left); - registerParameter(&length_right); + registerParameter( dynamic_cast(&length_left) ); + registerParameter( dynamic_cast(&length_right) ); } LPEPerpBisector::~LPEPerpBisector() diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index 88998aa49..365ff5389 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -414,21 +414,6 @@ LPEPerspectiveEnvelope::newWidget() reset_button->set_size_request(140,30); vbox->pack_start(*hbox, true,true,2); hbox->pack_start(*reset_button, false, false,2); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEPerspectiveEnvelope::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEPerspectiveEnvelope::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 435c91c2d..b83fb67d7 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -51,11 +51,11 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) : uses_plane_xy(_("Uses XY plane?"), _("If true, put the path on the left side of an imaginary box, otherwise on the right side"), "uses_plane_xy", &wr, this, true) { // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( &scalex); - registerParameter( &scaley); - registerParameter( &offsetx); - registerParameter( &offsety); - registerParameter( &uses_plane_xy); + registerParameter( dynamic_cast(&scalex) ); + registerParameter( dynamic_cast(&scaley) ); + registerParameter( dynamic_cast(&offsetx) ); + registerParameter( dynamic_cast(&offsety) ); + registerParameter( dynamic_cast(&uses_plane_xy) ); concatenate_before_pwd2 = true; // don't split the path into its subpaths _provides_knotholder_entities = true; diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index d87f92fcc..e9f3975c7 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -179,14 +179,14 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) : interpolator_beta.addSlider(true); interpolator_beta.param_set_range(0.,1.); - registerParameter(&offset_points); - registerParameter(&sort_points); - registerParameter(&interpolator_type); - registerParameter(&interpolator_beta); - registerParameter(&start_linecap_type); - registerParameter(&linejoin_type); - registerParameter(&miter_limit); - registerParameter(&end_linecap_type); + registerParameter( dynamic_cast(&offset_points) ); + registerParameter( dynamic_cast(&sort_points) ); + registerParameter( dynamic_cast(&interpolator_type) ); + registerParameter( dynamic_cast(&interpolator_beta) ); + registerParameter( dynamic_cast(&start_linecap_type) ); + registerParameter( dynamic_cast(&linejoin_type) ); + registerParameter( dynamic_cast(&miter_limit) ); + registerParameter( dynamic_cast(&end_linecap_type) ); } LPEPowerStroke::~LPEPowerStroke() diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index 47613f58e..aa0db920b 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -28,7 +28,7 @@ LPERecursiveSkeleton::LPERecursiveSkeleton(LivePathEffectObject *lpeobject) : concatenate_before_pwd2 = true; iterations.param_make_integer(true); iterations.param_set_range(1, 15); - registerParameter(&iterations); + registerParameter( dynamic_cast(&iterations) ); } diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index d832b3615..3cc8658ea 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -241,26 +241,26 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) : // bender(_("Global bending"), _("Relative position to a reference point defines global bending direction and amount"), "bender", &wr, this, Geom::Point(-5,0)) { - registerParameter(&direction); - registerParameter(&dist_rdm); - registerParameter(&growth); - registerParameter(&do_bend); - registerParameter(&bender); - registerParameter(&top_edge_variation); - registerParameter(&bot_edge_variation); - registerParameter(&top_tgt_variation); - registerParameter(&bot_tgt_variation); - registerParameter(&scale_tf); - registerParameter(&scale_tb); - registerParameter(&scale_bf); - registerParameter(&scale_bb); - registerParameter(&top_smth_variation); - registerParameter(&bot_smth_variation); - registerParameter(&fat_output); - registerParameter(&stroke_width_top); - registerParameter(&stroke_width_bot); - registerParameter(&front_thickness); - registerParameter(&back_thickness); + registerParameter( dynamic_cast(&direction) ); + registerParameter( dynamic_cast(&dist_rdm) ); + registerParameter( dynamic_cast(&growth) ); + registerParameter( dynamic_cast(&do_bend) ); + registerParameter( dynamic_cast(&bender) ); + registerParameter( dynamic_cast(&top_edge_variation) ); + registerParameter( dynamic_cast(&bot_edge_variation) ); + registerParameter( dynamic_cast(&top_tgt_variation) ); + registerParameter( dynamic_cast(&bot_tgt_variation) ); + registerParameter( dynamic_cast(&scale_tf) ); + registerParameter( dynamic_cast(&scale_tb) ); + registerParameter( dynamic_cast(&scale_bf) ); + registerParameter( dynamic_cast(&scale_bb) ); + registerParameter( dynamic_cast(&top_smth_variation) ); + registerParameter( dynamic_cast(&bot_smth_variation) ); + registerParameter( dynamic_cast(&fat_output) ); + registerParameter( dynamic_cast(&stroke_width_top) ); + registerParameter( dynamic_cast(&stroke_width_bot) ); + registerParameter( dynamic_cast(&front_thickness) ); + registerParameter( dynamic_cast(&back_thickness) ); //hatch_dist.param_set_range(0.1, Geom::infinity()); growth.param_set_range(0, Geom::infinity()); diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 8b2a07d59..e847494a2 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -163,21 +163,6 @@ Gtk::Widget *LPERoughen::newWidget() } ++it; } - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable parameters")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPERoughen::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPERoughen::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 852592219..60c2a3e1c 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -45,15 +45,15 @@ LPERuler::LPERuler(LivePathEffectObject *lpeobject) : offset(_("_Offset:"), _("Offset of first mark"), "offset", &wr, this, 0.0), border_marks(_("Border marks:"), _("Choose whether to draw marks at the beginning and end of the path"), "border_marks", BorderMarkTypeConverter, &wr, this, BORDERMARK_BOTH) { - registerParameter(&unit); - registerParameter(&mark_distance); - registerParameter(&mark_length); - registerParameter(&minor_mark_length); - registerParameter(&major_mark_steps); - registerParameter(&shift); - registerParameter(&offset); - registerParameter(&mark_dir); - registerParameter(&border_marks); + registerParameter(dynamic_cast(&unit)); + registerParameter(dynamic_cast(&mark_distance)); + registerParameter(dynamic_cast(&mark_length)); + registerParameter(dynamic_cast(&minor_mark_length)); + registerParameter(dynamic_cast(&major_mark_steps)); + registerParameter(dynamic_cast(&shift)); + registerParameter(dynamic_cast(&offset)); + registerParameter(dynamic_cast(&mark_dir)); + registerParameter(dynamic_cast(&border_marks)); major_mark_steps.param_make_integer(); major_mark_steps.param_set_range(1, 1000); diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 49d869cff..5de9816bb 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -115,21 +115,6 @@ LPESimplify::newWidget() ++it; } vbox->pack_start(*buttons,true, true, 2); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPESimplify::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPESimplify::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index d3c94269a..4fc18cee2 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -37,7 +37,7 @@ LPESkeleton::LPESkeleton(LivePathEffectObject *lpeobject) : //_provides_knotholder_entities /* register all your parameters here, so Inkscape knows which parameters this effect has: */ - registerParameter(&number); + registerParameter( dynamic_cast(&number) ); } LPESkeleton::~LPESkeleton() diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e3376b7e5..e01516f2e 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -62,25 +62,25 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : // register all your parameters here, so Inkscape knows which parameters this effect has: //Add some comment in the UI: *warning* the precise output of this effect might change in future releases! //convert to path if you want to keep exact output unchanged in future releases... - //registerParameter(&testpointA) ); - registerParameter(&nbiter_approxstrokes); - registerParameter(&strokelength); - registerParameter(&strokelength_rdm); - registerParameter(&strokeoverlap); - registerParameter(&strokeoverlap_rdm); - registerParameter(&ends_tolerance); - registerParameter(¶llel_offset); - registerParameter(&tremble_size); - registerParameter(&tremble_frequency); + //registerParameter( dynamic_cast(&testpointA) ); + registerParameter( dynamic_cast(&nbiter_approxstrokes) ); + registerParameter( dynamic_cast(&strokelength) ); + registerParameter( dynamic_cast(&strokelength_rdm) ); + registerParameter( dynamic_cast(&strokeoverlap) ); + registerParameter( dynamic_cast(&strokeoverlap_rdm) ); + registerParameter( dynamic_cast(&ends_tolerance) ); + registerParameter( dynamic_cast(¶llel_offset) ); + registerParameter( dynamic_cast(&tremble_size) ); + registerParameter( dynamic_cast(&tremble_frequency) ); #ifdef LPE_SKETCH_USE_CONSTRUCTION_LINES - registerParameter(&nbtangents); - registerParameter(&tgt_places_rdmness); - registerParameter(&tgtscale); - registerParameter(&tgtlength); - registerParameter(&tgtlength_rdm); + registerParameter( dynamic_cast(&nbtangents) ); + registerParameter( dynamic_cast(&tgt_places_rdmness) ); + registerParameter( dynamic_cast(&tgtscale) ); + registerParameter( dynamic_cast(&tgtlength) ); + registerParameter( dynamic_cast(&tgtlength_rdm) ); #ifdef LPE_SKETCH_USE_CURVATURE - registerParameter(&min_curvature); - registerParameter(&max_curvature); + registerParameter( dynamic_cast(&min_curvature) ); + registerParameter( dynamic_cast(&max_curvature) ); #endif #endif diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 69a4dfad9..5f63e1ee9 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -60,10 +60,10 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) : show_orig_path = true; _provides_knotholder_entities = true; - registerParameter(&angle); - registerParameter(&t_attach); - registerParameter(&length_left); - registerParameter(&length_right); + registerParameter( dynamic_cast(&angle) ); + registerParameter( dynamic_cast(&t_attach) ); + registerParameter( dynamic_cast(&length_left) ); + registerParameter( dynamic_cast(&length_right) ); } LPETangentToCurve::~LPETangentToCurve() diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index c484c88a2..324893706 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -21,12 +21,12 @@ LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) : point(_("Point param:"), "tooltip of point parameter", "point_param", &wr, this), path(_("Path param:"), "tooltip of path parameter", "path_param", &wr, this,"M 0,100 100,0") { - registerParameter(&step); - registerParameter(&point); - registerParameter(&path); + registerParameter( dynamic_cast(&step) ); + registerParameter( dynamic_cast(&point) ); + registerParameter( dynamic_cast(&path) ); point.set_oncanvas_looks(SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR, 0x00ff0000); - point.param_setValue(point); + point.param_setValue(point,true); } LPEdoEffectStackTest::~LPEdoEffectStackTest() diff --git a/src/live_effects/lpe-text_label.cpp b/src/live_effects/lpe-text_label.cpp index 0c1db2f04..709d05e18 100644 --- a/src/live_effects/lpe-text_label.cpp +++ b/src/live_effects/lpe-text_label.cpp @@ -23,7 +23,7 @@ LPETextLabel::LPETextLabel(LivePathEffectObject *lpeobject) : Effect(lpeobject), label(_("Label:"), _("Text label attached to the path"), "label", &wr, this, "This is a label") { - registerParameter(&label); + registerParameter( dynamic_cast(&label) ); } LPETextLabel::~LPETextLabel() diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index 6927ee13d..ef2900775 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -350,21 +350,6 @@ Gtk::Widget *LPETransform2Pts::newWidget() vbox->pack_start(*button2, true, true, 2); vbox->pack_start(*button3, true, true, 2); vbox->pack_start(*button4, true, true, 2); - if (show_default_widgets) { - Gtk::Label *default_label = Gtk::manage(new Gtk::Label( - Glib::ustring(_("Defaults set defaultable -prefs- parameters (*)")), - Gtk::ALIGN_START)); - default_label->set_use_markup(true); - vbox->pack_start(*default_label, true, true, 2); - Gtk::HBox * defaultBox = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *set_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Set")))); - set_default->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::setDefaultParams)); - Gtk::Button *reset_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); - reset_default->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::resetDefaultParams)); - defaultBox->pack_start(*set_default, true, true, 2); - defaultBox->pack_start(*reset_default, true, true, 2); - vbox->pack_start(*defaultBox, true, true, 2); - } return dynamic_cast(vbox); } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index b9fd8908a..47e2a1cec 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -53,15 +53,15 @@ LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) : maxComplexity(_("_Max complexity:"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000) { //FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug. - registerParameter(&ref_path); - //registerParameter(&refA) ); - //registerParameter(&refB) ); - registerParameter(&generator); - registerParameter(&similar_only); - registerParameter(&nbgenerations); - registerParameter(&drawall); - registerParameter(&maxComplexity); - //registerParameter(&draw_boxes) ); + registerParameter( dynamic_cast(&ref_path) ); + //registerParameter( dynamic_cast(&refA) ); + //registerParameter( dynamic_cast(&refB) ); + registerParameter( dynamic_cast(&generator) ); + registerParameter( dynamic_cast(&similar_only) ); + registerParameter( dynamic_cast(&nbgenerations) ); + registerParameter( dynamic_cast(&drawall) ); + registerParameter( dynamic_cast(&maxComplexity) ); + //registerParameter( dynamic_cast(&draw_boxes) ); apply_to_clippath_and_mask = true; nbgenerations.param_make_integer(); nbgenerations.param_set_range(0, Geom::infinity()); diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index fa08e1f91..a600f0257 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -59,7 +59,7 @@ public: g_strfreev (strarray); return true; } - virtual void param_update_default(const gchar * default_value){}; + virtual gchar * param_getSVGValue() const { Inkscape::SVGOStringStream os; writesvg(os, _vector); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index a031b5ced..813c06b4e 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -37,17 +37,11 @@ BoolParam::param_set_default() } void -BoolParam::param_update_default(bool default_value) +BoolParam::param_update_default(bool const default_value) { defvalue = default_value; } -void -BoolParam::param_update_default(const gchar * default_value) -{ - param_update_default(helperfns_read_bool(default_value, defvalue)); -} - bool BoolParam::param_readSVGValue(const gchar * strvalue) { @@ -66,18 +60,8 @@ Gtk::Widget * BoolParam::param_newWidget() { if(!hide_widget){ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredCheckButton( label, + new Inkscape::UI::Widget::RegisteredCheckButton( param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index a96966c46..7ad8a9368 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -36,9 +36,9 @@ public: void param_setValue(bool newvalue); virtual void param_set_default(); - void param_update_default(bool default_value); - virtual void param_update_default(const gchar * default_value); + void param_update_default(bool const default_value); bool get_value() const { return value; }; + inline operator bool() const { return value; }; private: diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index 0bb2d89b2..dbfc68623 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -76,15 +76,7 @@ public: void param_set_default() { param_set_value(defvalue); } - - void param_update_default(E default_value) { - defvalue = default_value; - } - - virtual void param_update_default(const gchar * default_value) { - param_update_default(enumdataconv->get_id_from_key(Glib::ustring(default_value))); - } - + void param_set_value(E val) { value = val; } diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h index 4e4268703..b81339a69 100644 --- a/src/live_effects/parameter/filletchamferpointarray.h +++ b/src/live_effects/parameter/filletchamferpointarray.h @@ -55,7 +55,6 @@ public: virtual void set_chamfer_steps(int value_chamfer_steps); virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); - virtual void param_update_default(const gchar * default_value){}; virtual bool providesKnotHolderEntities() const { return true; } diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp index ee76c4ab9..64c203093 100644 --- a/src/live_effects/parameter/fontbutton.cpp +++ b/src/live_effects/parameter/fontbutton.cpp @@ -33,11 +33,9 @@ FontButtonParam::param_set_default() { param_setValue(defvalue); } - void -FontButtonParam::param_update_default(const gchar * default_value) -{ - defvalue = (Glib::ustring)strdup(default_value); +FontButtonParam::param_update_default(const Glib::ustring default_value){ + defvalue = default_value; } bool @@ -58,24 +56,14 @@ FontButtonParam::param_getSVGValue() const Gtk::Widget * FontButtonParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredFontButton( label, + new Inkscape::UI::Widget::RegisteredFontButton( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - Glib::ustring fontspec = (Glib::ustring)param_getSVGValue(); + Glib::ustring fontspec = param_getSVGValue(); fontbuttonwdg->setValue( fontspec); fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter")); param_effect->upd_params = false; @@ -83,12 +71,11 @@ FontButtonParam::param_newWidget() } void -FontButtonParam::param_setValue(Glib::ustring newvalue) +FontButtonParam::param_setValue(const Glib::ustring newvalue) { value = newvalue; } - } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/fontbutton.h b/src/live_effects/parameter/fontbutton.h index 60e1aa46e..df47251a2 100644 --- a/src/live_effects/parameter/fontbutton.h +++ b/src/live_effects/parameter/fontbutton.h @@ -21,15 +21,15 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const Glib::ustring default_value = "Sans 10"); + const Glib::ustring default_value = ""); virtual ~FontButtonParam() {} virtual Gtk::Widget * param_newWidget(); virtual bool param_readSVGValue(const gchar * strvalue); - void param_update_default(const gchar * default_value); + void param_update_default(const Glib::ustring defvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(Glib::ustring newvalue); + void param_setValue(const Glib::ustring newvalue); virtual void param_set_default(); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index aba61b96a..93cf2b15f 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -60,10 +60,6 @@ ItemParam::param_set_default() param_readSVGValue(defvalue); } -void -ItemParam::param_update_default(const gchar * default_value){ - defvalue = strdup(default_value); -} void ItemParam::param_set_and_write_default() @@ -108,20 +104,10 @@ ItemParam::param_getSVGValue() const Gtk::Widget * ItemParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Gtk::HBox * _widget = Gtk::manage(new Gtk::HBox()); Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); - Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(label)); + Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); pButton->set_relief(Gtk::RELIEF_NONE); diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h index 89c32f9bd..6c719d451 100644 --- a/src/live_effects/parameter/item.h +++ b/src/live_effects/parameter/item.h @@ -36,7 +36,6 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - virtual void param_update_default(const gchar * default_value); void param_set_and_write_default(); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/parameter/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp index 8db8851bf..053062128 100644 --- a/src/live_effects/parameter/originalitem.cpp +++ b/src/live_effects/parameter/originalitem.cpp @@ -46,20 +46,10 @@ OriginalItemParam::~OriginalItemParam() Gtk::Widget * OriginalItemParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Gtk::HBox *_widget = Gtk::manage(new Gtk::HBox()); { // Label - Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(label)); + Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); } diff --git a/src/live_effects/parameter/originalitem.h b/src/live_effects/parameter/originalitem.h index de1a6ac25..58d04e05a 100644 --- a/src/live_effects/parameter/originalitem.h +++ b/src/live_effects/parameter/originalitem.h @@ -26,6 +26,7 @@ public: void setInverse(bool inversed) { inverse = inversed; } bool linksToItem() const { return (href != NULL); } SPItem * getObject() const { return ref.getObject(); } + virtual Gtk::Widget * param_newWidget(); protected: diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index 388a3b5e6..1e78f7fe1 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -47,20 +47,10 @@ OriginalPathParam::~OriginalPathParam() Gtk::Widget * OriginalPathParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Gtk::HBox *_widget = Gtk::manage(new Gtk::HBox()); { // Label - Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(label)); + Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); } diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index fe9371644..296c0f7f7 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -65,11 +65,12 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - virtual void param_update_default(const gchar * default_value){}; + /** Disable the canvas indicators of parent class by overriding this method */ virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector & /*hp_vec*/) {}; + std::vector _vector; protected: diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 359a51913..befac4df1 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -107,16 +107,6 @@ ScalarParam::param_update_default(gdouble default_value) defvalue = default_value; } -void -ScalarParam::param_update_default(const gchar * default_value) -{ - double newval; - unsigned int success = sp_svg_number_read_d(default_value, &newval); - if (success == 1) { - param_update_default(newval); - } -} - void ScalarParam::param_set_value(gdouble val) { @@ -172,18 +162,8 @@ Gtk::Widget * ScalarParam::param_newWidget() { if(!hide_widget){ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( - label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); rsu->setValue(value); rsu->setDigits(digits); diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index ee1d2d547..6cf10710c 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -60,7 +60,7 @@ public: void write_to_SVG(); virtual void param_set_default() = 0; - virtual void param_update_default(const gchar * default_value) = 0; + // This creates a new widget (newed with Gtk::manage(new ...);) virtual Gtk::Widget * param_newWidget() = 0; @@ -77,7 +77,6 @@ public: virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) {}; Glib::ustring param_key; - Glib::ustring param_tooltip; Inkscape::UI::Widget::Registry * param_wr; Glib::ustring param_label; @@ -85,6 +84,7 @@ public: bool widget_is_visible; protected: + Glib::ustring param_tooltip; Effect* param_effect; @@ -112,7 +112,6 @@ public: virtual void param_set_default(); void param_update_default(gdouble default_value); - virtual void param_update_default(const gchar * default_value); void param_set_value(gdouble val); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); @@ -121,6 +120,7 @@ public: void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; double param_get_max() { return max; }; double param_get_min() { return min; }; + void param_overwrite_widget(bool overwrite_widget); virtual Gtk::Widget * param_newWidget(); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 9bdebaf47..dafc6d406 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -170,19 +170,9 @@ PathParam::param_getSVGValue() const Gtk::Widget * PathParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Gtk::HBox * _widget = Gtk::manage(new Gtk::HBox()); - Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(label)); + Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); static_cast(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); @@ -449,10 +439,6 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); } -void -PathParam::param_update_default(const gchar * default_value){ - defvalue = strdup(default_value); -} /* CALLBACK FUNCTIONS FOR THE BUTTONS */ void diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 5381a6b36..d2dddbe97 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -40,7 +40,6 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - virtual void param_update_default(const gchar * default_value); void param_set_and_write_default(); void set_new_value (Geom::PathVector const &newpath, bool write_to_svg); void set_new_value (Geom::Piecewise > const &newpath, bool write_to_svg); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 2fbe4b3b4..db768090a 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -63,19 +63,6 @@ PointParam::param_update_default(Geom::Point default_point) defvalue = default_point; } -void -PointParam::param_update_default(const gchar * default_point) -{ - gchar ** strarray = g_strsplit(default_point, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2) { - param_update_default( Geom::Point(newx, newy) ); - } -} - void PointParam::param_setValue(Geom::Point newpoint, bool write) { @@ -126,18 +113,8 @@ PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) Gtk::Widget * PointParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredTransformedPoint( label, + new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index a5153ad80..5d145a81a 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -44,8 +44,6 @@ public: Geom::Point param_get_default() const; void param_set_liveupdate(bool live_update); void param_update_default(Geom::Point default_point); - - virtual void param_update_default(const gchar * default_point); virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index a34163ca1..56a609fa8 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -39,13 +39,13 @@ public: virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); - virtual void param_update_default(const gchar * default_value){}; void set_pwd2(Geom::Piecewise > const & pwd2_in, Geom::Piecewise > const & pwd2_normal_in); Geom::Piecewise > const & get_pwd2() const { return last_pwd2; } Geom::Piecewise > const & get_pwd2_normal() const { return last_pwd2_normal; } void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise > const & pwd2_in); + friend class PowerStrokePointArrayParamKnotHolderEntity; private: diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index bcba05399..075e85ee1 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -77,20 +77,6 @@ RandomParam::param_set_default() param_set_value(defvalue, defseed); } -void -RandomParam::param_update_default(gdouble default_value){ - defvalue = default_value; -} - -void -RandomParam::param_update_default(const gchar * default_value){ - double newval; - unsigned int success = sp_svg_number_read_d(default_value, &newval); - if (success == 1) { - param_update_default(newval); - } -} - void RandomParam::param_set_value(gdouble val, long newseed) { @@ -129,18 +115,8 @@ RandomParam::resetRandomizer() Gtk::Widget * RandomParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredRandom* regrandom = Gtk::manage( - new Inkscape::UI::Widget::RegisteredRandom( label, + new Inkscape::UI::Widget::RegisteredRandom( param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index 5fb6027ac..ca4440336 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -38,9 +38,9 @@ public: void param_set_value(gdouble val, long newseed); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); - void param_update_default(gdouble default_value); - virtual void param_update_default(const gchar * default_value); + void resetRandomizer(); + operator gdouble(); inline gdouble get_value() { return value; } ; diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 5c56e8447..5c4cdf4c6 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -50,9 +50,9 @@ TextParam::param_set_default() } void -TextParam::param_update_default(const gchar * default_value) +TextParam::param_update_default(Glib::ustring default_value) { - defvalue = (Glib::ustring)default_value; + defvalue = default_value; } void @@ -119,18 +119,8 @@ TextParam::param_getSVGValue() const Gtk::Widget * TextParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( - label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); + param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); rsu->setText(value); rsu->setProgrammatically = false; @@ -140,7 +130,7 @@ TextParam::param_newWidget() } void -TextParam::param_setValue(Glib::ustring newvalue) +TextParam::param_setValue(const Glib::ustring newvalue) { param_effect->upd_params = true; value = newvalue; diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 137f3ee02..553c84c0a 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -39,16 +39,16 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(Glib::ustring newvalue); + void param_setValue(const Glib::ustring newvalue); void param_hide_canvas_text(); virtual void param_set_default(); - virtual void param_update_default(const gchar * default_value); + void param_update_default(Glib::ustring default_value); void setPos(Geom::Point pos); void setPosAndAnchor(const Geom::Piecewise > &pwd2, const double t, const double length, bool use_curvature = false); void setAnchor(double x_value, double y_value); - const Glib::ustring get_value() const { return value; }; + const Glib::ustring get_value() const { return defvalue; }; private: TextParam(const TextParam&); diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 1d1bc82a6..b3f6442bb 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -60,37 +60,15 @@ ToggleButtonParam::param_getSVGValue() const return str; } -void -ToggleButtonParam::param_update_default(bool default_value) -{ - defvalue = default_value; -} - -void -ToggleButtonParam::param_update_default(const gchar * default_value) -{ - param_update_default(helperfns_read_bool(default_value, defvalue)); -} - Gtk::Widget * ToggleButtonParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } if (_toggled_connection.connected()) { _toggled_connection.disconnect(); } checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredToggleButton( label, + new Inkscape::UI::Widget::RegisteredToggleButton( param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h index d6ca15e75..8390fec86 100644 --- a/src/live_effects/parameter/togglebutton.h +++ b/src/live_effects/parameter/togglebutton.h @@ -51,8 +51,6 @@ public: sigc::signal& signal_toggled() { return _signal_toggled; } virtual void toggled(); - void param_update_default(bool default_value); - virtual void param_update_default(const gchar * default_value); private: ToggleButtonParam(const ToggleButtonParam&); diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp index 2081a8c0c..0d03432c3 100644 --- a/src/live_effects/parameter/transformedpoint.cpp +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -82,40 +82,11 @@ TransformedPointParam::param_getSVGValue() const return str; } -void -TransformedPointParam::param_update_default(Geom::Point default_point) -{ - defvalue = default_point; -} - -void -TransformedPointParam::param_update_default(const gchar * default_point) -{ - gchar ** strarray = g_strsplit(default_point, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2) { - param_update_default( Geom::Point(newx, newy) ); - } -} - Gtk::Widget * TransformedPointParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredVector( label, + new Inkscape::UI::Widget::RegisteredVector( param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h index 269cc508e..c96bedb53 100644 --- a/src/live_effects/parameter/transformedpoint.h +++ b/src/live_effects/parameter/transformedpoint.h @@ -51,9 +51,7 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - Geom::Point param_get_default() { return defvalue; } - void param_update_default(Geom::Point default_point); - virtual void param_update_default(const gchar * default_point); + virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index 684f29555..b6ea99bfe 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -55,9 +55,9 @@ UnitParam::param_set_default() } void -UnitParam::param_update_default(const gchar * default_unit) +UnitParam::param_update_default(const Glib::ustring default_unit) { - defunit = unit_table.getUnit((Glib::ustring)default_unit); + defunit = unit_table.getUnit(default_unit); } void @@ -75,18 +75,8 @@ UnitParam::get_abbreviation() const Gtk::Widget * UnitParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredUnitMenu* unit_menu = Gtk::manage( - new Inkscape::UI::Widget::RegisteredUnitMenu(label, + new Inkscape::UI::Widget::RegisteredUnitMenu(param_label, param_key, *param_wr, param_effect->getRepr(), diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index c662b6edc..ae58cf956 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -33,10 +33,11 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); void param_set_value(Inkscape::Util::Unit const &val); - virtual void param_update_default(const gchar * default_unit); + void param_update_default(const Glib::ustring default_unit); const gchar *get_abbreviation() const; + virtual Gtk::Widget * param_newWidget(); - + operator Inkscape::Util::Unit const *() const { return unit; } private: diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index d6593871d..55b4d4b32 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -48,25 +48,6 @@ VectorParam::param_set_default() setVector(defvalue); } -void -VectorParam::param_update_default(Geom::Point default_point) -{ - defvalue = default_point; -} - -void -VectorParam::param_update_default(const gchar * default_point) -{ - gchar ** strarray = g_strsplit(default_point, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2) { - param_update_default( Geom::Point(newx, newy) ); - } -} - bool VectorParam::param_readSVGValue(const gchar * strvalue) { @@ -104,18 +85,8 @@ VectorParam::param_getSVGValue() const Gtk::Widget * VectorParam::param_newWidget() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(param_effect->effectType()); - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)param_key; - Glib::ustring label = param_label; - if(prefs->getEntry(pref_path).isValid()){ - label = (Glib::ustring)"* " + param_label; - } Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredVector( label, + new Inkscape::UI::Widget::RegisteredVector( param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index d270e9f43..edee4ff4d 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -51,8 +51,7 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - void param_update_default(Geom::Point default_point); - virtual void param_update_default(const gchar * default_point); + virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); diff --git a/src/preferences.cpp b/src/preferences.cpp index 2849fe068..4d522a1d8 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -512,35 +512,6 @@ void Preferences::remove(Glib::ustring const &pref_path) Inkscape::XML::Node *node = _getNode(pref_path, false); if (node && node->parent()) { node->parent()->removeChild(node); - } else { //Handle to remove also attributes in path not only the container node - // verify path - g_assert( pref_path.at(0) == '/' ); - if (_prefs_doc == NULL){ - return; - } - node = _prefs_doc->root(); - Inkscape::XML::Node *child = NULL; - gchar **splits = g_strsplit(pref_path.c_str(), "/", 0); - if ( splits ) { - for (int part_i = 0; splits[part_i]; ++part_i) { - // skip empty path segments - if (!splits[part_i][0]) { - continue; - } - if (!node->firstChild()) { - node->setAttribute(splits[part_i], NULL); - g_strfreev(splits); - return; - } - for (child = node->firstChild(); child; child = child->next()) { - if (!strcmp(splits[part_i], child->attribute("id"))) { - break; - } - } - node = child; - } - } - g_strfreev(splits); } } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6e12104f0..646439613 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -27,10 +27,7 @@ #include "preferences.h" #include "verbs.h" #include "selcue.h" -#include "live_effects/effect-enum.h" -#include "live_effects/effect.h" -#include "live_effects/lpeobject.h" -#include "sp-defs.h" + #include "extension/internal/gdkpixbuf-input.h" #include "message-stack.h" #include "style.h" @@ -823,93 +820,6 @@ void InkscapePreferences::initPageUI() this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS); initKeyboardShortcuts(iter_ui); - - _page_lpe.add_group_header( _("Allow set default to this parameters:")); - SPDocument * doc = SP_ACTIVE_DOCUMENT; - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect"); - lpe_repr->setAttribute("id", "deleteme"); - SPObject *lpeo = SP_OBJECT(doc->getDefs()->appendChildRepr(lpe_repr)); - Inkscape::GC::release(lpe_repr); - Inkscape::UI::Widget::Registry * wr; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - for ( int le = Inkscape::LivePathEffect::EffectType::BEND_PATH; le != Inkscape::LivePathEffect::EffectType::INVALID_LPE; ++le){ - Inkscape::LivePathEffect::EffectType lpenr = static_cast(le); - Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(lpenr); - Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(lpenr); - bool is_text_label_lpe = effectkey == (Glib::ustring)"text_label"; - if (!effectname.empty() && !is_text_label_lpe){ - lpeo->setAttribute("effect", effectkey.c_str()); - LivePathEffectObject * lpeobj = dynamic_cast(lpeo); - Glib::ustring liveeffect = effectname +(Glib::ustring)_(":"); - Inkscape::LivePathEffect::Effect* effect = Inkscape::LivePathEffect::Effect::New(lpenr, lpeobj); - std::vector param_vector = effect->getParamVector(); - if (param_vector.size() == 1) { - continue; - } - std::vector::iterator it = param_vector.begin(); - Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); - vbox_expander->set_border_width(10); - vbox_expander->set_spacing(2); - while (it != param_vector.end()) { - Inkscape::LivePathEffect::Parameter * param = *it; - const gchar * key = param->param_key.c_str(); - if (strcmp(key,"is_visible") == 0 ){ - ++it; - continue; - } - const gchar * value = param->param_label.c_str(); - const gchar * tooltip_extra = _(". Toogling this check in preferences reset to default custom values for this parameter"); - Glib::ustring tooltip = param->param_tooltip + (Glib::ustring)tooltip_extra; - Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + - effectkey + - (Glib::ustring)"/" + - (Glib::ustring)key; - bool valid = prefs->getEntry(pref_path).isValid(); - bool set = false; - if(valid){ - set = true; - } - Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredCheckButton( param->param_label, - tooltip, - param->param_key, - *wr, - false, - NULL, - NULL) ); - checkwdg->setActive(set); - checkwdg->setProgrammatically = false; - checkwdg->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &InkscapePreferences::defaultLpeUpdater), pref_path, checkwdg)); - vbox_expander->pack_start(*dynamic_cast (checkwdg), true, true, 2); - ++it; - } - - Gtk::Expander * expander = Gtk::manage(new Gtk::Expander(liveeffect)); - expander->add(*vbox_expander); - expander->set_expanded(false); - Glib::ustring tip = (Glib::ustring)_("Set defaultables parameters for ") + liveeffect; - _page_lpe.add_line( true, "", *dynamic_cast(expander), "", tip.c_str() ); - } - } - lpeo->deleteObject(); - this->AddPage(_page_lpe, _("Live Effects"), iter_ui, PREFS_PAGE_UI_LPE); -} - -void -InkscapePreferences::defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Widget::RegisteredCheckButton * checkwdg) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (checkwdg->get_active()) - { - prefs->setString(pref_path, "--default"); - - } else { - prefs->remove(pref_path); - prefs->remove((Glib::ustring)"/live_effects/gdsgddssdggdsgdsgdsgs"); - prefs->remove((Glib::ustring)"/ddsdsdsgdsg"); - } } #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -2132,7 +2042,7 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) _page_list.expand_row(_path_tools, false); if (desired_page >= PREFS_PAGE_TOOLS_SHAPES && desired_page <= PREFS_PAGE_TOOLS_SHAPES_SPIRAL) _page_list.expand_row(_path_shapes, false); - if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_LPE) + if (desired_page >= PREFS_PAGE_UI && desired_page <= PREFS_PAGE_UI_KEYBOARD_SHORTCUTS) _page_list.expand_row(_path_ui, false); if (desired_page >= PREFS_PAGE_BEHAVIOR && desired_page <= PREFS_PAGE_BEHAVIOR_MASKS) _page_list.expand_row(_path_behavior, false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 6320ff49c..e6ba4e4b2 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -22,7 +22,6 @@ #include #include #include "ui/widget/preferences-widget.h" -#include "ui/widget/registered-widget.h" #include "ui/widget/button.h" #include #include @@ -31,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -75,7 +73,6 @@ enum { PREFS_PAGE_UI_WINDOWS, PREFS_PAGE_UI_GRIDS, PREFS_PAGE_UI_KEYBOARD_SHORTCUTS, - PREFS_PAGE_UI_LPE, PREFS_PAGE_BEHAVIOR, PREFS_PAGE_BEHAVIOR_SELECTING, PREFS_PAGE_BEHAVIOR_TRANSFORMS, @@ -190,7 +187,6 @@ protected: UI::Widget::DialogPage _page_spellcheck; UI::Widget::DialogPage _page_keyshortcuts; - UI::Widget::DialogPage _page_lpe; UI::Widget::PrefSpinButton _mouse_sens; UI::Widget::PrefSpinButton _mouse_thres; @@ -494,7 +490,7 @@ protected: Gtk::TreeModel::iterator AddPage(UI::Widget::DialogPage& p, Glib::ustring title, Gtk::TreeModel::iterator parent, int id); bool SetMaxDialogSize(const Gtk::TreeModel::iterator& iter); bool PresentPage(const Gtk::TreeModel::iterator& iter); - void defaultLpeUpdater(Glib::ustring pref_path, Inkscape::UI::Widget::RegisteredCheckButton * checkwdg); + static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); -- cgit v1.2.3 From e5601e5e84df30c40d93271fd69cecd31391e309 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 29 Apr 2017 02:01:22 +0200 Subject: Rewrite UX (bzr r15620.1.12) --- src/live_effects/effect.cpp | 102 +++++++++++++- src/live_effects/effect.h | 6 +- src/live_effects/lpe-measure-line.cpp | 152 ++++++++------------- src/live_effects/lpe-measure-line.h | 1 - src/live_effects/parameter/array.h | 2 +- src/live_effects/parameter/bool.cpp | 6 + src/live_effects/parameter/bool.h | 2 +- src/live_effects/parameter/enum.h | 10 +- .../parameter/filletchamferpointarray.h | 1 + src/live_effects/parameter/fontbutton.cpp | 7 +- src/live_effects/parameter/fontbutton.h | 6 +- src/live_effects/parameter/item.cpp | 4 + src/live_effects/parameter/item.h | 1 + src/live_effects/parameter/originalpatharray.h | 3 +- src/live_effects/parameter/parameter.cpp | 10 ++ src/live_effects/parameter/parameter.h | 6 +- src/live_effects/parameter/path.cpp | 4 + src/live_effects/parameter/path.h | 1 + src/live_effects/parameter/point.cpp | 13 ++ src/live_effects/parameter/point.h | 2 + src/live_effects/parameter/powerstrokepointarray.h | 2 +- src/live_effects/parameter/random.cpp | 14 ++ src/live_effects/parameter/random.h | 4 +- src/live_effects/parameter/text.cpp | 4 +- src/live_effects/parameter/text.h | 6 +- src/live_effects/parameter/togglebutton.cpp | 14 +- src/live_effects/parameter/togglebutton.h | 2 + src/live_effects/parameter/transformedpoint.cpp | 19 +++ src/live_effects/parameter/transformedpoint.h | 4 +- src/live_effects/parameter/unit.cpp | 4 +- src/live_effects/parameter/unit.h | 5 +- src/live_effects/parameter/vector.cpp | 19 +++ src/live_effects/parameter/vector.h | 3 +- src/preferences.cpp | 29 ++++ src/ui/dialog/livepatheffect-editor.cpp | 19 ++- 35 files changed, 351 insertions(+), 136 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index bfcca422e..37694f32f 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -73,6 +73,7 @@ #include "path-chemistry.h" #include "xml/sp-css-attr.h" #include "live_effects/lpeobject.h" +#include #include "display/curve.h" #include #include @@ -80,7 +81,7 @@ namespace Inkscape { namespace LivePathEffect { -const Glib::ustring DEFAULT_PREF_VALUE = "--default"; + const Util::EnumData LPETypeData[] = { // {constant defined in effect-enum.h, N_("name of your effect"), "name of your effect in SVG"} #ifdef LPE_ENABLE_TEST_EFFECTS @@ -645,6 +646,7 @@ void Effect::readallParameters(Inkscape::XML::Node const* repr) { std::vector::iterator it = param_vector.begin(); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); while (it != param_vector.end()) { Parameter * param = *it; const gchar * key = param->param_key.c_str(); @@ -655,10 +657,17 @@ Effect::readallParameters(Inkscape::XML::Node const* repr) g_warning("Effect::readallParameters - '%s' not accepted for %s", value, key); } } else { - // set default value - param->param_set_default(); + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + (Glib::ustring)LPETypeConverter.get_key(effectType()).c_str() + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(pref_path).isValid(); + if(valid){ + param->param_update_default(prefs->getString(pref_path).c_str()); + } else { + param->param_set_default(); + } } - ++it; } } @@ -777,6 +786,91 @@ Effect::newWidget() return dynamic_cast(vbox); } +/** + * This *creates* a new widget, with default values setter + */ +Gtk::Widget * +Effect::defaultParamSet() +{ + // use manage here, because after deletion of Effect object, others might still be pointing to this widget. + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox() ); + + vbox->set_border_width(5); + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); + vbox_expander->set_border_width(10); + vbox_expander->set_spacing(2); + Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(effectType()); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(effectType()); + std::vector::iterator it = param_vector.begin(); + Inkscape::UI::Widget::Registry * wr; + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Glib::ustring * tip = param->param_getTooltip(); + const gchar * key = param->param_key.c_str(); + const gchar * value = param->param_label.c_str(); + const gchar * tooltip_extra = _(". Change custom values for this parameter"); + Glib::ustring tooltip = param->param_tooltip + (Glib::ustring)tooltip_extra; + Glib::ustring pref_path = (Glib::ustring)"/live_effects/" + + effectkey + + (Glib::ustring)"/" + + (Glib::ustring)key; + bool valid = prefs->getEntry(pref_path).isValid(); + const gchar * set_or_upd; + if (valid) { + set_or_upd = _("Update"); + } else { + set_or_upd = _("Set"); + } + Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) ); + Gtk::Label *parameter_label = Gtk::manage(new Gtk::Label(value, Gtk::ALIGN_START)); + parameter_label->set_use_markup(true); + parameter_label->set_use_underline (true); + parameter_label->set_ellipsize(Pango::ELLIPSIZE_END); + vbox_param->pack_start(*parameter_label, true, true, 2); + Gtk::Button *set = Gtk::manage(new Gtk::Button((Glib::ustring)set_or_upd)); + Gtk::Button *unset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Unset")))); + unset->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &Effect::unsetDefaultParam), pref_path, set, unset)); + set->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &Effect::setDefaultParam), pref_path, param->param_getSVGValue(), set, unset)); + if (!valid) { + unset->set_sensitive(false); + } + vbox_param->pack_start(*set, true, true, 2); + vbox_param->pack_start(*unset, true, true, 2); + + vbox_expander->pack_start(*vbox_param, true, true, 2); + } + ++it; + } + Glib::ustring tip = "" + effectname + (Glib::ustring)_(": Set default parameters to current values"); + Gtk::Expander * expander = Gtk::manage(new Gtk::Expander(tip)); + expander->set_use_markup(true); + expander->add(*vbox_expander); + expander->set_expanded(false); + vbox->pack_start(*dynamic_cast (expander), true, true, 2); + return dynamic_cast(vbox); +} + +void +Effect::setDefaultParam(Glib::ustring pref_path, gchar * value, Gtk::Button *set , Gtk::Button *unset) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(pref_path, (Glib::ustring)value); + gchar * label = _("Update"); + set->set_label((Glib::ustring)label); + unset->set_sensitive(true); +} + +void +Effect::unsetDefaultParam(Glib::ustring pref_path, Gtk::Button *set, Gtk::Button *unset) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->remove(pref_path); + gchar * label = _("Set"); + set->set_label((Glib::ustring)label); + unset->set_sensitive(false); +} Inkscape::XML::Node *Effect::getRepr() { diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index f5e41d50e..c34c391c0 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -94,7 +94,7 @@ public: virtual void doEffect (SPCurve * curve); virtual Gtk::Widget * newWidget(); - + virtual Gtk::Widget * defaultParamSet(); /** * Sets all parameters to their default values and writes them to SVG. */ @@ -172,13 +172,15 @@ protected: // this boolean defaults to false, it concatenates the input path to one pwd2, // instead of normally 'splitting' the path into continuous pwd2 paths and calling doEffect_pwd2 for each. bool concatenate_before_pwd2; - SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them. SPShape * sp_shape; // these get stored in doBeforeEffect_impl before doEffect chain, or in performPathEffects on groups, and derived classes may do as they please with them. std::vector items; double current_zoom; std::vector selectedNodesPoints; + private: + void setDefaultParam(Glib::ustring pref_path, gchar * value, Gtk::Button *set , Gtk::Button *unset); + void unsetDefaultParam(Glib::ustring pref_path, Gtk::Button *set , Gtk::Button *unset); bool provides_own_flash_paths; // if true, the standard flash path is suppressed bool is_ready; diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index 86d72615c..52aa56fa0 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -49,32 +49,33 @@ static const Util::EnumDataConverter OMConverter(OrientationM LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : Effect(lpeobject), - unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"), - fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this), + unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"), + fontbutton(_("Font"), _("Font Selector"), "fontbutton", &wr, this), orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false), curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1), - precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2), - position(_("Position*"), _("Position"), "position", &wr, this, 5), - text_top_bottom(_("Text top/bottom*"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), - text_right_left(_("Text right/left*"), _("Text right/left"), "text_right_left", &wr, this, 0), - helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), - helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), - scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0), - format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), + precision(_("Precision"), _("Precision"), "precision", &wr, this, 2), + position(_("Position"), _("Position"), "position", &wr, this, 5), + text_top_bottom(_("Text top/bottom"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0), + text_right_left(_("Text right/left"), _("Text right/left"), "text_right_left", &wr, this, 0), + helpline_distance(_("Helpline distance"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0), + helpline_overlap(_("Helpline overlap"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0), + scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0), + format(_("Format"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"), id_origin("id_origin", "id_origin", "id_origin", &wr, this,""), arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false), - flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false), - scale_sensitive(_("Scale sensitive*"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), - local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true), - line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), - rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), - hide_back(_("Hide if label over*"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), - dimline_format(_("CSS DIN line*"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), - helperlines_format(_("CSS helpers*"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), - anotation_format(_("CSS anotation*"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), - arrows_format(_("CSS arrows*"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), + flip_side(_("Flip side"), _("Flip side"), "flip_side", &wr, this, false), + scale_sensitive(_("Scale sensitive"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true), + local_locale(_("Local Number Format"), _("Local number format"), "local_locale", &wr, this, true), + line_group_05(_("Line Group 0.5"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true), + rotate_anotation(_("Rotate Anotation"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true), + hide_back(_("Hide if label over"), _("Hide DIN line if label over"), "hide_back", &wr, this, true), + dimline_format(_("CSS DIN line"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""), + helperlines_format(_("CSS helpers"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""), + anotation_format(_("CSS anotation"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""), + arrows_format(_("CSS arrows"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""), expanded(false) { + //set to true the parameters you want to be changed his default values registerParameter(&unit); registerParameter(&fontbutton); registerParameter(&orientation); @@ -99,39 +100,16 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) : registerParameter(&anotation_format); registerParameter(&arrows_format); registerParameter(&id_origin); + id_origin.param_hide_canvas_text(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton"); - if(fontbutton_value.empty()){ - fontbutton_value = "Sans 10"; - } - fontbutton.param_update_default(fontbutton_value); - scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0)); - precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2)); - position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0)); - text_top_bottom.param_update_default(prefs->getDouble("/live_effects/measure-line/text_top_bottom", 5.0)); - helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0)); - helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0)); - Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit"); - if(unit_value.empty()){ - unit_value = "px"; - } - unit.param_update_default(unit_value); + Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format"); if(format_value.empty()){ format_value = "{measure}{unit}"; } - format.param_update_default(format_value); - dimline_format.param_update_default(prefs->getString("/live_effects/measure-line/dimline_format")); - helperlines_format.param_update_default(prefs->getString("/live_effects/measure-line/helperlines_format")); - anotation_format.param_update_default(prefs->getString("/live_effects/measure-line/anotation_format")); - arrows_format.param_update_default(prefs->getString("/live_effects/measure-line/arrows_format")); - flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side")); - scale_sensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_sensitive")); - local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale")); - line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05")); - rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation")); - hide_back.param_update_default(prefs->getBool("/live_effects/measure-line/hide_back")); + format.param_update_default(format_value.c_str()); + format.param_hide_canvas_text(); dimline_format.param_hide_canvas_text(); helperlines_format.param_hide_canvas_text(); @@ -375,7 +353,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl items.push_back(id); Geom::OptRect bounds = SP_ITEM(elemref)->bounds(SPItem::GEOMETRIC_BBOX); if (bounds) { - anotation_width = bounds->width() * 1.4; + anotation_width = bounds->width() * 1.15; } } @@ -405,8 +383,14 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, const char * id, b k = (Geom::distance(start,end)/2.0) - arrow_gap - (anotation_width/2.0); } if (Geom::distance(start,end) < anotation_width){ - return; + if ((elemref = document->getObjectById(id))) { + if (remove) { + elemref->deleteObject(); + } + return; + } } + //k = std::max(k , arrow_gap -1); Geom::Ray ray(end, start); Geom::Coord angle = ray.angle(); line_path.start(start); @@ -622,6 +606,9 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } bool overflow = false; const char * downline = g_strdup(Glib::ustring("downline-").append(this->getRepr()->attribute("id")).c_str()); + //delete residual lines if exist + createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); + //Create it if ((anotation_width/2) + std::abs(text_right_left) > Geom::distance(start,end)/2.0) { Geom::Point sstart = end - Point::polar(angle_cross, position); Geom::Point send = end - Point::polar(angle_cross, position); @@ -645,9 +632,6 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } overflow = true; createLine(sstart, prog_end, downline, true, overflow, false, false); - } else { - //erase it - createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false); } //LINE arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str()); @@ -708,44 +692,41 @@ Gtk::Widget *LPEMeasureLine::newWidget() vbox->set_spacing(2); std::vector::iterator it = param_vector.begin(); - Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0)); Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); vbox_expander->set_border_width(0); vbox_expander->set_spacing(2); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; - Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); - Glib::ustring *tip = param->param_getTooltip(); - if (widg) { - if (param->param_key != "dimline_format" && - param->param_key != "helperlines_format" && - param->param_key != "arrows_format" && - param->param_key != "anotation_format") { - vbox->pack_start(*widg, true, true, 2); - } else { - vbox_expander->pack_start(*widg, true, true, 2); - } - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); + if (param->param_key != "id_origin") { + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + if (param->param_key != "dimline_format" && + param->param_key != "helperlines_format" && + param->param_key != "arrows_format" && + param->param_key != "anotation_format") { + vbox->pack_start(*widg, true, true, 2); + } else { + vbox_expander->pack_start(*widg, true, true, 2); + } + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } } } } ++it; } - Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default")))); - save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault)); - button1->pack_start(*save_default, true, true, 2); expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override")))); expander->add(*vbox_expander); expander->set_expanded(expanded); expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureLine::onExpanderChanged) ); vbox->pack_start(*expander, true, true, 2); - vbox->pack_start(*button1, true, true, 2); return dynamic_cast(vbox); } @@ -766,31 +747,6 @@ LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in) return path_in; } -void -LPEMeasureLine::saveDefault() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString("/live_effects/measure-line/fontbutton", Glib::ustring(fontbutton.param_getSVGValue())); - prefs->setDouble("/live_effects/measure-line/scale", scale); - prefs->setInt("/live_effects/measure-line/precision", precision); - prefs->setDouble("/live_effects/measure-line/position", position); - prefs->setDouble("/live_effects/measure-line/text_top_bottom", text_top_bottom); - prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance); - prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap); - prefs->setString("/live_effects/measure-line/unit", Glib::ustring(unit.get_abbreviation())); - prefs->setString("/live_effects/measure-line/format", Glib::ustring(format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/dimline_format", Glib::ustring(dimline_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/helperlines_format", Glib::ustring(helperlines_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/anotation_format", Glib::ustring(anotation_format.param_getSVGValue())); - prefs->setString("/live_effects/measure-line/arrows_format", Glib::ustring(arrows_format.param_getSVGValue())); - prefs->setBool("/live_effects/measure-line/flip_side", flip_side); - prefs->setBool("/live_effects/measure-line/scale_sensitive", scale_sensitive); - prefs->setBool("/live_effects/measure-line/local_locale", local_locale); - prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05); - prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation); - prefs->setBool("/live_effects/measure-line/hide_back", hide_back); -} - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h index 724c0d924..b42f7cfd5 100644 --- a/src/live_effects/lpe-measure-line.h +++ b/src/live_effects/lpe-measure-line.h @@ -49,7 +49,6 @@ public: void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove, bool valid); void onExpanderChanged(); void createArrowMarker(const char * mode); - void saveDefault(); virtual Gtk::Widget *newWidget(); private: UnitParam unit; diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index a600f0257..fa08e1f91 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -59,7 +59,7 @@ public: g_strfreev (strarray); return true; } - + virtual void param_update_default(const gchar * default_value){}; virtual gchar * param_getSVGValue() const { Inkscape::SVGOStringStream os; writesvg(os, _vector); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 813c06b4e..fafa71368 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -42,6 +42,12 @@ BoolParam::param_update_default(bool const default_value) defvalue = default_value; } +void +BoolParam::param_update_default(const gchar * default_value) +{ + param_update_default(helperfns_read_bool(default_value, defvalue)); +} + bool BoolParam::param_readSVGValue(const gchar * strvalue) { diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 7ad8a9368..39f328eaa 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -37,8 +37,8 @@ public: void param_setValue(bool newvalue); virtual void param_set_default(); void param_update_default(bool const default_value); + virtual void param_update_default(const gchar * default_value); bool get_value() const { return value; }; - inline operator bool() const { return value; }; private: diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index dbfc68623..0bb2d89b2 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -76,7 +76,15 @@ public: void param_set_default() { param_set_value(defvalue); } - + + void param_update_default(E default_value) { + defvalue = default_value; + } + + virtual void param_update_default(const gchar * default_value) { + param_update_default(enumdataconv->get_id_from_key(Glib::ustring(default_value))); + } + void param_set_value(E val) { value = val; } diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h index b81339a69..4e4268703 100644 --- a/src/live_effects/parameter/filletchamferpointarray.h +++ b/src/live_effects/parameter/filletchamferpointarray.h @@ -55,6 +55,7 @@ public: virtual void set_chamfer_steps(int value_chamfer_steps); virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); + virtual void param_update_default(const gchar * default_value){}; virtual bool providesKnotHolderEntities() const { return true; } diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp index 64c203093..5ec98df8c 100644 --- a/src/live_effects/parameter/fontbutton.cpp +++ b/src/live_effects/parameter/fontbutton.cpp @@ -33,9 +33,11 @@ FontButtonParam::param_set_default() { param_setValue(defvalue); } + void -FontButtonParam::param_update_default(const Glib::ustring default_value){ - defvalue = default_value; +FontButtonParam::param_update_default(const gchar * default_value) +{ + defvalue = (Glib::ustring)strdup(default_value); } bool @@ -76,6 +78,7 @@ FontButtonParam::param_setValue(const Glib::ustring newvalue) value = newvalue; } + } /* namespace LivePathEffect */ } /* namespace Inkscape */ diff --git a/src/live_effects/parameter/fontbutton.h b/src/live_effects/parameter/fontbutton.h index df47251a2..60e1aa46e 100644 --- a/src/live_effects/parameter/fontbutton.h +++ b/src/live_effects/parameter/fontbutton.h @@ -21,15 +21,15 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - const Glib::ustring default_value = ""); + const Glib::ustring default_value = "Sans 10"); virtual ~FontButtonParam() {} virtual Gtk::Widget * param_newWidget(); virtual bool param_readSVGValue(const gchar * strvalue); - void param_update_default(const Glib::ustring defvalue); + void param_update_default(const gchar * default_value); virtual gchar * param_getSVGValue() const; - void param_setValue(const Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue); virtual void param_set_default(); diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 93cf2b15f..7b40f4540 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -60,6 +60,10 @@ ItemParam::param_set_default() param_readSVGValue(defvalue); } +void +ItemParam::param_update_default(const gchar * default_value){ + defvalue = strdup(default_value); +} void ItemParam::param_set_and_write_default() diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h index 6c719d451..89c32f9bd 100644 --- a/src/live_effects/parameter/item.h +++ b/src/live_effects/parameter/item.h @@ -36,6 +36,7 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); + virtual void param_update_default(const gchar * default_value); void param_set_and_write_default(); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h index 296c0f7f7..fe9371644 100644 --- a/src/live_effects/parameter/originalpatharray.h +++ b/src/live_effects/parameter/originalpatharray.h @@ -65,12 +65,11 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - + virtual void param_update_default(const gchar * default_value){}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {}; /** Disable the canvas indicators of parent class by overriding this method */ virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector & /*hp_vec*/) {}; - std::vector _vector; protected: diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index befac4df1..15c81d543 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -107,6 +107,16 @@ ScalarParam::param_update_default(gdouble default_value) defvalue = default_value; } +void +ScalarParam::param_update_default(const gchar * default_value) +{ + double newval; + unsigned int success = sp_svg_number_read_d(default_value, &newval); + if (success == 1) { + param_update_default(newval); + } +} + void ScalarParam::param_set_value(gdouble val) { diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 6cf10710c..ee1d2d547 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -60,7 +60,7 @@ public: void write_to_SVG(); virtual void param_set_default() = 0; - + virtual void param_update_default(const gchar * default_value) = 0; // This creates a new widget (newed with Gtk::manage(new ...);) virtual Gtk::Widget * param_newWidget() = 0; @@ -77,6 +77,7 @@ public: virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) {}; Glib::ustring param_key; + Glib::ustring param_tooltip; Inkscape::UI::Widget::Registry * param_wr; Glib::ustring param_label; @@ -84,7 +85,6 @@ public: bool widget_is_visible; protected: - Glib::ustring param_tooltip; Effect* param_effect; @@ -112,6 +112,7 @@ public: virtual void param_set_default(); void param_update_default(gdouble default_value); + virtual void param_update_default(const gchar * default_value); void param_set_value(gdouble val); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); @@ -120,7 +121,6 @@ public: void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; double param_get_max() { return max; }; double param_get_min() { return min; }; - void param_overwrite_widget(bool overwrite_widget); virtual Gtk::Widget * param_newWidget(); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index dafc6d406..aa87508ab 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -439,6 +439,10 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG); } +void +PathParam::param_update_default(const gchar * default_value){ + defvalue = strdup(default_value); +} /* CALLBACK FUNCTIONS FOR THE BUTTONS */ void diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index d2dddbe97..5381a6b36 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -40,6 +40,7 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); + virtual void param_update_default(const gchar * default_value); void param_set_and_write_default(); void set_new_value (Geom::PathVector const &newpath, bool write_to_svg); void set_new_value (Geom::Piecewise > const &newpath, bool write_to_svg); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index db768090a..561f1b34c 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -63,6 +63,19 @@ PointParam::param_update_default(Geom::Point default_point) defvalue = default_point; } +void +PointParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + void PointParam::param_setValue(Geom::Point newpoint, bool write) { diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 5d145a81a..a5153ad80 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -44,6 +44,8 @@ public: Geom::Point param_get_default() const; void param_set_liveupdate(bool live_update); void param_update_default(Geom::Point default_point); + + virtual void param_update_default(const gchar * default_point); virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h index 56a609fa8..a34163ca1 100644 --- a/src/live_effects/parameter/powerstrokepointarray.h +++ b/src/live_effects/parameter/powerstrokepointarray.h @@ -39,13 +39,13 @@ public: virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); + virtual void param_update_default(const gchar * default_value){}; void set_pwd2(Geom::Piecewise > const & pwd2_in, Geom::Piecewise > const & pwd2_normal_in); Geom::Piecewise > const & get_pwd2() const { return last_pwd2; } Geom::Piecewise > const & get_pwd2_normal() const { return last_pwd2_normal; } void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise > const & pwd2_in); - friend class PowerStrokePointArrayParamKnotHolderEntity; private: diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index 075e85ee1..90e53ca0e 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -77,6 +77,20 @@ RandomParam::param_set_default() param_set_value(defvalue, defseed); } +void +RandomParam::param_update_default(gdouble default_value){ + defvalue = default_value; +} + +void +RandomParam::param_update_default(const gchar * default_value){ + double newval; + unsigned int success = sp_svg_number_read_d(default_value, &newval); + if (success == 1) { + param_update_default(newval); + } +} + void RandomParam::param_set_value(gdouble val, long newseed) { diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index ca4440336..5fb6027ac 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -38,9 +38,9 @@ public: void param_set_value(gdouble val, long newseed); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); - + void param_update_default(gdouble default_value); + virtual void param_update_default(const gchar * default_value); void resetRandomizer(); - operator gdouble(); inline gdouble get_value() { return value; } ; diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 5c4cdf4c6..84603149e 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -50,9 +50,9 @@ TextParam::param_set_default() } void -TextParam::param_update_default(Glib::ustring default_value) +TextParam::param_update_default(const gchar * default_value) { - defvalue = default_value; + defvalue = (Glib::ustring)default_value; } void diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 553c84c0a..137f3ee02 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -39,16 +39,16 @@ public: virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; - void param_setValue(const Glib::ustring newvalue); + void param_setValue(Glib::ustring newvalue); void param_hide_canvas_text(); virtual void param_set_default(); - void param_update_default(Glib::ustring default_value); + virtual void param_update_default(const gchar * default_value); void setPos(Geom::Point pos); void setPosAndAnchor(const Geom::Piecewise > &pwd2, const double t, const double length, bool use_curvature = false); void setAnchor(double x_value, double y_value); - const Glib::ustring get_value() const { return defvalue; }; + const Glib::ustring get_value() const { return value; }; private: TextParam(const TextParam&); diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index b3f6442bb..b8058e9c8 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -60,6 +60,18 @@ ToggleButtonParam::param_getSVGValue() const return str; } +void +ToggleButtonParam::param_update_default(bool default_value) +{ + defvalue = default_value; +} + +void +ToggleButtonParam::param_update_default(const gchar * default_value) +{ + param_update_default(helperfns_read_bool(default_value, defvalue)); +} + Gtk::Widget * ToggleButtonParam::param_newWidget() { @@ -68,7 +80,7 @@ ToggleButtonParam::param_newWidget() } checkwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredToggleButton( param_label, + new Inkscape::UI::Widget::RegisteredToggleButton(param_label, param_tooltip, param_key, *param_wr, diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h index 8390fec86..d6ca15e75 100644 --- a/src/live_effects/parameter/togglebutton.h +++ b/src/live_effects/parameter/togglebutton.h @@ -51,6 +51,8 @@ public: sigc::signal& signal_toggled() { return _signal_toggled; } virtual void toggled(); + void param_update_default(bool default_value); + virtual void param_update_default(const gchar * default_value); private: ToggleButtonParam(const ToggleButtonParam&); diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp index 0d03432c3..22d5ba3a4 100644 --- a/src/live_effects/parameter/transformedpoint.cpp +++ b/src/live_effects/parameter/transformedpoint.cpp @@ -82,6 +82,25 @@ TransformedPointParam::param_getSVGValue() const return str; } +void +TransformedPointParam::param_update_default(Geom::Point default_point) +{ + defvalue = default_point; +} + +void +TransformedPointParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + Gtk::Widget * TransformedPointParam::param_newWidget() { diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h index c96bedb53..269cc508e 100644 --- a/src/live_effects/parameter/transformedpoint.h +++ b/src/live_effects/parameter/transformedpoint.h @@ -51,7 +51,9 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - + Geom::Point param_get_default() { return defvalue; } + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index b6ea99bfe..b78b75dbf 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -55,9 +55,9 @@ UnitParam::param_set_default() } void -UnitParam::param_update_default(const Glib::ustring default_unit) +UnitParam::param_update_default(const gchar * default_unit) { - defunit = unit_table.getUnit(default_unit); + defunit = unit_table.getUnit((Glib::ustring)default_unit); } void diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index ae58cf956..c662b6edc 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -33,11 +33,10 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); void param_set_value(Inkscape::Util::Unit const &val); - void param_update_default(const Glib::ustring default_unit); + virtual void param_update_default(const gchar * default_unit); const gchar *get_abbreviation() const; - virtual Gtk::Widget * param_newWidget(); - + operator Inkscape::Util::Unit const *() const { return unit; } private: diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp index 55b4d4b32..470fa9c2d 100644 --- a/src/live_effects/parameter/vector.cpp +++ b/src/live_effects/parameter/vector.cpp @@ -48,6 +48,25 @@ VectorParam::param_set_default() setVector(defvalue); } +void +VectorParam::param_update_default(Geom::Point default_point) +{ + defvalue = default_point; +} + +void +VectorParam::param_update_default(const gchar * default_point) +{ + gchar ** strarray = g_strsplit(default_point, ",", 2); + double newx, newy; + unsigned int success = sp_svg_number_read_d(strarray[0], &newx); + success += sp_svg_number_read_d(strarray[1], &newy); + g_strfreev (strarray); + if (success == 2) { + param_update_default( Geom::Point(newx, newy) ); + } +} + bool VectorParam::param_readSVGValue(const gchar * strvalue) { diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h index edee4ff4d..d270e9f43 100644 --- a/src/live_effects/parameter/vector.h +++ b/src/live_effects/parameter/vector.h @@ -51,7 +51,8 @@ public: void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); void set_oncanvas_color(guint32 color); - + void param_update_default(Geom::Point default_point); + virtual void param_update_default(const gchar * default_point); virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); diff --git a/src/preferences.cpp b/src/preferences.cpp index 4d522a1d8..2849fe068 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -512,6 +512,35 @@ void Preferences::remove(Glib::ustring const &pref_path) Inkscape::XML::Node *node = _getNode(pref_path, false); if (node && node->parent()) { node->parent()->removeChild(node); + } else { //Handle to remove also attributes in path not only the container node + // verify path + g_assert( pref_path.at(0) == '/' ); + if (_prefs_doc == NULL){ + return; + } + node = _prefs_doc->root(); + Inkscape::XML::Node *child = NULL; + gchar **splits = g_strsplit(pref_path.c_str(), "/", 0); + if ( splits ) { + for (int part_i = 0; splits[part_i]; ++part_i) { + // skip empty path segments + if (!splits[part_i][0]) { + continue; + } + if (!node->firstChild()) { + node->setAttribute(splits[part_i], NULL); + g_strfreev(splits); + return; + } + for (child = node->firstChild(); child; child = child->next()) { + if (!strcmp(splits[part_i], child->attribute("id"))) { + break; + } + } + node = child; + } + } + g_strfreev(splits); } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e5becdb5c..455c12bc3 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -19,7 +19,7 @@ #include "livepatheffect-editor.h" #include "desktop.h" - +#include #include "document.h" #include "document-undo.h" #include "helper/action.h" @@ -193,8 +193,14 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) if ( ! effect.upd_params ) { return; } - + bool expanderopen = false; if (effectwidget) { + Gtk::Expander * expander = NULL; + std::vector childs = dynamic_cast (effectwidget)->get_children(); + std::vector childs_default = dynamic_cast (childs[childs.size()-1])->get_children(); + if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ + expanderopen = expander->get_expanded(); + } effectcontrol_vbox.remove(*effectwidget); delete effectwidget; effectwidget = NULL; @@ -204,6 +210,15 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) effectwidget = effect.newWidget(); if (effectwidget) { + Gtk::Widget * defaultswidget = effect.defaultParamSet(); + if (defaultswidget) { + Gtk::Expander * expander = NULL; + std::vector childs_default = dynamic_cast (defaultswidget)->get_children(); + if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ + expander->set_expanded(expanderopen); + } + dynamic_cast (effectwidget)->pack_start(*defaultswidget, true, true); + } effectcontrol_vbox.pack_start(*effectwidget, true, true); } button_remove.show(); -- cgit v1.2.3 From a54924aece45764357c36d22d0475ef640b75ba1 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 29 Apr 2017 16:40:51 +0200 Subject: minor bugfixing (bzr r15620.1.13) --- src/live_effects/effect.cpp | 14 ++++++++------ src/live_effects/lpe-bspline.cpp | 2 +- src/live_effects/parameter/parameter.cpp | 1 + src/ui/dialog/livepatheffect-editor.cpp | 15 +++++++++------ 4 files changed, 19 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 37694f32f..22cc5567b 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -795,17 +795,15 @@ Effect::defaultParamSet() // use manage here, because after deletion of Effect object, others might still be pointing to this widget. Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox() ); - - vbox->set_border_width(5); Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox() ); - vbox_expander->set_border_width(10); - vbox_expander->set_spacing(2); Glib::ustring effectname = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_label(effectType()); Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(effectType()); std::vector::iterator it = param_vector.begin(); Inkscape::UI::Widget::Registry * wr; + bool has_params = false; while (it != param_vector.end()) { if ((*it)->widget_is_visible) { + has_params = true; Parameter * param = *it; Glib::ustring * tip = param->param_getTooltip(); const gchar * key = param->param_key.c_str(); @@ -843,13 +841,17 @@ Effect::defaultParamSet() } ++it; } - Glib::ustring tip = "" + effectname + (Glib::ustring)_(": Set default parameters to current values"); + Glib::ustring tip = "" + effectname + (Glib::ustring)_(": Set default parameters"); Gtk::Expander * expander = Gtk::manage(new Gtk::Expander(tip)); expander->set_use_markup(true); expander->add(*vbox_expander); expander->set_expanded(false); vbox->pack_start(*dynamic_cast (expander), true, true, 2); - return dynamic_cast(vbox); + if (has_params) { + return dynamic_cast(vbox); + } else { + return NULL; + } } void diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 1423e670a..5c227e68a 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -86,7 +86,7 @@ Gtk::Widget *LPEBSpline::newWidget() // use manage here, because after deletion of Effect object, others might // still be pointing to this widget. Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); - + vbox->set_homogeneous(false); vbox->set_border_width(5); std::vector::iterator it = param_vector.begin(); while (it != param_vector.end()) { diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 15c81d543..e35c89c09 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -91,6 +91,7 @@ ScalarParam::param_getSVGValue() const { Inkscape::SVGOStringStream os; os << value; + std::cout << value << "value\n"; gchar * str = g_strdup(os.str().c_str()); return str; } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 455c12bc3..f0ccce6d4 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -194,12 +194,15 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) return; } bool expanderopen = false; + Gtk::Widget * defaultswidget = effect.defaultParamSet(); if (effectwidget) { - Gtk::Expander * expander = NULL; - std::vector childs = dynamic_cast (effectwidget)->get_children(); - std::vector childs_default = dynamic_cast (childs[childs.size()-1])->get_children(); - if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ - expanderopen = expander->get_expanded(); + if (defaultswidget) { + Gtk::Expander * expander = NULL; + std::vector childs = dynamic_cast (effectwidget)->get_children(); + std::vector childs_default = dynamic_cast (childs[childs.size()-1])->get_children(); + if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ + expanderopen = expander->get_expanded(); + } } effectcontrol_vbox.remove(*effectwidget); delete effectwidget; @@ -210,7 +213,7 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) effectwidget = effect.newWidget(); if (effectwidget) { - Gtk::Widget * defaultswidget = effect.defaultParamSet(); + if (defaultswidget) { Gtk::Expander * expander = NULL; std::vector childs_default = dynamic_cast (defaultswidget)->get_children(); -- cgit v1.2.3 From 36dbe5ea8d5bcaba57339df7b0344ca91dce3dd9 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 1 May 2017 04:04:06 +0200 Subject: Remove couts (bzr r15620.1.16) --- src/live_effects/parameter/parameter.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 569736735..ccf8f37e7 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -91,7 +91,6 @@ ScalarParam::param_getSVGValue() const { Inkscape::SVGOStringStream os; os << value; - std::cout << value << "value\n"; gchar * str = g_strdup(os.str().c_str()); return str; } -- cgit v1.2.3