diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/effect.cpp | 8 | ||||
| -rw-r--r-- | src/live_effects/parameter/bool.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/parameter/fontbutton.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 54 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 8 |
6 files changed, 81 insertions, 15 deletions
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<Inkscape::LivePathEffect::EffectType>(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<LivePathEffectObject *>(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<Inkscape::LivePathEffect::Parameter *> param_vector = effect->getParamVector(); std::vector<Inkscape::LivePathEffect::Parameter *>::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<Glib::ustring, Inkscape::UI::Widget::RegisteredCheckButton *>(sigc::mem_fun(*this, &InkscapePreferences::defaultLpeUpdater), pref_path, checkwdg)); + vbox_expander->pack_start(*dynamic_cast<Gtk::Widget *> (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<Gtk::Widget *>(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 <iostream> #include <vector> #include "ui/widget/preferences-widget.h" +#include "ui/widget/registered-widget.h" #include "ui/widget/button.h" #include <stddef.h> #include <gtkmm/colorbutton.h> @@ -30,6 +31,7 @@ #include <gtkmm/treeview.h> #include <gtkmm/frame.h> #include <gtkmm/notebook.h> +#include <gtkmm/expander.h> #include <gtkmm/textview.h> #include <gtkmm/scrolledwindow.h> #include <gtkmm/liststore.h> @@ -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); |
