From 30faf29165b1bcd936e9e0ca3ecc8b4bad4c94d2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 9 Sep 2017 03:54:39 +0200 Subject: This commit is based on a coment on bug #1670644. And allow to fill the fill between many LPE widget that allow attach all paths on the clipboard instead only one Also added to this widget the option visible, to allow work with multiples paths wigout getting full cracy --- src/ui/clipboard.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/ui/clipboard.h | 1 + 2 files changed, 50 insertions(+) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 3cc8ac098..202c8d922 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -105,6 +105,7 @@ public: virtual bool pastePathEffect(ObjectSet *set); virtual Glib::ustring getPathParameter(SPDesktop* desktop); virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop); + virtual std::vector getElementsOfType(SPDesktop *desktop, gchar const *type); virtual const gchar *getFirstObjectID(); ClipboardManagerImpl(); @@ -652,6 +653,54 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) return svgd; } +/** + * Get all objects id from the clipboard. + * @return A vector containing all IDs or empty if no shape or text item was found. + * type. Set to "*" to retrive all elements of the types vector inside, feel free to populate more + */ +std::vector ClipboardManagerImpl::getElementsOfType(SPDesktop *desktop, gchar const *type) +{ + std::vector result; + SPDocument *tempdoc = _retrieveClipboard(); // any target will do here + if ( tempdoc == NULL ) { + _userWarn(desktop, _("Nothing on the clipboard.")); + return result; + } + Inkscape::XML::Node *root = tempdoc->getReprRoot(); + + // 1293979: strip out the defs of the document + root->removeChild(tempdoc->getDefs()->getRepr()); + std::vector reprs; + if (strcmp(type, "*") == 0){ + //TODO:Fill vector with all posible elements + std::vector types; + types.push_back((Glib::ustring)"svg:path"); + types.push_back((Glib::ustring)"svg:circle"); + types.push_back((Glib::ustring)"svg:rect"); + types.push_back((Glib::ustring)"svg:ellipse"); + types.push_back((Glib::ustring)"svg:text"); + types.push_back((Glib::ustring)"svg:g"); + types.push_back((Glib::ustring)"svg:image"); + for (auto i=types.begin();i!=types.end();++i) { + Glib::ustring type_elem = *i; + std::vector reprs_found = sp_repr_lookup_name_many(root, type_elem.c_str(), -1); // unlimited search depth + reprs.insert(reprs.end(), reprs_found.begin(), reprs_found.end()); + } + } else { + reprs = sp_repr_lookup_name_many(root, type, -1); // unlimited search depth + } + for (auto i=reprs.begin();i!=reprs.end();++i) { + Inkscape::XML::Node const * node = *i; + result.push_back(node->attribute("id")); + } + if ( result.empty() ) { + _userWarn(desktop, ((Glib::ustring)_("Clipboard does not contain any.") + (Glib::ustring)type).c_str()); + tempdoc->doUnref(); + return result; + } + return result; +} + /** * Iterate over a list of items and copy them to the clipboard. */ diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h index 32a49867c..12dbd51df 100644 --- a/src/ui/clipboard.h +++ b/src/ui/clipboard.h @@ -51,6 +51,7 @@ public: virtual bool pastePathEffect(ObjectSet *set) = 0; virtual Glib::ustring getPathParameter(SPDesktop* desktop) = 0; virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop) = 0; + virtual std::vector getElementsOfType(SPDesktop *desktop, gchar const *type = "*") = 0; virtual const gchar *getFirstObjectID() = 0; static ClipboardManager *get(); -- cgit v1.2.3 From 1c31310676b12bd4fd5e477192bf7bd9fffabf83 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 9 Sep 2017 06:28:03 +0200 Subject: Fix a bug when creating a cloned LPE with fill between many --- src/ui/dialog/livepatheffect-editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 98789f7b2..02f76dbbb 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -473,7 +473,7 @@ LivePathEffectEditor::onAdd() item = NULL; // run sp_selection_clone_original_path_lpe - sel->cloneOriginalPathLPE(); + sel->cloneOriginalPathLPE(true); SPItem *new_item = sel->singleItem(); // Check that the cloning was successful. We don't want to change the ID of the original referenced path! -- cgit v1.2.3 From bf5a9dd8028a965e4f072ea45a802b4feb6f821a Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Thu, 14 Sep 2017 11:05:47 +0200 Subject: Added new LPE parameter to store Items array, also bugfixing in patharray parameter --- src/ui/clipboard.cpp | 2 +- src/ui/clipboard.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 202c8d922..33ad4401c 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -658,7 +658,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) * @return A vector containing all IDs or empty if no shape or text item was found. * type. Set to "*" to retrive all elements of the types vector inside, feel free to populate more */ -std::vector ClipboardManagerImpl::getElementsOfType(SPDesktop *desktop, gchar const *type) +std::vector ClipboardManagerImpl::getElementsOfType(SPDesktop *desktop, gchar const* type) { std::vector result; SPDocument *tempdoc = _retrieveClipboard(); // any target will do here diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h index 12dbd51df..390830bba 100644 --- a/src/ui/clipboard.h +++ b/src/ui/clipboard.h @@ -51,7 +51,7 @@ public: virtual bool pastePathEffect(ObjectSet *set) = 0; virtual Glib::ustring getPathParameter(SPDesktop* desktop) = 0; virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop) = 0; - virtual std::vector getElementsOfType(SPDesktop *desktop, gchar const *type = "*") = 0; + virtual std::vector getElementsOfType(SPDesktop *desktop, gchar const* type = "*") = 0; virtual const gchar *getFirstObjectID() = 0; static ClipboardManager *get(); -- cgit v1.2.3 From 1da36c2be7f64ba0aed75ecad4a5cbb1e972f261 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 15 Sep 2017 21:33:13 +0200 Subject: Add default extension for native win32 file save dialog. We manually appended an extension already (so functionality does not change), however GetSaveFileNameW also adds the chosen name (which was the name without extension before) to the list of recently used documents which resulted in unusable links. --- src/ui/dialog/filedialogimpl-win32.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui') diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 4fb8089ee..7f0bf58c5 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -1781,6 +1781,7 @@ void FileSaveDialogImplWin32::GetSaveFileName_thread() ofn.lpstrFilter = _filter; ofn.nFilterIndex = _filter_index; ofn.lpfnHook = GetSaveFileName_hookproc; + ofn.lpstrDefExt = L"svg\0"; ofn.lCustData = (LPARAM)this; _result = GetSaveFileNameW(&ofn) != 0; -- cgit v1.2.3 From 9bedc7179f307d9ee937c527f7e879a08e6ce98d Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Mon, 11 Sep 2017 14:40:00 +0200 Subject: Refactor Box3d::string_from_axes to use Glib::ustring --- src/ui/tools/box3d-tool.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 276385335..410fc3010 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -530,8 +530,9 @@ void Box3dTool::drag(guint /*state*/) { } else { // use default style GString *pstring = g_string_new(""); - g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side)); - desktop->applyCurrentOrToolStyle (side, pstring->str, false); + Glib::ustring tool_path = Glib::ustring::compose("/tools/shapes/3dbox/%1", + box3d_side_axes_string(side)); + desktop->applyCurrentOrToolStyle (side, tool_path, false); } side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description -- cgit v1.2.3 From 5fd6657569a041c62ae92d274299fc3b38c3fd0f Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Tue, 12 Sep 2017 09:31:05 +0200 Subject: Remove usage of GString from tool/node.cpp --- src/ui/tool/node.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index d6e491ac3..4f42400d4 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -559,14 +559,11 @@ 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->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 x = x_q.string(_desktop->namedview->display_units); + Glib::ustring y = y_q.string(_desktop->namedview->display_units); + Glib::ustring len = len_q.string(_desktop->namedview->display_units); 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); - g_string_free(y, TRUE); - g_string_free(len, TRUE); + "Move handle by %s, %s; angle %.2f°, length %s"), x.c_str(), y.c_str(), angle, len.c_str()); return ret; } @@ -1458,11 +1455,9 @@ 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->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); + Glib::ustring x = x_q.string(_desktop->namedview->display_units); + Glib::ustring y = y_q.string(_desktop->namedview->display_units); + Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), x.c_str(), y.c_str()); return ret; } -- cgit v1.2.3 From f392aac0d90b79faad248fec46450eabea0671d6 Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Tue, 12 Sep 2017 09:36:35 +0200 Subject: Remove usage of GString from ui/tools/spiral-tool.cpp --- src/ui/tools/spiral-tool.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index b681aec38..d2be32855 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -372,11 +372,10 @@ 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->display_units).c_str()); + Glib::ustring rads = q.string(desktop->namedview->display_units); 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)); - g_string_free(rads, FALSE); + rads.c_str(), sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001)); } void SpiralTool::finishItem() { -- cgit v1.2.3 From f3b050c16ac1db287f00ddd542efdb27d3c543fc Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Tue, 12 Sep 2017 09:46:21 +0200 Subject: Remove unused GString in ui/tools/box3d-tool.cpp --- src/ui/tools/box3d-tool.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 410fc3010..69555d6c9 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -529,7 +529,6 @@ void Box3dTool::drag(guint /*state*/) { side->setAttribute("style", cur_style.data()); } else { // use default style - GString *pstring = g_string_new(""); Glib::ustring tool_path = Glib::ustring::compose("/tools/shapes/3dbox/%1", box3d_side_axes_string(side)); desktop->applyCurrentOrToolStyle (side, tool_path, false); -- cgit v1.2.3 From 36863a0e699b5a7cba346bca8a26e729be5a2f87 Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Tue, 12 Sep 2017 10:13:54 +0200 Subject: Remove remaining usage of GString in ui/tools/* --- src/ui/tools/arc-tool.cpp | 11 ++++------- src/ui/tools/pen-tool.cpp | 5 ++--- src/ui/tools/rect-tool.cpp | 23 ++++++++++++++--------- src/ui/tools/star-tool.cpp | 6 ++---- src/ui/tools/text-tool.cpp | 10 +++------- 5 files changed, 25 insertions(+), 30 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index b501962fb..9ad42c842 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -385,8 +385,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->display_units).c_str()); - GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str()); + Glib::ustring xs = rdimx_q.string(desktop->namedview->display_units); + Glib::ustring ys = rdimy_q.string(desktop->namedview->display_units); if (state & GDK_CONTROL_MASK) { int ratio_x, ratio_y; @@ -399,13 +399,10 @@ void ArcTool::drag(Geom::Point pt, guint state) { ratio_y = (int) rint (rdimy / rdimx); } - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s (constrained to ratio %d:%d); with Shift to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s (constrained to ratio %d:%d); with Shift to draw around the starting point"), xs.c_str(), ys.c_str(), ratio_x, ratio_y); } else { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s; with Ctrl to make square or integer-ratio ellipse; with Shift to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s; with Ctrl to make square or integer-ratio ellipse; with Shift to draw around the starting point"), xs.c_str(), ys.c_str()); } - - g_string_free(xs, FALSE); - g_string_free(ys, FALSE); } void ArcTool::finishItem() { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 77cb5b6f8..0db5c3954 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1291,7 +1291,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->display_units).c_str()); + Glib::ustring dist = q.string(desktop->namedview->display_units); 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) { @@ -1301,8 +1301,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t } } - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str); - g_string_free(dist, false); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist.c_str()); } // this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used. diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 9ebf51e76..c04f44877 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -397,8 +397,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->display_units).c_str()); - GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str()); + Glib::ustring xs = rdimx_q.string(desktop->namedview->display_units); + Glib::ustring ys = rdimy_q.string(desktop->namedview->display_units); if (state & GDK_CONTROL_MASK) { int ratio_x, ratio_y; @@ -421,20 +421,25 @@ void RectTool::drag(Geom::Point const pt, guint state) { } if (!is_golden_ratio) { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s (constrained to ratio %d:%d); with Shift to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("Rectangle: %s × %s (constrained to ratio %d:%d); with Shift to draw around the starting point"), + xs.c_str(), ys.c_str(), ratio_x, ratio_y); } else { if (ratio_y == 1) { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s (constrained to golden ratio 1.618 : 1); with Shift to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("Rectangle: %s × %s (constrained to golden ratio 1.618 : 1); with Shift to draw around the starting point"), + xs.c_str(), ys.c_str()); } else { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s (constrained to golden ratio 1 : 1.618); with Shift to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("Rectangle: %s × %s (constrained to golden ratio 1 : 1.618); with Shift to draw around the starting point"), + xs.c_str(), ys.c_str()); } } } else { - this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s; with Ctrl to make square or integer-ratio rectangle; with Shift to draw around the starting point"), xs->str, ys->str); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, + _("Rectangle: %s × %s; with Ctrl to make square or integer-ratio rectangle; with Shift to draw around the starting point"), + xs.c_str(), ys.c_str()); } - - g_string_free(xs, FALSE); - g_string_free(ys, FALSE); } void RectTool::finishItem() { diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index 32f0e6d92..05a1f8f7c 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -389,14 +389,12 @@ 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->display_units).c_str()); + Glib::ustring rads = q.string(desktop->namedview->display_units); this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, ( this->isflatsided? _("Polygon: radius %s, angle %5g°; with Ctrl to snap angle") : _("Star: radius %s, angle %5g°; with Ctrl to snap angle") ), - rads->str, sp_round((arg1) * 180 / M_PI, 0.0001)); - - g_string_free(rads, FALSE); + rads.c_str(), sp_round((arg1) * 180 / M_PI, 0.0001)); } void StarTool::finishItem() { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 9091b455e..ee48c2348 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -575,13 +575,9 @@ 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->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); - g_string_free(ys, FALSE); - + Glib::ustring xs = x_q.string(desktop->namedview->display_units); + Glib::ustring ys = y_q.string(desktop->namedview->display_units); + this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Flowed text frame: %s × %s"), xs.c_str(), ys.c_str()); } else if (!this->sp_event_context_knot_mouseover()) { SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); -- cgit v1.2.3 From a474159bf7130e9b46a8da1efaf32e9eac4c55b7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 21 Sep 2017 23:12:27 +0200 Subject: Fix for bug #1715433 Clone original LPE can no longer be used to fill a powerstroke path --- src/ui/dialog/livepatheffect-editor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 02f76dbbb..28a42929b 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -206,9 +206,11 @@ LivePathEffectEditor::showParams(LivePathEffect::Effect& effect) if (defaultswidget) { Gtk::Expander * expander = NULL; std::vector childs = dynamic_cast (effectwidget)->get_children(); - std::vector childs_default = dynamic_cast (childs[childs.size()-1])->get_children(); - if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ - expanderopen = expander->get_expanded(); + if (childs.size()) { + std::vector childs_default = dynamic_cast (childs[childs.size()-1])->get_children(); + if ((expander = dynamic_cast(childs_default[childs_default.size()-1]))){ + expanderopen = expander->get_expanded(); + } } } effectcontrol_vbox.remove(*effectwidget); -- cgit v1.2.3 From 944a8da0e8b0aad82c5bee3754e26cd925f44c50 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 23 Sep 2017 23:55:16 +0200 Subject: Fix bug #1094504 GTK3: RegisteredColorPicker (e.g. for grid, guides color) does not show preview of current color --- src/ui/widget/color-preview.cpp | 45 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index c9b6e56d2..54b2991f0 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -11,6 +11,7 @@ #include "ui/widget/color-preview.h" #include "display/cairo-utils.h" +#include #define SPCP_DEFAULT_WIDTH 32 #define SPCP_DEFAULT_HEIGHT 12 @@ -70,45 +71,45 @@ ColorPreview::setRgba32 (guint32 rgba) bool ColorPreview::on_draw(const Cairo::RefPtr& cr) { - GdkRectangle warea, carea; - gint w2; - + double x, y, width, height; const Gtk::Allocation& allocation = get_allocation(); - warea.x = allocation.get_x(); - warea.y = allocation.get_y(); - warea.width = allocation.get_width(); - warea.height = allocation.get_height(); + x = 0; + y = 0; + width = allocation.get_width()/2.0; + height = allocation.get_height(); + + double radius = height / 7.5; + double degrees = M_PI / 180.0; + cairo_new_sub_path (cr->cobj()); + cairo_line_to(cr->cobj(), width, 0); + cairo_line_to(cr->cobj(), width, height); + cairo_arc (cr->cobj(), x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees); + cairo_arc (cr->cobj(), x + radius, y + radius, radius, 180 * degrees, 270 * degrees); + cairo_close_path (cr->cobj()); /* Transparent area */ - w2 = warea.width / 2; - - carea.x = warea.x; - carea.y = warea.y; - carea.width = w2; - carea.height = warea.height; - cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard(); - cr->rectangle(carea.x, carea.y, carea.width, carea.height); cairo_set_source(cr->cobj(), checkers); cr->fill_preserve(); ink_cairo_set_source_rgba32(cr->cobj(), _rgba); cr->fill(); - cairo_pattern_destroy(checkers); /* Solid area */ - carea.x = warea.x + w2; - carea.y = warea.y; - carea.width = warea.width - w2; - carea.height = warea.height; + x = width; - cr->rectangle(carea.x, carea.y, carea.width, carea.height); + cairo_new_sub_path (cr->cobj()); + cairo_arc (cr->cobj(), x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees); + cairo_arc (cr->cobj(), x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees); + cairo_line_to(cr->cobj(), x, height); + cairo_line_to(cr->cobj(), x, y); + cairo_close_path (cr->cobj()); ink_cairo_set_source_rgba32(cr->cobj(), _rgba | 0xff); cr->fill(); - + return true; } -- cgit v1.2.3 From 6a03015b016c177e0657fc6274a571db16e48b64 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sat, 23 Sep 2017 10:02:16 +0200 Subject: Remove unused parameter in SPItem::doWriteTransform --- src/ui/dialog/grid-arrange-tab.cpp | 2 +- src/ui/dialog/layers.cpp | 4 ++-- src/ui/dialog/polar-arrange-tab.cpp | 2 +- src/ui/dialog/transformation.cpp | 2 +- src/ui/tools/arc-tool.cpp | 2 +- src/ui/tools/calligraphic-tool.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 2 +- src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/freehand-base.cpp | 2 +- src/ui/tools/measure-tool.cpp | 4 ++-- src/ui/tools/rect-tool.cpp | 2 +- src/ui/tools/spiral-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 4 ++-- src/ui/tools/star-tool.cpp | 2 +- src/ui/tools/text-tool.cpp | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 3cbc1b6e9..6e08645cf 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -329,7 +329,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); item->set_i2d_affine(item->i2dt_affine() * affine); - item->doWriteTransform(repr, item->transform, NULL); + item->doWriteTransform(item->transform); SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; } diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 3c99d1461..4a381a565 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -713,12 +713,12 @@ void LayersPanel::_doTreeMove( ) { if (_dnd_source && _dnd_source->getRepr() ) { if(!_dnd_target){ - _dnd_source->doWriteTransform(_dnd_source->getRepr(), _dnd_source->i2doc_affine() * _dnd_source->document->getRoot()->i2doc_affine().inverse()); + _dnd_source->doWriteTransform(_dnd_source->i2doc_affine() * _dnd_source->document->getRoot()->i2doc_affine().inverse()); }else{ SPItem* parent = _dnd_into ? _dnd_target : dynamic_cast(_dnd_target->parent); if(parent){ Geom::Affine move = _dnd_source->i2doc_affine() * parent->i2doc_affine().inverse(); - _dnd_source->doWriteTransform(_dnd_source->getRepr(), move); + _dnd_source->doWriteTransform(move); } } _dnd_source->moveTo(_dnd_target, _dnd_into); diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 2b4550d20..75e1a56b8 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -140,7 +140,7 @@ static void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &r center = item->getCenter(); item->set_i2d_affine(item->i2dt_affine() * affine); - item->doWriteTransform(item->getRepr(), item->transform); + item->doWriteTransform(item->transform); if(item->isCenterSet()) { diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 5ad1b9ec5..8713e6ddc 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -727,7 +727,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); item->set_i2d_affine(item->i2dt_affine() * scaler); - item->doWriteTransform(item->getRepr(), item->transform); + item->doWriteTransform(item->transform); } } } else { diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index b501962fb..712561b85 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -418,7 +418,7 @@ void ArcTool::finishItem() { } this->arc->updateRepr(); - this->arc->doWriteTransform(this->arc->getRepr(), this->arc->transform, NULL, true); + this->arc->doWriteTransform(this->arc->transform, NULL, true); desktop->canvas->endForcedFullRedraws(); diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 266375caa..3e00fe69c 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -947,7 +947,7 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) { result = desktop->getSelection()->singleItem(); } - result->doWriteTransform(result->getRepr(), result->transform, NULL, true); + result->doWriteTransform(result->transform, NULL, true); } else { if (this->repr) { sp_repr_unparent(this->repr); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 6d2682089..59d670d74 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -904,7 +904,7 @@ void ConnectorTool::_flushWhite(SPCurve *gc) { this->newconn->updateRepr(); } - this->newconn->doWriteTransform(this->newconn->getRepr(), this->newconn->transform, NULL, true); + this->newconn->doWriteTransform(this->newconn->transform, NULL, true); // Only set the selection after we are finished with creating the attributes of // the connector. Otherwise, the selection change may alter the defaults for diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b4246b9cc..b919c138c 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -780,7 +780,7 @@ void EraserTool::set_to_accumulated() { if (dup_clip) { SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip)); if (dup_clip_obj) { - dup_clip_obj->doWriteTransform(dup_clip, item->transform); + dup_clip_obj->doWriteTransform(item->transform); sp_object_ref(clip_path, 0); clip_path->deleteObject(true); sp_object_unref(clip_path); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index f6f9b4355..daeff228c 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -444,7 +444,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { - SP_ITEM(reprobj)->doWriteTransform(pathRepr, transform, NULL); + SP_ITEM(reprobj)->doWriteTransform(transform); // premultiply the item transform by the accumulated parent transform in the paste layer Geom::Affine local (SP_GROUP(desktop->currentLayer())->i2doc_affine()); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 4313c4e29..fce17542a 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -822,7 +822,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) Inkscape::GC::release(repr); item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); - item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + item->doWriteTransform(item->transform, NULL, true); spdc_check_for_and_apply_waiting_LPE(dc, item, c, false); dc->selection->set(repr); if(previous_shape_type == BEND_CLIPBOARD){ diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 0da883891..24295e7cf 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1005,7 +1005,7 @@ void MeasureTool::setLabelText(const char *value, Geom::Point pos, double fontsi text_item_box->transform *= Geom::Translate(pos); text_item_box->transform *= SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); text_item_box->updateRepr(); - text_item_box->doWriteTransform(text_item_box->getRepr(), text_item_box->transform, NULL, true); + text_item_box->doWriteTransform(text_item_box->transform, NULL, true); Inkscape::XML::Node *rlabel = text_item_box->getRepr(); text_item_box->deleteObject(); measure_repr->addChild(rlabel, NULL); @@ -1014,7 +1014,7 @@ void MeasureTool::setLabelText(const char *value, Geom::Point pos, double fontsi text_item->transform *= Geom::Rotate(angle); text_item->transform *= Geom::Translate(pos); text_item->transform *= SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - text_item->doWriteTransform(text_item->getRepr(), text_item->transform, NULL, true); + text_item->doWriteTransform(text_item->transform, NULL, true); } } diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 9ebf51e76..0a116e8cd 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -447,7 +447,7 @@ void RectTool::finishItem() { } this->rect->updateRepr(); - this->rect->doWriteTransform(this->rect->getRepr(), this->rect->transform, NULL, true); + this->rect->doWriteTransform(this->rect->transform, NULL, true); this->desktop->canvas->endForcedFullRedraws(); diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index b681aec38..8e10935e8 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -390,7 +390,7 @@ void SpiralTool::finishItem() { spiral->set_shape(); spiral->updateRepr(SP_OBJECT_WRITE_EXT); - spiral->doWriteTransform(spiral->getRepr(), spiral->transform, NULL, true); + spiral->doWriteTransform(spiral->transform, NULL, true); this->desktop->canvas->endForcedFullRedraws(); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index f3e7e6d3c..eec7babc4 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -120,7 +120,7 @@ static void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *i // Rotate item. item->set_i2d_affine(item->i2dt_affine() * affine); // Use each item's own transform writer, consistent with sp_selection_apply_affine() - item->doWriteTransform(item->getRepr(), item->transform); + item->doWriteTransform(item->transform); // Restore the center position (it's changed because the bbox center changed) if (item->isCenterSet()) { item->setCenter(c); @@ -133,7 +133,7 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it { Geom::Translate const s(c); item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); - item->doWriteTransform(item->getRepr(), item->transform); + item->doWriteTransform(item->transform); } SprayTool::SprayTool() diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index 32f0e6d92..d5e782f68 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -415,7 +415,7 @@ void StarTool::finishItem() { this->star->setCenter(this->center); this->star->set_shape(); this->star->updateRepr(SP_OBJECT_WRITE_EXT); - this->star->doWriteTransform(this->star->getRepr(), this->star->transform, NULL, true); + this->star->doWriteTransform(this->star->transform, NULL, true); desktop->canvas->endForcedFullRedraws(); diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 9091b455e..bab4ebb59 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -417,7 +417,7 @@ static void sp_text_context_setup_text(TextTool *tc) text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse(); text_item->updateRepr(); - text_item->doWriteTransform(text_item->getRepr(), text_item->transform, NULL, true); + text_item->doWriteTransform(text_item->transform, NULL, true); DocumentUndo::done(ec->desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Create text")); } -- cgit v1.2.3 From 943cb6ba767b1f3fd35fb3bb74161f224a53cdc7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Mon, 25 Sep 2017 21:33:14 +0200 Subject: Add improvements to meassure segments LPE pointed by CR --- src/ui/widget/registered-widget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 639bd4161..a88413347 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -412,9 +412,12 @@ RegisteredColorPicker::on_changed (guint32 rgba) local_repr = dt->getNamedView()->getRepr(); local_doc = dt->getDocument(); } - gchar c[32]; - sp_svg_write_color(c, sizeof(c), rgba); + if (_akey == _ckey + "_opacity_LPE") { //For LPE parameter we want stored with alpha + sprintf(c, "#%08x", rgba); + } else { + sp_svg_write_color(c, sizeof(c), rgba); + } bool saved = DocumentUndo::getUndoSensitive(local_doc); DocumentUndo::setUndoSensitive(local_doc, false); local_repr->setAttribute(_ckey.c_str(), c); -- cgit v1.2.3 From e79dffd40b61de158876961997df5c3cb3f34414 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 29 Sep 2017 18:31:55 +0200 Subject: remove helper/gnome-utils.* --- src/ui/interface.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui') diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 0223b2b3b..93e91b8f8 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -51,7 +51,6 @@ #include "sp-namedview.h" #include "sp-root.h" #include "helper/action.h" -#include "helper/gnome-utils.h" #include "helper/window.h" #include "io/sys.h" #include "ui/dialog-events.h" @@ -1339,12 +1338,13 @@ static void sp_ui_drag_leave( GtkWidget */*widget*/, static void sp_ui_import_files(gchar *buffer) { - GList *list = gnome_uri_list_extract_filenames(buffer); - if (!list) - return; - g_list_foreach(list, sp_ui_import_one_file_with_check, NULL); - g_list_foreach(list, (GFunc) g_free, NULL); - g_list_free(list); + gchar** l = g_uri_list_extract_uris(buffer); + for (int i = 0; i< g_strv_length (l); i++) { + gchar *f = g_filename_from_uri (l[i], NULL, NULL); + sp_ui_import_one_file_with_check(f, NULL); + g_free(f); + } + g_strfreev(l); } static void -- cgit v1.2.3 From 4ced018164553d115a24947ec74dace836e99732 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 30 Sep 2017 02:25:47 +0200 Subject: Hunted every GList to the last (except in libnrtype and libcroco) --- src/ui/dialog/clonetiler.cpp | 7 +++---- src/ui/dialog/inkscape-preferences.cpp | 18 +++++++----------- src/ui/interface.cpp | 10 ++++------ src/ui/widget/page-sizer.cpp | 14 ++++++-------- src/ui/widget/page-sizer.h | 2 +- 5 files changed, 21 insertions(+), 30 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index ad13ed8c4..5c9b31fb1 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2639,11 +2639,10 @@ void CloneTiler::reset_recursive(GtkWidget *w) } if (GTK_IS_CONTAINER(w)) { - GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); - for (GList *i = ch; i != NULL; i = i->next) { - reset_recursive (GTK_WIDGET(i->data)); + std::vector c = Glib::wrap(GTK_CONTAINER(w))->get_children(); + for ( auto i : c ) { + reset_recursive(i->gobj()); } - g_list_free (ch); } } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 13729cf0f..d87a3d94a 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "preferences.h" #include "verbs.h" @@ -2057,21 +2059,15 @@ bool InkscapePreferences::PresentPage(const Gtk::TreeModel::iterator& iter) void InkscapePreferences::on_reset_open_recent_clicked() { - GtkRecentManager* manager = gtk_recent_manager_get_default(); - GList* recent_list = gtk_recent_manager_get_items(manager); - GList* element; - GError* error; + Glib::RefPtr manager = Gtk::RecentManager::get_default(); + std::vector< Glib::RefPtr< Gtk::RecentInfo > > recent_list = manager->get_items(); //Remove only elements that were added by Inkscape - for (element = g_list_first(recent_list); element; element = g_list_next(element)){ - error = NULL; - GtkRecentInfo* info = (GtkRecentInfo*) element->data; - if (gtk_recent_info_has_application(info, g_get_prgname())){ - gtk_recent_manager_remove_item(manager, gtk_recent_info_get_uri(info), &error); + for (auto e : recent_list) { + if (e->has_application(g_get_prgname())) { + manager->remove_item(e->get_uri()); } - gtk_recent_info_unref (info); } - g_list_free(recent_list); } void InkscapePreferences::on_pagelist_selection_changed() diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 93e91b8f8..7a9b92378 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1436,14 +1436,12 @@ sp_ui_menu_item_set_name(GtkWidget *data, Glib::ustring const &name) if (GTK_IS_LABEL(child)) { gtk_label_set_markup_with_mnemonic(GTK_LABEL (child), name.c_str()); } else if (GTK_IS_BOX(child)) { - GList *children = gtk_container_get_children(GTK_CONTAINER(child)); + std::vector children = Glib::wrap(GTK_CONTAINER(child))->get_children(); // Label is second child in list - GtkWidget *label = GTK_WIDGET(children->next->data); - - gtk_label_set_markup_with_mnemonic( - GTK_LABEL (label), - name.c_str()); + Gtk::Label *label = dynamic_cast(children[1]); + if(!label) return; + label->set_markup_with_mnemonic(name); }//else sp_ui_menu_append_item_from_verb has been modified and can set //a menu item in yet another way... } diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index eb0e45f14..7427ad4e2 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -355,13 +355,12 @@ PageSizer::PageSizer(Registry & _wr) _fitPageMarginExpander.set_vexpand(); _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1); - _dimTabOrderGList = NULL; - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj()); - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionHeight.gobj()); - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionUnits.gobj()); - _dimTabOrderGList = g_list_append(_dimTabOrderGList, _fitPageMarginExpander.gobj()); - Glib::ListHandle dimFocusChain(_dimTabOrderGList, Glib::OWNERSHIP_NONE); - _customDimTable.set_focus_chain(dimFocusChain); + _dimTabOrderList.clear(); + _dimTabOrderList.push_back(&_dimensionWidth); + _dimTabOrderList.push_back(&_dimensionHeight); + _dimTabOrderList.push_back(&_dimensionUnits); + _dimTabOrderList.push_back(&_fitPageMarginExpander); + _customDimTable.set_focus_chain(_dimTabOrderList); //## Set up fit page expander _fitPageMarginExpander.set_use_underline(); @@ -454,7 +453,6 @@ PageSizer::PageSizer(Registry & _wr) */ PageSizer::~PageSizer() { - g_list_free(_dimTabOrderGList); } diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index f84f96782..329ecfc6d 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -220,7 +220,7 @@ protected: RegisteredUnitMenu _dimensionUnits; RegisteredScalarUnit _dimensionWidth; RegisteredScalarUnit _dimensionHeight; - GList * _dimTabOrderGList; + std::vector _dimTabOrderList; //### Fit Page options Gtk::Expander _fitPageMarginExpander; -- cgit v1.2.3 From d4432a4aaf3fb615d9808f53557a4283436bf035 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sun, 1 Oct 2017 15:27:03 +0200 Subject: Fix the editing of clipping and masking objects By passing along an edit_transform matrix, as done for clipping paths. Cleanups: - remove some unused methods - use member initialization --- src/ui/shape-editor.cpp | 19 +++++++------------ src/ui/shape-editor.h | 4 ++-- src/ui/tools/node-tool.cpp | 3 ++- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src/ui') diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index 6a8f5e931..2c0e662ee 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -31,10 +31,12 @@ namespace UI { bool ShapeEditor::_blockSetItem = false; -ShapeEditor::ShapeEditor(SPDesktop *dt) { - this->desktop = dt; - this->knotholder = NULL; - this->knotholder_listener_attached_for = NULL; +ShapeEditor::ShapeEditor(SPDesktop *dt, Geom::Affine edit_transform) : + desktop(dt), + knotholder(nullptr), + knotholder_listener_attached_for(nullptr), + _edit_transform(edit_transform) +{ } ShapeEditor::~ShapeEditor() { @@ -76,14 +78,6 @@ void ShapeEditor::decrement_local_change() { } } -const SPItem *ShapeEditor::get_item() { - const SPItem *item = NULL; - if (this->has_knotholder()) { - item = this->knotholder->getItem(); - } - return item; -} - void ShapeEditor::event_attr_changed(Inkscape::XML::Node * node, gchar const *name, gchar const *, gchar const *, bool, void *data) { g_assert(data); @@ -129,6 +123,7 @@ void ShapeEditor::set_item(SPItem *item, bool keep_knotholder) { this->knotholder = createKnotHolder(item, desktop); } if (this->knotholder) { + this->knotholder->setEditTransform(_edit_transform); this->knotholder->update_knots(); // setting new listener repr = this->knotholder->repr; diff --git a/src/ui/shape-editor.h b/src/ui/shape-editor.h index 7f435efca..e30b2d60b 100644 --- a/src/ui/shape-editor.h +++ b/src/ui/shape-editor.h @@ -23,7 +23,7 @@ namespace UI { class ShapeEditor { public: - ShapeEditor(SPDesktop *desktop); + ShapeEditor(SPDesktop *desktop, Geom::Affine edit_transform = Geom::identity()); ~ShapeEditor(); void set_item(SPItem *item, bool keep_knotholder = false); @@ -42,11 +42,11 @@ public: char const * /*new_value*/, bool /*is_interactive*/, void *data); private: void reset_item (bool keep_knotholder = true); - const SPItem *get_item(); static bool _blockSetItem; SPDesktop *desktop; Inkscape::XML::Node *knotholder_listener_attached_for; + Geom::Affine _edit_transform; }; } // namespace UI diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index d508a16f2..e7825e302 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -358,6 +358,7 @@ void NodeTool::set(const Inkscape::Preferences::Entry& value) { } /** Recursively collect ShapeRecords */ +static void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::ShapeRole role, std::set &s) { @@ -437,7 +438,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item) || SP_IS_GROUP(r.item) || SP_IS_OBJECTGROUP(r.item)) && this->_shape_editors.find(r.item) == this->_shape_editors.end()) { - ShapeEditor *si = new ShapeEditor(this->desktop); + ShapeEditor *si = new ShapeEditor(this->desktop, r.edit_transform); si->set_item(r.item); this->_shape_editors.insert(const_cast(r.item), si); } -- cgit v1.2.3 From 1d7b7827cef0755aa92387e48bdde4d2a9c06318 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sun, 1 Oct 2017 15:47:50 +0200 Subject: Rename object-edit.cpp to what it really is --- src/ui/CMakeLists.txt | 3 +- src/ui/object-edit.cpp | 1618 ---------------------------------- src/ui/object-edit.h | 84 -- src/ui/shape-editor-knotholders.cpp | 1666 +++++++++++++++++++++++++++++++++++ src/ui/shape-editor.cpp | 4 +- 5 files changed, 1669 insertions(+), 1706 deletions(-) delete mode 100644 src/ui/object-edit.cpp delete mode 100644 src/ui/object-edit.h create mode 100644 src/ui/shape-editor-knotholders.cpp (limited to 'src/ui') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index efdb279b4..be13d9b1b 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -5,10 +5,10 @@ set(ui_SRC dialog-events.cpp draw-anchor.cpp interface.cpp - object-edit.cpp previewholder.cpp selected-color.cpp shape-editor.cpp + shape-editor-knotholders.cpp tool-factory.cpp tools-switch.cpp uxmanager.cpp @@ -185,7 +185,6 @@ set(ui_SRC event-debug.h icon-names.h interface.h - object-edit.h previewable.h previewfillable.h previewholder.h diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp deleted file mode 100644 index a2b6a2de0..000000000 --- a/src/ui/object-edit.cpp +++ /dev/null @@ -1,1618 +0,0 @@ -/* - * Node editing extension to objects - * - * Authors: - * Lauris Kaplinski - * Mitsuru Oka - * Maximilian Albert - * Abhishek Sharma - * Jon A. Cruz - * - * Licensed under GNU GPL - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "sp-item.h" -#include "sp-rect.h" -#include "box3d.h" -#include "sp-ellipse.h" -#include "sp-star.h" -#include "sp-spiral.h" -#include "sp-offset.h" -#include "sp-flowtext.h" -#include "preferences.h" -#include "style.h" -#include "desktop.h" - -#include "sp-namedview.h" -#include "live_effects/effect.h" -#include "sp-pattern.h" -#include -#include "ui/object-edit.h" -#include "knot-holder-entity.h" - -#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) - -namespace { - -static KnotHolder *sp_lpe_knot_holder(SPLPEItem *item, SPDesktop *desktop) -{ - KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL); - - Inkscape::LivePathEffect::Effect *effect = item->getCurrentLPE(); - effect->addHandles(knot_holder, item); - - return knot_holder; -} - -} // namespace - -namespace Inkscape { -namespace UI { - -KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) -{ - KnotHolder *knotholder = NULL; - - SPLPEItem *lpe = dynamic_cast(item); - if (lpe && - lpe->getCurrentLPE() && - lpe->getCurrentLPE()->isVisible() && - lpe->getCurrentLPE()->providesKnotholder()) { - knotholder = sp_lpe_knot_holder(lpe, desktop); - } else if (dynamic_cast(item)) { - knotholder = new RectKnotHolder(desktop, item, NULL); - } else if (dynamic_cast(item)) { - knotholder = new Box3DKnotHolder(desktop, item, NULL); - } else if (dynamic_cast(item)) { - knotholder = new ArcKnotHolder(desktop, item, NULL); - } else if (dynamic_cast(item)) { - knotholder = new StarKnotHolder(desktop, item, NULL); - } else if (dynamic_cast(item)) { - knotholder = new SpiralKnotHolder(desktop, item, NULL); - } else if (dynamic_cast(item)) { - knotholder = new OffsetKnotHolder(desktop, item, NULL); - } else { - SPFlowtext *flowtext = dynamic_cast(item); - if (flowtext && flowtext->has_internal_frame()) { - knotholder = new FlowtextKnotHolder(desktop, flowtext->get_frame(NULL), NULL); - } else if ((item->style->fill.isPaintserver() && dynamic_cast(item->style->getFillPaintServer())) || - (item->style->stroke.isPaintserver() && dynamic_cast(item->style->getStrokePaintServer()))) { - knotholder = new KnotHolder(desktop, item, NULL); - knotholder->add_pattern_knotholder(); - } - } - - return knotholder; -} - -} -} // namespace Inkscape - -/* SPRect */ - -/* handle for horizontal rounding radius */ -class RectKnotHolderEntityRX : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -/* handle for vertical rounding radius */ -class RectKnotHolderEntityRY : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -/* handle for width/height adjustment */ -class RectKnotHolderEntityWH : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - -protected: - void set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -/* handle for x/y adjustment */ -class RectKnotHolderEntityXY : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -/* handle for position */ -class RectKnotHolderEntityCenter : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -Geom::Point -RectKnotHolderEntityRX::knot_get() const -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - return Geom::Point(rect->x.computed + rect->width.computed - rect->rx.computed, rect->y.computed); -} - -void -RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - //In general we cannot just snap this radius to an arbitrary point, as we have only a single - //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap - //the radius then we should have a constrained snap. snap_knot_position() is unconstrained - Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)), state); - - if (state & GDK_CONTROL_MASK) { - gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0; - rect->rx = rect->ry = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, temp); - } else { - rect->rx = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0); - } - - update_knot(); - - rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -void -RectKnotHolderEntityRX::knot_click(unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - if (state & GDK_SHIFT_MASK) { - /* remove rounding from rectangle */ - rect->getRepr()->setAttribute("rx", NULL); - rect->getRepr()->setAttribute("ry", NULL); - } else if (state & GDK_CONTROL_MASK) { - /* Ctrl-click sets the vertical rounding to be the same as the horizontal */ - rect->getRepr()->setAttribute("ry", rect->getRepr()->attribute("rx")); - } - -} - -Geom::Point -RectKnotHolderEntityRY::knot_get() const -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->ry.computed); -} - -void -RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - //In general we cannot just snap this radius to an arbitrary point, as we have only a single - //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap - //the radius then we should have a constrained snap. snap_knot_position() is unconstrained - Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)), state); - - if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry, - // resulting in a perfect circle (and not an ellipse) - gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0; - rect->rx = rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, 0.0, temp); - } else { - if (!rect->rx._set || rect->rx.computed == 0) { - rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, - 0.0, - MIN(rect->height.computed / 2.0, rect->width.computed / 2.0)); - } else { - rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, - 0.0, - rect->height.computed / 2.0); - } - } - - update_knot(); - - rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -void -RectKnotHolderEntityRY::knot_click(unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - if (state & GDK_SHIFT_MASK) { - /* remove rounding */ - rect->getRepr()->setAttribute("rx", NULL); - rect->getRepr()->setAttribute("ry", NULL); - } else if (state & GDK_CONTROL_MASK) { - /* Ctrl-click sets the vertical rounding to be the same as the horizontal */ - rect->getRepr()->setAttribute("rx", rect->getRepr()->attribute("ry")); - } -} - -#define SGN(x) ((x)>0?1:((x)<0?-1:0)) - -static void sp_rect_clamp_radii(SPRect *rect) -{ - // clamp rounding radii so that they do not exceed width/height - if (2 * rect->rx.computed > rect->width.computed) { - rect->rx = 0.5 * rect->width.computed; - } - if (2 * rect->ry.computed > rect->height.computed) { - rect->ry = 0.5 * rect->height.computed; - } -} - -Geom::Point -RectKnotHolderEntityWH::knot_get() const -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed); -} - -void -RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - Geom::Point s = p; - - if (state & GDK_CONTROL_MASK) { - // original width/height when drag started - gdouble const w_orig = (origin[Geom::X] - rect->x.computed); - gdouble const h_orig = (origin[Geom::Y] - rect->y.computed); - - //original ratio - gdouble ratio = (w_orig / h_orig); - - // mouse displacement since drag started - gdouble minx = p[Geom::X] - origin[Geom::X]; - gdouble miny = p[Geom::Y] - origin[Geom::Y]; - - Geom::Point p_handle(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed); - - if (fabs(minx) > fabs(miny)) { - // snap to horizontal or diagonal - if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) { - // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); - minx = s[Geom::X] - origin[Geom::X]; - // Dead assignment: Value stored to 'miny' is never read - //miny = s[Geom::Y] - origin[Geom::Y]; - rect->height = MAX(h_orig + minx / ratio, 0); - } else { - // closer to the horizontal, change only width, height is h_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state); - minx = s[Geom::X] - origin[Geom::X]; - // Dead assignment: Value stored to 'miny' is never read - //miny = s[Geom::Y] - origin[Geom::Y]; - rect->height = MAX(h_orig, 0); - } - rect->width = MAX(w_orig + minx, 0); - - } else { - // snap to vertical or diagonal - if (miny != 0 && fabs(minx/miny) > 0.5 * ratio && (SGN(minx) == SGN(miny))) { - // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); - // Dead assignment: Value stored to 'minx' is never read - //minx = s[Geom::X] - origin[Geom::X]; - miny = s[Geom::Y] - origin[Geom::Y]; - rect->width = MAX(w_orig + miny * ratio, 0); - } else { - // closer to the vertical, change only height, width is w_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state); - // Dead assignment: Value stored to 'minx' is never read - //minx = s[Geom::X] - origin[Geom::X]; - miny = s[Geom::Y] - origin[Geom::Y]; - rect->width = MAX(w_orig, 0); - } - rect->height = MAX(h_orig + miny, 0); - - } - - } else { - // move freely - s = snap_knot_position(p, state); - rect->width = MAX(s[Geom::X] - rect->x.computed, 0); - rect->height = MAX(s[Geom::Y] - rect->y.computed, 0); - } - - sp_rect_clamp_radii(rect); - - rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -void -RectKnotHolderEntityWH::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) -{ - set_internal(p, origin, state); - update_knot(); -} - -Geom::Point -RectKnotHolderEntityXY::knot_get() const -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - return Geom::Point(rect->x.computed, rect->y.computed); -} - -void -RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - // opposite corner (unmoved) - gdouble opposite_x = (rect->x.computed + rect->width.computed); - gdouble opposite_y = (rect->y.computed + rect->height.computed); - - // original width/height when drag started - gdouble w_orig = opposite_x - origin[Geom::X]; - gdouble h_orig = opposite_y - origin[Geom::Y]; - - Geom::Point s = p; - Geom::Point p_handle(rect->x.computed, rect->y.computed); - - // mouse displacement since drag started - gdouble minx = p[Geom::X] - origin[Geom::X]; - gdouble miny = p[Geom::Y] - origin[Geom::Y]; - - if (state & GDK_CONTROL_MASK) { - //original ratio - gdouble ratio = (w_orig / h_orig); - - if (fabs(minx) > fabs(miny)) { - // snap to horizontal or diagonal - if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) { - // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); - minx = s[Geom::X] - origin[Geom::X]; - // Dead assignment: Value stored to 'miny' is never read - //miny = s[Geom::Y] - origin[Geom::Y]; - rect->y = MIN(origin[Geom::Y] + minx / ratio, opposite_y); - rect->height = MAX(h_orig - minx / ratio, 0); - } else { - // closer to the horizontal, change only width, height is h_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state); - minx = s[Geom::X] - origin[Geom::X]; - // Dead assignment: Value stored to 'miny' is never read - //miny = s[Geom::Y] - origin[Geom::Y]; - rect->y = MIN(origin[Geom::Y], opposite_y); - rect->height = MAX(h_orig, 0); - } - rect->x = MIN(s[Geom::X], opposite_x); - rect->width = MAX(w_orig - minx, 0); - } else { - // snap to vertical or diagonal - if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) { - // closer to the diagonal and in same-sign quarters, change both using ratio - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); - // Dead assignment: Value stored to 'minx' is never read - //minx = s[Geom::X] - origin[Geom::X]; - miny = s[Geom::Y] - origin[Geom::Y]; - rect->x = MIN(origin[Geom::X] + miny * ratio, opposite_x); - rect->width = MAX(w_orig - miny * ratio, 0); - } else { - // closer to the vertical, change only height, width is w_orig - s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state); - // Dead assignment: Value stored to 'minx' is never read - //minx = s[Geom::X] - origin[Geom::X]; - miny = s[Geom::Y] - origin[Geom::Y]; - rect->x = MIN(origin[Geom::X], opposite_x); - rect->width = MAX(w_orig, 0); - } - rect->y = MIN(s[Geom::Y], opposite_y); - rect->height = MAX(h_orig - miny, 0); - } - - } else { - // move freely - s = snap_knot_position(p, state); - minx = s[Geom::X] - origin[Geom::X]; - miny = s[Geom::Y] - origin[Geom::Y]; - - rect->x = MIN(s[Geom::X], opposite_x); - rect->y = MIN(s[Geom::Y], opposite_y); - rect->width = MAX(w_orig - minx, 0); - rect->height = MAX(h_orig - miny, 0); - } - - sp_rect_clamp_radii(rect); - - update_knot(); - - rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -RectKnotHolderEntityCenter::knot_get() const -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - return Geom::Point(rect->x.computed + (rect->width.computed / 2.), rect->y.computed + (rect->height.computed / 2.)); -} - -void -RectKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPRect *rect = dynamic_cast(item); - g_assert(rect != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - rect->x = s[Geom::X] - (rect->width.computed / 2.); - rect->y = s[Geom::Y] - (rect->height.computed / 2.); - - // No need to call sp_rect_clamp_radii(): width and height haven't changed. - // No need to call update_knot(): the knot is set directly by the user. - - rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -RectKnotHolder::RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - RectKnotHolderEntityRX *entity_rx = new RectKnotHolderEntityRX(); - RectKnotHolderEntityRY *entity_ry = new RectKnotHolderEntityRY(); - RectKnotHolderEntityWH *entity_wh = new RectKnotHolderEntityWH(); - RectKnotHolderEntityXY *entity_xy = new RectKnotHolderEntityXY(); - RectKnotHolderEntityCenter *entity_center = new RectKnotHolderEntityCenter(); - - entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Adjust the horizontal rounding radius; with Ctrl " - "to make the vertical radius the same"), - SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - - entity_ry->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Adjust the vertical rounding radius; with Ctrl " - "to make the horizontal radius the same"), - SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - - entity_wh->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, - _("Adjust the width and height of the rectangle; with Ctrl " - "to lock ratio or stretch in one dimension only"), - SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - - entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, - _("Adjust the width and height of the rectangle; with Ctrl " - "to lock ratio or stretch in one dimension only"), - SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - - entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, - _("Drag to move the rectangle"), - SP_KNOT_SHAPE_CROSS); - - entity.push_back(entity_rx); - entity.push_back(entity_ry); - entity.push_back(entity_wh); - entity.push_back(entity_xy); - entity.push_back(entity_center); - - add_pattern_knotholder(); -} - -/* Box3D (= the new 3D box structure) */ - -class Box3DKnotHolderEntity : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const = 0; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) = 0; - - Geom::Point knot_get_generic(SPItem *item, unsigned int knot_id) const; - void knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &p, unsigned int state); -}; - -Geom::Point -Box3DKnotHolderEntity::knot_get_generic(SPItem *item, unsigned int knot_id) const -{ - SPBox3D *box = dynamic_cast(item); - if (box) { - return box3d_get_corner_screen(box, knot_id); - } else { - return Geom::Point(); // TODO investigate proper fallback - } -} - -void -Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, unsigned int state) -{ - Geom::Point const s = snap_knot_position(new_pos, state); - - g_assert(item != NULL); - SPBox3D *box = dynamic_cast(item); - g_assert(box != NULL); - Geom::Affine const i2dt (item->i2dt_affine ()); - - Box3D::Axis movement; - if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) { - movement = Box3D::XY; - } else { - movement = Box3D::Z; - } - - box3d_set_corner (box, knot_id, s * i2dt, movement, (state & GDK_CONTROL_MASK)); - box3d_set_z_orders(box); - box3d_position_set(box); -} - -class Box3DKnotHolderEntity0 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity1 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity2 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity3 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity4 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity5 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity6 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntity7 : public Box3DKnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class Box3DKnotHolderEntityCenter : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -Geom::Point -Box3DKnotHolderEntity0::knot_get() const -{ - return knot_get_generic(item, 0); -} - -Geom::Point -Box3DKnotHolderEntity1::knot_get() const -{ - return knot_get_generic(item, 1); -} - -Geom::Point -Box3DKnotHolderEntity2::knot_get() const -{ - return knot_get_generic(item, 2); -} - -Geom::Point -Box3DKnotHolderEntity3::knot_get() const -{ - return knot_get_generic(item, 3); -} - -Geom::Point -Box3DKnotHolderEntity4::knot_get() const -{ - return knot_get_generic(item, 4); -} - -Geom::Point -Box3DKnotHolderEntity5::knot_get() const -{ - return knot_get_generic(item, 5); -} - -Geom::Point -Box3DKnotHolderEntity6::knot_get() const -{ - return knot_get_generic(item, 6); -} - -Geom::Point -Box3DKnotHolderEntity7::knot_get() const -{ - return knot_get_generic(item, 7); -} - -Geom::Point -Box3DKnotHolderEntityCenter::knot_get() const -{ - SPBox3D *box = dynamic_cast(item); - if (box) { - return box3d_get_center_screen(box); - } else { - return Geom::Point(); // TODO investigate proper fallback - } -} - -void -Box3DKnotHolderEntity0::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 0, new_pos, state); -} - -void -Box3DKnotHolderEntity1::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 1, new_pos, state); -} - -void -Box3DKnotHolderEntity2::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 2, new_pos, state); -} - -void -Box3DKnotHolderEntity3::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 3, new_pos, state); -} - -void -Box3DKnotHolderEntity4::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 4, new_pos, state); -} - -void -Box3DKnotHolderEntity5::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 5, new_pos, state); -} - -void -Box3DKnotHolderEntity6::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 6, new_pos, state); -} - -void -Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) -{ - knot_set_generic(item, 7, new_pos, state); -} - -void -Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, unsigned int state) -{ - Geom::Point const s = snap_knot_position(new_pos, state); - - SPBox3D *box = dynamic_cast(item); - g_assert(box != NULL); - Geom::Affine const i2dt (item->i2dt_affine ()); - - box3d_set_center(box, s * i2dt, origin * i2dt, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, - state & GDK_CONTROL_MASK); - - box3d_set_z_orders(box); - box3d_position_set(box); -} - -Box3DKnotHolder::Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - Box3DKnotHolderEntity0 *entity_corner0 = new Box3DKnotHolderEntity0(); - Box3DKnotHolderEntity1 *entity_corner1 = new Box3DKnotHolderEntity1(); - Box3DKnotHolderEntity2 *entity_corner2 = new Box3DKnotHolderEntity2(); - Box3DKnotHolderEntity3 *entity_corner3 = new Box3DKnotHolderEntity3(); - Box3DKnotHolderEntity4 *entity_corner4 = new Box3DKnotHolderEntity4(); - Box3DKnotHolderEntity5 *entity_corner5 = new Box3DKnotHolderEntity5(); - Box3DKnotHolderEntity6 *entity_corner6 = new Box3DKnotHolderEntity6(); - Box3DKnotHolderEntity7 *entity_corner7 = new Box3DKnotHolderEntity7(); - Box3DKnotHolderEntityCenter *entity_center = new Box3DKnotHolderEntityCenter(); - - entity_corner0->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box in X/Y direction; with Shift along the Z axis; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box in X/Y direction; with Shift along the Z axis; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner2->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box in X/Y direction; with Shift along the Z axis; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner3->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box in X/Y direction; with Shift along the Z axis; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner4->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box along the Z axis; with Shift in X/Y direction; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner5->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box along the Z axis; with Shift in X/Y direction; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner6->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box along the Z axis; with Shift in X/Y direction; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_corner7->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Resize box along the Z axis; with Shift in X/Y direction; " - "with Ctrl to constrain to the directions of edges or diagonals")); - - entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, - _("Move the box in perspective"), - SP_KNOT_SHAPE_CROSS); - - entity.push_back(entity_corner0); - entity.push_back(entity_corner1); - entity.push_back(entity_corner2); - entity.push_back(entity_corner3); - entity.push_back(entity_corner4); - entity.push_back(entity_corner5); - entity.push_back(entity_corner6); - entity.push_back(entity_corner7); - entity.push_back(entity_center); - - add_pattern_knotholder(); -} - -/* SPArc */ - -class ArcKnotHolderEntityStart : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class ArcKnotHolderEntityEnd : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class ArcKnotHolderEntityRX : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class ArcKnotHolderEntityRY : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class ArcKnotHolderEntityCenter : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -/* - * return values: - * 1 : inside - * 0 : on the curves - * -1 : outside - */ -static gint -sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p) -{ - gdouble dx = (p[Geom::X] - ellipse->cx.computed) / ellipse->rx.computed; - gdouble dy = (p[Geom::Y] - ellipse->cy.computed) / ellipse->ry.computed; - - gdouble s = dx * dx + dy * dy; - // We add a bit of a buffer, so there's a decent chance the user will - // be able to adjust the arc without the closed status flipping between - // open and closed during micro mouse movements. - if (s < 0.75) return 1; - if (s > 1.25) return -1; - return 0; -} - -void -ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); - - SPGenericEllipse *arc = dynamic_cast(item); - g_assert(arc != NULL); - - gint side = sp_genericellipse_side(arc, p); - if(side != 0) { arc->setArcType( (side == -1) ? - SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE : - SP_GENERIC_ELLIPSE_ARC_TYPE_ARC); } - - Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); - Geom::Scale sc(arc->rx.computed, arc->ry.computed); - - double offset = arc->start - atan2(delta * sc.inverse()); - arc->start -= offset; - - if ((state & GDK_CONTROL_MASK) && snaps) { - arc->start = sp_round(arc->start, M_PI / snaps); - } - if (state & GDK_SHIFT_MASK) { - arc->end -= offset; - } - - arc->normalize(); - arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -ArcKnotHolderEntityStart::knot_get() const -{ - SPGenericEllipse const *ge = dynamic_cast(item); - g_assert(ge != NULL); - - return ge->getPointAtAngle(ge->start); -} - -void -ArcKnotHolderEntityStart::knot_click(unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - if (state & GDK_SHIFT_MASK) { - ge->end = ge->start = 0; - ge->updateRepr(); - } -} - -void -ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); - - SPGenericEllipse *arc = dynamic_cast(item); - g_assert(arc != NULL); - - gint side = sp_genericellipse_side(arc, p); - if(side != 0) { arc->setArcType( (side == -1) ? - SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE : - SP_GENERIC_ELLIPSE_ARC_TYPE_ARC); } - - Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); - Geom::Scale sc(arc->rx.computed, arc->ry.computed); - - double offset = arc->end - atan2(delta * sc.inverse()); - arc->end -= offset; - - if ((state & GDK_CONTROL_MASK) && snaps) { - arc->end = sp_round(arc->end, M_PI/snaps); - } - if (state & GDK_SHIFT_MASK) { - arc->start -= offset; - } - - arc->normalize(); - arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -ArcKnotHolderEntityEnd::knot_get() const -{ - SPGenericEllipse const *ge = dynamic_cast(item); - g_assert(ge != NULL); - - return ge->getPointAtAngle(ge->end); -} - - -void -ArcKnotHolderEntityEnd::knot_click(unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - if (state & GDK_SHIFT_MASK) { - ge->end = ge->start = 0; - ge->updateRepr(); - } -} - - -void -ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - ge->rx = fabs( ge->cx.computed - s[Geom::X] ); - - if ( state & GDK_CONTROL_MASK ) { - ge->ry = ge->rx.computed; - } - - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -ArcKnotHolderEntityRX::knot_get() const -{ - SPGenericEllipse const *ge = dynamic_cast(item); - g_assert(ge != NULL); - - return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(ge->rx.computed, 0)); -} - -void -ArcKnotHolderEntityRX::knot_click(unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - if (state & GDK_CONTROL_MASK) { - ge->ry = ge->rx.computed; - ge->updateRepr(); - } -} - -void -ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - ge->ry = fabs( ge->cy.computed - s[Geom::Y] ); - - if ( state & GDK_CONTROL_MASK ) { - ge->rx = ge->ry.computed; - } - - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -ArcKnotHolderEntityRY::knot_get() const -{ - SPGenericEllipse const *ge = dynamic_cast(item); - g_assert(ge != NULL); - - return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(0, ge->ry.computed)); -} - -void -ArcKnotHolderEntityRY::knot_click(unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - if (state & GDK_CONTROL_MASK) { - ge->rx = ge->ry.computed; - ge->updateRepr(); - } -} - -void -ArcKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPGenericEllipse *ge = dynamic_cast(item); - g_assert(ge != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - ge->cx = s[Geom::X]; - ge->cy = s[Geom::Y]; - - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -ArcKnotHolderEntityCenter::knot_get() const -{ - SPGenericEllipse const *ge = dynamic_cast(item); - g_assert(ge != NULL); - - return Geom::Point(ge->cx.computed, ge->cy.computed); -} - - -ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - ArcKnotHolderEntityRX *entity_rx = new ArcKnotHolderEntityRX(); - ArcKnotHolderEntityRY *entity_ry = new ArcKnotHolderEntityRY(); - ArcKnotHolderEntityStart *entity_start = new ArcKnotHolderEntityStart(); - ArcKnotHolderEntityEnd *entity_end = new ArcKnotHolderEntityEnd(); - ArcKnotHolderEntityCenter *entity_center = new ArcKnotHolderEntityCenter(); - - entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, - _("Adjust ellipse width, with Ctrl to make circle"), - SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - - entity_ry->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, - _("Adjust ellipse height, with Ctrl to make circle"), - SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); - - entity_start->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Position the start point of the arc or segment; with Shift to move " - "with end point; with Ctrl to snap angle; drag inside the " - "ellipse for arc, outside for segment"), - SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - - entity_end->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Position the end point of the arc or segment; with Shift to move " - "with start point; with Ctrl to snap angle; drag inside the " - "ellipse for arc, outside for segment"), - SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); - - entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, - _("Drag to move the ellipse"), - SP_KNOT_SHAPE_CROSS); - - entity.push_back(entity_rx); - entity.push_back(entity_ry); - entity.push_back(entity_start); - entity.push_back(entity_end); - entity.push_back(entity_center); - - add_pattern_knotholder(); -} - -/* SPStar */ - -class StarKnotHolderEntity1 : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class StarKnotHolderEntity2 : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class StarKnotHolderEntityCenter : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -void -StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPStar *star = dynamic_cast(item); - g_assert(star != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - Geom::Point d = s - star->center; - - double arg1 = atan2(d); - double darg1 = arg1 - star->arg[0]; - - if (state & GDK_MOD1_MASK) { - star->randomized = darg1/(star->arg[0] - star->arg[1]); - } else if (state & GDK_SHIFT_MASK) { - star->rounded = darg1/(star->arg[0] - star->arg[1]); - } else if (state & GDK_CONTROL_MASK) { - star->r[0] = L2(d); - } else { - star->r[0] = L2(d); - star->arg[0] = arg1; - star->arg[1] += darg1; - } - star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -void -StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPStar *star = dynamic_cast(item); - g_assert(star != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - if (star->flatsided == false) { - Geom::Point d = s - star->center; - - double arg1 = atan2(d); - double darg1 = arg1 - star->arg[1]; - - if (state & GDK_MOD1_MASK) { - star->randomized = darg1/(star->arg[0] - star->arg[1]); - } else if (state & GDK_SHIFT_MASK) { - star->rounded = fabs(darg1/(star->arg[0] - star->arg[1])); - } else if (state & GDK_CONTROL_MASK) { - star->r[1] = L2(d); - star->arg[1] = star->arg[0] + M_PI / star->sides; - } - else { - star->r[1] = L2(d); - star->arg[1] = atan2(d); - } - star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - } -} - -void -StarKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPStar *star = dynamic_cast(item); - g_assert(star != NULL); - - star->center = snap_knot_position(p, state); - - item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -StarKnotHolderEntity1::knot_get() const -{ - g_assert(item != NULL); - - SPStar const *star = dynamic_cast(item); - g_assert(star != NULL); - - return sp_star_get_xy(star, SP_STAR_POINT_KNOT1, 0); - -} - -Geom::Point -StarKnotHolderEntity2::knot_get() const -{ - g_assert(item != NULL); - - SPStar const *star = dynamic_cast(item); - g_assert(star != NULL); - - return sp_star_get_xy(star, SP_STAR_POINT_KNOT2, 0); -} - -Geom::Point -StarKnotHolderEntityCenter::knot_get() const -{ - g_assert(item != NULL); - - SPStar const *star = dynamic_cast(item); - g_assert(star != NULL); - - return star->center; -} - -static void -sp_star_knot_click(SPItem *item, unsigned int state) -{ - SPStar *star = dynamic_cast(item); - g_assert(star != NULL); - - if (state & GDK_MOD1_MASK) { - star->randomized = 0; - star->updateRepr(); - } else if (state & GDK_SHIFT_MASK) { - star->rounded = 0; - star->updateRepr(); - } else if (state & GDK_CONTROL_MASK) { - star->arg[1] = star->arg[0] + M_PI / star->sides; - star->updateRepr(); - } -} - -void -StarKnotHolderEntity1::knot_click(unsigned int state) -{ - sp_star_knot_click(item, state); -} - -void -StarKnotHolderEntity2::knot_click(unsigned int state) -{ - sp_star_knot_click(item, state); -} - -StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - SPStar *star = dynamic_cast(item); - g_assert(item != NULL); - - StarKnotHolderEntity1 *entity1 = new StarKnotHolderEntity1(); - entity1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Adjust the tip radius of the star or polygon; " - "with Shift to round; with Alt to randomize")); - - entity.push_back(entity1); - - if (star->flatsided == false) { - StarKnotHolderEntity2 *entity2 = new StarKnotHolderEntity2(); - entity2->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Adjust the base radius of the star; with Ctrl to keep star rays " - "radial (no skew); with Shift to round; with Alt to randomize")); - entity.push_back(entity2); - } - - StarKnotHolderEntityCenter *entity_center = new StarKnotHolderEntityCenter(); - entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, - _("Drag to move the star"), - SP_KNOT_SHAPE_CROSS); - entity.push_back(entity_center); - - add_pattern_knotholder(); -} - -/* SPSpiral */ - -class SpiralKnotHolderEntityInner : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); - virtual void knot_click(unsigned int state); -}; - -class SpiralKnotHolderEntityOuter : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -class SpiralKnotHolderEntityCenter : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - - -/* - * set attributes via inner (t=t0) knot point: - * [default] increase/decrease inner point - * [shift] increase/decrease inner and outer arg synchronizely - * [control] constrain inner arg to round per PI/4 - */ -void -SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); - - SPSpiral *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - gdouble dx = p[Geom::X] - spiral->cx; - gdouble dy = p[Geom::Y] - spiral->cy; - - gdouble moved_y = p[Geom::Y] - origin[Geom::Y]; - - if (state & GDK_MOD1_MASK) { - // adjust divergence by vertical drag, relative to rad - if (spiral->rad > 0) { - double exp_delta = 0.1*moved_y/(spiral->rad); // arbitrary multiplier to slow it down - spiral->exp += exp_delta; - if (spiral->exp < 1e-3) - spiral->exp = 1e-3; - } - } else { - // roll/unroll from inside - gdouble arg_t0; - spiral->getPolar(spiral->t0, NULL, &arg_t0); - - gdouble arg_tmp = atan2(dy, dx) - arg_t0; - gdouble arg_t0_new = arg_tmp - floor((arg_tmp+M_PI)/(2.0*M_PI))*2.0*M_PI + arg_t0; - spiral->t0 = (arg_t0_new - spiral->arg) / (2.0*M_PI*spiral->revo); - - /* round inner arg per PI/snaps, if CTRL is pressed */ - if ( ( state & GDK_CONTROL_MASK ) - && ( fabs(spiral->revo) > SP_EPSILON_2 ) - && ( snaps != 0 ) ) { - gdouble arg = 2.0*M_PI*spiral->revo*spiral->t0 + spiral->arg; - spiral->t0 = (sp_round(arg, M_PI/snaps) - spiral->arg)/(2.0*M_PI*spiral->revo); - } - - spiral->t0 = CLAMP(spiral->t0, 0.0, 0.999); - } - - spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -/* - * set attributes via outer (t=1) knot point: - * [default] increase/decrease revolution factor - * [control] constrain inner arg to round per PI/4 - */ -void -SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); - - SPSpiral *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - gdouble dx = p[Geom::X] - spiral->cx; - gdouble dy = p[Geom::Y] - spiral->cy; - - if (state & GDK_SHIFT_MASK) { // rotate without roll/unroll - spiral->arg = atan2(dy, dx) - 2.0*M_PI*spiral->revo; - if (!(state & GDK_MOD1_MASK)) { - // if alt not pressed, change also rad; otherwise it is locked - spiral->rad = MAX(hypot(dx, dy), 0.001); - } - if ( ( state & GDK_CONTROL_MASK ) - && snaps ) { - spiral->arg = sp_round(spiral->arg, M_PI/snaps); - } - } else { // roll/unroll - // arg of the spiral outer end - double arg_1; - spiral->getPolar(1, NULL, &arg_1); - - // its fractional part after the whole turns are subtracted - double arg_r = arg_1 - sp_round(arg_1, 2.0*M_PI); - - // arg of the mouse point relative to spiral center - double mouse_angle = atan2(dy, dx); - if (mouse_angle < 0) - mouse_angle += 2*M_PI; - - // snap if ctrl - if ( ( state & GDK_CONTROL_MASK ) && snaps ) { - mouse_angle = sp_round(mouse_angle, M_PI/snaps); - } - - // by how much we want to rotate the outer point - double diff = mouse_angle - arg_r; - if (diff > M_PI) - diff -= 2*M_PI; - else if (diff < -M_PI) - diff += 2*M_PI; - - // calculate the new rad; - // the value of t corresponding to the angle arg_1 + diff: - double t_temp = ((arg_1 + diff) - spiral->arg)/(2*M_PI*spiral->revo); - // the rad at that t: - double rad_new = 0; - if (t_temp > spiral->t0) - spiral->getPolar(t_temp, &rad_new, NULL); - - // change the revo (converting diff from radians to the number of turns) - spiral->revo += diff/(2*M_PI); - if (spiral->revo < 1e-3) - spiral->revo = 1e-3; - - // if alt not pressed and the values are sane, change the rad - if (!(state & GDK_MOD1_MASK) && rad_new > 1e-3 && rad_new/spiral->rad < 2) { - // adjust t0 too so that the inner point stays unmoved - double r0; - spiral->getPolar(spiral->t0, &r0, NULL); - spiral->rad = rad_new; - spiral->t0 = pow(r0 / spiral->rad, 1.0/spiral->exp); - } - if (!IS_FINITE(spiral->t0)) spiral->t0 = 0.0; - spiral->t0 = CLAMP(spiral->t0, 0.0, 0.999); - } - - spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -void -SpiralKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPSpiral *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - Geom::Point const s = snap_knot_position(p, state); - - spiral->cx = s[Geom::X]; - spiral->cy = s[Geom::Y]; - - spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - -Geom::Point -SpiralKnotHolderEntityInner::knot_get() const -{ - SPSpiral const *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - return spiral->getXY(spiral->t0); -} - -Geom::Point -SpiralKnotHolderEntityOuter::knot_get() const -{ - SPSpiral const *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - return spiral->getXY(1.0); -} - -Geom::Point -SpiralKnotHolderEntityCenter::knot_get() const -{ - SPSpiral const *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - return Geom::Point(spiral->cx, spiral->cy); -} - -void -SpiralKnotHolderEntityInner::knot_click(unsigned int state) -{ - SPSpiral *spiral = dynamic_cast(item); - g_assert(spiral != NULL); - - if (state & GDK_MOD1_MASK) { - spiral->exp = 1; - spiral->updateRepr(); - } else if (state & GDK_SHIFT_MASK) { - spiral->t0 = 0; - spiral->updateRepr(); - } -} - -SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - SpiralKnotHolderEntityCenter *entity_center = new SpiralKnotHolderEntityCenter(); - SpiralKnotHolderEntityInner *entity_inner = new SpiralKnotHolderEntityInner(); - SpiralKnotHolderEntityOuter *entity_outer = new SpiralKnotHolderEntityOuter(); - - // NOTE: entity_central and entity_inner can overlap. - // - // In that case it would be a problem if the center control point was ON - // TOP because it would steal the mouse focus and the user would loose the - // ability to access the inner control point using only the mouse. - // - // However if the inner control point is ON TOP, taking focus, the - // situation is a lot better: the user can still move the inner control - // point with the mouse to regain access to the center control point. - // - // So, create entity_inner AFTER entity_center; this ensures that - // entity_inner gets rendered ON TOP. - entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, - _("Drag to move the spiral"), - SP_KNOT_SHAPE_CROSS); - - entity_inner->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Roll/unroll the spiral from inside; with Ctrl to snap angle; " - "with Alt to converge/diverge")); - - entity_outer->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Roll/unroll the spiral from outside; with Ctrl to snap angle; " - "with Shift to scale/rotate; with Alt to lock radius")); - - entity.push_back(entity_center); - entity.push_back(entity_inner); - entity.push_back(entity_outer); - - add_pattern_knotholder(); -} - -/* SPOffset */ - -class OffsetKnotHolderEntity : public KnotHolderEntity { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -void -OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) -{ - SPOffset *offset = dynamic_cast(item); - g_assert(offset != NULL); - - Geom::Point const p_snapped = snap_knot_position(p, state); - - offset->rad = sp_offset_distance_to_original(offset, p_snapped); - offset->knot = p_snapped; - offset->knotSet = true; - - offset->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - - -Geom::Point -OffsetKnotHolderEntity::knot_get() const -{ - SPOffset const *offset = dynamic_cast(item); - g_assert(offset != NULL); - - Geom::Point np; - sp_offset_top_point(offset,&np); - return np; -} - -OffsetKnotHolder::OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - OffsetKnotHolderEntity *entity_offset = new OffsetKnotHolderEntity(); - entity_offset->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Adjust the offset distance")); - entity.push_back(entity_offset); - - add_pattern_knotholder(); -} - -// TODO: this is derived from RectKnotHolderEntityWH because it used the same static function -// set_internal as the latter before KnotHolderEntity was C++ified. Check whether this also makes -// sense logically. -class FlowtextKnotHolderEntity : public RectKnotHolderEntityWH { -public: - virtual Geom::Point knot_get() const; - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); -}; - -Geom::Point -FlowtextKnotHolderEntity::knot_get() const -{ - SPRect const *rect = dynamic_cast(item); - g_assert(rect != NULL); - - return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed); -} - -void -FlowtextKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) -{ - set_internal(p, origin, state); -} - -FlowtextKnotHolder::FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : - KnotHolder(desktop, item, relhandler) -{ - g_assert(item != NULL); - - FlowtextKnotHolderEntity *entity_flowtext = new FlowtextKnotHolderEntity(); - entity_flowtext->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, - _("Drag to resize the flowed text frame")); - entity.push_back(entity_flowtext); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/object-edit.h b/src/ui/object-edit.h deleted file mode 100644 index 75f3ce12b..000000000 --- a/src/ui/object-edit.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef OBJECT_EDIT_H_SEEN -#define OBJECT_EDIT_H_SEEN - -/* - * Node editing extension to objects - * - * Authors: - * Lauris Kaplinski - * Mitsuru Oka - * Jon A. Cruz - * - * Licensed under GNU GPL - */ - -#include "knotholder.h" - -namespace Inkscape { -namespace UI { - -KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop); - -} -} - -class RectKnotHolder : public KnotHolder { -public: - RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~RectKnotHolder() {}; -}; - -class Box3DKnotHolder : public KnotHolder { -public: - Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~Box3DKnotHolder() {}; -}; - -class ArcKnotHolder : public KnotHolder { -public: - ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~ArcKnotHolder() {}; -}; - -class StarKnotHolder : public KnotHolder { -public: - StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~StarKnotHolder() {}; -}; - -class SpiralKnotHolder : public KnotHolder { -public: - SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~SpiralKnotHolder() {}; -}; - -class OffsetKnotHolder : public KnotHolder { -public: - OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~OffsetKnotHolder() {}; -}; - -class FlowtextKnotHolder : public KnotHolder { -public: - FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~FlowtextKnotHolder() {}; -}; - -class MiscKnotHolder : public KnotHolder { -public: - MiscKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); - virtual ~MiscKnotHolder() {}; -}; - -#endif // OBJECT_EDIT_H_SEEN - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/shape-editor-knotholders.cpp b/src/ui/shape-editor-knotholders.cpp new file mode 100644 index 000000000..b2e41bac4 --- /dev/null +++ b/src/ui/shape-editor-knotholders.cpp @@ -0,0 +1,1666 @@ +/* + * Node editing extension to objects + * + * Authors: + * Lauris Kaplinski + * Mitsuru Oka + * Maximilian Albert + * Abhishek Sharma + * Jon A. Cruz + * + * Licensed under GNU GPL + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "sp-item.h" +#include "sp-rect.h" +#include "box3d.h" +#include "sp-ellipse.h" +#include "sp-star.h" +#include "sp-spiral.h" +#include "sp-offset.h" +#include "sp-flowtext.h" +#include "preferences.h" +#include "style.h" +#include "desktop.h" + +#include "sp-namedview.h" +#include "live_effects/effect.h" +#include "sp-pattern.h" +#include +#include "knotholder.h" +#include "knot-holder-entity.h" + +#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) + +class RectKnotHolder : public KnotHolder { +public: + RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~RectKnotHolder() {}; +}; + +class Box3DKnotHolder : public KnotHolder { +public: + Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~Box3DKnotHolder() {}; +}; + +class ArcKnotHolder : public KnotHolder { +public: + ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~ArcKnotHolder() {}; +}; + +class StarKnotHolder : public KnotHolder { +public: + StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~StarKnotHolder() {}; +}; + +class SpiralKnotHolder : public KnotHolder { +public: + SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~SpiralKnotHolder() {}; +}; + +class OffsetKnotHolder : public KnotHolder { +public: + OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~OffsetKnotHolder() {}; +}; + +class FlowtextKnotHolder : public KnotHolder { +public: + FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~FlowtextKnotHolder() {}; +}; + +class MiscKnotHolder : public KnotHolder { +public: + MiscKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler); + virtual ~MiscKnotHolder() {}; +}; + +namespace { + +static KnotHolder *sp_lpe_knot_holder(SPLPEItem *item, SPDesktop *desktop) +{ + KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL); + + Inkscape::LivePathEffect::Effect *effect = item->getCurrentLPE(); + effect->addHandles(knot_holder, item); + + return knot_holder; +} + +} // namespace + +namespace Inkscape { +namespace UI { + +KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) +{ + KnotHolder *knotholder = NULL; + + SPLPEItem *lpe = dynamic_cast(item); + if (lpe && + lpe->getCurrentLPE() && + lpe->getCurrentLPE()->isVisible() && + lpe->getCurrentLPE()->providesKnotholder()) { + knotholder = sp_lpe_knot_holder(lpe, desktop); + } else if (dynamic_cast(item)) { + knotholder = new RectKnotHolder(desktop, item, NULL); + } else if (dynamic_cast(item)) { + knotholder = new Box3DKnotHolder(desktop, item, NULL); + } else if (dynamic_cast(item)) { + knotholder = new ArcKnotHolder(desktop, item, NULL); + } else if (dynamic_cast(item)) { + knotholder = new StarKnotHolder(desktop, item, NULL); + } else if (dynamic_cast(item)) { + knotholder = new SpiralKnotHolder(desktop, item, NULL); + } else if (dynamic_cast(item)) { + knotholder = new OffsetKnotHolder(desktop, item, NULL); + } else { + SPFlowtext *flowtext = dynamic_cast(item); + if (flowtext && flowtext->has_internal_frame()) { + knotholder = new FlowtextKnotHolder(desktop, flowtext->get_frame(NULL), NULL); + } else if ((item->style->fill.isPaintserver() && dynamic_cast(item->style->getFillPaintServer())) || + (item->style->stroke.isPaintserver() && dynamic_cast(item->style->getStrokePaintServer()))) { + knotholder = new KnotHolder(desktop, item, NULL); + knotholder->add_pattern_knotholder(); + } + } + + return knotholder; +} + +} +} // namespace Inkscape + +/* SPRect */ + +/* handle for horizontal rounding radius */ +class RectKnotHolderEntityRX : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +/* handle for vertical rounding radius */ +class RectKnotHolderEntityRY : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +/* handle for width/height adjustment */ +class RectKnotHolderEntityWH : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + +protected: + void set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +/* handle for x/y adjustment */ +class RectKnotHolderEntityXY : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +/* handle for position */ +class RectKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +Geom::Point +RectKnotHolderEntityRX::knot_get() const +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + return Geom::Point(rect->x.computed + rect->width.computed - rect->rx.computed, rect->y.computed); +} + +void +RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + //In general we cannot just snap this radius to an arbitrary point, as we have only a single + //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap + //the radius then we should have a constrained snap. snap_knot_position() is unconstrained + Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(-1, 0)), state); + + if (state & GDK_CONTROL_MASK) { + gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0; + rect->rx = rect->ry = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, temp); + } else { + rect->rx = CLAMP(rect->x.computed + rect->width.computed - s[Geom::X], 0.0, rect->width.computed / 2.0); + } + + update_knot(); + + rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +RectKnotHolderEntityRX::knot_click(unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + if (state & GDK_SHIFT_MASK) { + /* remove rounding from rectangle */ + rect->getRepr()->setAttribute("rx", NULL); + rect->getRepr()->setAttribute("ry", NULL); + } else if (state & GDK_CONTROL_MASK) { + /* Ctrl-click sets the vertical rounding to be the same as the horizontal */ + rect->getRepr()->setAttribute("ry", rect->getRepr()->attribute("rx")); + } + +} + +Geom::Point +RectKnotHolderEntityRY::knot_get() const +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->ry.computed); +} + +void +RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + //In general we cannot just snap this radius to an arbitrary point, as we have only a single + //degree of freedom. For snapping to an arbitrary point we need two DOF. If we're going to snap + //the radius then we should have a constrained snap. snap_knot_position() is unconstrained + Geom::Point const s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed), Geom::Point(0, 1)), state); + + if (state & GDK_CONTROL_MASK) { // When holding control then rx will be kept equal to ry, + // resulting in a perfect circle (and not an ellipse) + gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0; + rect->rx = rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, 0.0, temp); + } else { + if (!rect->rx._set || rect->rx.computed == 0) { + rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, + 0.0, + MIN(rect->height.computed / 2.0, rect->width.computed / 2.0)); + } else { + rect->ry = CLAMP(s[Geom::Y] - rect->y.computed, + 0.0, + rect->height.computed / 2.0); + } + } + + update_knot(); + + rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +RectKnotHolderEntityRY::knot_click(unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + if (state & GDK_SHIFT_MASK) { + /* remove rounding */ + rect->getRepr()->setAttribute("rx", NULL); + rect->getRepr()->setAttribute("ry", NULL); + } else if (state & GDK_CONTROL_MASK) { + /* Ctrl-click sets the vertical rounding to be the same as the horizontal */ + rect->getRepr()->setAttribute("rx", rect->getRepr()->attribute("ry")); + } +} + +#define SGN(x) ((x)>0?1:((x)<0?-1:0)) + +static void sp_rect_clamp_radii(SPRect *rect) +{ + // clamp rounding radii so that they do not exceed width/height + if (2 * rect->rx.computed > rect->width.computed) { + rect->rx = 0.5 * rect->width.computed; + } + if (2 * rect->ry.computed > rect->height.computed) { + rect->ry = 0.5 * rect->height.computed; + } +} + +Geom::Point +RectKnotHolderEntityWH::knot_get() const +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed); +} + +void +RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &origin, unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + Geom::Point s = p; + + if (state & GDK_CONTROL_MASK) { + // original width/height when drag started + gdouble const w_orig = (origin[Geom::X] - rect->x.computed); + gdouble const h_orig = (origin[Geom::Y] - rect->y.computed); + + //original ratio + gdouble ratio = (w_orig / h_orig); + + // mouse displacement since drag started + gdouble minx = p[Geom::X] - origin[Geom::X]; + gdouble miny = p[Geom::Y] - origin[Geom::Y]; + + Geom::Point p_handle(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed); + + if (fabs(minx) > fabs(miny)) { + // snap to horizontal or diagonal + if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) { + // closer to the diagonal and in same-sign quarters, change both using ratio + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); + minx = s[Geom::X] - origin[Geom::X]; + // Dead assignment: Value stored to 'miny' is never read + //miny = s[Geom::Y] - origin[Geom::Y]; + rect->height = MAX(h_orig + minx / ratio, 0); + } else { + // closer to the horizontal, change only width, height is h_orig + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state); + minx = s[Geom::X] - origin[Geom::X]; + // Dead assignment: Value stored to 'miny' is never read + //miny = s[Geom::Y] - origin[Geom::Y]; + rect->height = MAX(h_orig, 0); + } + rect->width = MAX(w_orig + minx, 0); + + } else { + // snap to vertical or diagonal + if (miny != 0 && fabs(minx/miny) > 0.5 * ratio && (SGN(minx) == SGN(miny))) { + // closer to the diagonal and in same-sign quarters, change both using ratio + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); + // Dead assignment: Value stored to 'minx' is never read + //minx = s[Geom::X] - origin[Geom::X]; + miny = s[Geom::Y] - origin[Geom::Y]; + rect->width = MAX(w_orig + miny * ratio, 0); + } else { + // closer to the vertical, change only height, width is w_orig + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state); + // Dead assignment: Value stored to 'minx' is never read + //minx = s[Geom::X] - origin[Geom::X]; + miny = s[Geom::Y] - origin[Geom::Y]; + rect->width = MAX(w_orig, 0); + } + rect->height = MAX(h_orig + miny, 0); + + } + + } else { + // move freely + s = snap_knot_position(p, state); + rect->width = MAX(s[Geom::X] - rect->x.computed, 0); + rect->height = MAX(s[Geom::Y] - rect->y.computed, 0); + } + + sp_rect_clamp_radii(rect); + + rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +RectKnotHolderEntityWH::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) +{ + set_internal(p, origin, state); + update_knot(); +} + +Geom::Point +RectKnotHolderEntityXY::knot_get() const +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + return Geom::Point(rect->x.computed, rect->y.computed); +} + +void +RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + // opposite corner (unmoved) + gdouble opposite_x = (rect->x.computed + rect->width.computed); + gdouble opposite_y = (rect->y.computed + rect->height.computed); + + // original width/height when drag started + gdouble w_orig = opposite_x - origin[Geom::X]; + gdouble h_orig = opposite_y - origin[Geom::Y]; + + Geom::Point s = p; + Geom::Point p_handle(rect->x.computed, rect->y.computed); + + // mouse displacement since drag started + gdouble minx = p[Geom::X] - origin[Geom::X]; + gdouble miny = p[Geom::Y] - origin[Geom::Y]; + + if (state & GDK_CONTROL_MASK) { + //original ratio + gdouble ratio = (w_orig / h_orig); + + if (fabs(minx) > fabs(miny)) { + // snap to horizontal or diagonal + if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) { + // closer to the diagonal and in same-sign quarters, change both using ratio + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); + minx = s[Geom::X] - origin[Geom::X]; + // Dead assignment: Value stored to 'miny' is never read + //miny = s[Geom::Y] - origin[Geom::Y]; + rect->y = MIN(origin[Geom::Y] + minx / ratio, opposite_y); + rect->height = MAX(h_orig - minx / ratio, 0); + } else { + // closer to the horizontal, change only width, height is h_orig + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-1, 0)), state); + minx = s[Geom::X] - origin[Geom::X]; + // Dead assignment: Value stored to 'miny' is never read + //miny = s[Geom::Y] - origin[Geom::Y]; + rect->y = MIN(origin[Geom::Y], opposite_y); + rect->height = MAX(h_orig, 0); + } + rect->x = MIN(s[Geom::X], opposite_x); + rect->width = MAX(w_orig - minx, 0); + } else { + // snap to vertical or diagonal + if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) { + // closer to the diagonal and in same-sign quarters, change both using ratio + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(-ratio, -1)), state); + // Dead assignment: Value stored to 'minx' is never read + //minx = s[Geom::X] - origin[Geom::X]; + miny = s[Geom::Y] - origin[Geom::Y]; + rect->x = MIN(origin[Geom::X] + miny * ratio, opposite_x); + rect->width = MAX(w_orig - miny * ratio, 0); + } else { + // closer to the vertical, change only height, width is w_orig + s = snap_knot_position_constrained(p, Inkscape::Snapper::SnapConstraint(p_handle, Geom::Point(0, -1)), state); + // Dead assignment: Value stored to 'minx' is never read + //minx = s[Geom::X] - origin[Geom::X]; + miny = s[Geom::Y] - origin[Geom::Y]; + rect->x = MIN(origin[Geom::X], opposite_x); + rect->width = MAX(w_orig, 0); + } + rect->y = MIN(s[Geom::Y], opposite_y); + rect->height = MAX(h_orig - miny, 0); + } + + } else { + // move freely + s = snap_knot_position(p, state); + minx = s[Geom::X] - origin[Geom::X]; + miny = s[Geom::Y] - origin[Geom::Y]; + + rect->x = MIN(s[Geom::X], opposite_x); + rect->y = MIN(s[Geom::Y], opposite_y); + rect->width = MAX(w_orig - minx, 0); + rect->height = MAX(h_orig - miny, 0); + } + + sp_rect_clamp_radii(rect); + + update_knot(); + + rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +RectKnotHolderEntityCenter::knot_get() const +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + return Geom::Point(rect->x.computed + (rect->width.computed / 2.), rect->y.computed + (rect->height.computed / 2.)); +} + +void +RectKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPRect *rect = dynamic_cast(item); + g_assert(rect != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + rect->x = s[Geom::X] - (rect->width.computed / 2.); + rect->y = s[Geom::Y] - (rect->height.computed / 2.); + + // No need to call sp_rect_clamp_radii(): width and height haven't changed. + // No need to call update_knot(): the knot is set directly by the user. + + rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +RectKnotHolder::RectKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + RectKnotHolderEntityRX *entity_rx = new RectKnotHolderEntityRX(); + RectKnotHolderEntityRY *entity_ry = new RectKnotHolderEntityRY(); + RectKnotHolderEntityWH *entity_wh = new RectKnotHolderEntityWH(); + RectKnotHolderEntityXY *entity_xy = new RectKnotHolderEntityXY(); + RectKnotHolderEntityCenter *entity_center = new RectKnotHolderEntityCenter(); + + entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, + _("Adjust the horizontal rounding radius; with Ctrl " + "to make the vertical radius the same"), + SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + + entity_ry->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, + _("Adjust the vertical rounding radius; with Ctrl " + "to make the horizontal radius the same"), + SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + + entity_wh->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, + _("Adjust the width and height of the rectangle; with Ctrl " + "to lock ratio or stretch in one dimension only"), + SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); + + entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, + _("Adjust the width and height of the rectangle; with Ctrl " + "to lock ratio or stretch in one dimension only"), + SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); + + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Drag to move the rectangle"), + SP_KNOT_SHAPE_CROSS); + + entity.push_back(entity_rx); + entity.push_back(entity_ry); + entity.push_back(entity_wh); + entity.push_back(entity_xy); + entity.push_back(entity_center); + + add_pattern_knotholder(); +} + +/* Box3D (= the new 3D box structure) */ + +class Box3DKnotHolderEntity : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const = 0; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) = 0; + + Geom::Point knot_get_generic(SPItem *item, unsigned int knot_id) const; + void knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &p, unsigned int state); +}; + +Geom::Point +Box3DKnotHolderEntity::knot_get_generic(SPItem *item, unsigned int knot_id) const +{ + SPBox3D *box = dynamic_cast(item); + if (box) { + return box3d_get_corner_screen(box, knot_id); + } else { + return Geom::Point(); // TODO investigate proper fallback + } +} + +void +Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom::Point const &new_pos, unsigned int state) +{ + Geom::Point const s = snap_knot_position(new_pos, state); + + g_assert(item != NULL); + SPBox3D *box = dynamic_cast(item); + g_assert(box != NULL); + Geom::Affine const i2dt (item->i2dt_affine ()); + + Box3D::Axis movement; + if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) { + movement = Box3D::XY; + } else { + movement = Box3D::Z; + } + + box3d_set_corner (box, knot_id, s * i2dt, movement, (state & GDK_CONTROL_MASK)); + box3d_set_z_orders(box); + box3d_position_set(box); +} + +class Box3DKnotHolderEntity0 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity1 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity2 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity3 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity4 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity5 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity6 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntity7 : public Box3DKnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class Box3DKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +Geom::Point +Box3DKnotHolderEntity0::knot_get() const +{ + return knot_get_generic(item, 0); +} + +Geom::Point +Box3DKnotHolderEntity1::knot_get() const +{ + return knot_get_generic(item, 1); +} + +Geom::Point +Box3DKnotHolderEntity2::knot_get() const +{ + return knot_get_generic(item, 2); +} + +Geom::Point +Box3DKnotHolderEntity3::knot_get() const +{ + return knot_get_generic(item, 3); +} + +Geom::Point +Box3DKnotHolderEntity4::knot_get() const +{ + return knot_get_generic(item, 4); +} + +Geom::Point +Box3DKnotHolderEntity5::knot_get() const +{ + return knot_get_generic(item, 5); +} + +Geom::Point +Box3DKnotHolderEntity6::knot_get() const +{ + return knot_get_generic(item, 6); +} + +Geom::Point +Box3DKnotHolderEntity7::knot_get() const +{ + return knot_get_generic(item, 7); +} + +Geom::Point +Box3DKnotHolderEntityCenter::knot_get() const +{ + SPBox3D *box = dynamic_cast(item); + if (box) { + return box3d_get_center_screen(box); + } else { + return Geom::Point(); // TODO investigate proper fallback + } +} + +void +Box3DKnotHolderEntity0::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 0, new_pos, state); +} + +void +Box3DKnotHolderEntity1::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 1, new_pos, state); +} + +void +Box3DKnotHolderEntity2::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 2, new_pos, state); +} + +void +Box3DKnotHolderEntity3::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 3, new_pos, state); +} + +void +Box3DKnotHolderEntity4::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 4, new_pos, state); +} + +void +Box3DKnotHolderEntity5::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 5, new_pos, state); +} + +void +Box3DKnotHolderEntity6::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 6, new_pos, state); +} + +void +Box3DKnotHolderEntity7::knot_set(Geom::Point const &new_pos, Geom::Point const &/*origin*/, unsigned int state) +{ + knot_set_generic(item, 7, new_pos, state); +} + +void +Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point const &origin, unsigned int state) +{ + Geom::Point const s = snap_knot_position(new_pos, state); + + SPBox3D *box = dynamic_cast(item); + g_assert(box != NULL); + Geom::Affine const i2dt (item->i2dt_affine ()); + + box3d_set_center(box, s * i2dt, origin * i2dt, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, + state & GDK_CONTROL_MASK); + + box3d_set_z_orders(box); + box3d_position_set(box); +} + +Box3DKnotHolder::Box3DKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + Box3DKnotHolderEntity0 *entity_corner0 = new Box3DKnotHolderEntity0(); + Box3DKnotHolderEntity1 *entity_corner1 = new Box3DKnotHolderEntity1(); + Box3DKnotHolderEntity2 *entity_corner2 = new Box3DKnotHolderEntity2(); + Box3DKnotHolderEntity3 *entity_corner3 = new Box3DKnotHolderEntity3(); + Box3DKnotHolderEntity4 *entity_corner4 = new Box3DKnotHolderEntity4(); + Box3DKnotHolderEntity5 *entity_corner5 = new Box3DKnotHolderEntity5(); + Box3DKnotHolderEntity6 *entity_corner6 = new Box3DKnotHolderEntity6(); + Box3DKnotHolderEntity7 *entity_corner7 = new Box3DKnotHolderEntity7(); + Box3DKnotHolderEntityCenter *entity_center = new Box3DKnotHolderEntityCenter(); + + entity_corner0->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box in X/Y direction; with Shift along the Z axis; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box in X/Y direction; with Shift along the Z axis; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner2->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box in X/Y direction; with Shift along the Z axis; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner3->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box in X/Y direction; with Shift along the Z axis; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner4->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box along the Z axis; with Shift in X/Y direction; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner5->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box along the Z axis; with Shift in X/Y direction; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner6->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box along the Z axis; with Shift in X/Y direction; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_corner7->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Resize box along the Z axis; with Shift in X/Y direction; " + "with Ctrl to constrain to the directions of edges or diagonals")); + + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Move the box in perspective"), + SP_KNOT_SHAPE_CROSS); + + entity.push_back(entity_corner0); + entity.push_back(entity_corner1); + entity.push_back(entity_corner2); + entity.push_back(entity_corner3); + entity.push_back(entity_corner4); + entity.push_back(entity_corner5); + entity.push_back(entity_corner6); + entity.push_back(entity_corner7); + entity.push_back(entity_center); + + add_pattern_knotholder(); +} + +/* SPArc */ + +class ArcKnotHolderEntityStart : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class ArcKnotHolderEntityEnd : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class ArcKnotHolderEntityRX : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class ArcKnotHolderEntityRY : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class ArcKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +/* + * return values: + * 1 : inside + * 0 : on the curves + * -1 : outside + */ +static gint +sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p) +{ + gdouble dx = (p[Geom::X] - ellipse->cx.computed) / ellipse->rx.computed; + gdouble dy = (p[Geom::Y] - ellipse->cy.computed) / ellipse->ry.computed; + + gdouble s = dx * dx + dy * dy; + // We add a bit of a buffer, so there's a decent chance the user will + // be able to adjust the arc without the closed status flipping between + // open and closed during micro mouse movements. + if (s < 0.75) return 1; + if (s > 1.25) return -1; + return 0; +} + +void +ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); + + SPGenericEllipse *arc = dynamic_cast(item); + g_assert(arc != NULL); + + gint side = sp_genericellipse_side(arc, p); + if(side != 0) { arc->setArcType( (side == -1) ? + SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE : + SP_GENERIC_ELLIPSE_ARC_TYPE_ARC); } + + Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); + Geom::Scale sc(arc->rx.computed, arc->ry.computed); + + double offset = arc->start - atan2(delta * sc.inverse()); + arc->start -= offset; + + if ((state & GDK_CONTROL_MASK) && snaps) { + arc->start = sp_round(arc->start, M_PI / snaps); + } + if (state & GDK_SHIFT_MASK) { + arc->end -= offset; + } + + arc->normalize(); + arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityStart::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast(item); + g_assert(ge != NULL); + + return ge->getPointAtAngle(ge->start); +} + +void +ArcKnotHolderEntityStart::knot_click(unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + if (state & GDK_SHIFT_MASK) { + ge->end = ge->start = 0; + ge->updateRepr(); + } +} + +void +ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); + + SPGenericEllipse *arc = dynamic_cast(item); + g_assert(arc != NULL); + + gint side = sp_genericellipse_side(arc, p); + if(side != 0) { arc->setArcType( (side == -1) ? + SP_GENERIC_ELLIPSE_ARC_TYPE_SLICE : + SP_GENERIC_ELLIPSE_ARC_TYPE_ARC); } + + Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); + Geom::Scale sc(arc->rx.computed, arc->ry.computed); + + double offset = arc->end - atan2(delta * sc.inverse()); + arc->end -= offset; + + if ((state & GDK_CONTROL_MASK) && snaps) { + arc->end = sp_round(arc->end, M_PI/snaps); + } + if (state & GDK_SHIFT_MASK) { + arc->start -= offset; + } + + arc->normalize(); + arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityEnd::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast(item); + g_assert(ge != NULL); + + return ge->getPointAtAngle(ge->end); +} + + +void +ArcKnotHolderEntityEnd::knot_click(unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + if (state & GDK_SHIFT_MASK) { + ge->end = ge->start = 0; + ge->updateRepr(); + } +} + + +void +ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + ge->rx = fabs( ge->cx.computed - s[Geom::X] ); + + if ( state & GDK_CONTROL_MASK ) { + ge->ry = ge->rx.computed; + } + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityRX::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast(item); + g_assert(ge != NULL); + + return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(ge->rx.computed, 0)); +} + +void +ArcKnotHolderEntityRX::knot_click(unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + if (state & GDK_CONTROL_MASK) { + ge->ry = ge->rx.computed; + ge->updateRepr(); + } +} + +void +ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + ge->ry = fabs( ge->cy.computed - s[Geom::Y] ); + + if ( state & GDK_CONTROL_MASK ) { + ge->rx = ge->ry.computed; + } + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityRY::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast(item); + g_assert(ge != NULL); + + return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(0, ge->ry.computed)); +} + +void +ArcKnotHolderEntityRY::knot_click(unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + if (state & GDK_CONTROL_MASK) { + ge->rx = ge->ry.computed; + ge->updateRepr(); + } +} + +void +ArcKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPGenericEllipse *ge = dynamic_cast(item); + g_assert(ge != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + ge->cx = s[Geom::X]; + ge->cy = s[Geom::Y]; + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +ArcKnotHolderEntityCenter::knot_get() const +{ + SPGenericEllipse const *ge = dynamic_cast(item); + g_assert(ge != NULL); + + return Geom::Point(ge->cx.computed, ge->cy.computed); +} + + +ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + ArcKnotHolderEntityRX *entity_rx = new ArcKnotHolderEntityRX(); + ArcKnotHolderEntityRY *entity_ry = new ArcKnotHolderEntityRY(); + ArcKnotHolderEntityStart *entity_start = new ArcKnotHolderEntityStart(); + ArcKnotHolderEntityEnd *entity_end = new ArcKnotHolderEntityEnd(); + ArcKnotHolderEntityCenter *entity_center = new ArcKnotHolderEntityCenter(); + + entity_rx->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, + _("Adjust ellipse width, with Ctrl to make circle"), + SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); + + entity_ry->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, + _("Adjust ellipse height, with Ctrl to make circle"), + SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); + + entity_start->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, + _("Position the start point of the arc or segment; with Shift to move " + "with end point; with Ctrl to snap angle; drag inside the " + "ellipse for arc, outside for segment"), + SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + + entity_end->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, + _("Position the end point of the arc or segment; with Shift to move " + "with start point; with Ctrl to snap angle; drag inside the " + "ellipse for arc, outside for segment"), + SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Drag to move the ellipse"), + SP_KNOT_SHAPE_CROSS); + + entity.push_back(entity_rx); + entity.push_back(entity_ry); + entity.push_back(entity_start); + entity.push_back(entity_end); + entity.push_back(entity_center); + + add_pattern_knotholder(); +} + +/* SPStar */ + +class StarKnotHolderEntity1 : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class StarKnotHolderEntity2 : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class StarKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +void +StarKnotHolderEntity1::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPStar *star = dynamic_cast(item); + g_assert(star != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + Geom::Point d = s - star->center; + + double arg1 = atan2(d); + double darg1 = arg1 - star->arg[0]; + + if (state & GDK_MOD1_MASK) { + star->randomized = darg1/(star->arg[0] - star->arg[1]); + } else if (state & GDK_SHIFT_MASK) { + star->rounded = darg1/(star->arg[0] - star->arg[1]); + } else if (state & GDK_CONTROL_MASK) { + star->r[0] = L2(d); + } else { + star->r[0] = L2(d); + star->arg[0] = arg1; + star->arg[1] += darg1; + } + star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +StarKnotHolderEntity2::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPStar *star = dynamic_cast(item); + g_assert(star != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + if (star->flatsided == false) { + Geom::Point d = s - star->center; + + double arg1 = atan2(d); + double darg1 = arg1 - star->arg[1]; + + if (state & GDK_MOD1_MASK) { + star->randomized = darg1/(star->arg[0] - star->arg[1]); + } else if (state & GDK_SHIFT_MASK) { + star->rounded = fabs(darg1/(star->arg[0] - star->arg[1])); + } else if (state & GDK_CONTROL_MASK) { + star->r[1] = L2(d); + star->arg[1] = star->arg[0] + M_PI / star->sides; + } + else { + star->r[1] = L2(d); + star->arg[1] = atan2(d); + } + star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + } +} + +void +StarKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPStar *star = dynamic_cast(item); + g_assert(star != NULL); + + star->center = snap_knot_position(p, state); + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +StarKnotHolderEntity1::knot_get() const +{ + g_assert(item != NULL); + + SPStar const *star = dynamic_cast(item); + g_assert(star != NULL); + + return sp_star_get_xy(star, SP_STAR_POINT_KNOT1, 0); + +} + +Geom::Point +StarKnotHolderEntity2::knot_get() const +{ + g_assert(item != NULL); + + SPStar const *star = dynamic_cast(item); + g_assert(star != NULL); + + return sp_star_get_xy(star, SP_STAR_POINT_KNOT2, 0); +} + +Geom::Point +StarKnotHolderEntityCenter::knot_get() const +{ + g_assert(item != NULL); + + SPStar const *star = dynamic_cast(item); + g_assert(star != NULL); + + return star->center; +} + +static void +sp_star_knot_click(SPItem *item, unsigned int state) +{ + SPStar *star = dynamic_cast(item); + g_assert(star != NULL); + + if (state & GDK_MOD1_MASK) { + star->randomized = 0; + star->updateRepr(); + } else if (state & GDK_SHIFT_MASK) { + star->rounded = 0; + star->updateRepr(); + } else if (state & GDK_CONTROL_MASK) { + star->arg[1] = star->arg[0] + M_PI / star->sides; + star->updateRepr(); + } +} + +void +StarKnotHolderEntity1::knot_click(unsigned int state) +{ + sp_star_knot_click(item, state); +} + +void +StarKnotHolderEntity2::knot_click(unsigned int state) +{ + sp_star_knot_click(item, state); +} + +StarKnotHolder::StarKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + SPStar *star = dynamic_cast(item); + g_assert(item != NULL); + + StarKnotHolderEntity1 *entity1 = new StarKnotHolderEntity1(); + entity1->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Adjust the tip radius of the star or polygon; " + "with Shift to round; with Alt to randomize")); + + entity.push_back(entity1); + + if (star->flatsided == false) { + StarKnotHolderEntity2 *entity2 = new StarKnotHolderEntity2(); + entity2->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Adjust the base radius of the star; with Ctrl to keep star rays " + "radial (no skew); with Shift to round; with Alt to randomize")); + entity.push_back(entity2); + } + + StarKnotHolderEntityCenter *entity_center = new StarKnotHolderEntityCenter(); + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Drag to move the star"), + SP_KNOT_SHAPE_CROSS); + entity.push_back(entity_center); + + add_pattern_knotholder(); +} + +/* SPSpiral */ + +class SpiralKnotHolderEntityInner : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); + virtual void knot_click(unsigned int state); +}; + +class SpiralKnotHolderEntityOuter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +class SpiralKnotHolderEntityCenter : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + + +/* + * set attributes via inner (t=t0) knot point: + * [default] increase/decrease inner point + * [shift] increase/decrease inner and outer arg synchronizely + * [control] constrain inner arg to round per PI/4 + */ +void +SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); + + SPSpiral *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + gdouble dx = p[Geom::X] - spiral->cx; + gdouble dy = p[Geom::Y] - spiral->cy; + + gdouble moved_y = p[Geom::Y] - origin[Geom::Y]; + + if (state & GDK_MOD1_MASK) { + // adjust divergence by vertical drag, relative to rad + if (spiral->rad > 0) { + double exp_delta = 0.1*moved_y/(spiral->rad); // arbitrary multiplier to slow it down + spiral->exp += exp_delta; + if (spiral->exp < 1e-3) + spiral->exp = 1e-3; + } + } else { + // roll/unroll from inside + gdouble arg_t0; + spiral->getPolar(spiral->t0, NULL, &arg_t0); + + gdouble arg_tmp = atan2(dy, dx) - arg_t0; + gdouble arg_t0_new = arg_tmp - floor((arg_tmp+M_PI)/(2.0*M_PI))*2.0*M_PI + arg_t0; + spiral->t0 = (arg_t0_new - spiral->arg) / (2.0*M_PI*spiral->revo); + + /* round inner arg per PI/snaps, if CTRL is pressed */ + if ( ( state & GDK_CONTROL_MASK ) + && ( fabs(spiral->revo) > SP_EPSILON_2 ) + && ( snaps != 0 ) ) { + gdouble arg = 2.0*M_PI*spiral->revo*spiral->t0 + spiral->arg; + spiral->t0 = (sp_round(arg, M_PI/snaps) - spiral->arg)/(2.0*M_PI*spiral->revo); + } + + spiral->t0 = CLAMP(spiral->t0, 0.0, 0.999); + } + + spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +/* + * set attributes via outer (t=1) knot point: + * [default] increase/decrease revolution factor + * [control] constrain inner arg to round per PI/4 + */ +void +SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); + + SPSpiral *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + gdouble dx = p[Geom::X] - spiral->cx; + gdouble dy = p[Geom::Y] - spiral->cy; + + if (state & GDK_SHIFT_MASK) { // rotate without roll/unroll + spiral->arg = atan2(dy, dx) - 2.0*M_PI*spiral->revo; + if (!(state & GDK_MOD1_MASK)) { + // if alt not pressed, change also rad; otherwise it is locked + spiral->rad = MAX(hypot(dx, dy), 0.001); + } + if ( ( state & GDK_CONTROL_MASK ) + && snaps ) { + spiral->arg = sp_round(spiral->arg, M_PI/snaps); + } + } else { // roll/unroll + // arg of the spiral outer end + double arg_1; + spiral->getPolar(1, NULL, &arg_1); + + // its fractional part after the whole turns are subtracted + double arg_r = arg_1 - sp_round(arg_1, 2.0*M_PI); + + // arg of the mouse point relative to spiral center + double mouse_angle = atan2(dy, dx); + if (mouse_angle < 0) + mouse_angle += 2*M_PI; + + // snap if ctrl + if ( ( state & GDK_CONTROL_MASK ) && snaps ) { + mouse_angle = sp_round(mouse_angle, M_PI/snaps); + } + + // by how much we want to rotate the outer point + double diff = mouse_angle - arg_r; + if (diff > M_PI) + diff -= 2*M_PI; + else if (diff < -M_PI) + diff += 2*M_PI; + + // calculate the new rad; + // the value of t corresponding to the angle arg_1 + diff: + double t_temp = ((arg_1 + diff) - spiral->arg)/(2*M_PI*spiral->revo); + // the rad at that t: + double rad_new = 0; + if (t_temp > spiral->t0) + spiral->getPolar(t_temp, &rad_new, NULL); + + // change the revo (converting diff from radians to the number of turns) + spiral->revo += diff/(2*M_PI); + if (spiral->revo < 1e-3) + spiral->revo = 1e-3; + + // if alt not pressed and the values are sane, change the rad + if (!(state & GDK_MOD1_MASK) && rad_new > 1e-3 && rad_new/spiral->rad < 2) { + // adjust t0 too so that the inner point stays unmoved + double r0; + spiral->getPolar(spiral->t0, &r0, NULL); + spiral->rad = rad_new; + spiral->t0 = pow(r0 / spiral->rad, 1.0/spiral->exp); + } + if (!IS_FINITE(spiral->t0)) spiral->t0 = 0.0; + spiral->t0 = CLAMP(spiral->t0, 0.0, 0.999); + } + + spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +void +SpiralKnotHolderEntityCenter::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPSpiral *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + Geom::Point const s = snap_knot_position(p, state); + + spiral->cx = s[Geom::X]; + spiral->cy = s[Geom::Y]; + + spiral->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + +Geom::Point +SpiralKnotHolderEntityInner::knot_get() const +{ + SPSpiral const *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + return spiral->getXY(spiral->t0); +} + +Geom::Point +SpiralKnotHolderEntityOuter::knot_get() const +{ + SPSpiral const *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + return spiral->getXY(1.0); +} + +Geom::Point +SpiralKnotHolderEntityCenter::knot_get() const +{ + SPSpiral const *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + return Geom::Point(spiral->cx, spiral->cy); +} + +void +SpiralKnotHolderEntityInner::knot_click(unsigned int state) +{ + SPSpiral *spiral = dynamic_cast(item); + g_assert(spiral != NULL); + + if (state & GDK_MOD1_MASK) { + spiral->exp = 1; + spiral->updateRepr(); + } else if (state & GDK_SHIFT_MASK) { + spiral->t0 = 0; + spiral->updateRepr(); + } +} + +SpiralKnotHolder::SpiralKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + SpiralKnotHolderEntityCenter *entity_center = new SpiralKnotHolderEntityCenter(); + SpiralKnotHolderEntityInner *entity_inner = new SpiralKnotHolderEntityInner(); + SpiralKnotHolderEntityOuter *entity_outer = new SpiralKnotHolderEntityOuter(); + + // NOTE: entity_central and entity_inner can overlap. + // + // In that case it would be a problem if the center control point was ON + // TOP because it would steal the mouse focus and the user would loose the + // ability to access the inner control point using only the mouse. + // + // However if the inner control point is ON TOP, taking focus, the + // situation is a lot better: the user can still move the inner control + // point with the mouse to regain access to the center control point. + // + // So, create entity_inner AFTER entity_center; this ensures that + // entity_inner gets rendered ON TOP. + entity_center->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + _("Drag to move the spiral"), + SP_KNOT_SHAPE_CROSS); + + entity_inner->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Roll/unroll the spiral from inside; with Ctrl to snap angle; " + "with Alt to converge/diverge")); + + entity_outer->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Roll/unroll the spiral from outside; with Ctrl to snap angle; " + "with Shift to scale/rotate; with Alt to lock radius")); + + entity.push_back(entity_center); + entity.push_back(entity_inner); + entity.push_back(entity_outer); + + add_pattern_knotholder(); +} + +/* SPOffset */ + +class OffsetKnotHolderEntity : public KnotHolderEntity { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +void +OffsetKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, unsigned int state) +{ + SPOffset *offset = dynamic_cast(item); + g_assert(offset != NULL); + + Geom::Point const p_snapped = snap_knot_position(p, state); + + offset->rad = sp_offset_distance_to_original(offset, p_snapped); + offset->knot = p_snapped; + offset->knotSet = true; + + offset->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); +} + + +Geom::Point +OffsetKnotHolderEntity::knot_get() const +{ + SPOffset const *offset = dynamic_cast(item); + g_assert(offset != NULL); + + Geom::Point np; + sp_offset_top_point(offset,&np); + return np; +} + +OffsetKnotHolder::OffsetKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + OffsetKnotHolderEntity *entity_offset = new OffsetKnotHolderEntity(); + entity_offset->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Adjust the offset distance")); + entity.push_back(entity_offset); + + add_pattern_knotholder(); +} + +// TODO: this is derived from RectKnotHolderEntityWH because it used the same static function +// set_internal as the latter before KnotHolderEntity was C++ified. Check whether this also makes +// sense logically. +class FlowtextKnotHolderEntity : public RectKnotHolderEntityWH { +public: + virtual Geom::Point knot_get() const; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state); +}; + +Geom::Point +FlowtextKnotHolderEntity::knot_get() const +{ + SPRect const *rect = dynamic_cast(item); + g_assert(rect != NULL); + + return Geom::Point(rect->x.computed + rect->width.computed, rect->y.computed + rect->height.computed); +} + +void +FlowtextKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state) +{ + set_internal(p, origin, state); +} + +FlowtextKnotHolder::FlowtextKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler) : + KnotHolder(desktop, item, relhandler) +{ + g_assert(item != NULL); + + FlowtextKnotHolderEntity *entity_flowtext = new FlowtextKnotHolderEntity(); + entity_flowtext->create(desktop, item, this, Inkscape::CTRL_TYPE_SHAPER, + _("Drag to resize the flowed text frame")); + entity.push_back(entity_flowtext); +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index 2c0e662ee..4851c413f 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -20,15 +20,15 @@ #include "sp-shape.h" #include "sp-path.h" #include "inkscape.h" -#include "ui/object-edit.h" #include "ui/shape-editor.h" #include "xml/node-event-vector.h" -//using Inkscape::createKnotHolder; namespace Inkscape { namespace UI { +KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop); + bool ShapeEditor::_blockSetItem = false; ShapeEditor::ShapeEditor(SPDesktop *dt, Geom::Affine edit_transform) : -- cgit v1.2.3 From e0957537cd0938313803c290a2f3922a3889e6f1 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 1 Oct 2017 17:49:26 +0200 Subject: Removed all GSList occurences in .h files --- src/ui/dialog/spellcheck.cpp | 87 +++++++++++++------------------------- src/ui/dialog/spellcheck.h | 11 +++-- src/ui/dialog/symbols.cpp | 46 +++++++++----------- src/ui/dialog/symbols.h | 12 +++--- src/ui/tool/manipulator.h | 9 ++-- src/ui/tools/calligraphic-tool.cpp | 20 ++++----- src/ui/tools/dynamic-base.cpp | 7 ++- src/ui/tools/dynamic-base.h | 3 +- src/ui/tools/eraser-tool.cpp | 18 ++++---- src/ui/tools/freehand-base.cpp | 72 +++++++++++++------------------ src/ui/tools/freehand-base.h | 6 +-- src/ui/tools/pen-tool.cpp | 54 +++++++++++------------ src/ui/tools/pencil-tool.cpp | 8 ++-- src/ui/widget/selected-style.cpp | 8 ++-- src/ui/widget/selected-style.h | 2 +- src/ui/widget/unit-tracker.cpp | 51 ++++++++++------------ src/ui/widget/unit-tracker.h | 6 +-- 17 files changed, 181 insertions(+), 239 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 4f7657f4f..3318b5e6b 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -50,8 +50,6 @@ namespace Dialog { SpellCheck::SpellCheck (void) : UI::Widget::Panel ("", "/dialogs/spellcheck/", SP_VERB_DIALOG_SPELLCHECK), - _rects(NULL), - _seen_objects(NULL), _text(NULL), _layout(NULL), _stops(0), @@ -196,12 +194,11 @@ void SpellCheck::setTargetDesktop(SPDesktop *desktop) void SpellCheck::clearRects() { - for (GSList *it = _rects; it; it = it->next) { - sp_canvas_item_hide(SP_CANVAS_ITEM(it->data)); - sp_canvas_item_destroy(SP_CANVAS_ITEM(it->data)); + for(auto t : _rects) { + sp_canvas_item_hide(t); + sp_canvas_item_destroy(t); } - g_slist_free(_rects); - _rects = NULL; + _rects.clear(); } void SpellCheck::disconnect() @@ -214,47 +211,39 @@ void SpellCheck::disconnect() } } -GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool locked) +void SpellCheck::allTextItems (SPObject *r, std::vector &l, bool hidden, bool locked) { if (!desktop) - return l; // no desktop to check + return; // no desktop to check if (SP_IS_DEFS(r)) - return l; // we're not interested in items in defs + return; // we're not interested in items in defs if (!strcmp(r->getRepr()->name(), "svg:metadata")) { - return l; // we're not interested in metadata + return; // we're not interested in metadata } for (auto& child: r->children) { if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) { if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child)) - l = g_slist_prepend (l, &child); + l.push_back(static_cast(&child)); } } - l = allTextItems (&child, l, hidden, locked); + allTextItems (&child, l, hidden, locked); } - return l; + return; } bool SpellCheck::textIsValid (SPObject *root, SPItem *text) { - GSList *l = NULL; - l = allTextItems (root, l, false, true); - for (GSList *i = l; i; i = i->next) { - SPItem *item = static_cast(i->data); - if (item == text) { - g_slist_free (l); - return true; - } - } - g_slist_free (l); - return false; + std::vector l; + allTextItems (root, l, false, true); + return (std::find(l.begin(), l.end(), text) != l.end()); } -gint SpellCheck::compareTextBboxes (gconstpointer a, gconstpointer b) +bool SpellCheck::compareTextBboxes (gconstpointer a, gconstpointer b)//returns adesktopVisualBounds(); Geom::OptRect bbox2 = i2->desktopVisualBounds(); if (!bbox1 || !bbox2) { - return 0; + return false; } // vector between top left corners Geom::Point diff = Geom::Point(bbox2->min()[Geom::X], bbox2->max()[Geom::Y]) - Geom::Point(bbox1->min()[Geom::X], bbox1->max()[Geom::Y]); - // sort top to bottom, left to right, but: - // if i2 is higher only 0.2 or less times it is righter than i1, put i1 first - if (diff[Geom::Y] > 0.2 * diff[Geom::X]) - return 1; - else - return -1; - - return 0; + return diff[Geom::Y] == 0 ? (diff[Geom::X] < 0) : (diff[Geom::Y] < 0); } // We regenerate and resort the list every time, because user could have changed it while the // dialog was waiting SPItem *SpellCheck::getText (SPObject *root) { - GSList *l = NULL; - l = allTextItems (root, l, false, true); - l = g_slist_sort(l, (GCompareFunc)SpellCheck::compareTextBboxes); - - for (GSList *i = l; i; i = i->next) { - SPItem *item = static_cast(i->data); - if (!g_slist_find (_seen_objects, item)) { - _seen_objects = g_slist_prepend(_seen_objects, item); - g_slist_free(l); + std::vector l; + allTextItems (root, l, false, true); + std::sort(l.begin(),l.end(),SpellCheck::compareTextBboxes); + + for (auto item:l) { + if(_seen_objects.insert(item).second) return item; - } } - - g_slist_free(l); return NULL; } @@ -402,8 +378,7 @@ SpellCheck::init(SPDesktop *d) _root = desktop->getDocument()->getRoot(); // empty the list of objects we've checked - g_slist_free (_seen_objects); - _seen_objects = NULL; + _seen_objects.clear(); // grab first text nextText(); @@ -456,8 +431,7 @@ SpellCheck::finished () g_free(label); } - g_slist_free(_seen_objects); - _seen_objects = NULL; + _seen_objects.clear(); desktop = NULL; _root = NULL; @@ -615,7 +589,7 @@ SpellCheck::nextWord() curve->lineto(area.corner(0)); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(rect), curve); sp_canvas_item_show(rect); - _rects = g_slist_prepend(_rects, rect); + _rects.push_back(rect); // scroll to make it all visible Geom::Point const center = desktop->get_display_area().midpoint(); @@ -707,10 +681,10 @@ SpellCheck::nextWord() void SpellCheck::deleteLastRect () { - if (_rects) { - sp_canvas_item_hide(SP_CANVAS_ITEM(_rects->data)); - sp_canvas_item_destroy(SP_CANVAS_ITEM(_rects->data)); - _rects = _rects->next; // pop latest-prepended rect + if (!_rects.empty()) { + sp_canvas_item_hide(_rects.back()); + sp_canvas_item_destroy(_rects.back()); + _rects.pop_back(); // pop latest-prepended rect } } @@ -861,7 +835,6 @@ SpellCheck::onStart () } } - /* Local Variables: mode:c++ diff --git a/src/ui/dialog/spellcheck.h b/src/ui/dialog/spellcheck.h index 834f23c24..e7563ad1e 100644 --- a/src/ui/dialog/spellcheck.h +++ b/src/ui/dialog/spellcheck.h @@ -16,6 +16,9 @@ # include #endif +#include +#include + #include #include #include @@ -68,7 +71,7 @@ private: /** * Returns a list of all the text items in the SPObject */ - GSList *allTextItems (SPObject *r, GSList *l, bool hidden, bool locked); + void allTextItems (SPObject *r, std::vector &l, bool hidden, bool locked); /** * Is text inside the SPOject's tree @@ -78,7 +81,7 @@ private: /** * Compare the visual bounds of 2 SPItems referred to by a and b */ - static gint compareTextBboxes (gconstpointer a, gconstpointer b); + static bool compareTextBboxes (gconstpointer a, gconstpointer b); SPItem *getText (SPObject *root); void nextText (); @@ -165,12 +168,12 @@ private: /** * list of canvasitems (currently just rects) that mark misspelled things on canvas */ - GSList *_rects; + std::vector _rects; /** * list of text objects we have already checked in this session */ - GSList *_seen_objects; + std::set _seen_objects; /** * the object currently being checked diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index b876fa98c..558b0b19e 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -617,52 +617,48 @@ void SymbolsDialog::get_symbols() { } } -GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) +void SymbolsDialog::symbols_in_doc_recursive (SPObject *r, std::vector &l) { - g_return_val_if_fail(r != NULL, l); + if(!r) return; // Stop multiple counting of same symbol if ( dynamic_cast(r) ) { - return l; + return; } if ( dynamic_cast(r) ) { - l = g_slist_prepend (l, r); + l.push_back(dynamic_cast(r)); } for (auto& child: r->children) { - l = symbols_in_doc_recursive( &child, l ); + symbols_in_doc_recursive( &child, l ); } - - return l; } -GSList* SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) { +std::vector SymbolsDialog::symbols_in_doc( SPDocument* symbolDocument ) +{ - GSList *l = NULL; - l = symbols_in_doc_recursive (symbolDocument->getRoot(), l ); - l = g_slist_reverse( l ); + std::vector l; + symbols_in_doc_recursive (symbolDocument->getRoot(), l ); return l; } -GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) +void SymbolsDialog::use_in_doc_recursive (SPObject *r, std::vector &l) { if ( dynamic_cast(r) ) { - l = g_slist_prepend (l, r); + l.push_back(dynamic_cast(r)); } for (auto& child: r->children) { - l = use_in_doc_recursive( &child, l ); + use_in_doc_recursive( &child, l ); } - - return l; } -GSList* SymbolsDialog::use_in_doc( SPDocument* useDocument ) { +std::vector SymbolsDialog::use_in_doc( SPDocument* useDocument ) { - GSList *l = NULL; - l = use_in_doc_recursive (useDocument->getRoot(), l ); + std::vector l; + use_in_doc_recursive (useDocument->getRoot(), l); return l; } @@ -671,10 +667,8 @@ GSList* SymbolsDialog::use_in_doc( SPDocument* useDocument ) { gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* document) { gchar const* style = 0; - GSList* l = use_in_doc( document ); - for( ; l != NULL; l = l->next ) { - SPObject *obj = reinterpret_cast(l->data); - SPUse *use = dynamic_cast(obj); + std::vector l = use_in_doc( document ); + for( auto use:l ) { if ( use ) { gchar const *href = use->getRepr()->attribute("xlink:href"); if( href ) { @@ -693,10 +687,8 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen void SymbolsDialog::add_symbols( SPDocument* symbolDocument ) { - GSList* l = symbols_in_doc( symbolDocument ); - for( ; l != NULL; l = l->next ) { - SPObject *obj = reinterpret_cast(l->data); - SPSymbol *symbol = dynamic_cast(obj); + std::vector l = symbols_in_doc( symbolDocument ); + for(auto symbol:l) { if (symbol) { add_symbol( symbol ); } diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 5dc1e3cad..747e5c6c9 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -14,10 +14,10 @@ #define INKSCAPE_UI_DIALOG_SYMBOLS_H #include "display/drawing.h" - #include "ui/dialog/desktop-tracker.h" - #include "ui/widget/panel.h" +#include "sp-symbol.h" +#include "sp-use.h" #include @@ -85,10 +85,10 @@ private: void add_symbol( SPObject* symbol_document ); SPDocument* symbols_preview_doc(); - GSList* symbols_in_doc_recursive(SPObject *r, GSList *l); - GSList* symbols_in_doc( SPDocument* document ); - GSList* use_in_doc_recursive(SPObject *r, GSList *l); - GSList* use_in_doc( SPDocument* document ); + void symbols_in_doc_recursive(SPObject *r, std::vector &l); + std::vector symbols_in_doc( SPDocument* document ); + void use_in_doc_recursive(SPObject *r, std::vector &l); + std::vector use_in_doc( SPDocument* document ); gchar const* style_from_use( gchar const* id, SPDocument* document); Glib::RefPtr draw_symbol(SPObject *symbol); diff --git a/src/ui/tool/manipulator.h b/src/ui/tool/manipulator.h index 07e01a656..0f26c6de1 100644 --- a/src/ui/tool/manipulator.h +++ b/src/ui/tool/manipulator.h @@ -98,16 +98,17 @@ public: bool empty() { return _mmap.empty(); } - void setItems(GSList const *list) { + + void setItems(std::vector list) { // this function is not called anywhere ... delete ? std::set to_remove; for (typename MapType::iterator mi = _mmap.begin(); mi != _mmap.end(); ++mi) { to_remove.insert(mi->first); } - for (GSList *i = const_cast(list); i; i = i->next) { - if (_isItemType(i->data)) { + for (auto i:list) { + if (_isItemType(i)) { // erase returns the number of items removed // if nothing was removed, it means this item did not have a manipulator - add it - if (!to_remove.erase(i->data)) addItem(i->data); + if (!to_remove.erase(i)) addItem(i); } } typedef typename std::set::iterator RmIter; diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 3e00fe69c..ca94ac75f 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -421,10 +421,9 @@ void CalligraphicTool::cancel() { sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0); /* Remove all temporary line segments */ - while (this->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); - this->segments = g_slist_remove(this->segments, this->segments->data); - } + for (auto i:this->segments) + sp_canvas_item_destroy(SP_CANVAS_ITEM(i)); + this->segments.clear(); /* reset accumulated curve */ this->accumulated->reset(); @@ -731,10 +730,9 @@ bool CalligraphicTool::root_handler(GdkEvent* event) { this->apply(motion_dt); /* Remove all temporary line segments */ - while (this->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); - this->segments = g_slist_remove(this->segments, this->segments->data); - } + for (auto i:this->segments) + sp_canvas_item_destroy(SP_CANVAS_ITEM(i)); + this->segments.clear(); /* Create object */ this->fit_and_split(true); @@ -1089,7 +1087,7 @@ void CalligraphicTool::fit_and_split(bool release) { this->currentcurve->curveto(bp2[2], bp2[1], bp2[0]); } // FIXME: dc->segments is always NULL at this point?? - if (!this->segments) { // first segment + if (this->segments.empty()) { // first segment add_cap(this->currentcurve, b2[0], b1[0], this->cap_rounding); } this->currentcurve->closepath(); @@ -1143,8 +1141,8 @@ void CalligraphicTool::fit_and_split(bool release) { sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); /* fixme: Cannot we cascade it to root more clearly? */ g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), desktop); - - this->segments = g_slist_prepend(this->segments, cbp); + + this->segments.push_back(cbp); } this->point1[0] = this->point1[this->npoints - 1]; diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp index bb4989333..1026c26c6 100644 --- a/src/ui/tools/dynamic-base.cpp +++ b/src/ui/tools/dynamic-base.cpp @@ -21,7 +21,6 @@ namespace Tools { DynamicBase::DynamicBase(gchar const *const *cursor_shape) : ToolBase(cursor_shape) , accumulated(NULL) - , segments(NULL) , currentshape(NULL) , currentcurve(NULL) , cal1(NULL) @@ -62,10 +61,10 @@ DynamicBase::~DynamicBase() { this->accumulated = 0; } - while (this->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); - this->segments = g_slist_remove(this->segments, this->segments->data); + for (auto i:segments) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(i)); } + segments.clear(); if (this->currentcurve) { this->currentcurve = this->currentcurve->unref(); diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h index e270052f3..b9ffd71ce 100644 --- a/src/ui/tools/dynamic-base.h +++ b/src/ui/tools/dynamic-base.h @@ -20,6 +20,7 @@ */ #include "ui/tools/tool-base.h" +#include "display/sp-canvas-item.h" struct SPCanvasItem; class SPCurve; @@ -48,7 +49,7 @@ protected: SPCurve *accumulated; /** canvas items for "committed" segments */ - GSList *segments; + std::vector segments; /** canvas item for red "leading" segment */ SPCanvasItem *currentshape; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b919c138c..83039be18 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -360,10 +360,9 @@ void EraserTool::cancel() { this->is_drawing = false; sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0); /* Remove all temporary line segments */ - while (this->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); - this->segments = g_slist_remove(this->segments, this->segments->data); - } + for (auto i : this->segments) + sp_canvas_item_destroy(SP_CANVAS_ITEM(i)); + this->segments.clear(); /* reset accumulated curve */ this->accumulated->reset(); this->clear_current(); @@ -464,10 +463,9 @@ bool EraserTool::root_handler(GdkEvent* event) { this->apply(motion_dt); /* Remove all temporary line segments */ - while (this->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); - this->segments = g_slist_remove(this->segments, this->segments->data); - } + for (auto i : this->segments) + sp_canvas_item_destroy(SP_CANVAS_ITEM(i)); + this->segments.clear(); /* Create object */ this->fit_and_split(true); @@ -1015,7 +1013,7 @@ void EraserTool::fit_and_split(bool release) { } // FIXME: this->segments is always NULL at this point?? - if (!this->segments) { // first segment + if (this->segments.empty()) { // first segment add_cap(this->currentcurve, b2[1], b2[0], b1[0], b1[1], this->cap_rounding); } @@ -1072,7 +1070,7 @@ void EraserTool::fit_and_split(bool release) { /* fixme: Cannot we cascade it to root more clearly? */ g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), desktop); - this->segments = g_slist_prepend(this->segments, cbp); + this->segments.push_back(cbp); if (eraser_mode == ERASER_MODE_DELETE) { sp_canvas_item_hide(cbp); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index fce17542a..a85c89400 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -76,13 +76,10 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape) , red_curve(NULL) , blue_bpath(NULL) , blue_curve(NULL) - , green_bpaths(NULL) , green_curve(NULL) , green_anchor(NULL) , green_closed(false) , white_item(NULL) - , white_curves(NULL) - , white_anchors(NULL) , overwrite_curve(NULL) , sa(NULL) , ea(NULL) @@ -558,22 +555,20 @@ static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/ SPCurve *norm = SP_PATH(item)->get_curve_for_edit(); norm->transform((dc->white_item)->i2dt_affine()); g_return_if_fail( norm != NULL ); - dc->white_curves = g_slist_reverse(norm->split()); + dc->white_curves = norm->split(); norm->unref(); // Anchor list - for (GSList *l = dc->white_curves; l != NULL; l = l->next) { - SPCurve *c; - c = static_cast(l->data); + for (auto c:dc->white_curves) { g_return_if_fail( c->get_segment_count() > 0 ); if ( !c->is_closed() ) { SPDrawAnchor *a; a = sp_draw_anchor_new(dc, c, TRUE, *(c->first_point())); if (a) - dc->white_anchors = g_slist_prepend(dc->white_anchors, a); + dc->white_anchors.push_back(a); a = sp_draw_anchor_new(dc, c, FALSE, *(c->last_point())); if (a) - dc->white_anchors = g_slist_prepend(dc->white_anchors, a); + dc->white_anchors.push_back(a); } } // fixme: recalculate active anchor? @@ -645,10 +640,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Green dc->green_curve = new SPCurve(); - while (dc->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); - dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data); - } + for (auto i : dc->green_bpaths) + sp_canvas_item_destroy(i); + dc->green_bpaths.clear(); // Blue c->append_continuous(dc->blue_curve, 0.0625); @@ -698,8 +692,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->unref(); dc->overwrite_curve->closepath_current(); if(dc->sa){ - dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); - dc->white_curves = g_slist_append(dc->white_curves, dc->overwrite_curve); + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve)); + dc->white_curves.push_back(dc->overwrite_curve); } }else{ dc->sa->curve->append_continuous(c, 0.0625); @@ -713,7 +707,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) // Step C - test start if (dc->sa) { SPCurve *s = dc->sa->curve; - dc->white_curves = g_slist_remove(dc->white_curves, s); + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), s)); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ s = dc->overwrite_curve; @@ -726,7 +720,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c = s; } else /* Step D - test end */ if (dc->ea) { SPCurve *e = dc->ea->curve; - dc->white_curves = g_slist_remove(dc->white_curves, e); + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), e)); if (!dc->ea->start) { e = reverse_then_unref(e); } @@ -766,11 +760,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) { SPCurve *c; - if (dc->white_curves) { + if (! dc->white_curves.empty()) { g_assert(dc->white_item); c = SPCurve::concat(dc->white_curves); - g_slist_free(dc->white_curves); - dc->white_curves = NULL; + dc->white_curves.clear(); if (gc) { c->append(gc, FALSE); } @@ -856,8 +849,8 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) active = sp_draw_anchor_test(dc->green_anchor, p, TRUE); } - for (GSList *l = dc->white_anchors; l != NULL; l = l->next) { - SPDrawAnchor *na = sp_draw_anchor_test(static_cast(l->data), p, !active); + for (auto i:dc->white_anchors) { + SPDrawAnchor *na = sp_draw_anchor_test(i, p, !active); if ( !active && na ) { active = na; } @@ -871,14 +864,12 @@ static void spdc_reset_white(FreehandBase *dc) // We do not hold refcount dc->white_item = NULL; } - while (dc->white_curves) { - reinterpret_cast(dc->white_curves->data)->unref(); - dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data); - } - while (dc->white_anchors) { - sp_draw_anchor_destroy(static_cast(dc->white_anchors->data)); - dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data); - } + for (auto i: dc->white_curves) + i->unref(); + dc->white_curves.clear(); + for (auto i:dc->white_anchors) + sp_draw_anchor_destroy(i); + dc->white_anchors.clear(); } static void spdc_free_colors(FreehandBase *dc) @@ -902,10 +893,9 @@ static void spdc_free_colors(FreehandBase *dc) } // Green - while (dc->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); - dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data); - } + for (auto i : dc->green_bpaths) + sp_canvas_item_destroy(i); + dc->green_bpaths.clear(); if (dc->green_curve) { dc->green_curve = dc->green_curve->unref(); } @@ -918,14 +908,12 @@ static void spdc_free_colors(FreehandBase *dc) // We do not hold refcount dc->white_item = NULL; } - while (dc->white_curves) { - reinterpret_cast(dc->white_curves->data)->unref(); - dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data); - } - while (dc->white_anchors) { - sp_draw_anchor_destroy(static_cast(dc->white_anchors->data)); - dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data); - } + for (auto i: dc->white_curves) + i->unref(); + dc->white_curves.clear(); + for (auto i:dc->white_anchors) + sp_draw_anchor_destroy(i); + dc->white_anchors.clear(); } void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) { diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index a3069aa09..dc114ef68 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -66,15 +66,15 @@ public: SPCurve *blue_curve; // Green - GSList *green_bpaths; + std::vector green_bpaths; SPCurve *green_curve; SPDrawAnchor *green_anchor; gboolean green_closed; // a flag meaning we hit the green anchor, so close the path on itself // White SPItem *white_item; - GSList *white_curves; - GSList *white_anchors; + std::list white_curves; + std::vector white_anchors; // Alternative curve to use on continuing the exisiting curve in case of // bspline or spirolive, because using anchor curves gives random memory diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 0db5c3954..f8dfd7a10 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -860,18 +860,18 @@ bool PenTool::_handle2ButtonPress(GdkEventButton const &bevent) { void PenTool::_redrawAll() { // green - if (this->green_bpaths) { + if (! this->green_bpaths.empty()) { // remove old piecewise green canvasitems - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i : this->green_bpaths){ + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); // one canvas bpath for all of green_curve SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); } if (this->green_anchor) { SP_CTRL(this->green_anchor->ctrl)->moveto(this->green_anchor->dp); @@ -1253,10 +1253,10 @@ void PenTool::_resetColors() { this->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL, true); // Green - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i:this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); this->green_curve->reset(); if (this->green_anchor) { this->green_anchor = sp_draw_anchor_destroy(this->green_anchor); @@ -1332,17 +1332,17 @@ void PenTool::_bsplineSpiroColor() } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified - if (this->green_bpaths) { + if (!this->green_bpaths.empty()) { // remove old piecewise green canvasitems - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i:this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); // one canvas bpath for all of green_curve SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); } sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); } @@ -1555,18 +1555,18 @@ void PenTool::_bsplineSpiroMotion(guint const state){ this->overwrite_curve = tmp_curve->copy(); } } - if (this->green_bpaths) { + if (!this->green_bpaths.empty()) { this->green_curve = tmp_curve->copy(); // remove old piecewise green canvasitems - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i: this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); // one canvas bpath for all of green_curve SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); } } if (cubic) { @@ -1927,7 +1927,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { curve->unref(); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); + this->green_bpaths.push_back(canvas_shape); this->p[0] = this->p[3]; this->p[1] = this->p[4]; @@ -1953,11 +1953,9 @@ bool PenTool::_undoLastPoint() { // Reset red curve this->red_curve->reset(); // Destroy topmost green bpath - if (this->green_bpaths) { - if (this->green_bpaths->data) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - } - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + if (!this->green_bpaths.empty()) { + sp_canvas_item_destroy(this->green_bpaths.back()); + this->green_bpaths.pop_back(); } // Get last segment if ( this->green_curve->is_unset() ) { @@ -1985,11 +1983,9 @@ bool PenTool::_undoLastPoint() { // delete the last segment of the green curve if (this->green_curve->get_segment_count() == 1) { this->npoints = 5; - if (this->green_bpaths) { - if (this->green_bpaths->data) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - } - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + if (!this->green_bpaths.empty()) { + sp_canvas_item_destroy(this->green_bpaths.back()); + this->green_bpaths.pop_back(); } this->green_curve->reset(); } else { diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 99b8103c3..61799b306 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -437,10 +437,10 @@ void PencilTool::_cancel() { this->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL); - while (this->green_bpaths) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); - this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + for (auto i:this->green_bpaths) { + sp_canvas_item_destroy(i); } + this->green_bpaths.clear(); this->green_curve->reset(); if (this->green_anchor) { this->green_anchor = sp_draw_anchor_destroy(this->green_anchor); @@ -858,7 +858,7 @@ void PencilTool::_fitAndSplit() { } sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - this->green_bpaths = g_slist_prepend(this->green_bpaths, cshape); + this->green_bpaths.push_back(cshape); this->red_curve_is_valid = false; } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 68acddfcc..5d911e9d2 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -139,7 +139,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_blocked (false), - _unit_mis(NULL), _sw_unit(NULL) { set_name("SelectedStyle"); @@ -336,7 +335,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) while(iter != m.end()) { Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); mi->add(*(new Gtk::Label(iter->first, Gtk::ALIGN_START))); - _unit_mis = g_slist_append(_unit_mis, mi); + _unit_mis.push_back(mi); Inkscape::Util::Unit const *u = unit_table.getUnit(iter->first); mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u)); _popup_sw.attach(*mi, 0,1, row, row+1); @@ -449,6 +448,7 @@ SelectedStyle::~SelectedStyle() delete selection_modified_connection; subselection_changed_connection->disconnect(); delete subselection_changed_connection; + _unit_mis.clear(); for (int i = SS_FILL; i <= SS_STROKE; i++) { delete _color_preview[i]; @@ -488,9 +488,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) _sw_unit = desktop->getNamedView()->display_units; // Set the doc default unit active in the units list - gint length = g_slist_length(_unit_mis); - for (int i = 0; i < length; i++) { - Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i); + for ( auto mi:_unit_mis ) { if (mi && mi->get_label() == _sw_unit->abbr) { mi->set_active(); break; diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 065d745f0..b7f3d5dda 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -267,7 +267,7 @@ protected: Gtk::Menu _popup_sw; Gtk::RadioButtonGroup _sw_group; - GSList *_unit_mis; + std::vector _unit_mis; void on_popup_units(Inkscape::Util::Unit const *u); void on_popup_preset(int i); Gtk::MenuItem _popup_sw_remove; diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index a1501c229..d36220b74 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -14,7 +14,7 @@ #include "style-internal.h" #include "unit-tracker.h" -#include "widgets/ege-select-one-action.h" +//#include "widgets/ege-select-one-action.h" #define COLUMN_STRING 0 @@ -31,9 +31,6 @@ UnitTracker::UnitTracker(UnitType unit_type) : _activeUnit(NULL), _activeUnitInitialized(false), _store(0), - _unitList(0), - _actionList(0), - _adjList(0), _priorValues() { _store = gtk_list_store_new(1, G_TYPE_STRING); @@ -58,17 +55,17 @@ UnitTracker::UnitTracker(UnitType unit_type) : UnitTracker::~UnitTracker() { // Unhook weak references to GtkActions - while (_actionList) { - g_signal_handlers_disconnect_by_func(G_OBJECT(_actionList->data), (gpointer) _unitChangedCB, this); - g_object_weak_unref(G_OBJECT(_actionList->data), _actionFinalizedCB, this); - _actionList = g_slist_delete_link(_actionList, _actionList); + for (auto i : _actionList) { + g_signal_handlers_disconnect_by_func(G_OBJECT(i), (gpointer) _unitChangedCB, this); + g_object_weak_unref(G_OBJECT(i), _actionFinalizedCB, this); } + _actionList.clear(); // Unhook weak references to GtkAdjustments - while (_adjList) { - g_object_weak_unref(G_OBJECT(_adjList->data), _adjustmentFinalizedCB, this); - _adjList = g_slist_delete_link(_adjList, _adjList); + for (auto i : _adjList) { + g_object_weak_unref(G_OBJECT(i), _adjustmentFinalizedCB, this); } + _adjList.clear(); } bool UnitTracker::isUpdating() const @@ -109,9 +106,9 @@ void UnitTracker::setActiveUnitByAbbr(gchar const *abbr) void UnitTracker::addAdjustment(GtkAdjustment *adj) { - if (!g_slist_find(_adjList, adj)) { + if (std::find(_adjList.begin(),_adjList.end(),adj)!=_adjList.end()) { g_object_weak_ref(G_OBJECT(adj), _adjustmentFinalizedCB, this); - _adjList = g_slist_append(_adjList, adj); + _adjList.push_back(adj); } } @@ -147,7 +144,7 @@ GtkAction *UnitTracker::createAction(gchar const *name, gchar const *label, gcha ege_select_one_action_set_appearance(act1, "minimal"); g_object_weak_ref(G_OBJECT(act1), _actionFinalizedCB, this); g_signal_connect(G_OBJECT(act1), "changed", G_CALLBACK(_unitChangedCB), this); - _actionList = g_slist_append(_actionList, act1); + _actionList.push_back(act1); return GTK_ACTION(act1); } @@ -180,9 +177,10 @@ void UnitTracker::_adjustmentFinalizedCB(gpointer data, GObject *where_the_objec void UnitTracker::_actionFinalized(GObject *where_the_object_was) { - GSList *target = g_slist_find(_actionList, where_the_object_was); - if (target) { - _actionList = g_slist_remove(_actionList, where_the_object_was); + EgeSelectOneAction* act = (EgeSelectOneAction*)(where_the_object_was); + auto it = std::find(_actionList.begin(),_actionList.end(), act); + if (it != _actionList.end()) { + _actionList.erase(it); } else { g_warning("Received a finalization callback for unknown object %p", where_the_object_was); } @@ -190,9 +188,10 @@ void UnitTracker::_actionFinalized(GObject *where_the_object_was) void UnitTracker::_adjustmentFinalized(GObject *where_the_object_was) { - GSList *target = g_slist_find(_adjList, where_the_object_was); - if (target) { - _adjList = g_slist_remove(_adjList, where_the_object_was); + GtkAdjustment* adj = (GtkAdjustment*)(where_the_object_was); + auto it = std::find(_adjList.begin(),_adjList.end(), adj); + if (it != _adjList.end()) { + _adjList.erase(it); } else { g_warning("Received a finalization callback for unknown object %p", where_the_object_was); } @@ -217,7 +216,7 @@ void UnitTracker::_setActive(gint active) Inkscape::Util::Unit const *newUnit = unit_table.getUnit(newAbbr); _activeUnit = newUnit; - if (_adjList) { + if (!_adjList.empty()) { _fixupAdjustments(unit, newUnit); } @@ -230,11 +229,8 @@ void UnitTracker::_setActive(gint active) _active = active; - for ( GSList *cur = _actionList ; cur ; cur = g_slist_next(cur) ) { - if (IS_EGE_SELECT_ONE_ACTION(cur->data)) { - EgeSelectOneAction *act = EGE_SELECT_ONE_ACTION(cur->data); - ege_select_one_action_set_active(act, active); - } + for (auto act:_actionList) { + ege_select_one_action_set_active(act, active); } _activeUnitInitialized = true; @@ -244,8 +240,7 @@ void UnitTracker::_setActive(gint active) void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit) { _isUpdating = true; - for ( GSList *cur = _adjList ; cur ; cur = g_slist_next(cur) ) { - GtkAdjustment *adj = GTK_ADJUSTMENT(cur->data); + for ( auto adj : _adjList ) { gdouble oldVal = gtk_adjustment_get_value(adj); gdouble val = oldVal; diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index 8fa9ff304..643ac4e51 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -17,6 +17,7 @@ #include #include "util/units.h" +#include "widgets/ege-select-one-action.h" using Inkscape::Util::Unit; using Inkscape::Util::UnitType; @@ -65,9 +66,8 @@ private: Inkscape::Util::Unit const *_activeUnit; bool _activeUnitInitialized; GtkListStore *_store; - GSList *_unitList; - GSList *_actionList; - GSList *_adjList; + std::vector _actionList; + std::vector _adjList; std::map _priorValues; }; -- cgit v1.2.3 From c20891fabc8c3ee2251e0545878e06545b6f0cdd Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 1 Oct 2017 23:57:52 +0200 Subject: First batch --- src/ui/contextmenu.cpp | 2 +- src/ui/dialog/clonetiler.cpp | 8 ++-- src/ui/dialog/grid-arrange-tab.cpp | 10 ++--- src/ui/dialog/tags.cpp | 8 ---- src/ui/interface.cpp | 91 ++++++++++++++++++-------------------- src/ui/widget/color-notebook.cpp | 5 ++- 6 files changed, 55 insertions(+), 69 deletions(-) (limited to 'src/ui') diff --git a/src/ui/contextmenu.cpp b/src/ui/contextmenu.cpp index 1bc87574e..3ca752c82 100644 --- a/src/ui/contextmenu.cpp +++ b/src/ui/contextmenu.cpp @@ -253,7 +253,7 @@ context_menu_item_on_my_deselect(void */*object*/, SPAction *action) // TODO: Update this to allow radio items to be used -void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb)//, SPDesktop *view)//, bool radio, GSList *group) +void ContextMenu::AppendItemFromVerb(Inkscape::Verb *verb) { SPAction *action; SPDesktop *view = _desktop; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 5c9b31fb1..71edcf259 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1993,18 +1993,16 @@ void CloneTiler::remove(bool do_undo/* = true*/) SPObject *parent = obj->parent; // remove old tiling - GSList *to_delete = NULL; + std::vector to_delete; for (auto& child: parent->children) { if (is_a_clone_of (&child, obj)) { - to_delete = g_slist_prepend (to_delete, &child); + to_delete.push_back(&child); } } - for (GSList *i = to_delete; i; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (auto obj:to_delete) { g_assert(obj != NULL); obj->deleteObject(); } - g_slist_free (to_delete); change_selection (selection); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 6e08645cf..c16e60c5f 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -298,15 +298,14 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h std::vector::iterator it = sorted.begin(); for (row_cnt=0; ((it != sorted.end()) && (row_cnt current_row; col_cnt = 0; for(;it!=sorted.end()&&col_cntnext) { - SPItem *item=SP_ITEM(current_row->data); + for (auto item:current_row) { Inkscape::XML::Node *repr = item->getRepr(); Geom::OptRect b = item->documentVisualBounds(); Geom::Point min; @@ -330,10 +329,9 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); item->set_i2d_affine(item->i2dt_affine() * affine); item->doWriteTransform(item->transform); - SP_OBJECT (current_row->data)->updateRepr(); + item->updateRepr(); cnt +=1; } - g_slist_free (current_row); } DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_ARRANGE, diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 176719995..5a5417eb5 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -1103,14 +1103,6 @@ void TagsPanel::setDesktop( SPDesktop* desktop ) setDocument(_desktop, _desktop->doc()); } } -/* - GSList const *layers = _desktop->doc()->getResourceList( "layer" ); - g_message( "layers list starts at %p", layers ); - for ( GSList const *iter=layers ; iter ; iter = iter->next ) { - SPObject *layer=static_cast(iter->data); - g_message(" {%s} [%s]", layer->id, layer->label() ); - } -*/ deskTrack.setBase(desktop); } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 7a9b92378..f6a353b33 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -25,6 +25,8 @@ #include "ui/dialog/dialog-manager.h" #include +#include +#include #include "file.h" #include @@ -220,19 +222,14 @@ sp_create_window(SPViewWidget *vw, bool editable) if ( completeDropTargets == 0 || completeDropTargetsCount == 0 ) { - std::vector types; - - GSList *list = gdk_pixbuf_get_formats(); - while ( list ) { - int i = 0; - GdkPixbufFormat *one = (GdkPixbufFormat*)list->data; - gchar** typesXX = gdk_pixbuf_format_get_mime_types(one); - for ( i = 0; typesXX[i]; i++ ) { - types.push_back(g_strdup(typesXX[i])); - } - g_strfreev(typesXX); + std::vector types; - list = g_slist_next(list); + std::vector list = Gdk::Pixbuf::get_formats(); + for (auto one:list) { + std::vector typesXX = one.get_mime_types(); + for (auto i:typesXX) { + types.push_back(i); + } } completeDropTargetsCount = nui_drop_target_entries + types.size(); completeDropTargets = new GtkTargetEntry[completeDropTargetsCount]; @@ -241,8 +238,8 @@ sp_create_window(SPViewWidget *vw, bool editable) } int pos = nui_drop_target_entries; - for (std::vector::iterator it = types.begin() ; it != types.end() ; ++it) { - completeDropTargets[pos].target = *it; + for (std::vector::iterator it = types.begin() ; it != types.end() ; ++it) { + completeDropTargets[pos].target = g_strdup((*it).c_str()); completeDropTargets[pos].flags = 0; completeDropTargets[pos].info = IMAGE_DATA; pos++; @@ -451,14 +448,14 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men Inkscape::UI::View::View *view, bool show_icon = false, bool radio = false, - GSList *group = NULL) + Gtk::RadioMenuItem::Group *group = NULL) { - GtkWidget *item; + Gtk::Widget *item; // Just create a menu separator if this isn't a real action. // Otherwise, create a real menu item if (verb->get_code() == SP_VERB_NONE) { - item = gtk_separator_menu_item_new(); + item = new Gtk::SeparatorMenuItem(); } else { SPAction *action = verb->get_action(Inkscape::ActionContext(view)); @@ -467,9 +464,9 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men // Create the menu item itself, either as a radio menu item, or just // a regular menu item depending on whether the "radio" flag is set if (radio) { - item = gtk_radio_menu_item_new(group); + item = new Gtk::RadioMenuItem(*group); } else { - item = gtk_menu_item_new(); + item = new Gtk::MenuItem(); } // Create a box to contain all the widgets (icon, label, accelerator) @@ -490,8 +487,8 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men GtkAccelGroup *accel_group = sp_shortcut_get_accel_group(); gtk_menu_set_accel_group(menu, accel_group); - sp_shortcut_add_accelerator(item, sp_shortcut_get_primary(verb)); - gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), item); + sp_shortcut_add_accelerator(item->gobj(), sp_shortcut_get_primary(verb)); + gtk_accel_label_set_accel_widget(GTK_ACCEL_LABEL(label), item->gobj()); GtkWidget *icon; @@ -508,33 +505,34 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *men gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 0); // Finally, pack all the widgets into the menu item - gtk_container_add(GTK_CONTAINER(item), box); + gtk_container_add(GTK_CONTAINER(item->gobj()), box); action->signal_set_sensitive.connect( sigc::bind<0>( sigc::ptr_fun(>k_widget_set_sensitive), - item)); + item->gobj())); action->signal_set_name.connect( sigc::bind<0>( sigc::ptr_fun(&sp_ui_menu_item_set_name), - item)); + item->gobj())); if (!action->sensitive) { - gtk_widget_set_sensitive(item, FALSE); + item->set_sensitive(false); } - gtk_widget_set_events(item, GDK_KEY_PRESS_MASK); - g_object_set_data(G_OBJECT(item), "view", (gpointer) view); - g_signal_connect( G_OBJECT(item), "activate", G_CALLBACK(sp_ui_menu_activate), action ); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select_action), action ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect_action), action ); + gtk_widget_set_events(item->gobj(), GDK_KEY_PRESS_MASK); + + g_object_set_data(G_OBJECT(item->gobj()), "view", (gpointer) view); + g_signal_connect( G_OBJECT(item->gobj()), "activate", G_CALLBACK(sp_ui_menu_activate), action ); + g_signal_connect( G_OBJECT(item->gobj()), "select", G_CALLBACK(sp_ui_menu_select_action), action ); + g_signal_connect( G_OBJECT(item->gobj()), "deselect", G_CALLBACK(sp_ui_menu_deselect_action), action ); } - gtk_widget_show_all(item); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); + item->show_all(); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), item->gobj()); - return item; + return item->gobj(); } // end of sp_ui_menu_append_item_from_verb @@ -769,25 +767,24 @@ static void addTaskMenuItems(GtkMenu *menu, Inkscape::UI::View::View *view) 0, 0 }; - GSList *group = 0; + Gtk::RadioMenuItem::Group group; int count = 0; gint active = Inkscape::UI::UXManager::getInstance()->getDefaultTask( dynamic_cast(view) ); for (gchar const **strs = data; strs[0]; strs += 2, count++) { - GtkWidget *item = gtk_radio_menu_item_new_with_label( group, strs[0] ); - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item) ); + Gtk::RadioMenuItem *item = new Gtk::RadioMenuItem(group,Glib::ustring(strs[0])); if ( count == active ) { - gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item), TRUE ); + item->set_active(); } - g_object_set_data( G_OBJECT(item), "view", view ); - g_signal_connect( G_OBJECT(item), "toggled", reinterpret_cast(taskToggled), GINT_TO_POINTER(count) ); - g_signal_connect( G_OBJECT(item), "select", G_CALLBACK(sp_ui_menu_select), const_cast(strs[1]) ); - g_signal_connect( G_OBJECT(item), "deselect", G_CALLBACK(sp_ui_menu_deselect), 0 ); + g_object_set_data( G_OBJECT(item->gobj()), "view", view ); + g_signal_connect( G_OBJECT(item->gobj()), "toggled", reinterpret_cast(taskToggled), GINT_TO_POINTER(count) ); + g_signal_connect( G_OBJECT(item->gobj()), "select", G_CALLBACK(sp_ui_menu_select), const_cast(strs[1]) ); + g_signal_connect( G_OBJECT(item->gobj()), "deselect", G_CALLBACK(sp_ui_menu_deselect), 0 ); - gtk_widget_show( item ); - gtk_menu_shell_append( GTK_MENU_SHELL(menu), item ); + item->show(); + gtk_menu_shell_append( GTK_MENU_SHELL(menu), GTK_WIDGET(item->gobj()) ); } } @@ -831,7 +828,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I { if (menus == NULL) return; if (menu == NULL) return; - GSList *group = NULL; + Gtk::RadioMenuItem::Group group; for (Inkscape::XML::Node *menu_pntr = menus; menu_pntr != NULL; @@ -863,8 +860,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I if (verb != NULL) { if (menu_pntr->attribute("radio") != NULL) { - GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, show_icon, true, group); - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item)); + GtkWidget *item = sp_ui_menu_append_item_from_verb (GTK_MENU(menu), verb, view, show_icon, true, &group); if (menu_pntr->attribute("default") != NULL) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); } @@ -880,7 +876,8 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I } } else { sp_ui_menu_append_item_from_verb(GTK_MENU(menu), verb, view, show_icon); - group = NULL; + Gtk::RadioMenuItem::Group group2; + group = group2; } } else { gchar string[120]; diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index a4df8187f..ba333d0ed 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "preferences.h" #include "widgets/spw-utilities.h" @@ -325,8 +326,8 @@ void ColorNotebook::_addPage(Page &page) _buttons[page_num] = gtk_radio_button_new_with_label(NULL, mode_name.c_str()); gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(_buttons[page_num]), FALSE); if (page_num > 0) { - GSList *group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(_buttons[0])); - gtk_radio_button_set_group(GTK_RADIO_BUTTON(_buttons[page_num]), group); + auto g = Glib::wrap(GTK_RADIO_BUTTON(_buttons[0]))->get_group(); + Glib::wrap(GTK_RADIO_BUTTON(_buttons[page_num]))->set_group(g); } gtk_widget_show(_buttons[page_num]); gtk_box_pack_start(GTK_BOX(_buttonbox), _buttons[page_num], TRUE, TRUE, 0); -- cgit v1.2.3 From 8761f46f7b8c2a2df82203f5be89d60072998a82 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 2 Oct 2017 02:12:27 +0200 Subject: Second batch --- src/ui/tools/gradient-tool.cpp | 85 ++++++++++++++++++------------------------ src/ui/tools/mesh-tool.cpp | 62 ------------------------------ src/ui/tools/tweak-tool.cpp | 13 +++---- 3 files changed, 42 insertions(+), 118 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 95d940bd6..966183b1a 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -219,7 +219,7 @@ sp_gradient_context_is_over_line (GradientTool *rc, SPItem *item, Geom::Point ev } static std::vector -sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSList **next_stops) +sp_gradient_context_get_stop_intervals (GrDrag *drag, std::vector &these_stops, std::vector &next_stops) { std::vector coords; @@ -285,15 +285,15 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi } // if both adjacent draggers selected, - if (!g_slist_find(*these_stops, this_stop) && dnext && dnext->isSelected()) { + if ((std::find(these_stops.begin(),these_stops.end(),this_stop)==these_stops.end()) && dnext && dnext->isSelected()) { // remember the coords of the future dragger to select it coords.push_back(0.5*(dragger->point + dnext->point)); // do not insert a stop now, it will confuse the loop; // just remember the stops - *these_stops = g_slist_prepend (*these_stops, this_stop); - *next_stops = g_slist_prepend (*next_stops, next_stop); + these_stops.push_back(this_stop); + next_stops.push_back(next_stop); } } } @@ -307,12 +307,12 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc) SPDocument *doc = NULL; GrDrag *drag = rc->_grdrag; - GSList *these_stops = NULL; - GSList *next_stops = NULL; + std::vector these_stops; + std::vector next_stops; - std::vector coords = sp_gradient_context_get_stop_intervals (drag, &these_stops, &next_stops); + std::vector coords = sp_gradient_context_get_stop_intervals (drag, these_stops, next_stops); - if (g_slist_length(these_stops) == 0 && drag->numSelected() == 1) { + if (these_stops.empty() && drag->numSelected() == 1) { // if a single stop is selected, add between that stop and the next one GrDragger *dragger = *(drag->selected.begin()); for (std::vector::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { @@ -330,47 +330,42 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc) if (this_stop) { SPStop *next_stop = this_stop->getNextStop(); if (next_stop) { - these_stops = g_slist_prepend (these_stops, this_stop); - next_stops = g_slist_prepend (next_stops, next_stop); + these_stops.push_back(this_stop); + next_stops.push_back(next_stop); } } } } // now actually create the new stops - GSList *i = these_stops; - GSList *j = next_stops; - GSList *new_stops = NULL; + auto i = these_stops.rbegin(); + auto j = next_stops.rbegin(); + std::vector new_stops; - for (; i != NULL && j != NULL; i = i->next, j = j->next) { - SPStop *this_stop = (SPStop *) i->data; - SPStop *next_stop = (SPStop *) j->data; + for (;i != these_stops.rend() && j != next_stops.rend(); ++i, ++j ) { + SPStop *this_stop = *i; + SPStop *next_stop = *j; gfloat offset = 0.5*(this_stop->offset + next_stop->offset); SPObject *parent = this_stop->parent; if (SP_IS_GRADIENT (parent)) { doc = parent->document; SPStop *new_stop = sp_vector_add_stop (SP_GRADIENT (parent), this_stop, next_stop, offset); - new_stops = g_slist_prepend (new_stops, new_stop); + new_stops.push_back(new_stop); SP_GRADIENT(parent)->ensureVector(); } } - if (g_slist_length(these_stops) > 0 && doc) { + if (!these_stops.empty() && doc) { DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop")); drag->updateDraggers(); // so that it does not automatically update draggers in idle loop, as this would deselect drag->local_change = true; // select the newly created stops - for (GSList *s = new_stops; s != NULL; s = s->next) { - drag->selectByStop((SPStop *)s->data); + for (auto i:new_stops) { + drag->selectByStop(i); } - } - - g_slist_free (these_stops); - g_slist_free (next_stops); - g_slist_free (new_stops); } static double sqr(double x) {return x*x;} @@ -381,26 +376,25 @@ sp_gradient_simplify(GradientTool *rc, double tolerance) SPDocument *doc = NULL; GrDrag *drag = rc->_grdrag; - GSList *these_stops = NULL; - GSList *next_stops = NULL; + std::vector these_stops; + std::vector next_stops; - std::vector coords = sp_gradient_context_get_stop_intervals (drag, &these_stops, &next_stops); + std::vector coords = sp_gradient_context_get_stop_intervals (drag, these_stops, next_stops); - GSList *todel = NULL; + std::set todel; - GSList *i = these_stops; - GSList *j = next_stops; - for (; i != NULL && j != NULL; i = i->next, j = j->next) { - SPStop *stop0 = (SPStop *) i->data; - SPStop *stop1 = (SPStop *) j->data; + auto i = these_stops.begin(); + auto j = next_stops.end(); + for (; i != these_stops.end() && j != next_stops.end(); ++i, ++j) { + SPStop *stop0 = *i; + SPStop *stop1 = *j; - gint i1 = g_slist_index(these_stops, stop1); - if (i1 != -1) { - GSList *next_next = g_slist_nth (next_stops, i1); - if (next_next) { - SPStop *stop2 = (SPStop *) next_next->data; + auto i1 = std::find(these_stops.begin(), these_stops.end(), stop1); + if (i1 != these_stops.end()) { + if (next_stops.size()>(i1-these_stops.begin())) { + SPStop *stop2 = *(next_stops.begin() + (i1-these_stops.begin())); - if (g_slist_find(todel, stop0) || g_slist_find(todel, stop2)) + if (todel.find(stop0)!=todel.end() || todel.find(stop2) != todel.end()) continue; guint32 const c0 = stop0->get_rgba32(); @@ -416,28 +410,23 @@ sp_gradient_simplify(GradientTool *rc, double tolerance) sqr(SP_RGBA32_A_F(c1) - SP_RGBA32_A_F(c1r)); if (diff < tolerance) - todel = g_slist_prepend (todel, stop1); + todel.insert(stop1); } } } - for (i = todel; i != NULL; i = i->next) { - SPStop *stop = (SPStop*) i->data; + for (auto stop : todel) { doc = stop->document; Inkscape::XML::Node * parent = stop->getRepr()->parent(); parent->removeChild( stop->getRepr() ); } - if (g_slist_length(todel) > 0) { + if (!todel.empty()) { DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Simplify gradient")); drag->local_change = true; drag->updateDraggers(); drag->selectByCoords(coords); } - - g_slist_free (todel); - g_slist_free (these_stops); - g_slist_free (next_stops); } diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index d79741270..1ded5e146 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -170,68 +170,6 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { // FIXME // We need to update mesh gradient handles. // Get gradient this drag belongs too.. - // std::cout << "mesh_selection_changed: selection: objects: " << n_obj << std::endl; - // GSList *itemList = (GSList *) selection->itemList(); - // while( itemList ) { - - // SPItem *item = SP_ITEM( itemList->data ); - // // std::cout << " item: " << SP_OBJECT(item)->getId() << std::endl; - - // SPStyle *style = item->style; - // if (style && (style->fill.isPaintserver())) { - - // SPPaintServer *server = item->style->getFillPaintServer(); - // if ( SP_IS_MESHGRADIENT(server) ) { - - // SPMeshGradient *mg = SP_MESHGRADIENT(server); - - // guint rows = 0;//mg->array.patches.size(); - // for ( guint i = 0; i < rows; ++i ) { - // guint columns = 0;//mg->array.patches[0].size(); - // for ( guint j = 0; j < columns; ++j ) { - // } - // } - // } - // } - // itemList = itemList->next; - // } - - // GList* dragger_ptr = drag->draggers; // Points to GrDragger class (group of GrDraggable) - // guint count = 0; - // while( dragger_ptr ) { - - // std::cout << "mesh_selection_changed: dragger: " << ++count << std::endl; - // GSList* draggable_ptr = ((GrDragger *) dragger_ptr->data)->draggables; - - // while( draggable_ptr ) { - - // std::cout << "mesh_selection_changed: draggable: " << draggable_ptr << std::endl; - // GrDraggable *draggable = (GrDraggable *) draggable_ptr->data; - - // gint point_type = draggable->point_type; - // gint point_i = draggable->point_i; - // bool fill_or_stroke = draggable->fill_or_stroke; - - // if( point_type == POINT_MG_CORNER ) { - - // //std::cout << "mesh_selection_changed: POINT_MG_CORNER: " << point_i << std::endl; - // // Now we must create or destroy corresponding handles. - - // if( g_list_find( drag->selected, dragger_ptr->data ) ) { - // //std::cout << "gradient_selection_changed: Selected: " << point_i << std::endl; - // // Which meshes does this point belong to? - - // } else { - // //std::cout << "mesh_selection_changed: Not Selected: " << point_i << std::endl; - // } - // } - - // draggable_ptr = draggable_ptr->next; - - // } - - // dragger_ptr = dragger_ptr->next; - // } } void MeshTool::setup() { diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index dcd9413fb..fca96a483 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -374,23 +374,20 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } if (dynamic_cast(item) && !dynamic_cast(item)) { - GSList *children = NULL; + std::vector children; for (auto& child: item->children) { - if (dynamic_cast(static_cast(&child))) { - children = g_slist_prepend(children, &child); + if (dynamic_cast(&child)) { + children.push_back(dynamic_cast(&child)); } } - for (GSList *i = children; i; i = i->next) { - SPItem *child = dynamic_cast(static_cast(i->data)); + for (auto i = children.rbegin(); i!= children.rend(); ++i) { + SPItem *child = *i; g_assert(child != NULL); if (sp_tweak_dilate_recursive (selection, child, p, vector, mode, radius, force, fidelity, reverse)) { did = true; } } - - g_slist_free(children); - } else { if (mode == TWEAK_MODE_MOVE) { -- cgit v1.2.3 From a4a165df79514f34736282e699180cb8ae81c949 Mon Sep 17 00:00:00 2001 From: Andrey Mozzhuhin Date: Sun, 1 Oct 2017 18:13:05 +0300 Subject: Fix bug #1226962 - Keyboard shortcuts (hotkeys) not functional in some cases in non-latin keyboard layouts The key group with zero index can be a non-Latin layout. Try to determine Latin layout group index at runtime by checking available keymap entries for Latin 'a' keyval. --- src/ui/tools/tool-base.cpp | 39 ++++++++++++++++++++++++++++++++++++--- src/ui/tools/tool-base.h | 1 + 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 12c3a3675..58e4b32a9 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -71,6 +71,10 @@ static guint32 scroll_event_time = 0; static gdouble scroll_multiply = 1; static guint scroll_keyval = 0; +// globals for key processing +static bool latin_keys_group_valid = FALSE; +static gint latin_keys_group; + namespace Inkscape { namespace UI { @@ -1159,8 +1163,36 @@ void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, } /** - * Return the keyval corresponding to the key event in group 0, i.e., - * in the main (English) layout. + * Try to determine the keys group of Latin layout. + * Check available keymap entries for Latin 'a' key and find the minimal integer value. + */ +static void update_latin_keys_group() { + GdkKeymapKey* keys; + gint n_keys; + + latin_keys_group_valid = FALSE; + if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), GDK_KEY_a, &keys, &n_keys)) { + for (gint i = 0; i < n_keys; i++) { + if (!latin_keys_group_valid || keys[i].group < latin_keys_group) { + latin_keys_group = keys[i].group; + latin_keys_group_valid = TRUE; + } + } + g_free(keys); + } +} + +/** + * Initialize Latin keys group handling. + */ +void init_latin_keys_group() { + g_signal_connect(G_OBJECT(gdk_keymap_get_default()), + "keys-changed", G_CALLBACK(update_latin_keys_group), NULL); + update_latin_keys_group(); +} + +/** + * Return the keyval corresponding to the key event in Latin group. * * Use this instead of simply event->keyval, so that your keyboard shortcuts * work regardless of layouts (e.g., in Cyrillic). @@ -1168,10 +1200,11 @@ void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, guint get_group0_keyval(GdkEventKey const *event, guint *consumed_modifiers /*= NULL*/) { guint keyval = 0; GdkModifierType modifiers; + gint group = latin_keys_group_valid ? latin_keys_group : event->group; gdk_keymap_translate_keyboard_state( gdk_keymap_get_for_display(gdk_display_get_default()), - event->hardware_keycode, (GdkModifierType) event->state, 0 /*event->group*/, + event->hardware_keycode, (GdkModifierType) event->state, group, &keyval, NULL, NULL, &modifiers); if (consumed_modifiers) { diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 09a9db660..1a049abb3 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -251,6 +251,7 @@ gint gobble_motion_events(gint mask); void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEvent *event, gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip); +void init_latin_keys_group(); guint get_group0_keyval(GdkEventKey const *event, guint *consumed_modifiers = NULL); SPItem *sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p, bool select_under, bool into_groups); -- cgit v1.2.3 From 525c6c0c7ea39c6bdb0013c546d08b6e94e51e61 Mon Sep 17 00:00:00 2001 From: Andrey Mozzhuhin Date: Fri, 6 Oct 2017 00:46:14 +0300 Subject: Rename get_group0_keyval to get_latin_keyval --- src/ui/dialog-events.cpp | 2 +- src/ui/dialog/dialog.cpp | 2 +- src/ui/dialog/knot-properties.cpp | 2 +- src/ui/dialog/layer-properties.cpp | 2 +- src/ui/dialog/layers.cpp | 2 +- src/ui/dialog/lpe-powerstroke-properties.cpp | 2 +- src/ui/dialog/objects.cpp | 2 +- src/ui/dialog/tags.cpp | 2 +- src/ui/dialog/xml-tree.cpp | 2 +- src/ui/tool/control-point.cpp | 2 +- src/ui/tools/arc-tool.cpp | 2 +- src/ui/tools/box3d-tool.cpp | 2 +- src/ui/tools/calligraphic-tool.cpp | 4 ++-- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/dropper-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 4 ++-- src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/freehand-base.cpp | 2 +- src/ui/tools/gradient-tool.cpp | 12 ++++++------ src/ui/tools/lpe-tool.cpp | 4 ++-- src/ui/tools/mesh-tool.cpp | 12 ++++++------ src/ui/tools/node-tool.cpp | 2 +- src/ui/tools/pen-tool.cpp | 2 +- src/ui/tools/pencil-tool.cpp | 4 ++-- src/ui/tools/rect-tool.cpp | 4 ++-- src/ui/tools/select-tool.cpp | 24 ++++++++++++------------ src/ui/tools/spiral-tool.cpp | 4 ++-- src/ui/tools/spray-tool.cpp | 4 ++-- src/ui/tools/star-tool.cpp | 4 ++-- src/ui/tools/text-tool.cpp | 10 +++++----- src/ui/tools/tool-base.cpp | 16 ++++++++-------- src/ui/tools/tool-base.h | 2 +- src/ui/tools/tweak-tool.cpp | 4 ++-- src/ui/tools/zoom-tool.cpp | 4 ++-- src/ui/widget/spinbutton.cpp | 2 +- 35 files changed, 77 insertions(+), 77 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog-events.cpp b/src/ui/dialog-events.cpp index d7d56fa50..cf11490f3 100644 --- a/src/ui/dialog-events.cpp +++ b/src/ui/dialog-events.cpp @@ -100,7 +100,7 @@ sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data) case GDK_KEY_PRESS: - switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) { + switch (Inkscape::UI::Tools::get_latin_keyval (&event->key)) { case GDK_KEY_Escape: sp_dialog_defocus (win); ret = TRUE; diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 9037e8377..e50824c7b 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -257,7 +257,7 @@ bool Dialog::_onEvent(GdkEvent *event) switch (event->type) { case GDK_KEY_PRESS: { - switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) { + switch (Inkscape::UI::Tools::get_latin_keyval (&event->key)) { case GDK_KEY_Escape: { _defocus(); ret = true; diff --git a/src/ui/dialog/knot-properties.cpp b/src/ui/dialog/knot-properties.cpp index b094dc0e7..29e1cb2bb 100644 --- a/src/ui/dialog/knot-properties.cpp +++ b/src/ui/dialog/knot-properties.cpp @@ -151,7 +151,7 @@ KnotPropertiesDialog::_close() bool KnotPropertiesDialog::_handleKeyEvent(GdkEventKey * /*event*/) { - /*switch (get_group0_keyval(event)) { + /*switch (get_latin_keyval(event)) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: { _apply(); diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 562484022..4ab6e130e 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -290,7 +290,7 @@ SPObject* LayerPropertiesDialog::_selectedLayer() bool LayerPropertiesDialog::_handleKeyEvent(GdkEventKey *event) { - switch (Inkscape::UI::Tools::get_group0_keyval(event)) { + switch (Inkscape::UI::Tools::get_latin_keyval(event)) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: { _strategy->perform(*this); diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 4a381a565..6223bd627 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -542,7 +542,7 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol ) bool LayersPanel::_handleKeyEvent(GdkEventKey *event) { - switch (Inkscape::UI::Tools::get_group0_keyval(event)) { + switch (Inkscape::UI::Tools::get_latin_keyval(event)) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: case GDK_KEY_F2: { diff --git a/src/ui/dialog/lpe-powerstroke-properties.cpp b/src/ui/dialog/lpe-powerstroke-properties.cpp index 9bd98c7c0..e66229dcd 100644 --- a/src/ui/dialog/lpe-powerstroke-properties.cpp +++ b/src/ui/dialog/lpe-powerstroke-properties.cpp @@ -146,7 +146,7 @@ PowerstrokePropertiesDialog::_close() bool PowerstrokePropertiesDialog::_handleKeyEvent(GdkEventKey * /*event*/) { - /*switch (get_group0_keyval(event)) { + /*switch (get_latin_keyval(event)) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: { _apply(); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 1e0ab9604..49ffa38f5 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -735,7 +735,7 @@ bool ObjectsPanel::_handleKeyEvent(GdkEventKey *event) // handle events for the treeview bool empty = _desktop->selection->isEmpty(); - switch (Inkscape::UI::Tools::get_group0_keyval(event)) { + switch (Inkscape::UI::Tools::get_latin_keyval(event)) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: { diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 5a5417eb5..d804e1f68 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -522,7 +522,7 @@ void TagsPanel::_checkTreeSelection() bool TagsPanel::_handleKeyEvent(GdkEventKey *event) { - switch (Inkscape::UI::Tools::get_group0_keyval(event)) { + switch (Inkscape::UI::Tools::get_latin_keyval(event)) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: case GDK_KEY_F2: { diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 83c0de45b..c245890bc 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -856,7 +856,7 @@ void XmlTree::on_document_uri_set(gchar const * /*uri*/, SPDocument * /*document gboolean XmlTree::quit_on_esc (GtkWidget *w, GdkEventKey *event, GObject */*tbl*/) { - switch (Inkscape::UI::Tools::get_group0_keyval (event)) { + switch (Inkscape::UI::Tools::get_latin_keyval (event)) { case GDK_KEY_Escape: // defocus gtk_widget_destroy(w); return TRUE; diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index d9374c790..8ab9fcbd7 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -380,7 +380,7 @@ bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, G // update tips on modifier state change // TODO add ESC keybinding as drag cancel case GDK_KEY_PRESS: - switch (Inkscape::UI::Tools::get_group0_keyval(&event->key)) + switch (Inkscape::UI::Tools::get_latin_keyval(&event->key)) { case GDK_KEY_Escape: { // ignore Escape if this is not a drag diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index a670f577e..33f323eb3 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -227,7 +227,7 @@ bool ArcTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 69555d6c9..09ee2cda9 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -335,7 +335,7 @@ bool Box3dTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_KP_Up: diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index ca94ac75f..2a29b25b0 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -777,7 +777,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) { } case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY(event)) { @@ -858,7 +858,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) { break; case GDK_KEY_RELEASE: - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: this->message_context->clear(); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 59d670d74..b9d36706f 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -434,7 +434,7 @@ bool ConnectorTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - ret = this->_handleKeyPress(get_group0_keyval (&event->key)); + ret = this->_handleKeyPress(get_latin_keyval (&event->key)); break; default: diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 53a99e481..7bde1b698 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -345,7 +345,7 @@ bool DropperTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_KP_Up: diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 83039be18..7892e865b 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -492,7 +492,7 @@ bool EraserTool::root_handler(GdkEvent* event) { } case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { // case GDK_KEY_Up: // case GDK_KEY_KP_Up: // if (!MOD__CTRL_ONLY(event)) { @@ -596,7 +596,7 @@ bool EraserTool::root_handler(GdkEvent* event) { break; case GDK_KEY_RELEASE: - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: this->message_context->clear(); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index daeff228c..401b50c1c 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -1189,7 +1189,7 @@ bool FloodTool::root_handler(GdkEvent* event) { } break; case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_KP_Up: diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index a85c89400..328dc0220 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -168,7 +168,7 @@ bool FreehandBase::root_handler(GdkEvent* event) { switch (event->type) { case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_KP_Up: diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 966183b1a..1735a78df 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -665,7 +665,7 @@ bool GradientTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: @@ -719,7 +719,7 @@ bool GradientTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_4: if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { drag->selected_move_screen(mul*-10, 0); // shift @@ -742,7 +742,7 @@ bool GradientTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_8: if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { drag->selected_move_screen(0, mul*10); // shift @@ -766,7 +766,7 @@ bool GradientTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_6: if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -791,7 +791,7 @@ bool GradientTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_2: if (!MOD__CTRL(event)) { // not ctrl gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -848,7 +848,7 @@ bool GradientTool::root_handler(GdkEvent* event) { break; case GDK_KEY_RELEASE: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 35e6d14a0..ad3964f4a 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -225,14 +225,14 @@ bool LpeTool::root_handler(GdkEvent* event) { case GDK_KEY_PRESS: /** - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { } break; **/ case GDK_KEY_RELEASE: /** - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_Control_L: case GDK_Control_R: dc->_message_context->clear(); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 1ded5e146..fdfae84df 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -825,7 +825,7 @@ bool MeshTool::root_handler(GdkEvent* event) { #endif // FIXME: tip - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: @@ -864,7 +864,7 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Left: case GDK_KEY_KP_4: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -888,7 +888,7 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Up: case GDK_KEY_KP_8: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -912,7 +912,7 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Right: case GDK_KEY_KP_6: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -936,7 +936,7 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Down: case GDK_KEY_KP_2: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -1034,7 +1034,7 @@ bool MeshTool::root_handler(GdkEvent* event) { #ifdef DEBUG_MESH std::cout << "sp_mesh_context_root_handler: GDK_KEY_RELEASE" << std::endl; #endif - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index e7825e302..2b3de5203 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -550,7 +550,7 @@ bool NodeTool::root_handler(GdkEvent* event) { // otherwise some features cease to work case GDK_KEY_PRESS: - switch (get_group0_keyval(&event->key)) + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Escape: // deselect everything if (this->_selected_nodes->empty()) { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index f8dfd7a10..04e2ca7c2 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1062,7 +1062,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { } } - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Left: // move last point left case GDK_KEY_KP_Left: if (!MOD__CTRL(event)) { // not ctrl diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 61799b306..f25c1d673 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -455,7 +455,7 @@ void PencilTool::_cancel() { bool PencilTool::_handleKeyPress(GdkEventKey const &event) { bool ret = false; - switch (get_group0_keyval(&event)) { + switch (get_latin_keyval(&event)) { case GDK_KEY_Up: case GDK_KEY_Down: case GDK_KEY_KP_Up: @@ -508,7 +508,7 @@ bool PencilTool::_handleKeyPress(GdkEventKey const &event) { bool PencilTool::_handleKeyRelease(GdkEventKey const &event) { bool ret = false; - switch (get_group0_keyval(&event)) { + switch (get_latin_keyval(&event)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Meta_L: diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 91725a00b..655650ef4 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -258,7 +258,7 @@ bool RectTool::root_handler(GdkEvent* event) { } break; case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: @@ -326,7 +326,7 @@ bool RectTool::root_handler(GdkEvent* event) { } break; case GDK_KEY_RELEASE: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index fca2173ca..3dfb764bb 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -344,18 +344,18 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) { break; case GDK_KEY_PRESS: - if (get_group0_keyval (&event->key) == GDK_KEY_space) { + if (get_latin_keyval (&event->key) == GDK_KEY_space) { if (this->dragging && this->grabbed) { /* stamping mode: show content mode moving */ _seltrans->stamp(); ret = TRUE; } - } else if (get_group0_keyval (&event->key) == GDK_KEY_Tab) { + } else if (get_latin_keyval (&event->key) == GDK_KEY_Tab) { if (this->dragging && this->grabbed) { _seltrans->getNextClosestPoint(false); ret = TRUE; } - } else if (get_group0_keyval (&event->key) == GDK_KEY_ISO_Left_Tab) { + } else if (get_latin_keyval (&event->key) == GDK_KEY_ISO_Left_Tab) { if (this->dragging && this->grabbed) { _seltrans->getNextClosestPoint(true); ret = TRUE; @@ -854,7 +854,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_PRESS: // keybindings for select context { { - guint keyval = get_group0_keyval(&event->key); + guint keyval = get_latin_keyval(&event->key); bool alt = ( MOD__ALT(event) || (keyval == GDK_KEY_Alt_L) @@ -896,11 +896,11 @@ bool SelectTool::root_handler(GdkEvent* event) { gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000, "px"); int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Left: // move selection left case GDK_KEY_KP_Left: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events( get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -923,7 +923,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_Up: // move selection up case GDK_KEY_KP_Up: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -946,7 +946,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_Right: // move selection right case GDK_KEY_KP_Right: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -969,7 +969,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_Down: // move selection down case GDK_KEY_KP_Down: if (!MOD__CTRL(event)) { // not ctrl - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { @@ -1024,7 +1024,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_bracketleft: if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask selection->rotateScreen(mul*1); } else if (MOD__CTRL(event)) { selection->rotate(90); @@ -1037,7 +1037,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_bracketright: if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask + gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask selection->rotateScreen(-1*mul); } else if (MOD__CTRL(event)) { selection->rotate(-90); @@ -1097,7 +1097,7 @@ bool SelectTool::root_handler(GdkEvent* event) { break; } case GDK_KEY_RELEASE: { - guint keyval = get_group0_keyval(&event->key); + guint keyval = get_latin_keyval(&event->key); if (key_is_a_modifier (keyval)) { this->defaultMessageContext()->clear(); } diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 9240df760..bb8ce6356 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -232,7 +232,7 @@ bool SpiralTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Alt_R: case GDK_KEY_Control_L: case GDK_KEY_Control_R: @@ -291,7 +291,7 @@ bool SpiralTool::root_handler(GdkEvent* event) { break; case GDK_KEY_RELEASE: - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index eec7babc4..5593ceb34 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -1375,7 +1375,7 @@ bool SprayTool::root_handler(GdkEvent* event) { } case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_j: case GDK_KEY_J: if (MOD__SHIFT_ONLY(event)) { @@ -1487,7 +1487,7 @@ bool SprayTool::root_handler(GdkEvent* event) { case GDK_KEY_RELEASE: { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: this->update_cursor(false); diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index cda3389f9..ed25503c4 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -246,7 +246,7 @@ bool StarTool::root_handler(GdkEvent* event) { break; case GDK_KEY_PRESS: - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Alt_R: case GDK_KEY_Control_L: case GDK_KEY_Control_R: @@ -306,7 +306,7 @@ bool StarTool::root_handler(GdkEvent* event) { break; case GDK_KEY_RELEASE: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Alt_L: case GDK_KEY_Alt_R: case GDK_KEY_Control_L: diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 91d94cc22..692b65c44 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -653,7 +653,7 @@ bool TextTool::root_handler(GdkEvent* event) { } break; case GDK_KEY_PRESS: { - guint const group0_keyval = get_group0_keyval(&event->key); + guint const group0_keyval = get_latin_keyval(&event->key); if (group0_keyval == GDK_KEY_KP_Add || group0_keyval == GDK_KEY_KP_Subtract) { @@ -961,7 +961,7 @@ bool TextTool::root_handler(GdkEvent* event) { if (this->text) { if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(mul*-10, 0)); else @@ -985,7 +985,7 @@ bool TextTool::root_handler(GdkEvent* event) { if (this->text) { if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(mul*10, 0)); else @@ -1009,7 +1009,7 @@ bool TextTool::root_handler(GdkEvent* event) { if (this->text) { if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(0, mul*-10)); else @@ -1033,7 +1033,7 @@ bool TextTool::root_handler(GdkEvent* event) { if (this->text) { if (MOD__ALT(event)) { gint mul = 1 + gobble_key_events( - get_group0_keyval(&event->key), 0); // with any mask + get_latin_keyval(&event->key), 0); // with any mask if (MOD__SHIFT(event)) sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(0, mul*10)); else diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 58e4b32a9..7b4f67da9 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -602,7 +602,7 @@ bool ToolBase::root_handler(GdkEvent* event) { int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000); - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets // in the editing window). So we resteal them back and run our regular shortcut // invoker on them. @@ -642,7 +642,7 @@ bool ToolBase::root_handler(GdkEvent* event) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, desktop->getCanvas())); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(i, 0)); ret = TRUE; } else { @@ -657,7 +657,7 @@ bool ToolBase::root_handler(GdkEvent* event) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, desktop->getCanvas())); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(0, i)); ret = TRUE; } else { @@ -672,7 +672,7 @@ bool ToolBase::root_handler(GdkEvent* event) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, desktop->getCanvas())); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(-i, 0)); ret = TRUE; } else { @@ -687,7 +687,7 @@ bool ToolBase::root_handler(GdkEvent* event) { int i = (int) floor(key_scroll * accelerate_scroll(event, acceleration, desktop->getCanvas())); - gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); + gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(0, -i)); ret = TRUE; } else { @@ -756,7 +756,7 @@ bool ToolBase::root_handler(GdkEvent* event) { gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); } - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_space: if (within_tolerance) { // Space was pressed, but not panned @@ -1142,7 +1142,7 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event) void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEvent *event, gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip) { - guint keyval = get_group0_keyval(&event->key); + guint keyval = get_latin_keyval(&event->key); bool ctrl = ctrl_tip && (MOD__CTRL(event) || (keyval == GDK_KEY_Control_L) || (keyval == GDK_KEY_Control_R)); @@ -1197,7 +1197,7 @@ void init_latin_keys_group() { * Use this instead of simply event->keyval, so that your keyboard shortcuts * work regardless of layouts (e.g., in Cyrillic). */ -guint get_group0_keyval(GdkEventKey const *event, guint *consumed_modifiers /*= NULL*/) { +guint get_latin_keyval(GdkEventKey const *event, guint *consumed_modifiers /*= NULL*/) { guint keyval = 0; GdkModifierType modifiers; gint group = latin_keys_group_valid ? latin_keys_group : event->group; diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 1a049abb3..7185b787e 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -252,7 +252,7 @@ void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEv gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip); void init_latin_keys_group(); -guint get_group0_keyval(GdkEventKey const *event, guint *consumed_modifiers = NULL); +guint get_latin_keyval(GdkEventKey const *event, guint *consumed_modifiers = NULL); SPItem *sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p, bool select_under, bool into_groups); SPItem *sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index fca96a483..9348ef842 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1284,7 +1284,7 @@ bool TweakTool::root_handler(GdkEvent* event) { } case GDK_KEY_PRESS: { - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_m: case GDK_KEY_M: case GDK_KEY_0: @@ -1479,7 +1479,7 @@ bool TweakTool::root_handler(GdkEvent* event) { } case GDK_KEY_RELEASE: { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - switch (get_group0_keyval(&event->key)) { + switch (get_latin_keyval(&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: this->update_cursor(false); diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index 8ba0c17b3..6f7fca242 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -168,7 +168,7 @@ bool ZoomTool::root_handler(GdkEvent* event) { break; } case GDK_KEY_PRESS: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Escape: if (!Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::SelectionHelper::selectNone(desktop); @@ -206,7 +206,7 @@ bool ZoomTool::root_handler(GdkEvent* event) { } break; case GDK_KEY_RELEASE: - switch (get_group0_keyval (&event->key)) { + switch (get_latin_keyval (&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: this->cursor_shape = cursor_zoom_xpm; diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index d1776e630..0c082d3ce 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -71,7 +71,7 @@ bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) bool SpinButton::on_my_key_press_event(GdkEventKey* event) { - switch (Inkscape::UI::Tools::get_group0_keyval (event)) { + switch (Inkscape::UI::Tools::get_latin_keyval (event)) { case GDK_KEY_Escape: undo(); return true; // I consumed the event -- cgit v1.2.3 From 5433ac0513099a4a12caba0cda8a2a9d30e13a22 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Fri, 13 Oct 2017 19:03:28 +0200 Subject: Remove deprecated GNOME VFS Just use Gio::File when access to non-local files is needed. --- src/ui/dialog/export.cpp | 10 +------ src/ui/dialog/filedialogimpl-gtkmm.cpp | 50 +++++++++++----------------------- 2 files changed, 17 insertions(+), 43 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 56f3a29c0..d878b50a4 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -27,10 +27,6 @@ #include #include -#ifdef WITH_GNOME_VFS -# include // gnome_vfs_initialized -#endif - #include #include @@ -1300,11 +1296,7 @@ void Export::onBrowse () _("_Save"), GTK_RESPONSE_ACCEPT, NULL ); -#ifdef WITH_GNOME_VFS - if (gnome_vfs_initialized()) { - gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(fs), false); - } -#endif + gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(fs), false); sp_transientize (fs); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index b69e9ce97..64f6c98c6 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -31,10 +31,6 @@ #include "path-prefix.h" #include "preferences.h" -#ifdef WITH_GNOME_VFS -#include -#endif - #include #include @@ -663,11 +659,9 @@ void FileDialogBaseGtk::_updatePreviewCallback() Glib::ustring fileName = get_preview_filename(); bool enabled = previewCheckbox.get_active(); -#ifdef WITH_GNOME_VFS - if (fileName.empty() && gnome_vfs_initialized()) { + if (fileName.empty()) { fileName = get_preview_uri(); } -#endif if (enabled && !fileName.empty()) { svgPreview.set(fileName, _dialogType); @@ -698,11 +692,7 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window &parentWindow, const Gl set_select_multiple(true); } -#ifdef WITH_GNOME_VFS - if (gnome_vfs_initialized()) { - set_local_only(false); - } -#endif + set_local_only(false); /* Initalize to Autodetect */ extension = NULL; @@ -883,10 +873,11 @@ bool FileOpenDialogImplGtk::show() extension = extensionMap[gtk_file_filter_get_name(filter)]; } myFilename = get_filename(); -#ifdef WITH_GNOME_VFS - if (myFilename.empty() && gnome_vfs_initialized()) + + if (myFilename.empty()) { myFilename = get_uri(); -#endif + } + cleanup(true); return true; } else { @@ -928,10 +919,10 @@ std::vector FileOpenDialogImplGtk::getFilenames() for (auto it : result_tmp) result.push_back(it); -#ifdef WITH_GNOME_VFS - if (result.empty() && gnome_vfs_initialized()) + if (result.empty()) { result = get_uris(); -#endif + } + return result; } @@ -963,11 +954,7 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl /* One file at a time */ set_select_multiple(false); -#ifdef WITH_GNOME_VFS - if (gnome_vfs_initialized()) { - set_local_only(false); - } -#endif + set_local_only(false); /* Initalize to Autodetect */ extension = NULL; @@ -1310,11 +1297,11 @@ void FileSaveDialogImplGtk::updateNameAndExtension() { // Pick up any changes the user has typed in. Glib::ustring tmp = get_filename(); -#ifdef WITH_GNOME_VFS - if (tmp.empty() && gnome_vfs_initialized()) { + + if (tmp.empty()) { tmp = get_uri(); } -#endif + if (!tmp.empty()) { myFilename = tmp; } @@ -1449,11 +1436,7 @@ FileExportDialogImpl::FileExportDialogImpl(Gtk::Window &parentWindow, const Glib /* One file at a time */ set_select_multiple(false); -#ifdef WITH_GNOME_VFS - if (gnome_vfs_initialized()) { - set_local_only(false); - } -#endif + set_local_only(false); /* Initalize to Autodetect */ extension = NULL; @@ -1634,11 +1617,10 @@ bool FileExportDialogImpl::show() extension = type.extension; } myFilename = get_filename(); -#ifdef WITH_GNOME_VFS - if (myFilename.empty() && gnome_vfs_initialized()) { + + if (myFilename.empty()) { myFilename = get_uri(); } -#endif /* -- cgit v1.2.3 From c943a6db760a6c5eb8110179c240e8f7bd021ac5 Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Mon, 16 Oct 2017 13:00:24 +0200 Subject: Remove std::auto_ptr As C++11-compiler is now mandatory, conditional use of auto_ptr is no longer usefull. This commit does not remove the usage of std::auto_ptr in 2geom. --- src/ui/control-manager.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/control-manager.h b/src/ui/control-manager.h index 3f090d0bd..418591991 100644 --- a/src/ui/control-manager.h +++ b/src/ui/control-manager.h @@ -76,11 +76,7 @@ public: private: ControlManager(); -#if __cplusplus <= 199711L - std::auto_ptr _impl; -#else std::unique_ptr _impl; -#endif friend class ControlManagerImpl; }; -- cgit v1.2.3 From 8ef37560aeca3d38db6603ca573929b19ea90105 Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Mon, 16 Oct 2017 13:28:28 +0200 Subject: Replace boost::scoped_ptr This replaces all usage of boost::scoped_ptr with std::unique_ptr. Also removes the corresponding includes. --- src/ui/dialog/icon-preview.cpp | 1 - src/ui/dialog/objects.h | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 991139aa8..f9cd8929a 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -18,7 +18,6 @@ #endif #include -#include #include #include diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h index b7fd1b4f8..8ad1b15ef 100644 --- a/src/ui/dialog/objects.h +++ b/src/ui/dialog/objects.h @@ -16,7 +16,6 @@ # include #endif -#include #include #include #include @@ -168,7 +167,7 @@ private: Gtk::Box _blur_vbox; Gtk::Dialog _colorSelectorDialog; - boost::scoped_ptr _selectedColor; + std::unique_ptr _selectedColor; //Methods: -- cgit v1.2.3 From e1cb749aab3c773073b1adde1b4cd07b2a6ce93e Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Tue, 17 Oct 2017 08:31:32 +0200 Subject: Replace boost::shared_ptr Replace boost::shared_ptr with C++11 smartpointer and remove the boost/shared_ptr.hpp header. --- src/ui/tool/manipulator.h | 7 +++---- src/ui/tool/multi-path-manipulator.cpp | 5 ++--- src/ui/tool/multi-path-manipulator.h | 8 ++++---- src/ui/tool/node.h | 8 +++----- src/ui/tool/path-manipulator.h | 4 +--- 5 files changed, 13 insertions(+), 19 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/manipulator.h b/src/ui/tool/manipulator.h index 0f26c6de1..66b47ce98 100644 --- a/src/ui/tool/manipulator.h +++ b/src/ui/tool/manipulator.h @@ -17,7 +17,6 @@ #include #include #include -#include #include "ui/tools/tool-base.h" class SPDesktop; @@ -76,14 +75,14 @@ template class MultiManipulator : public PointManipulator { public: //typedef typename T::ItemType ItemType; - typedef typename std::pair > MapPair; - typedef typename std::map > MapType; + typedef typename std::pair > MapPair; + typedef typename std::map > MapType; MultiManipulator(SPDesktop *d, ControlPointSelection &sel) : PointManipulator(d, sel) {} void addItem(void *item) { - boost::shared_ptr m(_createManipulator(item)); + std::shared_ptr m(_createManipulator(item)); _mmap.insert(MapPair(item, m)); } void removeItem(void *item) { diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index f30c7e349..9cfa4ed31 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -10,7 +10,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include "node.h" #include #include "desktop.h" @@ -161,7 +160,7 @@ void MultiPathManipulator::setItems(std::set const &s) if (sr.edit_transform != sr_new.edit_transform || sr.role != sr_new.role) { - boost::shared_ptr hold(i->second); + std::shared_ptr hold(i->second); if (sr.edit_transform != sr_new.edit_transform) hold->setControlsTransform(sr_new.edit_transform); if (sr.role != sr_new.role) { @@ -179,7 +178,7 @@ void MultiPathManipulator::setItems(std::set const &s) for (std::set::iterator i = shapes.begin(); i != shapes.end(); ++i) { ShapeRecord const &r = *i; if (!SP_IS_PATH(r.item) && !IS_LIVEPATHEFFECT(r.item)) continue; - boost::shared_ptr newpm(new PathManipulator(*this, (SPPath*) r.item, + std::shared_ptr newpm(new PathManipulator(*this, (SPPath*) r.item, r.edit_transform, _getOutlineColor(r.role, r.item), r.lpe_key)); newpm->showHandles(_show_handles); // always show outlines for clips and masks diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h index 4f152e0a2..742c6d421 100644 --- a/src/ui/tool/multi-path-manipulator.h +++ b/src/ui/tool/multi-path-manipulator.h @@ -77,8 +77,8 @@ public: sigc::signal signal_coords_changed; /// Emitted whenever the coordinates /// shown in the status bar need updating private: - typedef std::pair > MapPair; - typedef std::map > MapType; + typedef std::pair > MapPair; + typedef std::map > MapType; template void invokeForAll(R (PathManipulator::*method)()) { @@ -88,11 +88,11 @@ private: // be a valid iterator and then assign i to it. MapType::iterator next_i = i; ++next_i; - // i->second is a boost::shared_ptr so try to hold on to it so + // i->second is a std::shared_ptr so try to hold on to it so // it won't get freed prematurely by the WriteXML() method or // whatever. See https://bugs.launchpad.net/inkscape/+bug/1617615 // Applicable to empty paths. - boost::shared_ptr hold(i->second); + std::shared_ptr hold(i->second); ((hold.get())->*method)(); i = next_i; } diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index a05f0e3b9..2964b66ca 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -22,8 +22,6 @@ #include #include -#include -#include #include "ui/tool/selectable-control-point.h" #include "snapped-point.h" #include "ui/tool/node-types.h" @@ -357,7 +355,7 @@ private: friend class NodeList; }; -class NodeList : ListNode, boost::noncopyable, public boost::enable_shared_from_this { +class NodeList : ListNode, boost::noncopyable { public: typedef std::size_t size_type; typedef Node &reference; @@ -465,9 +463,9 @@ private: * List of node lists. Represents an editable path. * Editable path composed of one or more subpaths. */ -class SubpathList : public std::list< boost::shared_ptr > { +class SubpathList : public std::list< std::shared_ptr > { public: - typedef std::list< boost::shared_ptr > list_type; + typedef std::list< std::shared_ptr > list_type; SubpathList(PathManipulator &pm) : _path_manipulator(pm) {} PathManipulator &pm() { return _path_manipulator; } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 283cb610a..5fa24c23b 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -15,8 +15,6 @@ #include #include <2geom/pathvector.h> #include <2geom/affine.h> -#include -#include #include "ui/tool/node.h" #include "ui/tool/manipulator.h" #include "live_effects/lpe-bspline.h" @@ -105,7 +103,7 @@ public: static bool is_item_type(void *item); private: typedef NodeList Subpath; - typedef boost::shared_ptr SubpathPtr; + typedef std::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); -- cgit v1.2.3 From 41b862f1c4eaea48bdd0d546e2bb31907f15857b Mon Sep 17 00:00:00 2001 From: Jan Lingscheid Date: Wed, 18 Oct 2017 16:03:34 +0200 Subject: Refactor Util::ptr_shared Util::ptr_shared was only used in its specialization, so it is now refactored into a non-template class. Using it with arbitary classes was dangerous anyway. --- src/ui/dialog/objects.cpp | 4 ++-- src/ui/dialog/styledialog.cpp | 12 ++++++------ src/ui/dialog/tags.cpp | 4 ++-- src/ui/tool/path-manipulator.cpp | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 49ffa38f5..b50d68239 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -148,8 +148,8 @@ public: _pnl->_objectsChanged( _obj ); } } - virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {} - virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) { + virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {} + virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) { if ( _pnl && _obj ) { if ( name == _lockedAttr || name == _labelAttr || name == _highlightAttr || name == _groupAttr || name == _styleAttr || name == _clipAttr || name == _maskAttr ) { _pnl->_updateObject(_obj, name == _highlightAttr); diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index aa453e8e8..60138fa89 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -56,8 +56,8 @@ public: }; virtual void notifyContentChanged(Inkscape::XML::Node &node, - Inkscape::Util::ptr_shared old_content, - Inkscape::Util::ptr_shared new_content); + Inkscape::Util::ptr_shared old_content, + Inkscape::Util::ptr_shared new_content); StyleDialog * _styleDialog; }; @@ -66,8 +66,8 @@ public: void StyleDialog::NodeObserver::notifyContentChanged( Inkscape::XML::Node &/*node*/, - Inkscape::Util::ptr_shared /*old_content*/, - Inkscape::Util::ptr_shared /*new_content*/ ) { + Inkscape::Util::ptr_shared /*old_content*/, + Inkscape::Util::ptr_shared /*new_content*/ ) { #ifdef DEBUG_STYLEDIALOG std::cout << "StyleDialog::NodeObserver::notifyContentChanged" << std::endl; @@ -111,8 +111,8 @@ public: virtual void notifyAttributeChanged( Inkscape::XML::Node &node, GQuark qname, - Util::ptr_shared /*old_value*/, - Util::ptr_shared /*new_value*/ ) { + Util::ptr_shared /*old_value*/, + Util::ptr_shared /*new_value*/ ) { if ( _styleDialog && _repr ) { // For the moment only care about attributes that are directly used in selectors. diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index d804e1f68..ae45654a7 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -106,8 +106,8 @@ public: _pnl->_objectsChanged( _obj ); } } - virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {} - virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) { + virtual void notifyContentChanged( Node &/*node*/, Util::ptr_shared /*old_content*/, Util::ptr_shared /*new_content*/ ) {} + virtual void notifyAttributeChanged( Node &/*node*/, GQuark name, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) { if ( _pnl && _obj ) { if ( name == _labelAttr ) { _pnl->_updateObject( _obj); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index f2899dd01..2c99e7fc8 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -68,7 +68,7 @@ public: } virtual void notifyAttributeChanged(Inkscape::XML::Node &/*node*/, GQuark attr, - Util::ptr_shared, Util::ptr_shared) + Util::ptr_shared, Util::ptr_shared) { // do nothing if blocked if (_blocked) return; -- cgit v1.2.3 From 846fc829ce4ab4487a8b6836083d7cc72db16463 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sat, 14 Oct 2017 11:50:10 +0200 Subject: Use standard glib macro instead of a custom one --- src/ui/interface.cpp | 3 +-- src/ui/widget/selected-style.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ui') diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index f6a353b33..4f1e5cd6f 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -110,8 +110,7 @@ static GtkTargetEntry *completeDropTargets = 0; static int completeDropTargetsCount = 0; static bool temporarily_block_actions = false; -#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0]) -static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries); +static guint nui_drop_target_entries = G_N_ELEMENTS(ui_drop_target_entries); static void sp_ui_import_files(gchar *buffer); static void sp_ui_import_one_file(char const *filename); static void sp_ui_import_one_file_with_check(gpointer filename, gpointer unused); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 5d911e9d2..d9b93f6db 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -107,8 +107,7 @@ static const GtkTargetEntry ui_drop_target_entries [] = { {"application/x-color", 0, APP_X_COLOR} }; -#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0]) -static guint nui_drop_target_entries = ENTRIES_SIZE(ui_drop_target_entries); +static guint nui_drop_target_entries = G_N_ELEMENTS(ui_drop_target_entries); /* convenience function */ static Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop); -- cgit v1.2.3 From 4636481acc66c8ac24aff6642257d09e562eedb5 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Mon, 16 Oct 2017 00:41:54 +0200 Subject: Remove unused util/accumulators.h --- src/ui/tool/control-point-selection.h | 1 - src/ui/tool/control-point.h | 12 ------------ 2 files changed, 13 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h index f122a468d..ec845b1b3 100644 --- a/src/ui/tool/control-point-selection.h +++ b/src/ui/tool/control-point-selection.h @@ -20,7 +20,6 @@ #include <2geom/forward.h> #include <2geom/point.h> #include <2geom/rect.h> -#include "util/accumulators.h" #include "util/unordered-containers.h" #include "ui/tool/commit-events.h" #include "ui/tool/manipulator.h" diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h index 4a01b9f21..bc1f060cd 100644 --- a/src/ui/tool/control-point.h +++ b/src/ui/tool/control-point.h @@ -18,7 +18,6 @@ #include <2geom/point.h> #include "ui/control-types.h" -#include "util/accumulators.h" #include "display/sodipodi-ctrl.h" #include "enums.h" @@ -76,8 +75,6 @@ namespace UI { */ class ControlPoint : boost::noncopyable, public sigc::trackable { public: - typedef Inkscape::Util::ReverseInterruptible RInt; - typedef Inkscape::Util::Interruptible Int; /** * Enumeration representing the possible states of the control point, used to determine @@ -162,15 +159,6 @@ public: void transferGrab(ControlPoint *from, GdkEventMotion *event); /// @} - /// @name Receive notifications about control point events - /// @{ - /*sigc::signal signal_dragged; - sigc::signal::accumulated signal_clicked; - sigc::signal::accumulated signal_doubleclicked; - sigc::signal::accumulated signal_grabbed; - sigc::signal signal_ungrabbed;*/ - /// @} - /// @name Inspect the state of the control point /// @{ State state() const { return _state; } -- cgit v1.2.3 From 347e5f3b12400d94812eefc275e1197ed224470b Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Tue, 17 Oct 2017 22:22:10 +0200 Subject: Remove unused icon-size.h --- src/ui/widget/panel.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 9332fe0f9..aea9b7e8e 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -24,7 +24,6 @@ #include #include "panel.h" -#include "icon-size.h" #include "preferences.h" #include "desktop.h" -- cgit v1.2.3 From 935c7b7808cb7c0e2d9952fda8962359d63781a2 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Tue, 17 Oct 2017 22:27:43 +0200 Subject: Remove all unused makefile.in --- src/ui/cache/makefile.in | 17 ----------------- src/ui/dialog/makefile.in | 17 ----------------- src/ui/makefile.in | 17 ----------------- src/ui/view/makefile.in | 17 ----------------- src/ui/widget/makefile.in | 17 ----------------- 5 files changed, 85 deletions(-) delete mode 100644 src/ui/cache/makefile.in delete mode 100644 src/ui/dialog/makefile.in delete mode 100644 src/ui/makefile.in delete mode 100644 src/ui/view/makefile.in delete mode 100644 src/ui/widget/makefile.in (limited to 'src/ui') diff --git a/src/ui/cache/makefile.in b/src/ui/cache/makefile.in deleted file mode 100644 index af45adb0f..000000000 --- a/src/ui/cache/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd ../.. && $(MAKE) ui/cache/all - -clean %.a %.$(OBJEXT): - cd ../.. && $(MAKE) ui/cache/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/ui/dialog/makefile.in b/src/ui/dialog/makefile.in deleted file mode 100644 index 805c48aef..000000000 --- a/src/ui/dialog/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd ../.. && $(MAKE) ui/dialog/all - -clean %.a %.$(OBJEXT): - cd ../.. && $(MAKE) ui/dialog/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/ui/makefile.in b/src/ui/makefile.in deleted file mode 100644 index f8a407592..000000000 --- a/src/ui/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) ui/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) ui/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/ui/view/makefile.in b/src/ui/view/makefile.in deleted file mode 100644 index 0fe15637a..000000000 --- a/src/ui/view/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd ../.. && $(MAKE) ui/view/all - -clean %.a %.$(OBJEXT): - cd ../.. && $(MAKE) ui/view/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/ui/widget/makefile.in b/src/ui/widget/makefile.in deleted file mode 100644 index e479d7031..000000000 --- a/src/ui/widget/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd ../.. && $(MAKE) ui/widget/all - -clean %.a %.$(OBJEXT): - cd ../.. && $(MAKE) ui/widget/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) -- cgit v1.2.3 From c419daf4e13efc020401b3bcbbe8b6116bb3cdd7 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Wed, 18 Oct 2017 22:08:15 +0200 Subject: Drop obsolete wrapper around Glib::file_open_tmp --- src/ui/dialog/print.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index 4d248fd09..532a8c364 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -26,7 +26,6 @@ #include "util/units.h" #include "helper/png-write.h" #include "svg/svg-color.h" -#include "io/sys.h" #include @@ -52,7 +51,7 @@ static void draw_page(GtkPrintOperation *, std::string tmp_base = "inkscape-print-png-XXXXXX"; int tmp_fd; - if ( (tmp_fd = Inkscape::IO::file_open_tmp (tmp_png, tmp_base)) >= 0) { + if ( (tmp_fd = Glib::file_open_tmp(tmp_png, tmp_base)) >= 0) { close(tmp_fd); guint32 bgcolor = 0x00000000; -- cgit v1.2.3 From 75444920325ba8a134eb16c4844f7fa15f34dd55 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Fri, 20 Oct 2017 22:59:35 +0200 Subject: Add preference to load additional fonts from 'fonts' directories - 'use_fontsdir_system' for /share/inkscape/fonts - 'use_fontsdir_user' for /inkscape/fonts in user config (both activated by default) --- src/ui/dialog/inkscape-preferences.cpp | 8 +++++++- src/ui/dialog/inkscape-preferences.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index d87a3d94a..5ceacd7b8 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -460,11 +460,17 @@ void InkscapePreferences::initPageTools() _page_text.add_group_header( _("Text units")); _font_unit_type.init( "/options/font/unitType", sizeLabels, sizeValues, G_N_ELEMENTS(sizeLabels), SP_CSS_UNIT_PT ); - _page_text.add_line( false, _("Text size unit type:"), _font_unit_type, "", + _page_text.add_line( true, _("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_group_header( _("Font directories")); + _font_fontsdir_system.init( _("Use Inkscape's fonts directory"), "/options/font/use_fontsdir_system", true); + _page_text.add_line( true, "", _font_fontsdir_system, "", _("Load additional fonts from \"fonts\" directory located in Inkscape's global \"share\" directory")); + _font_fontsdir_user.init( _("Use user's fonts directory"), "/options/font/use_fontsdir_user", true); + _page_text.add_line( true, "", _font_fontsdir_user, "", _("Load additional fonts from \"fonts\" directory located in Inkscape's user configuration directory")); + this->AddNewObjectsStyle(_page_text, "/tools/text"); //Spray diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index e6ba4e4b2..38b622095 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -328,6 +328,8 @@ protected: UI::Widget::PrefCheckButton _font_dialog; UI::Widget::PrefCombo _font_unit_type; UI::Widget::PrefCheckButton _font_output_px; + UI::Widget::PrefCheckButton _font_fontsdir_system; + UI::Widget::PrefCheckButton _font_fontsdir_user; UI::Widget::PrefCheckButton _misc_comment; UI::Widget::PrefCheckButton _misc_default_metadata; -- cgit v1.2.3 From fd55cff81015288863feceaa9cb579e2cdb2986e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 21 Oct 2017 17:50:19 +0200 Subject: Add preferences widget 'PrefMultiEntry' This is a multiline text input, similar to 'PrefEntry' Newlines characters in the multiline input will be converted to '|' in the saved preference. This is because the XML parser will convert real newline characters to spaces when reading the preferences file the next time. --- src/ui/widget/preferences-widget.cpp | 31 +++++++++++++++++++++++++++++++ src/ui/widget/preferences-widget.h | 12 ++++++++++++ 2 files changed, 43 insertions(+) (limited to 'src/ui') diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 2981316c0..e93b83db4 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -34,6 +34,7 @@ #include #include +#include #ifdef WIN32 #include @@ -859,6 +860,36 @@ void PrefEntry::on_changed() } } +void PrefMultiEntry::init(Glib::ustring const &prefs_path, int height) +{ + // TODO: Figure out if there's a way to specify height in lines instead of px + // and how to obtain a reasonable default width if 'expand_widget' is not used + set_size_request(100, height); + set_hexpand(true); + set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + set_shadow_type(Gtk::SHADOW_IN); + + add(_text); + + _prefs_path = prefs_path; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring value = prefs->getString(_prefs_path); + value = Glib::Regex::create("\\|")->replace_literal(value, 0, "\n", (Glib::RegexMatchFlags)0); + _text.get_buffer()->set_text(value); + _text.get_buffer()->signal_changed().connect(sigc::mem_fun(*this, &PrefMultiEntry::on_changed)); +} + +void PrefMultiEntry::on_changed() +{ + if (get_visible()) //only take action if user changed value + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring value = _text.get_buffer()->get_text(); + value = Glib::Regex::create("\\n")->replace_literal(value, 0, "|", (Glib::RegexMatchFlags)0); + prefs->setString(_prefs_path, value); + } +} + void PrefColorPicker::init(Glib::ustring const &label, Glib::ustring const &prefs_path, guint32 default_rgba) { diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 142793509..2578be533 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -195,6 +197,16 @@ protected: void on_changed(); }; +class PrefMultiEntry : public Gtk::ScrolledWindow +{ +public: + void init(Glib::ustring const &prefs_path, int height); +protected: + Glib::ustring _prefs_path; + Gtk::TextView _text; + void on_changed(); +}; + class PrefEntryButtonHBox : public Gtk::HBox { public: -- cgit v1.2.3 From 2dc0f89864fded681d8ece1d077d6ff5c77bbe97 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 21 Oct 2017 18:25:18 +0200 Subject: Add preference to load additional fonts from custom directories 'custom_fontdirs' is a list of paths to search for fonts --- src/ui/dialog/inkscape-preferences.cpp | 3 +++ src/ui/dialog/inkscape-preferences.h | 1 + 2 files changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 5ceacd7b8..ae013a27b 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -470,6 +470,9 @@ void InkscapePreferences::initPageTools() _page_text.add_line( true, "", _font_fontsdir_system, "", _("Load additional fonts from \"fonts\" directory located in Inkscape's global \"share\" directory")); _font_fontsdir_user.init( _("Use user's fonts directory"), "/options/font/use_fontsdir_user", true); _page_text.add_line( true, "", _font_fontsdir_user, "", _("Load additional fonts from \"fonts\" directory located in Inkscape's user configuration directory")); + _font_fontdirs_custom.init("/options/font/custom_fontdirs", 50); + _page_text.add_line(true, _("Additional font directories"), _font_fontdirs_custom, "", _("Load additional fonts from custom locations (one path per line)"), true); + this->AddNewObjectsStyle(_page_text, "/tools/text"); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 38b622095..531533cee 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -330,6 +330,7 @@ protected: UI::Widget::PrefCheckButton _font_output_px; UI::Widget::PrefCheckButton _font_fontsdir_system; UI::Widget::PrefCheckButton _font_fontsdir_user; + UI::Widget::PrefMultiEntry _font_fontdirs_custom; UI::Widget::PrefCheckButton _misc_comment; UI::Widget::PrefCheckButton _misc_default_metadata; -- cgit v1.2.3 From bd536de52298231e37a37ad0509c27dbd6615728 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 22 Oct 2017 16:57:27 +0200 Subject: Preferences: fix inputs not properly expanding horizontally (gtk3 issue) --- src/ui/widget/preferences-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index e93b83db4..8b8e663a5 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -79,6 +79,7 @@ void DialogPage::add_line(bool indent, auto hb = Gtk::manage(new Gtk::Box()); hb->set_spacing(12); + hb->set_hexpand(true); hb->pack_start(widget, expand_widget, expand_widget); // Pack an additional widget into a box with the widget if desired @@ -865,7 +866,6 @@ void PrefMultiEntry::init(Glib::ustring const &prefs_path, int height) // TODO: Figure out if there's a way to specify height in lines instead of px // and how to obtain a reasonable default width if 'expand_widget' is not used set_size_request(100, height); - set_hexpand(true); set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); set_shadow_type(Gtk::SHADOW_IN); -- cgit v1.2.3 From e6919ea013dc0c926e049a1e7b1188829060baac Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 22 Oct 2017 17:21:09 +0200 Subject: Preferences: Simplify code from 9f2c9d85b73ff773e6181d700678f28757714992 --- src/ui/dialog/inkscape-preferences.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index ae013a27b..bd4f5c75e 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1930,12 +1930,7 @@ void InkscapePreferences::initPageSpellcheck() static void appendList( Glib::ustring& tmp, const gchar* const*listing ) { - bool first = true; for (const gchar* const* ptr = listing; *ptr; ptr++) { - if (!first) { - tmp += " "; - } - first = false; tmp += *ptr; tmp += "\n"; } @@ -2000,22 +1995,12 @@ void InkscapePreferences::initPageSystem() _sys_systemdata_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _page_system.add_line(true, _("System data: "), _sys_systemdata_scroll, "", _("Locations of system data"), true); - { - tmp = ""; - gchar** paths = 0; - gint count = 0; - gtk_icon_theme_get_search_path(gtk_icon_theme_get_default(), &paths, &count); - if (count > 0) { - tmp += paths[0]; - tmp += "\n"; - for (int i = 1; i < count; i++) { - tmp += " "; - tmp += paths[i]; - tmp += "\n"; - } - } - } - + tmp = ""; + gchar** paths = 0; + gint count = 0; + gtk_icon_theme_get_search_path(gtk_icon_theme_get_default(), &paths, &count); + appendList( tmp, paths ); + g_strfreev(paths); _sys_icon.get_buffer()->insert(_sys_icon.get_buffer()->end(), tmp); } _sys_icon.set_editable(false); -- cgit v1.2.3 From 8059f2c4d9751a531a1b672699508ccd2cc3c53b Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 22 Oct 2017 17:21:38 +0200 Subject: Preferences: Minor consistency fixes for UI --- src/ui/dialog/inkscape-preferences.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index bd4f5c75e..351eb0845 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1991,9 +1991,10 @@ void InkscapePreferences::initPageSystem() _sys_systemdata.get_buffer()->insert(_sys_systemdata.get_buffer()->end(), tmp); _sys_systemdata.set_editable(false); _sys_systemdata_scroll.add(_sys_systemdata); - _sys_systemdata_scroll.set_size_request(0, 80); + _sys_systemdata_scroll.set_size_request(100, 80); _sys_systemdata_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - _page_system.add_line(true, _("System data: "), _sys_systemdata_scroll, "", _("Locations of system data"), true); + _sys_systemdata_scroll.set_shadow_type(Gtk::SHADOW_IN); + _page_system.add_line(true, _("System data: "), _sys_systemdata_scroll, "", _("Locations of system data"), true); tmp = ""; gchar** paths = 0; @@ -2005,8 +2006,9 @@ void InkscapePreferences::initPageSystem() } _sys_icon.set_editable(false); _sys_icon_scroll.add(_sys_icon); - _sys_icon_scroll.set_size_request(0, 80); + _sys_icon_scroll.set_size_request(100, 80); _sys_icon_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _sys_icon_scroll.set_shadow_type(Gtk::SHADOW_IN); _page_system.add_line(true, _("Icon theme: "), _sys_icon_scroll, "", _("Locations of icon themes"), true); this->AddPage(_page_system, _("System"), PREFS_PAGE_SYSTEM); -- cgit v1.2.3 From f63768018051ac3213df44bb086aea1024df070a Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 22 Oct 2017 17:25:13 +0200 Subject: Preferences: cleanup --- src/ui/dialog/inkscape-preferences.cpp | 97 ++++++++++++++++------------------ 1 file changed, 46 insertions(+), 51 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 351eb0845..09ba06720 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1946,64 +1946,59 @@ void InkscapePreferences::initPageSystem() _page_system.add_line( false, "", _misc_namedicon_delay, "", _("When on, named icons will be rendered before displaying the ui. This is for working around bugs in GTK+ named icon notification"), true); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - { - // TRANSLATORS: following strings are paths in Inkscape preferences - Misc - System info - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - _page_system.add_group_header( _("System info")); + _page_system.add_group_header( _("System info")); - _sys_user_config.set_text((char const *)Inkscape::IO::Resource::profile_path("")); - _sys_user_config.set_editable(false); - _page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true); + _sys_user_config.set_text((char const *)Inkscape::IO::Resource::profile_path("")); + _sys_user_config.set_editable(false); + _page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true); - _sys_user_prefs.set_text(prefs->getPrefsFilename()); - _sys_user_prefs.set_editable(false); - _page_system.add_line(true, _("User preferences: "), _sys_user_prefs, "", _("Location of the users preferences file"), true); + _sys_user_prefs.set_text(prefs->getPrefsFilename()); + _sys_user_prefs.set_editable(false); + _page_system.add_line(true, _("User preferences: "), _sys_user_prefs, "", _("Location of the users preferences file"), true); - _sys_user_extension_dir.set_text((char const *)IO::Resource::get_path(IO::Resource::USER, IO::Resource::EXTENSIONS, "")); - _sys_user_extension_dir.set_editable(false); - _page_system.add_line(true, _("User extensions: "), _sys_user_extension_dir, "", _("Location of the users extensions"), true); + _sys_user_extension_dir.set_text((char const *)IO::Resource::get_path(IO::Resource::USER, IO::Resource::EXTENSIONS, "")); + _sys_user_extension_dir.set_editable(false); + _page_system.add_line(true, _("User extensions: "), _sys_user_extension_dir, "", _("Location of the users extensions"), true); - _sys_user_cache.set_text(g_get_user_cache_dir()); - _sys_user_cache.set_editable(false); - _page_system.add_line(true, _("User cache: "), _sys_user_cache, "", _("Location of users cache"), true); + _sys_user_cache.set_text(g_get_user_cache_dir()); + _sys_user_cache.set_editable(false); + _page_system.add_line(true, _("User cache: "), _sys_user_cache, "", _("Location of users cache"), true); - Glib::ustring tmp_dir = prefs->getString("/options/autosave/path"); - if (tmp_dir.empty()) { - tmp_dir = Glib::get_tmp_dir(); - } - _sys_tmp_files.set_text(tmp_dir); - _sys_tmp_files.set_editable(false); - _page_system.add_line(true, _("Temporary files: "), _sys_tmp_files, "", _("Location of the temporary files used for autosave"), true); - - _sys_data.set_text( INKSCAPE_DATADIR ); - _sys_data.set_editable(false); - _page_system.add_line(true, _("Inkscape data: "), _sys_data, "", _("Location of Inkscape data"), true); - - _sys_extension_dir.set_text(INKSCAPE_EXTENSIONDIR); - _sys_extension_dir.set_editable(false); - _page_system.add_line(true, _("Inkscape extensions: "), _sys_extension_dir, "", _("Location of the Inkscape extensions"), true); - - Glib::ustring tmp; - appendList( tmp, g_get_system_data_dirs() ); - _sys_systemdata.get_buffer()->insert(_sys_systemdata.get_buffer()->end(), tmp); - _sys_systemdata.set_editable(false); - _sys_systemdata_scroll.add(_sys_systemdata); - _sys_systemdata_scroll.set_size_request(100, 80); - _sys_systemdata_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - _sys_systemdata_scroll.set_shadow_type(Gtk::SHADOW_IN); - _page_system.add_line(true, _("System data: "), _sys_systemdata_scroll, "", _("Locations of system data"), true); - - tmp = ""; - gchar** paths = 0; - gint count = 0; - gtk_icon_theme_get_search_path(gtk_icon_theme_get_default(), &paths, &count); - appendList( tmp, paths ); - g_strfreev(paths); - _sys_icon.get_buffer()->insert(_sys_icon.get_buffer()->end(), tmp); + Glib::ustring tmp_dir = prefs->getString("/options/autosave/path"); + if (tmp_dir.empty()) { + tmp_dir = Glib::get_tmp_dir(); } + _sys_tmp_files.set_text(tmp_dir); + _sys_tmp_files.set_editable(false); + _page_system.add_line(true, _("Temporary files: "), _sys_tmp_files, "", _("Location of the temporary files used for autosave"), true); + + _sys_data.set_text( INKSCAPE_DATADIR ); + _sys_data.set_editable(false); + _page_system.add_line(true, _("Inkscape data: "), _sys_data, "", _("Location of Inkscape data"), true); + + _sys_extension_dir.set_text(INKSCAPE_EXTENSIONDIR); + _sys_extension_dir.set_editable(false); + _page_system.add_line(true, _("Inkscape extensions: "), _sys_extension_dir, "", _("Location of the Inkscape extensions"), true); + + Glib::ustring tmp; + appendList( tmp, g_get_system_data_dirs() ); + _sys_systemdata.get_buffer()->insert(_sys_systemdata.get_buffer()->end(), tmp); + _sys_systemdata.set_editable(false); + _sys_systemdata_scroll.add(_sys_systemdata); + _sys_systemdata_scroll.set_size_request(100, 80); + _sys_systemdata_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _sys_systemdata_scroll.set_shadow_type(Gtk::SHADOW_IN); + _page_system.add_line(true, _("System data: "), _sys_systemdata_scroll, "", _("Locations of system data"), true); + + tmp = ""; + gchar** paths = 0; + gint count = 0; + gtk_icon_theme_get_search_path(gtk_icon_theme_get_default(), &paths, &count); + appendList( tmp, paths ); + g_strfreev(paths); + _sys_icon.get_buffer()->insert(_sys_icon.get_buffer()->end(), tmp); _sys_icon.set_editable(false); _sys_icon_scroll.add(_sys_icon); _sys_icon_scroll.set_size_request(100, 80); -- cgit v1.2.3 From 68d1c505514fe4024c72df86d60a57bcb2b827c8 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sun, 22 Oct 2017 19:10:24 +0200 Subject: Fix regression after r14761: handle size of selected nodes too big and sticky In r14761 a bug was introduced in ControlManagerImpl::setSelected(), the fixed value _resize was used to set the final value of targetSize for the node instead of item->ctrlResize which is decided conditionally depending on the node state. https://bugs.launchpad.net/inkscape/+bug/1568644 --- src/ui/control-manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index d0285e467..d0106bfcd 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -330,10 +330,12 @@ void ControlManagerImpl::setSelected(SPCanvasItem *item, bool selected) if (selected && _resizeOnSelect.count(item->ctrlType)) { item->ctrlResize = 2; + } else { + item->ctrlResize = 0; } // TODO refresh colors - double targetSize = _sizeTable[item->ctrlType][_size - 1] + _resize; + double targetSize = _sizeTable[item->ctrlType][_size - 1] + item->ctrlResize; g_object_set(item, "size", targetSize, NULL); } } -- cgit v1.2.3 From a00c71b8589567f01ae95ee7a1c8263f97126be9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 27 Oct 2017 10:51:47 +0200 Subject: Enable reopening of Prototype dialog on startup. --- src/ui/dialog/prototype.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ui') diff --git a/src/ui/dialog/prototype.cpp b/src/ui/dialog/prototype.cpp index b3bf60aab..b7c9f7abf 100644 --- a/src/ui/dialog/prototype.cpp +++ b/src/ui/dialog/prototype.cpp @@ -22,6 +22,8 @@ namespace Inkscape { namespace UI { namespace Dialog { +// Note that in order for a dialog to be restored, it must be listed in SPDesktop::show_dialogs(). + Prototype::Prototype() : // UI::Widget::Panel("Prototype Label", "/dialogs/prototype", SP_VERB_DIALOG_PROTOTYPE, // "Prototype Apply Label", true), -- cgit v1.2.3