From bad0504958a10f1b99db3ae2557305541f388a52 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Nov 2014 20:56:53 +0100 Subject: Units: make it absolutely clear that Document properties unit dropdown is for UI Display Units. Upon document load, calculate the units used for SVG values, if a viewbox is available. If not, default to "px" SVG units. Change all code to use either Display units OR svg units. (bzr r13751) --- src/ui/dialog/clonetiler.cpp | 4 ++-- src/ui/dialog/document-properties.cpp | 4 ++-- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/guides.cpp | 4 ++-- src/ui/dialog/transformation.cpp | 4 ++-- src/ui/tool/node.cpp | 10 +++++----- src/ui/tools/arc-tool.cpp | 4 ++-- src/ui/tools/pen-tool.cpp | 2 +- src/ui/tools/rect-tool.cpp | 4 ++-- src/ui/tools/spiral-tool.cpp | 2 +- src/ui/tools/star-tool.cpp | 2 +- src/ui/tools/text-tool.cpp | 4 ++-- src/ui/widget/page-sizer.cpp | 4 ++-- src/ui/widget/selected-style.cpp | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index d1a675735..7a776a9b8 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1096,7 +1096,7 @@ CloneTiler::CloneTiler (void) : // unitmenu unit_menu = new Inkscape::UI::Widget::UnitMenu(); unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); - unit_menu->setUnit(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units->abbr); + unit_menu->setUnit(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->display_units->abbr); unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed)); { @@ -2251,7 +2251,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) clonetiler_remove (NULL, dlg, false); - double scale_units = Inkscape::Util::Quantity::convert(1, "px", sp_desktop_document(desktop)->getDefaultUnit()); + double scale_units = Inkscape::Util::Quantity::convert(1, "px", &sp_desktop_document(desktop)->getSVGUnit()); double shiftx_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shiftx_per_i", 0, -10000, 10000); double shifty_per_i = 0.01 * prefs->getDoubleLimited(prefs_path + "shifty_per_i", 0, -10000, 10000); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 9ab607ed2..f7701655c 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1480,8 +1480,8 @@ void DocumentProperties::update() _rcb_antialias.set_xml_target(root->getRepr(), dt->getDocument()); _rcb_antialias.setActive(root->style->shape_rendering.computed != SP_CSS_SHAPE_RENDERING_CRISPEDGES); - if (nv->doc_units) { - _rum_deflt.setUnit (nv->doc_units->abbr); + if (nv->display_units) { + _rum_deflt.setUnit (nv->display_units->abbr); } double doc_w = sp_desktop_document(dt)->getRoot()->width.value; diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index b044a6e2c..37022a186 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -206,7 +206,7 @@ Export::Export (void) : SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { - unit_selector.setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); + unit_selector.setUnit(sp_desktop_namedview(desktop)->display_units->abbr); } unitChangedConn = unit_selector.signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); unitbox.pack_end(unit_selector, false, false, 0); diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 4519a905f..221f9a1c0 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -216,8 +216,8 @@ void GuidelinePropertiesDialog::_setup() { /* fixme: We should allow percents here too, as percents of the canvas size */ _unit_menu.setUnitType(UNIT_TYPE_LINEAR); _unit_menu.setUnit("px"); - if (_desktop->namedview->doc_units) { - _unit_menu.setUnit( _desktop->namedview->doc_units->abbr ); + if (_desktop->namedview->display_units) { + _unit_menu.setUnit( _desktop->namedview->display_units->abbr ); } _spin_angle.setUnit(_angle_unit_status); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 3e135b9b2..6dbcf4a05 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -208,8 +208,8 @@ void Transformation::layoutPageMove() // Setting default unit to document unit SPDesktop *dt = getDesktop(); SPNamedView *nv = sp_desktop_namedview(dt); - if (nv->doc_units) { - _units_move.setUnit(nv->doc_units->abbr); + if (nv->display_units) { + _units_move.setUnit(nv->display_units->abbr); } _scalar_move_horizontal.initScalar(-1e6, 1e6); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8a1ca0b90..8c22f7c6e 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -566,9 +566,9 @@ Glib::ustring Handle::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); - GString *x = g_string_new(x_q.string(_desktop->namedview->doc_units).c_str()); - GString *y = g_string_new(y_q.string(_desktop->namedview->doc_units).c_str()); - GString *len = g_string_new(len_q.string(_desktop->namedview->doc_units).c_str()); + GString *x = g_string_new(x_q.string(_desktop->namedview->display_units).c_str()); + GString *y = g_string_new(y_q.string(_desktop->namedview->display_units).c_str()); + GString *len = g_string_new(len_q.string(_desktop->namedview->display_units).c_str()); Glib::ustring ret = format_tip(C_("Path handle tip", "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); g_string_free(x, TRUE); @@ -1490,8 +1490,8 @@ Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); - GString *x = g_string_new(x_q.string(_desktop->namedview->doc_units).c_str()); - GString *y = g_string_new(y_q.string(_desktop->namedview->doc_units).c_str()); + GString *x = g_string_new(x_q.string(_desktop->namedview->display_units).c_str()); + GString *y = g_string_new(y_q.string(_desktop->namedview->display_units).c_str()); Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x->str, y->str); g_string_free(x, TRUE); g_string_free(y, TRUE); diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index 4f64ade25..9c3195a42 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -405,8 +405,8 @@ void ArcTool::drag(Geom::Point pt, guint state) { Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px"); Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px"); - GString *xs = g_string_new(rdimx_q.string(desktop->namedview->doc_units).c_str()); - GString *ys = g_string_new(rdimy_q.string(desktop->namedview->doc_units).c_str()); + GString *xs = g_string_new(rdimx_q.string(desktop->namedview->display_units).c_str()); + GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str()); if (state & GDK_CONTROL_MASK) { int ratio_x, ratio_y; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 92937a135..fbcdf6142 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1366,7 +1366,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t Geom::Point rel = p - this->p[pc_point_to_compare]; Inkscape::Util::Quantity q = Inkscape::Util::Quantity(Geom::L2(rel), "px"); - GString *dist = g_string_new(q.string(desktop->namedview->doc_units).c_str()); + GString *dist = g_string_new(q.string(desktop->namedview->display_units).c_str()); double angle = atan2(rel[Geom::Y], rel[Geom::X]) * 180 / M_PI; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/compassangledisplay/value", 0) != 0) { diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index de91dcff4..67df0d9a5 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -422,8 +422,8 @@ void RectTool::drag(Geom::Point const pt, guint state) { Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px"); Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px"); - GString *xs = g_string_new(rdimx_q.string(desktop->namedview->doc_units).c_str()); - GString *ys = g_string_new(rdimy_q.string(desktop->namedview->doc_units).c_str()); + GString *xs = g_string_new(rdimx_q.string(desktop->namedview->display_units).c_str()); + GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str()); if (state & GDK_CONTROL_MASK) { int ratio_x, ratio_y; diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 18c3e4e2d..31c4e8829 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -395,7 +395,7 @@ void SpiralTool::drag(Geom::Point const &p, guint state) { /* status text */ Inkscape::Util::Quantity q = Inkscape::Util::Quantity(rad, "px"); - GString *rads = g_string_new(q.string(desktop->namedview->doc_units).c_str()); + GString *rads = g_string_new(q.string(desktop->namedview->display_units).c_str()); this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Spiral: radius %s, angle %5g°; with Ctrl to snap angle"), rads->str, sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001)); diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index 7604ba04e..b5544d263 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -411,7 +411,7 @@ void StarTool::drag(Geom::Point p, guint state) /* status text */ Inkscape::Util::Quantity q = Inkscape::Util::Quantity(r1, "px"); - GString *rads = g_string_new(q.string(desktop->namedview->doc_units).c_str()); + GString *rads = g_string_new(q.string(desktop->namedview->display_units).c_str()); this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, ( this->isflatsided? _("Polygon: radius %s, angle %5g°; with Ctrl to snap angle") diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index a72748733..578add843 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -590,8 +590,8 @@ bool TextTool::root_handler(GdkEvent* event) { // status text Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(fabs((p - this->p0)[Geom::X]), "px"); Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(fabs((p - this->p0)[Geom::Y]), "px"); - GString *xs = g_string_new(x_q.string(desktop->namedview->doc_units).c_str()); - GString *ys = g_string_new(y_q.string(desktop->namedview->doc_units).c_str()); + GString *xs = g_string_new(x_q.string(desktop->namedview->display_units).c_str()); + GString *ys = g_string_new(y_q.string(desktop->namedview->display_units).c_str()); this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Flowed text frame: %s × %s"), xs->str, ys->str); g_string_free(xs, FALSE); diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 32e357c57..b775b3c49 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -313,8 +313,8 @@ PageSizer::PageSizer(Registry & _wr) _wr.setUpdating (true); if (nv->page_size_units) { _dimensionUnits.setUnit(nv->page_size_units->abbr); - } else if (nv->doc_units) { - _dimensionUnits.setUnit(nv->doc_units->abbr); + } else if (nv->display_units) { + _dimensionUnits.setUnit(nv->display_units->abbr); } _wr.setUpdating (false); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index d22c59aa4..aebef2c4e 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -498,7 +498,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = sp_desktop_namedview(desktop)->doc_units; + _sw_unit = sp_desktop_namedview(desktop)->display_units; // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); -- cgit v1.2.3 From 3156b05d7fd41f6d770de9c330338654f6e1f03e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 24 Nov 2014 22:36:41 +0100 Subject: Fix a bug in pen/cil modes triangle in/out (bzr r13752) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index bd84e0efb..32702a17e 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -256,7 +256,7 @@ static void spdc_apply_powerstroke_shape(const std::vector & points std::ostringstream s; s.imbue(std::locale::classic()); - s << "0," << stroke_width / 2.; + s << points[0][Geom::X] << "," << stroke_width / 2.; // write powerstroke parameters: lpe->getRepr()->setAttribute("start_linecap_type", "zerowidth"); -- cgit v1.2.3 From 2c2ff538314e55a3e18104cbaee4a1b4d37ed396 Mon Sep 17 00:00:00 2001 From: Josh Andler Date: Tue, 25 Nov 2014 12:29:16 -0800 Subject: Disable preference widget to allow saving fonts in non-px units (bzr r13760) --- src/ui/dialog/inkscape-preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 75cfe5bfe..1fd8aa9be 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -461,7 +461,7 @@ void InkscapePreferences::initPageTools() _page_text.add_line( false, _("Text size unit type:"), _font_unit_type, "", _("Set the type of unit used in the text toolbar and text dialogs"), false); _font_output_px.init ( _("Always output text size in pixels (px)"), "/options/font/textOutputPx", true); - _page_text.add_line( false, "", _font_output_px, "", _("Always convert the text size units above into pixels (px) before saving to file")); +// _page_text.add_line( false, "", _font_output_px, "", _("Always convert the text size units above into pixels (px) before saving to file")); this->AddNewObjectsStyle(_page_text, "/tools/text"); -- cgit v1.2.3 From 8e07cf502ee5cfd1a31a394e19b39be80322413f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 25 Nov 2014 21:50:40 +0100 Subject: Fix applying LPE to clones (through the "+" button in the LPE dialog). The caller to sp_selection_clone_original_path_lpe expects a new path to be selected, and it will change the SVG "id" of that selected path. The bug was that sp_selection_clone_original_path_lpe no longer selected the new path, it maintained the selection of the path to be "clone_original_path'ed". And thus the path referenced by the original clone got its ID changed. Horror resulted. Fixed by selecting the newly created path, as before. Added code to the caller that checks if the newly selected path is not nullptr, and that it is not the same as the selected path before the call. (bzr r13761) --- src/ui/dialog/livepatheffect-editor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index eb3857ee7..178c32c38 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -475,9 +475,13 @@ LivePathEffectEditor::onAdd() // run sp_selection_clone_original_path_lpe sp_selection_clone_original_path_lpe(current_desktop); + SPItem *new_item = sel->singleItem(); - new_item->getRepr()->setAttribute("id", id); - new_item->getRepr()->setAttribute("transform", transform); + // Check that the cloning was successful. We don't want to change the ID of the original referenced path! + if (new_item && (new_item != orig)) { + new_item->getRepr()->setAttribute("id", id); + new_item->getRepr()->setAttribute("transform", transform); + } g_free(id); g_free(transform); -- cgit v1.2.3