From c60177d361dd435e58caa902a395fa21c9415f51 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 18:12:31 -0400 Subject: Removed "helper/unit.*" dependency from "ui/widget/registered-widget.*". (bzr r12380.1.21) --- src/live_effects/parameter/unit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index 602d806a0..fffbabb1d 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -74,7 +74,7 @@ UnitParam::param_newWidget() param_effect->getRepr(), param_effect->getSPDoc())); - unit_menu->setUnit(unit); + unit_menu->setUnit(unit->abbr); unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter")); return dynamic_cast (unit_menu); -- cgit v1.2.3 From 5b8a6e510cb69d33bc8834a7586142be800471b5 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 16:31:57 -0400 Subject: Ported "live_effects/parameter/unit.*". (bzr r12380.1.41) --- src/live_effects/parameter/unit.cpp | 22 ++++++++++++---------- src/live_effects/parameter/unit.h | 15 +++++++++------ 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index fffbabb1d..264b4b9ee 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -10,6 +10,7 @@ #include "live_effects/parameter/unit.h" #include "live_effects/effect.h" #include "verbs.h" +#include "util/units.h" namespace Inkscape { @@ -18,10 +19,11 @@ namespace LivePathEffect { UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, SPUnitId default_value) + Effect* effect, Glib::ustring default_unit) : Parameter(label, tip, key, wr, effect) { - defunit = &sp_unit_get_by_id(default_value);; + Inkscape::Util::UnitTable unit_table; + defunit = new Inkscape::Util::Unit(unit_table.getUnit(default_unit)); unit = defunit; } @@ -32,9 +34,9 @@ UnitParam::~UnitParam() bool UnitParam::param_readSVGValue(const gchar * strvalue) { - SPUnit const *newval = sp_unit_get_by_abbreviation(strvalue); - if (newval) { - param_set_value(newval); + Inkscape::Util::UnitTable unit_table; + if (strvalue) { + param_set_value(unit_table.getUnit(strvalue)); return true; } return false; @@ -43,25 +45,25 @@ UnitParam::param_readSVGValue(const gchar * strvalue) gchar * UnitParam::param_getSVGValue() const { - return g_strdup(sp_unit_get_abbreviation(unit)); + return g_strdup(unit->abbr.c_str()); } void UnitParam::param_set_default() { - param_set_value(defunit); + param_set_value(*defunit); } void -UnitParam::param_set_value(SPUnit const *val) +UnitParam::param_set_value(Inkscape::Util::Unit const &val) { - unit = val; + unit = new Inkscape::Util::Unit(val); } const gchar * UnitParam::get_abbreviation() const { - return sp_unit_get_abbreviation(unit); + return unit->abbr.c_str(); } Gtk::Widget * diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index ea7a0112a..59a483018 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -10,10 +10,13 @@ */ #include "live_effects/parameter/parameter.h" -#include namespace Inkscape { +namespace Util { + class Unit; +} + namespace LivePathEffect { class UnitParam : public Parameter { @@ -23,22 +26,22 @@ public: const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, - SPUnitId default_value = SP_UNIT_PX); + Glib::ustring default_unit = "px"); virtual ~UnitParam(); virtual bool param_readSVGValue(const gchar * strvalue); virtual gchar * param_getSVGValue() const; virtual void param_set_default(); - void param_set_value(SPUnit const *val); + void param_set_value(Inkscape::Util::Unit const &val); const gchar *get_abbreviation() const; virtual Gtk::Widget * param_newWidget(); - operator SPUnit const *() const { return unit; } + operator Inkscape::Util::Unit const *() const { return unit; } private: - SPUnit const *unit; - SPUnit const *defunit; + Inkscape::Util::Unit const *unit; + Inkscape::Util::Unit const *defunit; UnitParam(const UnitParam&); UnitParam& operator=(const UnitParam&); -- cgit v1.2.3 From 6ae6c0bea96eef09907091279e0678aa5f83102d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 4 Aug 2013 18:01:18 -0400 Subject: Switched to global UnitTable. (bzr r12380.1.62) --- src/live_effects/parameter/unit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index 264b4b9ee..561766920 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -12,6 +12,8 @@ #include "verbs.h" #include "util/units.h" +using Inkscape::Util::unit_table; + namespace Inkscape { namespace LivePathEffect { @@ -22,7 +24,6 @@ UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip, Effect* effect, Glib::ustring default_unit) : Parameter(label, tip, key, wr, effect) { - Inkscape::Util::UnitTable unit_table; defunit = new Inkscape::Util::Unit(unit_table.getUnit(default_unit)); unit = defunit; } @@ -34,7 +35,6 @@ UnitParam::~UnitParam() bool UnitParam::param_readSVGValue(const gchar * strvalue) { - Inkscape::Util::UnitTable unit_table; if (strvalue) { param_set_value(unit_table.getUnit(strvalue)); return true; -- cgit v1.2.3