diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 14af8c473bf808154714c59ed50df3243255c4f6..3327a51bc2c10e3e1039ae4c1f0d3f107a5a6b11 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -1571,14 +1571,16 @@ Effect::defaultParamSet() pref_path += key; bool valid = prefs->getEntry(pref_path).isValid(); const gchar * set_or_upd; - Glib::ustring def = Glib::ustring(_("Default value: ")) + defvalue + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); + Glib::ustring def = Glib::ustring(_("Default value: ")) + defvalue + pref_path; + Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + Glib::ustring(prefs->getString(pref_path)) + pref_path; if (valid) { set_or_upd = _("Update"); - def = Glib::ustring(_("Default value: ")) + defvalue + Glib::ustring("\n"); + def = ""; + //def = Glib::ustring(_("Default value: ")) + defvalue + Glib::ustring("\n"); } else { set_or_upd = _("Set"); - ove = Glib::ustring(_("Default value overridden: None\n")); + ove = ""; + //ove = Glib::ustring(_("Default value overridden: None\n")); } Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) ); Gtk::HBox *namedicon = Gtk::manage(new Gtk::HBox(true)); @@ -1587,7 +1589,7 @@ Effect::defaultParamSet() parameter_label->set_use_underline(true); parameter_label->set_ellipsize(Pango::ELLIPSIZE_END); Glib::ustring tooltip = Glib::ustring("") + parameter_label->get_text() + Glib::ustring("\n") + - param->param_tooltip + Glib::ustring("\n\n"); + param->param_tooltip + Glib::ustring("\n"); Gtk::Image *info = sp_get_icon_image("info", 20); Gtk::EventBox *infoeventbox = Gtk::manage(new Gtk::EventBox()); infoeventbox->add(*info); @@ -1644,9 +1646,8 @@ void Effect::setDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, Par gchar * label = _("Update"); set->set_label((Glib::ustring)label); unset->set_sensitive(true); - Glib::ustring def = Glib::ustring(_("Default value: ")) + defvalue + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + value + Glib::ustring("\n"); - info->set_tooltip_markup((tooltip + def + ove).c_str()); + Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + value; + info->set_tooltip_markup((tooltip + ove).c_str()); } void Effect::unsetDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, Parameter *param, Gtk::Image *info, @@ -1659,9 +1660,8 @@ void Effect::unsetDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, P gchar * label = _("Set"); set->set_label((Glib::ustring)label); unset->set_sensitive(false); - Glib::ustring def = Glib::ustring(_("Default value: ")) + defvalue + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overridden: None\n")); - info->set_tooltip_markup((tooltip + def + ove).c_str()); + Glib::ustring def = Glib::ustring(_("Default value: Default")); + info->set_tooltip_markup((tooltip + def).c_str()); } Inkscape::XML::Node *Effect::getRepr() diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 46349598a8b89510235453f2f09ec03b8806aa20..2c9964557b4604279f241aeefe448a9156b03820 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -98,6 +98,56 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem) } } +Gtk::Widget * +LPEBendPath::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() ); + + vbox->set_border_width(5); + + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = param->param_newWidget(); + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + if (param->widget_is_enabled) { + widg->set_sensitive(true); + } else { + widg->set_sensitive(false); + } + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } + + ++it; + } + if(Gtk::Widget* widg = defaultParamSet()) { + vbox->pack_start(*widg, true, true, 2); + } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(effectType()); + const gchar * key = prop_scale.param_key.c_str(); + Glib::ustring pref_path = "/live_effects/"; + pref_path += effectkey; + pref_path +="/"; + pref_path += key; + default_width_overrided = prefs->getEntry(pref_path).isValid(); + if (default_width_overrided) { + prop_scale.param_set_default(); + prefs->setDouble("/live_effects/bend/width_knot", prop_scale); + } + return dynamic_cast(vbox); +} + void LPEBendPath::transform_multiply(Geom::Affine const &postmul, bool /*set*/) { if (sp_lpe_item && sp_lpe_item->pathEffectsEnabled() && sp_lpe_item->optimizeTransforms()) { @@ -216,9 +266,10 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& } else { lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/live_effects/bend/width", lpe->prop_scale); - + if (!lpe->default_width_overrided) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/live_effects/bend/width_knot", lpe->prop_scale); + } sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index b34f2886b1031194dabaea8bd3f92996991b23fd..a3392943cd7f465a0d8bf933d8f989408282ef32 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -50,6 +50,8 @@ public: void addKnotHolderEntities(KnotHolder * knotholder, SPItem * item) override; + Gtk::Widget *newWidget() override; + PathParam bend_path; friend class BeP::KnotHolderEntityWidthBendPath; @@ -64,7 +66,7 @@ private: Geom::PathVector helper_path; Geom::Piecewise > uskeleton; Geom::Piecewise > n; - + bool default_width_overrided; void on_pattern_pasted(); LPEBendPath(const LPEBendPath&); diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 09755a4ab005cc6a4b83833b87dec188ac7a4e2d..5c3c17d5baf4de91d4782758ff49ff01d070e13e 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -113,7 +113,6 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) : prop_scale.param_set_increments(0.01, 0.10); _knot_entity = nullptr; _provides_knotholder_entities = true; - } LPEPatternAlongPath::~LPEPatternAlongPath() @@ -126,6 +125,56 @@ void LPEPatternAlongPath::transform_multiply(Geom::Affine const &postmul, bool / } } +Gtk::Widget * +LPEPatternAlongPath::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() ); + + vbox->set_border_width(5); + + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = param->param_newWidget(); + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + if (param->widget_is_enabled) { + widg->set_sensitive(true); + } else { + widg->set_sensitive(false); + } + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } + + ++it; + } + if(Gtk::Widget* widg = defaultParamSet()) { + vbox->pack_start(*widg, true, true, 2); + } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring effectkey = (Glib::ustring)Inkscape::LivePathEffect::LPETypeConverter.get_key(effectType()); + const gchar * key = prop_scale.param_key.c_str(); + Glib::ustring pref_path = "/live_effects/"; + pref_path += effectkey; + pref_path +="/"; + pref_path += key; + default_width_overrided = prefs->getEntry(pref_path).isValid(); + if (default_width_overrided) { + prop_scale.param_set_default(); + prefs->setDouble("/live_effects/skeletal/width_knot", prop_scale); + } + return dynamic_cast(vbox); +} + void LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem) { @@ -326,8 +375,10 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin } else { lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/live_effects/pap/width", lpe->prop_scale); + if (!lpe->default_width_overrided) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/live_effects/skeletal/width_knot", lpe->prop_scale); + } } } sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h index 690aaa99f3d1121b366d1706078c6eaabe6c6fbd..d46a6e3a5ef33d6187edf6842f1b6d6f2987e12f 100644 --- a/src/live_effects/lpe-patternalongpath.h +++ b/src/live_effects/lpe-patternalongpath.h @@ -46,6 +46,8 @@ public: void addKnotHolderEntities(KnotHolder * knotholder, SPItem * item) override; + Gtk::Widget *newWidget() override; + PathParam pattern; friend class WPAP::KnotHolderEntityWidthPatternAlongPath; @@ -65,6 +67,7 @@ private: ScalarParam fuse_tolerance; KnotHolderEntity * _knot_entity; Geom::PathVector helper_path; + bool default_width_overrided; void on_pattern_pasted(); LPEPatternAlongPath(const LPEPatternAlongPath&); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 1126ea110f7d5e42ef549a5a6362d5f9e1fc37c1..69d35a63e66b84171b17e4d0b5671eed6cdc8c65 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -230,7 +230,7 @@ static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath, Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); static_cast(lpe)->pattern.set_new_value(newpath,true); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double scale = prefs->getDouble("/live_effects/pap/width", 0.265); + double scale = prefs->getDouble("/live_effects/skeletal/width_knot", 0.265); if (!scale) { scale = 1 / document->getDocumentScale()[0]; } @@ -344,7 +344,7 @@ static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *i // write bend parameters: Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double scale = prefs->getDouble("/live_effects/bend/width", 1); + double scale = prefs->getDouble("/live_effects/bend/width_knot", 1); if (!scale) { scale = 1; } @@ -450,7 +450,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, const char *stroke_width = sp_repr_css_property(css_item, "stroke-width", "0"); double swidth; sp_svg_number_read_d(stroke_width, &swidth); - swidth = prefs->getDouble("/live_effects/powerstroke/width", swidth/2); + swidth = prefs->getDouble("/live_effects/powerstroke/width_knot", swidth/2); if (!swidth) { swidth = swidth/2; }