From 6feb3acbebce6b87bfb440b985871fbc0b4764d8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 28 Aug 2012 16:17:07 +0900 Subject: Fix for 1042602 : Select toolbar : Width and height are not initially 0 (bzr r11629) --- src/widgets/select-toolbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 4378bc19d..4dfebe11f 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -497,19 +497,19 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // four spinbuttons eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X", - -1e6, GTK_WIDGET(desktop->canvas), tracker, spw, + 0.0, GTK_WIDGET(desktop->canvas), tracker, spw, _("Horizontal coordinate of selection"), TRUE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y", - -1e6, GTK_WIDGET(desktop->canvas), tracker, spw, + 0.0, GTK_WIDGET(desktop->canvas), tracker, spw, _("Vertical coordinate of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); eact = create_adjustment_action( "WidthAction", C_("Select toolbar", "Width"), C_("Select toolbar", "W:"), "width", - 1e-3, GTK_WIDGET(desktop->canvas), tracker, spw, + 0.0, GTK_WIDGET(desktop->canvas), tracker, spw, _("Width of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); @@ -528,7 +528,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb } eact = create_adjustment_action( "HeightAction", C_("Select toolbar", "Height"), C_("Select toolbar", "H:"), "height", - 1e-3, GTK_WIDGET(desktop->canvas), tracker, spw, + 0.0, GTK_WIDGET(desktop->canvas), tracker, spw, _("Height of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); -- cgit v1.2.3 From 659322af2957eb263b61301a19cd7d965c944207 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 5 Sep 2012 07:54:05 +0900 Subject: Fix for 1042602 : Select toolbar, fix for regression when X and Y values are negative (bzr r11651) --- src/widgets/select-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 4dfebe11f..61b04121a 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -497,13 +497,13 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // four spinbuttons eact = create_adjustment_action( "XAction", C_("Select toolbar", "X position"), C_("Select toolbar", "X:"), "X", - 0.0, GTK_WIDGET(desktop->canvas), tracker, spw, + -1e6, GTK_WIDGET(desktop->canvas), tracker, spw, _("Horizontal coordinate of selection"), TRUE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); eact = create_adjustment_action( "YAction", C_("Select toolbar", "Y position"), C_("Select toolbar", "Y:"), "Y", - 0.0, GTK_WIDGET(desktop->canvas), tracker, spw, + -1e6, GTK_WIDGET(desktop->canvas), tracker, spw, _("Vertical coordinate of selection"), FALSE ); gtk_action_group_add_action( selectionActions, GTK_ACTION(eact) ); contextActions->push_back( GTK_ACTION(eact) ); -- cgit v1.2.3 From aca1914d674a5e81234208248e3c8515a60dd19d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 12:30:12 +1000 Subject: code cleanup: make more functions static, add includes. (bzr r11737) --- src/widgets/select-toolbar.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 61b04121a..3ccfa9cf9 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -52,6 +52,7 @@ #include "ink-action.h" #include <2geom/rect.h> #include "ui/icon-names.h" +#include "select-toolbar.h" using Inkscape::UnitTracker; using Inkscape::DocumentUndo; -- cgit v1.2.3 From 8ee9827502fadcae0b02fec434799e94ee115357 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 25 Dec 2012 22:50:08 +0000 Subject: Convert a load more C-style pointer casts to GObject or C++ casts (merry christmas\!) (bzr r11986) --- src/widgets/select-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 3ccfa9cf9..549581610 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -88,13 +88,13 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) if (unit.base == SP_UNIT_DIMENSIONLESS) { double const val = 1. / unit.unittobase; for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { - GtkAdjustment *a = (GtkAdjustment *) g_object_get_data(G_OBJECT(spw), keyval[i].key); + GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); gtk_adjustment_set_value(a, val); tracker->setFullVal( a, keyval[i].val ); } } else { for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { - GtkAdjustment *a = (GtkAdjustment *) g_object_get_data(G_OBJECT(spw), keyval[i].key); + GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); gtk_adjustment_set_value(a, sp_pixels_get_units(keyval[i].val, unit)); } } -- cgit v1.2.3 From c3a160589a9cb41c70a56e5e7b66a65857a0d10e Mon Sep 17 00:00:00 2001 From: Eric Greveson Date: Mon, 1 Jul 2013 21:04:32 +0100 Subject: Factored layer model out into new Inkscape::LayerModel class. This allows Inkscape::Selection to use a LayerModel that is not associated with a UI. Changed the interface of verbs (SPAction) to use a new ActionContext rather than UI::View::View, again so that verbs may be used in a console mode. Modified boolean operation verbs to work in console-only mode. Fixed up DESKTOP_IS_ACTIVE macro to work in the case of no desktops. Modified main.cpp to process selections and verbs in no-GUI mode. Other changes are all consequences of the SPDesktop, Selection and LayerModel interface changes. (bzr r12387.1.1) --- src/widgets/select-toolbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 549581610..1bfc841e3 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -37,6 +37,8 @@ #include "sp-namedview.h" #include "toolbox.h" #include +#include "helper/action.h" +#include "helper/action-context.h" #include "helper/unit-menu.h" #include "helper/units.h" #include "inkscape.h" @@ -413,7 +415,7 @@ static GtkAction* create_action_for_verb( Inkscape::Verb* verb, Inkscape::UI::Vi { GtkAction* act = 0; - SPAction* targetAction = verb->get_action(view); + SPAction* targetAction = verb->get_action(Inkscape::ActionContext(view)); InkAction* inky = ink_action_new( verb->get_id(), verb->get_name(), verb->get_tip(), verb->get_image(), size ); act = GTK_ACTION(inky); -- cgit v1.2.3 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/select-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 549581610..693fc870b 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -488,7 +488,7 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // Create the units menu. UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); tracker->addUnit( SP_UNIT_PERCENT, 0 ); - tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); + //tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); g_object_set_data( G_OBJECT(spw), "tracker", tracker ); g_signal_connect( G_OBJECT(spw), "destroy", G_CALLBACK(destroy_tracker), spw ); -- 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/select-toolbar.cpp | 62 +++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 28 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index c0018751c..ffab3deab 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -39,8 +39,7 @@ #include #include "helper/action.h" #include "helper/action-context.h" -#include "helper/unit-menu.h" -#include "helper/units.h" +#include "util/units.h" #include "inkscape.h" #include "verbs.h" #include "selection.h" @@ -48,7 +47,7 @@ #include "sp-item-transform.h" #include "message-stack.h" #include "display/sp-canvas.h" -#include "helper/unit-tracker.h" +#include "ui/widget/unit-tracker.h" #include "ege-adjustment-action.h" #include "ege-output-action.h" #include "ink-action.h" @@ -56,7 +55,9 @@ #include "ui/icon-names.h" #include "select-toolbar.h" -using Inkscape::UnitTracker; +using Inkscape::UI::Widget::UnitTracker; +using Inkscape::Util::Unit; +using Inkscape::Util::Quantity; using Inkscape::DocumentUndo; static void @@ -78,7 +79,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) Geom::OptRect const bbox(sel->bounds(bbox_type)); if ( bbox ) { UnitTracker *tracker = reinterpret_cast(g_object_get_data(G_OBJECT(spw), "tracker")); - SPUnit const &unit = *tracker->getActiveUnit(); + Unit const unit = tracker->getActiveUnit(); struct { char const *key; double val; } const keyval[] = { { "X", bbox->min()[X] }, @@ -87,17 +88,19 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) { "height", bbox->dimensions()[Y] } }; - if (unit.base == SP_UNIT_DIMENSIONLESS) { - double const val = 1. / unit.unittobase; + if (unit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) { + double const val = unit.factor; for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); gtk_adjustment_set_value(a, val); tracker->setFullVal( a, keyval[i].val ); } } else { + Inkscape::Util::UnitTable unit_table; + Unit px = unit_table.getUnit("px"); for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); - gtk_adjustment_set_value(a, sp_pixels_get_units(keyval[i].val, unit)); + gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, &px, &unit)); } } } @@ -183,28 +186,31 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) gdouble y1 = 0; gdouble xrel = 0; gdouble yrel = 0; - SPUnit const &unit = *tracker->getActiveUnit(); + Unit const unit = tracker->getActiveUnit(); GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "X" ) ); GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "Y" ) ); GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) ); GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) ); - if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { - x0 = sp_units_get_pixels (gtk_adjustment_get_value (a_x), unit); - y0 = sp_units_get_pixels (gtk_adjustment_get_value (a_y), unit); - x1 = x0 + sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit); - xrel = sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit) / bbox_user->dimensions()[Geom::X]; - y1 = y0 + sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit); - yrel = sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit) / bbox_user->dimensions()[Geom::Y]; + Inkscape::Util::UnitTable unit_table; + Unit px = unit_table.getUnit("px"); + + if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { + x0 = Quantity::convert(gtk_adjustment_get_value(a_x), &unit, &px); + y0 = Quantity::convert(gtk_adjustment_get_value(a_y), &unit, &px); + x1 = x0 + Quantity::convert(gtk_adjustment_get_value(a_w), &unit, &px); + xrel = Quantity::convert(gtk_adjustment_get_value(a_w), &unit, &px) / bbox_user->dimensions()[Geom::X]; + y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), &unit, &px);; + yrel = Quantity::convert(gtk_adjustment_get_value(a_h), &unit, &px) / bbox_user->dimensions()[Geom::Y]; } else { - double const x0_propn = gtk_adjustment_get_value (a_x) * unit.unittobase; + double const x0_propn = gtk_adjustment_get_value (a_x) * unit.factor; x0 = bbox_user->min()[Geom::X] * x0_propn; - double const y0_propn = gtk_adjustment_get_value (a_y) * unit.unittobase; + double const y0_propn = gtk_adjustment_get_value (a_y) * unit.factor; y0 = y0_propn * bbox_user->min()[Geom::Y]; - xrel = gtk_adjustment_get_value (a_w) * unit.unittobase; + xrel = gtk_adjustment_get_value (a_w) * unit.factor; x1 = x0 + xrel * bbox_user->dimensions()[Geom::X]; - yrel = gtk_adjustment_get_value (a_h) * unit.unittobase; + yrel = gtk_adjustment_get_value (a_h) * unit.factor; y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y]; } @@ -225,11 +231,11 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) double sv = fabs(y1 - bbox_user->max()[Geom::Y]); // unless the unit is %, convert the scales and moves to the unit - if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { - mh = sp_pixels_get_units (mh, unit); - sh = sp_pixels_get_units (sh, unit); - mv = sp_pixels_get_units (mv, unit); - sv = sp_pixels_get_units (sv, unit); + if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { + mh = Quantity::convert(mh, &px, &unit); + sh = Quantity::convert(sh, &px, &unit); + mv = Quantity::convert(mv, &px, &unit); + sv = Quantity::convert(sv, &px, &unit); } // do the action only if one of the scales/moves is greater than half the last significant @@ -488,9 +494,9 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb gtk_container_add(GTK_CONTAINER(spw), vb); // Create the units menu. - UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); - tracker->addUnit( SP_UNIT_PERCENT, 0 ); - //tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); + UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); + //tracker->addUnit( SP_UNIT_PERCENT, 0 ); + tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); g_object_set_data( G_OBJECT(spw), "tracker", tracker ); g_signal_connect( G_OBJECT(spw), "destroy", G_CALLBACK(destroy_tracker), spw ); -- 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/select-toolbar.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index ffab3deab..617757845 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -97,10 +97,9 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) } } else { Inkscape::Util::UnitTable unit_table; - Unit px = unit_table.getUnit("px"); for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); - gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, &px, &unit)); + gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, "px", unit)); } } } @@ -194,15 +193,14 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) ); Inkscape::Util::UnitTable unit_table; - Unit px = unit_table.getUnit("px"); if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { - x0 = Quantity::convert(gtk_adjustment_get_value(a_x), &unit, &px); - y0 = Quantity::convert(gtk_adjustment_get_value(a_y), &unit, &px); - x1 = x0 + Quantity::convert(gtk_adjustment_get_value(a_w), &unit, &px); - xrel = Quantity::convert(gtk_adjustment_get_value(a_w), &unit, &px) / bbox_user->dimensions()[Geom::X]; - y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), &unit, &px);; - yrel = Quantity::convert(gtk_adjustment_get_value(a_h), &unit, &px) / bbox_user->dimensions()[Geom::Y]; + x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px"); + y0 = Quantity::convert(gtk_adjustment_get_value(a_y), unit, "px"); + x1 = x0 + Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px"); + xrel = Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px") / bbox_user->dimensions()[Geom::X]; + y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px");; + yrel = Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px") / bbox_user->dimensions()[Geom::Y]; } else { double const x0_propn = gtk_adjustment_get_value (a_x) * unit.factor; x0 = bbox_user->min()[Geom::X] * x0_propn; @@ -232,10 +230,10 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) // unless the unit is %, convert the scales and moves to the unit if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { - mh = Quantity::convert(mh, &px, &unit); - sh = Quantity::convert(sh, &px, &unit); - mv = Quantity::convert(mv, &px, &unit); - sv = Quantity::convert(sv, &px, &unit); + mh = Quantity::convert(mh, "px", unit); + sh = Quantity::convert(sh, "px", unit); + mv = Quantity::convert(mv, "px", unit); + sv = Quantity::convert(sv, "px", unit); } // do the action only if one of the scales/moves is greater than half the last significant -- cgit v1.2.3 From c135cb8c39a4004e9eb8adb227ba4c54848a8c45 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 16:45:07 -0400 Subject: Added percent support back to select toolbar. (bzr r12380.1.53) --- src/widgets/select-toolbar.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 617757845..ab6d6ca3b 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -89,7 +89,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) }; if (unit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) { - double const val = unit.factor; + double const val = unit.factor * 100; for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); gtk_adjustment_set_value(a, val); @@ -202,13 +202,13 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px");; yrel = Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px") / bbox_user->dimensions()[Geom::Y]; } else { - double const x0_propn = gtk_adjustment_get_value (a_x) * unit.factor; + double const x0_propn = gtk_adjustment_get_value (a_x) / 100 / unit.factor; x0 = bbox_user->min()[Geom::X] * x0_propn; - double const y0_propn = gtk_adjustment_get_value (a_y) * unit.factor; + double const y0_propn = gtk_adjustment_get_value (a_y) / 100 / unit.factor; y0 = y0_propn * bbox_user->min()[Geom::Y]; - xrel = gtk_adjustment_get_value (a_w) * unit.factor; + xrel = gtk_adjustment_get_value (a_w) / 100 / unit.factor; x1 = x0 + xrel * bbox_user->dimensions()[Geom::X]; - yrel = gtk_adjustment_get_value (a_h) * unit.factor; + yrel = gtk_adjustment_get_value (a_h) / 100 / unit.factor; y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y]; } @@ -493,7 +493,8 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // Create the units menu. UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); - //tracker->addUnit( SP_UNIT_PERCENT, 0 ); + Inkscape::Util::UnitTable unit_table; + tracker->addUnit(unit_table.getUnit("%")); tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); g_object_set_data( G_OBJECT(spw), "tracker", tracker ); -- cgit v1.2.3 From cd953884af566fce30421a9beee6cb71811ca792 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 1 Aug 2013 12:41:35 -0400 Subject: Improved math formatting. (bzr r12380.1.55) --- src/widgets/select-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index ab6d6ca3b..b39423635 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -206,9 +206,9 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) x0 = bbox_user->min()[Geom::X] * x0_propn; double const y0_propn = gtk_adjustment_get_value (a_y) / 100 / unit.factor; y0 = y0_propn * bbox_user->min()[Geom::Y]; - xrel = gtk_adjustment_get_value (a_w) / 100 / unit.factor; + xrel = gtk_adjustment_get_value (a_w) / (100 / unit.factor); x1 = x0 + xrel * bbox_user->dimensions()[Geom::X]; - yrel = gtk_adjustment_get_value (a_h) / 100 / unit.factor; + yrel = gtk_adjustment_get_value (a_h) / (100 / unit.factor); y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y]; } -- 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/select-toolbar.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index b39423635..e4a5a2905 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -59,6 +59,7 @@ using Inkscape::UI::Widget::UnitTracker; using Inkscape::Util::Unit; using Inkscape::Util::Quantity; using Inkscape::DocumentUndo; +using Inkscape::Util::unit_table; static void sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) @@ -96,7 +97,6 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) tracker->setFullVal( a, keyval[i].val ); } } else { - Inkscape::Util::UnitTable unit_table; for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); gtk_adjustment_set_value(a, Quantity::convert(keyval[i].val, "px", unit)); @@ -192,8 +192,6 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) ); GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) ); - Inkscape::Util::UnitTable unit_table; - if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px"); y0 = Quantity::convert(gtk_adjustment_get_value(a_y), unit, "px"); @@ -493,7 +491,6 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb // Create the units menu. UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); - Inkscape::Util::UnitTable unit_table; tracker->addUnit(unit_table.getUnit("%")); tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); -- cgit v1.2.3 From 5614df9770b985070122b3c08b45902317c9bd15 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 19:07:21 -0400 Subject: Enable unit evaluation in toolbars. (bzr r12475.1.22) --- src/widgets/select-toolbar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index e4a5a2905..590b0867f 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -273,7 +273,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE)); } -static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits ) +static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker ) { #if WITH_GTKMM_3_0 Glib::RefPtr adj = Glib::wrap(adjustment, true); @@ -281,6 +281,7 @@ static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRa #else Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits); #endif + inkSpinner->addUnitTracker(unit_tracker); inkSpinner = Gtk::manage( inkSpinner ); GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() ); return widget; @@ -313,7 +314,7 @@ static EgeAdjustmentAction * create_adjustment_action( gchar const *name, g_object_set_data( G_OBJECT(spw), data, adj ); } - EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3 ); + EgeAdjustmentAction* act = ege_adjustment_action_new( adj, name, Q_(label), tooltip, 0, SPIN_STEP, 3, tracker ); if ( shortLabel ) { g_object_set( act, "short_label", Q_(shortLabel), NULL ); } -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/widgets/select-toolbar.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 590b0867f..58d7134b3 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -80,7 +80,7 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) Geom::OptRect const bbox(sel->bounds(bbox_type)); if ( bbox ) { UnitTracker *tracker = reinterpret_cast(g_object_get_data(G_OBJECT(spw), "tracker")); - Unit const unit = tracker->getActiveUnit(); + Unit const *unit = tracker->getActiveUnit(); struct { char const *key; double val; } const keyval[] = { { "X", bbox->min()[X] }, @@ -89,8 +89,8 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) { "height", bbox->dimensions()[Y] } }; - if (unit.type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) { - double const val = unit.factor * 100; + if (unit->type == Inkscape::Util::UNIT_TYPE_DIMENSIONLESS) { + double const val = unit->factor * 100; for (unsigned i = 0; i < G_N_ELEMENTS(keyval); ++i) { GtkAdjustment *a = GTK_ADJUSTMENT(g_object_get_data(G_OBJECT(spw), keyval[i].key)); gtk_adjustment_set_value(a, val); @@ -185,14 +185,14 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) gdouble y1 = 0; gdouble xrel = 0; gdouble yrel = 0; - Unit const unit = tracker->getActiveUnit(); + Unit const *unit = tracker->getActiveUnit(); GtkAdjustment* a_x = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "X" ) ); GtkAdjustment* a_y = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "Y" ) ); GtkAdjustment* a_w = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "width" ) ); GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) ); - if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { + if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { x0 = Quantity::convert(gtk_adjustment_get_value(a_x), unit, "px"); y0 = Quantity::convert(gtk_adjustment_get_value(a_y), unit, "px"); x1 = x0 + Quantity::convert(gtk_adjustment_get_value(a_w), unit, "px"); @@ -200,13 +200,13 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) y1 = y0 + Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px");; yrel = Quantity::convert(gtk_adjustment_get_value(a_h), unit, "px") / bbox_user->dimensions()[Geom::Y]; } else { - double const x0_propn = gtk_adjustment_get_value (a_x) / 100 / unit.factor; + double const x0_propn = gtk_adjustment_get_value (a_x) / 100 / unit->factor; x0 = bbox_user->min()[Geom::X] * x0_propn; - double const y0_propn = gtk_adjustment_get_value (a_y) / 100 / unit.factor; + double const y0_propn = gtk_adjustment_get_value (a_y) / 100 / unit->factor; y0 = y0_propn * bbox_user->min()[Geom::Y]; - xrel = gtk_adjustment_get_value (a_w) / (100 / unit.factor); + xrel = gtk_adjustment_get_value (a_w) / (100 / unit->factor); x1 = x0 + xrel * bbox_user->dimensions()[Geom::X]; - yrel = gtk_adjustment_get_value (a_h) / (100 / unit.factor); + yrel = gtk_adjustment_get_value (a_h) / (100 / unit->factor); y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y]; } @@ -227,7 +227,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) double sv = fabs(y1 - bbox_user->max()[Geom::Y]); // unless the unit is %, convert the scales and moves to the unit - if (unit.type == Inkscape::Util::UNIT_TYPE_LINEAR) { + if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { mh = Quantity::convert(mh, "px", unit); sh = Quantity::convert(sh, "px", unit); mv = Quantity::convert(mv, "px", unit); -- cgit v1.2.3 From 3b7a3bd5d820cb7c41fe99254129d6603a5e9ff2 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Tue, 17 Dec 2013 18:01:44 -0500 Subject: modify transform behaviour for scaled stroke width, Preserved Transforms (bzr r12852) --- src/widgets/select-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 58d7134b3..542f6f115 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -259,7 +259,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) // we'll just use the old get_scale_transform_for_uniform_stroke() for now. // 2) get_scale_transform_for_uniform_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, x0, y0, x1, y1); + scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); -- cgit v1.2.3 From 08945ee8afa6e300b0a7ad8f20710db4756c2528 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 30 Dec 2013 15:23:58 -0500 Subject: modify transform behaviour for unscaled stroke width, Preserved Transforms (Bug 1262146) Fixed bugs: - https://launchpad.net/bugs/1262146 (bzr r12863) --- src/widgets/select-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 542f6f115..cf772320f 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -259,7 +259,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) // we'll just use the old get_scale_transform_for_uniform_stroke() for now. // 2) get_scale_transform_for_uniform_stroke() is intended for visual bounding boxes, not geometrical ones! // we'll trick it into using a geometric bounding box though, by setting the stroke width to zero - scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, false, false, x0, y0, x1, y1); + scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, 0, false, false, x0, y0, x1, y1); } sp_selection_apply_affine(selection, scaler); -- cgit v1.2.3 From e2b4cd6d88088f5be17bff214c62d85f2030eb20 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 4 Jan 2014 17:37:17 -0500 Subject: modify get_scale_transform_for_variable_stroke() to be consistent with get_scale_transform_for_uniform_stroke() (Bug 1262146) Fixed bugs: - https://launchpad.net/bugs/1262146 (bzr r12881) --- src/widgets/select-toolbar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index cf772320f..1cd4347d6 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -249,11 +249,12 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) // FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed sp_desktop_canvas(desktop)->forceFullRedrawAfterInterruptions(0); - int transform_stroke = prefs->getBool("/options/transform/stroke", true) ? 1 : 0; + bool transform_stroke = prefs->getBool("/options/transform/stroke", true); + bool preserve = prefs->getBool("/options/preservetransform/value", false); Geom::Affine scaler; if (bbox_type == SPItem::VISUAL_BBOX) { - scaler = get_scale_transform_for_variable_stroke (*bbox_vis, *bbox_geom, transform_stroke, x0, y0, x1, y1); + scaler = get_scale_transform_for_variable_stroke (*bbox_vis, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); } else { // 1) We could have use the newer get_scale_transform_for_variable_stroke() here, but to avoid regressions // we'll just use the old get_scale_transform_for_uniform_stroke() for now. -- cgit v1.2.3 From 7825ad6d1ac979689ac79d6497079aec36c6ae4b Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 2 Mar 2014 23:58:28 +0100 Subject: Fixed includes for tools. (bzr r13097) --- src/widgets/select-toolbar.cpp | 54 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'src/widgets/select-toolbar.cpp') diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 1cd4347d6..284e436bf 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -16,44 +16,36 @@ # include "config.h" #endif -#include "ui/widget/spinbutton.h" -#include - -#include "widgets/button.h" -#include "widgets/spw-utilities.h" -#include "widgets/widget-sizes.h" -#include "widgets/spinbutton-events.h" -#include "widgets/icon.h" -#include "widgets/sp-widget.h" +#include <2geom/rect.h> -#include "preferences.h" -#include "selection-chemistry.h" -#include "document.h" -#include "document-undo.h" -#include "inkscape.h" -#include "desktop-style.h" -#include "desktop.h" -#include "desktop-handles.h" -#include "sp-namedview.h" -#include "toolbox.h" +#include "ui/widget/spinbutton.h" #include -#include "helper/action.h" +#include "select-toolbar.h" +#include "desktop-handles.h" +#include "desktop.h" +#include "display/sp-canvas.h" +#include "document-undo.h" +#include "document.h" +#include "ege-adjustment-action.h" #include "helper/action-context.h" -#include "util/units.h" +#include "helper/action.h" +#include "ink-action.h" #include "inkscape.h" -#include "verbs.h" -#include "selection.h" +#include "message-stack.h" +#include "preferences.h" #include "selection-chemistry.h" +#include "selection.h" #include "sp-item-transform.h" -#include "message-stack.h" -#include "display/sp-canvas.h" -#include "ui/widget/unit-tracker.h" -#include "ege-adjustment-action.h" -#include "ege-output-action.h" -#include "ink-action.h" -#include <2geom/rect.h> +#include "sp-namedview.h" +#include "toolbox.h" #include "ui/icon-names.h" -#include "select-toolbar.h" +#include "ui/widget/unit-tracker.h" +#include "util/units.h" +#include "verbs.h" +#include "widgets/icon.h" +#include "widgets/sp-widget.h" +#include "widgets/spw-utilities.h" +#include "widgets/widget-sizes.h" using Inkscape::UI::Widget::UnitTracker; using Inkscape::Util::Unit; -- cgit v1.2.3