summaryrefslogtreecommitdiffstats
path: root/src/widgets/rect-toolbar.cpp
diff options
context:
space:
mode:
authorSebastian Wüst <sebi@timewaster.de>2013-10-20 15:32:08 +0000
committerSebastian Wüst <sebi@timewaster.de>2013-10-20 15:32:08 +0000
commit82908f949129e1fcbf62002799ee7b1b77986eed (patch)
treec02098dd7720cdf424f2793ecd3ddac2ea86b969 /src/widgets/rect-toolbar.cpp
parentchanged text (diff)
parentFix build errors with clang 3.3 and c++11 enabled. (diff)
downloadinkscape-82908f949129e1fcbf62002799ee7b1b77986eed.tar.gz
inkscape-82908f949129e1fcbf62002799ee7b1b77986eed.zip
merge from trunk
(bzr r12417.1.24)
Diffstat (limited to 'src/widgets/rect-toolbar.cpp')
-rw-r--r--src/widgets/rect-toolbar.cpp68
1 files changed, 37 insertions, 31 deletions
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 8c1a735c5..0287a9aeb 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -53,18 +53,20 @@
#include "../xml/repr.h"
#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;
+using Inkscape::Util::unit_table;
//########################
@@ -86,17 +88,17 @@ static void sp_rtb_sensitivize( GObject *tbl )
static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_name,
- void (*setter)(SPRect *, gdouble))
+ void (SPRect::*setter)(gdouble))
{
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();
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
@@ -112,8 +114,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
for (GSList const *items = selection->itemList(); items != NULL; items = items->next) {
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));
+ (SP_RECT(items->data)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, sp_desktop_namedview(desktop)->doc_units));
} else {
SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL);
}
@@ -133,22 +134,22 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
static void sp_rtb_rx_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "rx", sp_rect_set_visible_rx);
+ sp_rtb_value_changed(adj, tbl, "rx", &SPRect::setVisibleRx);
}
static void sp_rtb_ry_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "ry", sp_rect_set_visible_ry);
+ sp_rtb_value_changed(adj, tbl, "ry", &SPRect::setVisibleRy);
}
static void sp_rtb_width_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "width", sp_rect_set_visible_width);
+ sp_rtb_value_changed(adj, tbl, "width", &SPRect::setVisibleWidth);
}
static void sp_rtb_height_value_changed(GtkAdjustment *adj, GObject *tbl)
{
- sp_rtb_value_changed(adj, tbl, "height", sp_rect_set_visible_height);
+ sp_rtb_value_changed(adj, tbl, "height", &SPRect::setVisibleHeight);
}
@@ -184,32 +185,37 @@ 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();
+ Unit const *doc_unit = sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units;
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));
+
+ gdouble rx = SP_RECT(item)->getVisibleRx();
+ gtk_adjustment_set_value(adj, Quantity::convert(rx, doc_unit, 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));
+
+ gdouble ry = SP_RECT(item)->getVisibleRy();
+ gtk_adjustment_set_value(adj, Quantity::convert(ry, doc_unit, 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));
+
+ gdouble width = SP_RECT(item)->getVisibleWidth();
+ gtk_adjustment_set_value(adj, Quantity::convert(width, doc_unit, 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));
+
+ gdouble height = SP_RECT(item)->getVisibleHeight();
+ gtk_adjustment_set_value(adj, Quantity::convert(height, doc_unit, unit));
}
}
@@ -301,7 +307,7 @@ 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 );
@@ -314,10 +320,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RectWidthAction",
_("Width"), _("W:"), _("Width of rectangle"),
"/tools/shapes/rect/width", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-rect",
+ GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-rect",
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_width_value_changed );
+ sp_rtb_width_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
g_object_set_data( holder, "width_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -331,10 +337,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RectHeightAction",
_("Height"), _("H:"), _("Height of rectangle"),
"/tools/shapes/rect/height", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_height_value_changed );
+ sp_rtb_height_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
g_object_set_data( holder, "height_action", eact );
gtk_action_set_sensitive( GTK_ACTION(eact), FALSE );
@@ -348,10 +354,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RadiusXAction",
_("Horizontal radius"), _("Rx:"), _("Horizontal radius of rounded corners"),
"/tools/shapes/rect/rx", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_rx_value_changed);
+ sp_rtb_rx_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}
@@ -363,10 +369,10 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
eact = create_adjustment_action( "RadiusYAction",
_("Vertical radius"), _("Ry:"), _("Vertical radius of rounded corners"),
"/tools/shapes/rect/ry", 0,
- GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL,
+ GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
0, 1e6, SPIN_STEP, SPIN_PAGE_STEP,
labels, values, G_N_ELEMENTS(labels),
- sp_rtb_ry_value_changed);
+ sp_rtb_ry_value_changed, tracker);
tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}