diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-08-04 22:01:18 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-08-04 22:01:18 +0000 |
| commit | 6ae6c0bea96eef09907091279e0678aa5f83102d (patch) | |
| tree | 825708d13704e27c33cb90a5269b25ae390cf4d2 /src/ui | |
| parent | Fix handling of SVG lengths with spaces [Bug #1208002]. (diff) | |
| download | inkscape-6ae6c0bea96eef09907091279e0678aa5f83102d.tar.gz inkscape-6ae6c0bea96eef09907091279e0678aa5f83102d.zip | |
Switched to global UnitTable.
(bzr r12380.1.62)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/clonetiler.cpp | 6 | ||||
| -rw-r--r-- | src/ui/dialog/export.cpp | 4 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 3 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.h | 1 | ||||
| -rw-r--r-- | src/ui/widget/scalar-unit.cpp | 7 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 3 | ||||
| -rw-r--r-- | src/ui/widget/unit-menu.cpp | 16 | ||||
| -rw-r--r-- | src/ui/widget/unit-menu.h | 3 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.cpp | 12 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.h | 2 |
10 files changed, 26 insertions, 31 deletions
diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index abb2512f7..b3675440b 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -58,6 +58,7 @@ #include "sp-root.h" using Inkscape::DocumentUndo; +using Inkscape::Util::unit_table; namespace Inkscape { namespace UI { @@ -1107,7 +1108,6 @@ CloneTiler::CloneTiler (void) : double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); Inkscape::Util::Unit const unit = unit_menu->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); @@ -1141,7 +1141,6 @@ CloneTiler::CloneTiler (void) : double value = prefs->getDouble(prefs_path + "fillheight", 50.0); Inkscape::Util::Unit const unit = unit_menu->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); @@ -2950,7 +2949,6 @@ void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI: { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const unit = u->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2961,7 +2959,6 @@ void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI { gdouble const raw_dist = gtk_adjustment_get_value (adj); Inkscape::Util::Unit const unit = u->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -2975,7 +2972,6 @@ void CloneTiler::clonetiler_unit_changed() gdouble height_pixels = prefs->getDouble(prefs_path + "fillheight"); Inkscape::Util::Unit unit = unit_menu->getUnit(); - Inkscape::Util::UnitTable unit_table; gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, "px", unit); gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, "px", unit); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 063902aa7..2c92608d7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -107,6 +107,8 @@ #include "verbs.h" #include "export.h" +using Inkscape::Util::unit_table; + namespace { class MessageCleaner @@ -1883,7 +1885,6 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val) #endif { const Unit unit = unit_selector->getUnit(); - Inkscape::Util::UnitTable unit_table; setValue(adj, Inkscape::Util::Quantity::convert(val, "px", unit)); @@ -1934,7 +1935,6 @@ float Export::getValuePx( Gtk::Adjustment *adj ) { float value = getValue( adj); const Unit unit = unit_selector->getUnit(); - Inkscape::Util::UnitTable unit_table; return Inkscape::Util::Quantity::convert(value, unit, "px"); } // end of sp_export_value_get_px() diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b15ab2823..d912fd9d3 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -47,9 +47,8 @@ #include "xml/node.h" #include "xml/repr.h" -static Inkscape::Util::UnitTable unit_table; - using std::pair; +using Inkscape::Util::unit_table; namespace Inkscape { namespace UI { diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index fc8edeeac..34ed7592d 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -117,7 +117,6 @@ private: name = ""; smaller = 0.0; larger = 0.0; - static Inkscape::Util::UnitTable unit_table; unit = unit_table.getUnit("px"); } diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index 99ff70846..2f4c1f341 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -16,6 +16,8 @@ #include "scalar-unit.h" #include "spinbutton.h" +using Inkscape::Util::unit_table; + namespace Inkscape { namespace UI { namespace Widget { @@ -226,9 +228,8 @@ void ScalarUnit::on_unit_changed() Glib::ustring abbr = _unit_menu->getUnitAbbr(); _suffix->set_label(abbr); - Inkscape::Util::UnitTable &table = _unit_menu->getUnitTable(); - Inkscape::Util::Unit new_unit = (table.getUnit(abbr)); - Inkscape::Util::Unit old_unit = (table.getUnit(lastUnits)); + Inkscape::Util::Unit new_unit = (unit_table.getUnit(abbr)); + Inkscape::Util::Unit old_unit = (unit_table.getUnit(lastUnits)); double convertedVal = 0; if (old_unit.type == UNIT_TYPE_DIMENSIONLESS && new_unit.type == UNIT_TYPE_LINEAR) { diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index edf53d25c..388a0bcea 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -52,6 +52,8 @@ #include "gradient-chemistry.h" #include "util/units.h" +using Inkscape::Util::unit_table; + static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -307,7 +309,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) { int row = 0; - Inkscape::Util::UnitTable unit_table; Inkscape::Util::UnitTable::UnitMap m = unit_table.units(Inkscape::Util::UNIT_TYPE_LINEAR); Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { diff --git a/src/ui/widget/unit-menu.cpp b/src/ui/widget/unit-menu.cpp index 18b7bcab9..111226774 100644 --- a/src/ui/widget/unit-menu.cpp +++ b/src/ui/widget/unit-menu.cpp @@ -15,6 +15,8 @@ #include "unit-menu.h" +using Inkscape::Util::unit_table; + namespace Inkscape { namespace UI { namespace Widget { @@ -30,7 +32,7 @@ UnitMenu::~UnitMenu() { bool UnitMenu::setUnitType(UnitType unit_type) { // Expand the unit widget with unit entries from the unit table - UnitTable::UnitMap m = _unit_table.units(unit_type); + UnitTable::UnitMap m = unit_table.units(unit_type); UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { Glib::ustring text = (*iter).first; @@ -38,7 +40,7 @@ bool UnitMenu::setUnitType(UnitType unit_type) ++iter; } _type = unit_type; - set_active_text(_unit_table.primary(unit_type)); + set_active_text(unit_table.primary(unit_type)); return true; } @@ -52,7 +54,7 @@ bool UnitMenu::resetUnitType(UnitType unit_type) void UnitMenu::addUnit(Unit const& u) { - _unit_table.addUnit(u, false); + unit_table.addUnit(u, false); append(u.abbr); } @@ -60,9 +62,9 @@ Unit UnitMenu::getUnit() const { if (get_active_text() == "") { g_assert(_type != UNIT_TYPE_NONE); - return _unit_table.getUnit(_unit_table.primary(_type)); + return unit_table.getUnit(unit_table.primary(_type)); } - return _unit_table.getUnit(get_active_text()); + return unit_table.getUnit(get_active_text()); } bool UnitMenu::setUnit(Glib::ustring const & unit) @@ -112,8 +114,8 @@ double UnitMenu::getConversion(Glib::ustring const &new_unit_abbr, Glib::ustring { double old_factor = getUnit().factor; if (old_unit_abbr != "no_unit") - old_factor = _unit_table.getUnit(old_unit_abbr).factor; - Unit new_unit = _unit_table.getUnit(new_unit_abbr); + old_factor = unit_table.getUnit(old_unit_abbr).factor; + Unit new_unit = unit_table.getUnit(new_unit_abbr); // Catch the case of zero or negative unit factors (error!) if (old_factor < 0.0000001 || diff --git a/src/ui/widget/unit-menu.h b/src/ui/widget/unit-menu.h index 3104d5aef..3f4df6bf9 100644 --- a/src/ui/widget/unit-menu.h +++ b/src/ui/widget/unit-menu.h @@ -127,10 +127,7 @@ public: */ bool isRadial() const; - UnitTable &getUnitTable() {return _unit_table;} - protected: - UnitTable _unit_table; UnitType _type; }; diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 99074be40..5b2dc031b 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -17,6 +17,9 @@ #define COLUMN_STRING 0 +using Inkscape::Util::UnitTable; +using Inkscape::Util::unit_table; + namespace Inkscape { namespace UI { namespace Widget { @@ -32,10 +35,9 @@ UnitTracker::UnitTracker(UnitType unit_type) : _priorValues() { _store = gtk_list_store_new(1, G_TYPE_STRING); - static Inkscape::Util::UnitTable unit_table; GtkTreeIter iter; - UnitTable::UnitMap m = _unit_table.units(unit_type); + UnitTable::UnitMap m = unit_table.units(unit_type); UnitTable::UnitMap::iterator m_iter = m.begin(); while(m_iter != m.end()) { Glib::ustring text = (*m_iter).first; @@ -99,7 +101,7 @@ void UnitTracker::setActiveUnit(Inkscape::Util::Unit const *unit) void UnitTracker::setActiveUnitByAbbr(gchar const *abbr) { - Inkscape::Util::Unit u = _unit_table.getUnit(abbr); + Inkscape::Util::Unit u = unit_table.getUnit(abbr); setActiveUnit(&u); } @@ -195,13 +197,13 @@ void UnitTracker::_setActive(gint active) if (found) { gchar *abbr; gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &abbr, -1); - Inkscape::Util::Unit unit = _unit_table.getUnit(abbr); + Inkscape::Util::Unit unit = unit_table.getUnit(abbr); found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, active); if (found) { gchar *newAbbr; gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &newAbbr, -1); - Inkscape::Util::Unit newUnit = _unit_table.getUnit(newAbbr); + Inkscape::Util::Unit newUnit = unit_table.getUnit(newAbbr); _activeUnit = newUnit; if (_adjList) { diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index cdcb07c57..19559ae1c 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -21,7 +21,6 @@ #include "util/units.h" using Inkscape::Util::Unit; -using Inkscape::Util::UnitTable; using Inkscape::Util::UnitType; namespace Inkscape { @@ -46,7 +45,6 @@ public: GtkAction *createAction(gchar const *name, gchar const *label, gchar const *tooltip); protected: - UnitTable _unit_table; UnitType _type; private: |
