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 ++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 55 deletions(-) (limited to 'src/live_effects/effect.cpp') 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) { -- 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 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/live_effects/effect.cpp') 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(); } -- 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects/effect.cpp') 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); -- 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 ++++++++++++++------------------------------ 1 file changed, 55 insertions(+), 120 deletions(-) (limited to 'src/live_effects/effect.cpp') 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) { -- 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 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 4 deletions(-) (limited to 'src/live_effects/effect.cpp') 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() { -- 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 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/live_effects/effect.cpp') 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 -- cgit v1.2.3