summaryrefslogtreecommitdiffstats
path: root/src/widgets/rect-toolbar.cpp
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-07-17 13:53:18 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-07-17 13:53:18 +0000
commit10067e713619333f20201c7d01c99e302464f6b2 (patch)
treedba02600760724653c45c48b36c414a247bca456 /src/widgets/rect-toolbar.cpp
parentFixed botched merge. (diff)
downloadinkscape-10067e713619333f20201c7d01c99e302464f6b2.tar.gz
inkscape-10067e713619333f20201c7d01c99e302464f6b2.zip
Port remaining files away from "helper/unit-tracker.h".
(bzr r12380.1.19)
Diffstat (limited to 'src/widgets/rect-toolbar.cpp')
-rw-r--r--src/widgets/rect-toolbar.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 5fa96289f..359bc48e0 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -54,17 +54,19 @@
#include "ui/uxmanager.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 "../pen-context.h"
#include "../sp-namedview.h"
#include "../sp-rect.h"
-using Inkscape::UnitTracker;
+using Inkscape::UI::Widget::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::Util::Unit;
+using Inkscape::Util::Quantity;
//########################
@@ -91,12 +93,14 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data( tbl, "tracker" ));
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const unit = tracker->getActiveUnit();
+ Inkscape::Util::UnitTable unit_table;
+ Unit const px = unit_table.getUnit("px");
if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble(Glib::ustring("/tools/shapes/rect/") + value_name,
- 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
@@ -113,7 +117,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
if (SP_IS_RECT(items->data)) {
if (gtk_adjustment_get_value(adj) != 0) {
setter(SP_RECT(items->data),
- sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit));
+ Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px));
} else {
SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL);
}
@@ -184,32 +188,34 @@ static void rect_tb_event_attr_changed(Inkscape::XML::Node * /*repr*/, gchar con
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) );
- SPUnit const *unit = tracker->getActiveUnit();
+ Unit const unit = tracker->getActiveUnit();
+ Inkscape::Util::UnitTable unit_table;
+ Unit const px = unit_table.getUnit("px");
gpointer item = g_object_get_data( tbl, "item" );
if (item && SP_IS_RECT(item)) {
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "rx" ) );
gdouble rx = sp_rect_get_visible_rx(SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(rx, *unit));
+ gtk_adjustment_set_value(adj, Quantity::convert(rx, &px, &unit));
}
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "ry" ) );
gdouble ry = sp_rect_get_visible_ry(SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(ry, *unit));
+ gtk_adjustment_set_value(adj, Quantity::convert(ry, &px, &unit));
}
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "width" ) );
gdouble width = sp_rect_get_visible_width (SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(width, *unit));
+ gtk_adjustment_set_value(adj, Quantity::convert(width, &px, &unit));
}
{
GtkAdjustment *adj = GTK_ADJUSTMENT( g_object_get_data( tbl, "height" ) );
gdouble height = sp_rect_get_visible_height (SP_RECT(item));
- gtk_adjustment_set_value(adj, sp_pixels_get_units(height, *unit));
+ gtk_adjustment_set_value(adj, Quantity::convert(height, &px, &unit));
}
}
@@ -301,10 +307,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
}
// rx/ry units menu: create
- UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE );
+ UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR);
//tracker->addUnit( SP_UNIT_PERCENT, 0 );
// fixme: add % meaning per cent of the width/height
- //tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
+ tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units );
g_object_set_data( holder, "tracker", tracker );
/* W */