summaryrefslogtreecommitdiffstats
path: root/src/widgets/node-toolbar.cpp
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-07-17 04:53:51 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-07-17 04:53:51 +0000
commit9711852491cd6eb2992039f286ce3ced50b83d06 (patch)
treee38e7ce94d16b74b52604424dffafccbd5bfd269 /src/widgets/node-toolbar.cpp
parentFixed memory corruption introduced in a previous commit. (diff)
downloadinkscape-9711852491cd6eb2992039f286ce3ced50b83d06.tar.gz
inkscape-9711852491cd6eb2992039f286ce3ced50b83d06.zip
Ported "widgets/node-toolbar.cpp".
(bzr r12380.1.15)
Diffstat (limited to 'src/widgets/node-toolbar.cpp')
-rw-r--r--src/widgets/node-toolbar.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index d6de74817..50880f481 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -58,13 +58,14 @@
#include "../ui/tool/node-tool.h"
#include "../ui/tool/multi-path-manipulator.h"
#include "../ui/icon-names.h"
-#include "../helper/unit-menu.h"
-#include "../helper/units.h"
-#include "../helper/unit-tracker.h"
+#include "util/units.h"
+#include "ui/widget/unit-tracker.h"
#include "../lpe-tool-context.h"
#include "../sp-namedview.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
@@ -238,7 +239,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb
if (!tracker) {
return;
}
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const unit = tracker->getActiveUnit();
InkNodeTool *nt = get_node_tool();
if (!nt || nt->_selected_nodes->empty()) {
@@ -248,15 +249,17 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb
} else {
gtk_action_set_sensitive(xact, TRUE);
gtk_action_set_sensitive(yact, TRUE);
- Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
- Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit);
+ Inkscape::Util::UnitTable unit_table;
+ Unit px = unit_table.getUnit("px");
+ Geom::Coord oldx = Quantity::convert(gtk_adjustment_get_value(xadj), &unit, &px);
+ Geom::Coord oldy = Quantity::convert(gtk_adjustment_get_value(yadj), &unit, &px);
Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint();
if (oldx != mid[Geom::X]) {
- gtk_adjustment_set_value(xadj, sp_pixels_get_units(mid[Geom::X], *unit));
+ gtk_adjustment_set_value(xadj, Quantity::convert(mid[Geom::X], &px, &unit));
}
if (oldy != mid[Geom::Y]) {
- gtk_adjustment_set_value(yadj, sp_pixels_get_units(mid[Geom::Y], *unit));
+ gtk_adjustment_set_value(yadj, Quantity::convert(mid[Geom::Y], &px, &unit));
}
}
@@ -272,11 +275,14 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
if (!tracker) {
return;
}
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const unit = tracker->getActiveUnit();
+
+ Inkscape::Util::UnitTable unit_table;
+ Unit px = unit_table.getUnit("px");
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"),
- sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit));
+ Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px));
}
// quit if run by the attr_changed listener
@@ -289,7 +295,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
InkNodeTool *nt = get_node_tool();
if (nt && !nt->_selected_nodes->empty()) {
- double val = sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit);
+ double val = Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px);
double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d];
Geom::Point delta(0,0);
delta[d] = val - oldval;
@@ -339,8 +345,9 @@ static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint /
void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
- //tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
+ Unit doc_units = *sp_desktop_namedview(desktop)->doc_units;
+ tracker->setActiveUnit(&doc_units);
g_object_set_data( holder, "tracker", tracker );
Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);