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/ui/dialog/export.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index a851503fe..25300cfc0 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -200,8 +200,8 @@ Export::Export (void) : earlier than that */ unit_selector = Glib::wrap(sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE)); SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) - sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); + //if (desktop) + // sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); unitbox.pack_end(*unit_selector, false, false, 0); unitbox.pack_end(units_label, false, false, 3); -- cgit v1.2.3 From 64e66e01886be870fc9615e65416097e64ad544b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 18:13:19 -0400 Subject: Ported "ui/dialog/export.*". (bzr r12380.1.22) --- src/ui/dialog/export.cpp | 74 ++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 46 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 25300cfc0..61fb6e4ee 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -48,8 +48,8 @@ #include #include -#include "helper/unit-menu.h" -#include "helper/units.h" +#include "ui/widget/unit-menu.h" +#include "util/units.h" #include "unit-constants.h" #include "helper/window.h" #include "inkscape-private.h" @@ -198,10 +198,13 @@ Export::Export (void) : /* Units box */ /* gets added to the vbox later, but the unit selector is needed earlier than that */ - unit_selector = Glib::wrap(sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE)); + unit_selector = new Inkscape::UI::Widget::UnitMenu(); + unit_selector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); + unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; - //if (desktop) - // sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); + if (desktop) + unit_selector->setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); unitbox.pack_end(*unit_selector, false, false, 0); unitbox.pack_end(units_label, false, false, 3); @@ -226,28 +229,28 @@ Export::Export (void) : t->set_col_spacings (4); #endif - x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaX0Change); - x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaX1Change); width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, - unit_selector->gobj(), t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, + ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaWidthChange); - y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaY0Change); - y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), + y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaY1Change); height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, - unit_selector->gobj(), t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, + ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, &Export::onAreaHeightChange); area_box.pack_start(togglebox, false, false, 3); @@ -496,9 +499,6 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl #else Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 ); #endif - if (us) { - sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us), GTK_ADJUSTMENT (adj->gobj()) ); - } int pos = 0; Gtk::Label *l = NULL; @@ -979,6 +979,12 @@ Glib::ustring Export::absolutize_path_from_document_location (SPDocument *doc, c return path; } +// Called when unit is changed +void Export::onUnitChanged() +{ + onAreaToggled(); +} + void Export::onHideExceptSelected () { prefs->setBool("/dialogs/export/hideexceptselected/value", hide_export.get_active()); @@ -1507,10 +1513,6 @@ void Export::areaXChange (Gtk::Adjustment *adj) return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; x0 = getValuePx(x0_adj); @@ -1554,10 +1556,6 @@ void Export::areaYChange (Gtk::Adjustment *adj) return; } - if (sp_unit_selector_update_test (SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; y0 = getValuePx(y0_adj); @@ -1597,10 +1595,6 @@ void Export::onAreaWidthChange() return; } - if (sp_unit_selector_update_test(reinterpret_cast(unit_selector->gobj()))) { - return; - } - update = true; float x0 = getValuePx(x0_adj); @@ -1630,10 +1624,6 @@ void Export::onAreaHeightChange() return; } - if (sp_unit_selector_update_test(reinterpret_cast(unit_selector->gobj()))) { - return; - } - update = true; float y0 = getValuePx(y0_adj); @@ -1709,10 +1699,6 @@ void Export::onBitmapWidthChange () return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; x0 = getValuePx(x0_adj); @@ -1743,10 +1729,6 @@ void Export::onBitmapHeightChange () return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; y0 = getValuePx(y0_adj); @@ -1803,10 +1785,6 @@ void Export::onExportXdpiChange() return; } - if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { - return; - } - update = true; x0 = getValuePx(x0_adj); @@ -1905,9 +1883,11 @@ void Export::setValuePx(Glib::RefPtr& adj, double val) void Export::setValuePx( Gtk::Adjustment *adj, double val) #endif { - const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj()) ); + const Unit unit = unit_selector->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit px = unit_table.getUnit("px"); - setValue(adj, sp_pixels_get_units (val, *unit)); + setValue(adj, Inkscape::Util::Quantity::convert(val, &px, &unit)); return; } @@ -1955,9 +1935,11 @@ float Export::getValuePx( Gtk::Adjustment *adj ) #endif { float value = getValue( adj); - const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj())); + const Unit unit = unit_selector->getUnit(); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::Unit px = unit_table.getUnit("px"); - return sp_units_get_pixels (value, *unit); + return Inkscape::Util::Quantity::convert(value, &unit, &px); } // end of sp_export_value_get_px() /** -- 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/ui/dialog/export.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 61fb6e4ee..5cb9357c3 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1885,9 +1885,8 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val) { const Unit unit = unit_selector->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit px = unit_table.getUnit("px"); - setValue(adj, Inkscape::Util::Quantity::convert(val, &px, &unit)); + setValue(adj, Inkscape::Util::Quantity::convert(val, "px", unit)); return; } @@ -1937,9 +1936,8 @@ float Export::getValuePx( Gtk::Adjustment *adj ) float value = getValue( adj); const Unit unit = unit_selector->getUnit(); Inkscape::Util::UnitTable unit_table; - Inkscape::Util::Unit px = unit_table.getUnit("px"); - return Inkscape::Util::Quantity::convert(value, &unit, &px); + return Inkscape::Util::Quantity::convert(value, unit, "px"); } // end of sp_export_value_get_px() /** -- cgit v1.2.3 From f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 18:33:03 -0400 Subject: Eliminate "unit-constants.h". (bzr r12380.1.54) --- src/ui/dialog/export.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/ui/dialog/export.cpp') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 5cb9357c3..063902aa7 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -50,7 +50,6 @@ #include "ui/widget/unit-menu.h" #include "util/units.h" -#include "unit-constants.h" #include "helper/window.h" #include "inkscape-private.h" #include "document.h" @@ -98,7 +97,7 @@ #define SP_EXPORT_MIN_SIZE 1.0 -#define DPI_BASE PX_PER_IN +#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px") #define EXPORT_COORD_PRECISION 3 @@ -1048,8 +1047,8 @@ void Export::onExport () Geom::OptRect area = item->desktopVisualBounds(); if (area) { - gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); - gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); + gint width = (gint) (area->width() * dpi / DPI_BASE + 0.5); + gint height = (gint) (area->height() * dpi / DPI_BASE + 0.5); if (width > 1 && height > 1) { // Do export -- 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/ui/dialog/export.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/dialog/export.cpp') 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() -- cgit v1.2.3