From 9dc7b786c9ef31060012ea4ae13a8188548b4f62 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 9 Jul 2013 16:42:04 -0400 Subject: Ported sp-namedview.cpp (todo: fix a bunch of things). (bzr r12380.1.8) --- src/widgets/rect-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/rect-toolbar.cpp') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 8c1a735c5..5fa96289f 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -304,7 +304,7 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); //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 */ -- cgit v1.2.3 From 10067e713619333f20201c7d01c99e302464f6b2 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 09:53:18 -0400 Subject: Port remaining files away from "helper/unit-tracker.h". (bzr r12380.1.19) --- src/widgets/rect-toolbar.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/widgets/rect-toolbar.cpp') 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(g_object_get_data( tbl, "desktop" )); UnitTracker* tracker = reinterpret_cast(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( 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 */ -- cgit v1.2.3 From 3772fc428950b2b946a1bd7c7c97e06219c3165f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 18 Jul 2013 17:21:24 -0400 Subject: Switch unit functions from using pointer arguements to reference arguements. (bzr r12380.1.28) --- src/widgets/rect-toolbar.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/widgets/rect-toolbar.cpp') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 359bc48e0..d91b08273 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -95,12 +95,11 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); 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, - Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px)); + Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); } // quit if run by the attr_changed listener @@ -117,7 +116,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), - Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px)); + Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); } else { SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL); } @@ -190,32 +189,31 @@ static void rect_tb_event_attr_changed(Inkscape::XML::Node * /*repr*/, gchar con UnitTracker* tracker = reinterpret_cast( g_object_get_data( tbl, "tracker" ) ); 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, Quantity::convert(rx, &px, &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, Quantity::convert(ry, &px, &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, Quantity::convert(width, &px, &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, Quantity::convert(height, &px, &unit)); + gtk_adjustment_set_value(adj, Quantity::convert(height, "px", unit)); } } -- cgit v1.2.3 From 5ce7ccd3fb416c686f570e86295c5f619bd86973 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 14:02:26 -0400 Subject: Removed "helper/unit-menu.h" from "widgets/rect-toolbar.*" and "widgets/spw-utilities.h". (bzr r12380.1.29) --- src/widgets/rect-toolbar.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets/rect-toolbar.cpp') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index d91b08273..e54a2df07 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -53,7 +53,6 @@ #include "../xml/repr.h" #include "ui/uxmanager.h" #include "../ui/icon-names.h" -#include "../helper/unit-menu.h" #include "util/units.h" #include "ui/widget/unit-tracker.h" #include "../pen-context.h" -- cgit v1.2.3 From ef3bfa7e8bb2996c4042314accc34f6a72f072e1 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 14:19:03 -0400 Subject: Removed "helper/unit-menu.h" from "widgest/toolbar.*" and associated files. (bzr r12380.1.30) --- src/widgets/rect-toolbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/rect-toolbar.cpp') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index e54a2df07..29488031f 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -317,7 +317,7 @@ 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 ); @@ -334,7 +334,7 @@ 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 ); @@ -351,7 +351,7 @@ 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); @@ -366,7 +366,7 @@ 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); -- 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/widgets/rect-toolbar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/widgets/rect-toolbar.cpp') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 29488031f..6dfd9cfcb 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -66,6 +66,7 @@ using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; using Inkscape::Util::Unit; using Inkscape::Util::Quantity; +using Inkscape::Util::unit_table; //######################## @@ -93,7 +94,6 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); Unit const unit = tracker->getActiveUnit(); - Inkscape::Util::UnitTable unit_table; if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -187,7 +187,6 @@ static void rect_tb_event_attr_changed(Inkscape::XML::Node * /*repr*/, gchar con UnitTracker* tracker = reinterpret_cast( g_object_get_data( tbl, "tracker" ) ); Unit const unit = tracker->getActiveUnit(); - Inkscape::Util::UnitTable unit_table; gpointer item = g_object_get_data( tbl, "item" ); if (item && SP_IS_RECT(item)) { -- cgit v1.2.3