summaryrefslogtreecommitdiffstats
path: root/src/ui/tools
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-10-03 20:51:05 +0000
committerjabiertxof <info@marker.es>2016-10-03 20:51:05 +0000
commit4db35e8a6706ddece9e977e5f26d4a6867ff8cbe (patch)
treef9711f260f694d96e26bf3216fb64f2b38611b2b /src/ui/tools
parentupdate to trunk (diff)
parentMerge in jabiertxof's hover information for measure tool (diff)
downloadinkscape-4db35e8a6706ddece9e977e5f26d4a6867ff8cbe.tar.gz
inkscape-4db35e8a6706ddece9e977e5f26d4a6867ff8cbe.zip
Update to trunk
(bzr r15017.1.35)
Diffstat (limited to 'src/ui/tools')
-rw-r--r--src/ui/tools/Makefile_insert34
-rw-r--r--src/ui/tools/arc-tool.cpp3
-rw-r--r--src/ui/tools/box3d-tool.cpp13
-rw-r--r--src/ui/tools/calligraphic-tool.cpp21
-rw-r--r--src/ui/tools/connector-tool.cpp23
-rw-r--r--src/ui/tools/dropper-tool.cpp13
-rw-r--r--src/ui/tools/dynamic-base.cpp6
-rw-r--r--src/ui/tools/eraser-tool.cpp179
-rw-r--r--src/ui/tools/eraser-tool.h4
-rw-r--r--src/ui/tools/flood-tool.cpp14
-rw-r--r--src/ui/tools/freehand-base.cpp42
-rw-r--r--src/ui/tools/gradient-tool.cpp28
-rw-r--r--src/ui/tools/lpe-tool.cpp9
-rw-r--r--src/ui/tools/measure-tool.cpp130
-rw-r--r--src/ui/tools/measure-tool.h9
-rw-r--r--src/ui/tools/mesh-tool.cpp54
-rw-r--r--src/ui/tools/node-tool.cpp26
-rw-r--r--src/ui/tools/pen-tool.cpp34
-rw-r--r--src/ui/tools/pencil-tool.cpp7
-rw-r--r--src/ui/tools/rect-tool.cpp5
-rw-r--r--src/ui/tools/select-tool.cpp14
-rw-r--r--src/ui/tools/spiral-tool.cpp5
-rw-r--r--src/ui/tools/spray-tool.cpp72
-rw-r--r--src/ui/tools/spray-tool.h9
-rw-r--r--src/ui/tools/star-tool.cpp5
-rw-r--r--src/ui/tools/text-tool.cpp6
-rw-r--r--src/ui/tools/tool-base.cpp42
-rw-r--r--src/ui/tools/tweak-tool.cpp42
-rw-r--r--src/ui/tools/zoom-tool.cpp1
29 files changed, 410 insertions, 440 deletions
diff --git a/src/ui/tools/Makefile_insert b/src/ui/tools/Makefile_insert
deleted file mode 100644
index 686dfedd8..000000000
--- a/src/ui/tools/Makefile_insert
+++ /dev/null
@@ -1,34 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- ui/tools/arc-tool.cpp ui/tools/arc-tool.h \
- ui/tools/box3d-tool.cpp ui/tools/box3d-tool.h \
- ui/tools/calligraphic-tool.cpp ui/tools/calligraphic-tool.h \
- ui/tools/connector-tool.cpp ui/tools/connector-tool.h \
- ui/tools/dropper-tool.cpp ui/tools/dropper-tool.h \
- ui/tools/dynamic-base.cpp ui/tools/dynamic-base.h \
- ui/tools/eraser-tool.cpp ui/tools/eraser-tool.h \
- ui/tools/freehand-base.cpp ui/tools/freehand-base.h \
- ui/tools/gradient-tool.cpp ui/tools/gradient-tool.h \
- ui/tools/lpe-tool.cpp ui/tools/lpe-tool.h \
- ui/tools/measure-tool.cpp ui/tools/measure-tool.h \
- ui/tools/mesh-tool.cpp ui/tools/mesh-tool.h \
- ui/tools/node-tool.cpp ui/tools/node-tool.h \
- ui/tools/pen-tool.cpp ui/tools/pen-tool.h \
- ui/tools/pencil-tool.cpp ui/tools/pencil-tool.h \
- ui/tools/rect-tool.cpp ui/tools/rect-tool.h \
- ui/tools/select-tool.cpp ui/tools/select-tool.h \
- ui/tools/spiral-tool.cpp ui/tools/spiral-tool.h \
- ui/tools/spray-tool.cpp ui/tools/spray-tool.h \
- ui/tools/star-tool.cpp ui/tools/star-tool.h \
- ui/tools/text-tool.cpp ui/tools/text-tool.h \
- ui/tools/tool-base.cpp ui/tools/tool-base.h \
- ui/tools/tweak-tool.cpp ui/tools/tweak-tool.h \
- ui/tools/zoom-tool.cpp ui/tools/zoom-tool.h
-
-if HAVE_POTRACE
-
-ink_common_sources += \
- ui/tools/flood-tool.cpp ui/tools/flood-tool.h
-
-endif
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index c6a9bb23a..6652f7ab5 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -17,7 +17,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gdk/gdkkeysyms.h>
@@ -30,7 +30,6 @@
#include "sp-namedview.h"
#include "selection.h"
-#include "snap.h"
#include "pixmaps/cursor-ellipse.xpm"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 27e755add..94488a700 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -15,8 +15,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <gdk/gdkkeysyms.h>
#include "macros.h"
@@ -27,8 +25,6 @@
#include "selection.h"
#include "selection-chemistry.h"
-#include "snap.h"
-#include "display/curve.h"
#include "display/sp-canvas-item.h"
#include "desktop.h"
#include "message-context.h"
@@ -36,17 +32,12 @@
#include "box3d.h"
#include "ui/tools/box3d-tool.h"
#include <glibmm/i18n.h>
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "preferences.h"
#include "context-fns.h"
#include "desktop-style.h"
-#include "transf_mat_3x4.h"
#include "perspective-line.h"
-#include "persp3d.h"
#include "box3d-side.h"
#include "document-private.h"
-#include "line-geometry.h"
#include "ui/shape-editor.h"
#include "verbs.h"
@@ -118,8 +109,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
SPDefs *defs = document->getDefs();
bool has_persp = false;
- for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) {
- if (SP_IS_PERSP3D(child)) {
+ for (auto& child: defs->children) {
+ if (SP_IS_PERSP3D(&child)) {
has_persp = true;
break;
}
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 28195eb75..9b4dbb1a2 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -23,8 +23,6 @@
#define noDYNA_DRAW_VERBOSE
-#include "config.h"
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -35,12 +33,10 @@
#include "svg/svg.h"
#include "display/canvas-bpath.h"
#include "display/cairo-utils.h"
-#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
#include <2geom/bezier-utils.h>
#include <2geom/circle.h>
#include "display/curve.h"
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "document-undo.h"
@@ -50,20 +46,15 @@
#include "desktop-style.h"
#include "message-context.h"
-#include "preferences.h"
#include "pixmaps/cursor-calligraphy.xpm"
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
#include "inkscape.h"
-#include "color.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
#include "sp-text.h"
#include "display/sp-canvas.h"
-#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "livarot/Shape.h"
#include "verbs.h"
@@ -144,7 +135,7 @@ void CalligraphicTool::setup() {
SPCurve *c = new SPCurve(path);
- this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c);
+ this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c, true);
c->unref();
@@ -930,10 +921,10 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
if (unionize) {
desktop->getSelection()->add(this->repr);
- sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
+ sp_selected_path_union_skip_undo(desktop->getSelection());
} else if (subtract) {
desktop->getSelection()->add(this->repr);
- sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop);
+ sp_selected_path_diff_skip_undo(desktop->getSelection());
} else {
if (this->keep_selected) {
desktop->getSelection()->set(this->repr);
@@ -1099,7 +1090,7 @@ void CalligraphicTool::fit_and_split(bool release) {
add_cap(this->currentcurve, b2[0], b1[0], this->cap_rounding);
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
/* Current calligraphic */
@@ -1135,7 +1126,7 @@ void CalligraphicTool::fit_and_split(bool release) {
SP_TYPE_CANVAS_BPATH,
NULL);
SPCurve *curve = this->currentcurve->copy();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve, true);
curve->unref();
guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/calligraphic", true);
@@ -1179,7 +1170,7 @@ void CalligraphicTool::draw_temporary_box() {
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
}
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 74f2664fe..7e6fb4b72 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -75,7 +75,6 @@
#include "ui/tools/connector-tool.h"
#include "pixmaps/cursor-connector.xpm"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
#include "svg/svg.h"
#include "desktop.h"
#include "desktop-style.h"
@@ -86,19 +85,13 @@
#include "message-stack.h"
#include "selection.h"
#include "inkscape.h"
-#include "preferences.h"
#include "sp-path.h"
#include "display/sp-canvas.h"
#include "display/canvas-bpath.h"
-#include "display/sodipodi-ctrl.h"
#include <glibmm/i18n.h>
#include <glibmm/stringutils.h>
#include "snap.h"
-#include "knot.h"
#include "sp-conn-end.h"
-#include "sp-conn-end-pair.h"
-#include "conn-avoid-ref.h"
-#include "libavoid/vertices.h"
#include "libavoid/router.h"
#include "context-fns.h"
#include "sp-namedview.h"
@@ -627,7 +620,7 @@ bool ConnectorTool::_handleMotionNotify(GdkEventMotion const &mevent) {
this->red_curve = path->get_curve_for_edit();
this->red_curve->transform(i2d);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
ret = true;
break;
}
@@ -818,7 +811,7 @@ void ConnectorTool::_setSubsequentPoint(Geom::Point const p) {
// Recreate curve from libavoid route.
recreateCurve( this->red_curve, this->newConnRef, this->curvature );
this->red_curve->transform(desktop->doc2dt());
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
}
@@ -1042,7 +1035,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, ConnectorTool *cc)
cc->red_curve = SP_PATH(cc->clickeditem)->get_curve_for_edit();
Geom::Affine i2d = (cc->clickeditem)->i2dt_affine();
cc->red_curve->transform(i2d);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve, true);
cc->clickeditem->setHidden(true);
@@ -1114,9 +1107,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) {
// The idea here is to try and add a group's children to solidify
// connection handling. We react to path objects with only one node.
- for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) {
- if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) {
- this->_activeShapeAddKnot((SPItem *) child);
+ for (auto& child: item->children) {
+ if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) {
+ this->_activeShapeAddKnot((SPItem *) &child);
}
}
this->_activeShapeAddKnot(item);
@@ -1306,8 +1299,8 @@ void cc_selection_set_avoid(bool const set_avoid)
int changes = 0;
- std::vector<SPItem*> l = selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end(); ++i) {
+ auto l = selection->items();
+ for(auto i=l.begin();i!=l.end(); ++i) {
SPItem *item = *i;
char const *value = (set_avoid) ? "true" : NULL;
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index c838c27d5..99177dc75 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -12,7 +12,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <glibmm/i18n.h>
@@ -27,7 +27,6 @@
#include "display/curve.h"
#include "display/cairo-utils.h"
#include "svg/svg-color.h"
-#include "color.h"
#include "color-rgba.h"
#include "desktop-style.h"
#include "preferences.h"
@@ -36,7 +35,6 @@
#include "desktop.h"
#include "selection.h"
-#include "document.h"
#include "document-undo.h"
#include "pixmaps/cursor-dropper-f.xpm"
@@ -45,7 +43,6 @@
#include "ui/tools/dropper-tool.h"
#include "message-context.h"
#include "verbs.h"
-#include "ui/tools/tool-base.h"
using Inkscape::DocumentUndo;
@@ -121,20 +118,12 @@ void DropperTool::finish() {
}
if (cursor_dropper_fill) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor_dropper_fill);
-#else
- gdk_cursor_unref (cursor_dropper_fill);
-#endif
cursor_dropper_fill = NULL;
}
if (cursor_dropper_stroke) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(cursor_dropper_stroke);
-#else
- gdk_cursor_unref (cursor_dropper_stroke);
-#endif
cursor_dropper_fill = NULL;
}
diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp
index eb789d850..6627a470e 100644
--- a/src/ui/tools/dynamic-base.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -1,13 +1,7 @@
#include "ui/tools/dynamic-base.h"
-#include <gtk/gtk.h>
-
-#include "config.h"
-
#include "message-context.h"
-#include "streq.h"
-#include "preferences.h"
#include "display/sp-canvas-item.h"
#include "desktop.h"
#include "display/curve.h"
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 6b32b5901..12686160b 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -24,8 +24,6 @@
#define noERASER_VERBOSE
-#include "config.h"
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -38,7 +36,6 @@
#include "display/canvas-bpath.h"
#include <2geom/bezier-utils.h>
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "selection.h"
@@ -47,30 +44,28 @@
#include "desktop-style.h"
#include "message-context.h"
-#include "preferences.h"
#include "pixmaps/cursor-eraser.xpm"
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
-#include "color.h"
#include "rubberband.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
+#include "sp-clippath.h"
+#include "sp-rect.h"
#include "sp-text.h"
+#include "sp-root.h"
#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
-#include "livarot/Shape.h"
#include "document-undo.h"
#include "verbs.h"
#include "style.h"
-#include "style-enums.h"
-#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
#include "path-chemistry.h"
+#include "selection-chemistry.h"
#include "display/curve.h"
-
+#include "layer-model.h"
+#include "layer-manager.h"
#include "ui/tools/eraser-tool.h"
using Inkscape::DocumentUndo;
@@ -380,7 +375,7 @@ void EraserTool::cancel() {
bool EraserTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode", 2);
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !this->space_panning) {
@@ -400,7 +395,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
if (this->repr) {
this->repr = NULL;
}
- if ( ! eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
}
@@ -448,7 +443,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if ( !eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
this->accumulated->reset();
Inkscape::Rubberband::get(desktop)->move(motion_dt);
}
@@ -491,7 +486,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
- if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) {
+ if (eraser_mode == ERASER_MODE_DELETE && Inkscape::Rubberband::get(desktop)->is_started()) {
Inkscape::Rubberband::get(desktop)->stop();
}
@@ -578,7 +573,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_Escape:
- if ( !eraserMode ) {
+ if ( eraser_mode == ERASER_MODE_DELETE ) {
Inkscape::Rubberband::get(desktop)->stop();
}
if (this->is_drawing) {
@@ -640,65 +635,66 @@ void EraserTool::clear_current() {
void EraserTool::set_to_accumulated() {
bool workDone = false;
-
+ SPDocument *document = this->desktop->doc();
if (!this->accumulated->is_empty()) {
if (!this->repr) {
/* Create object */
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
/* Set style */
- sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false);
+ sp_desktop_apply_style_tool (this->desktop, repr, "/tools/eraser", false);
this->repr = repr;
}
- SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr));
+ SPObject * top_layer = desktop->layer_manager->nthChildOf(desktop->layers->currentRoot(), 0);
+ SPItem *item_repr = SP_ITEM(top_layer->appendChildRepr(this->repr));
Inkscape::GC::release(this->repr);
- item->updateRepr();
- Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc();
- pathv *= item->i2doc_affine().inverse();
+ item_repr->updateRepr();
+ Geom::PathVector pathv = this->accumulated->get_pathvector() * this->desktop->dt2doc();
+ pathv *= item_repr->i2doc_affine().inverse();
gchar *str = sp_svg_write_path(pathv);
g_assert( str != NULL );
this->repr->setAttribute("d", str);
g_free(str);
-
+ Geom::OptRect eraserBbox;
if ( this->repr ) {
bool wasSelection = false;
- Inkscape::Selection *selection = desktop->getSelection();
+ Inkscape::Selection *selection = this->desktop->getSelection();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode", ERASER_MODE_CLIP);
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
- SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr));
- Geom::OptRect eraserBbox = acid->desktopVisualBounds();
+ SPItem* acid = SP_ITEM(this->desktop->doc()->getObjectByRepr(this->repr));
+ eraserBbox = acid->desktopVisualBounds();
std::vector<SPItem*> remainingItems;
std::vector<SPItem*> toWorkOn;
if (selection->isEmpty()) {
- if ( eraserMode ) {
- toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox);
+ if (eraser_mode == ERASER_MODE_CUT || eraser_mode == ERASER_MODE_CLIP) {
+ toWorkOn = document->getItemsPartiallyInBox(this->desktop->dkey, *eraserBbox);
} else {
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
- toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop);
+ toWorkOn = document->getItemsAtPoints(this->desktop->dkey, r->getPoints());
}
toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end());
} else {
- if ( !eraserMode ) {
- Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop);
+ if (eraser_mode == ERASER_MODE_DELETE) {
+ Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop);
std::vector<SPItem*> touched;
- touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints());
+ touched = document->getItemsAtPoints(this->desktop->dkey, r->getPoints());
for (std::vector<SPItem*>::const_iterator i = touched.begin();i!=touched.end();++i) {
if(selection->includes(*i)){
toWorkOn.push_back((*i));
}
}
} else {
- toWorkOn = selection->itemList();
+ toWorkOn.insert(toWorkOn.end(), selection->items().begin(), selection->items().end());
}
wasSelection = true;
}
if ( !toWorkOn.empty() ) {
- if ( eraserMode ) {
+ if (eraser_mode == ERASER_MODE_CUT) {
for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
SPItem *item = *i;
SPUse *use = dynamic_cast<SPUse *>(item);
@@ -708,7 +704,6 @@ void EraserTool::set_to_accumulated() {
item->deleteObject(true);
sp_object_unref(item);
workDone = true;
- workDone = true;
} else if (SP_IS_GROUP(item) || use ) {
/*Do nothing*/
} else {
@@ -719,33 +714,33 @@ void EraserTool::set_to_accumulated() {
Inkscape::GC::release(dup); // parent takes over
selection->set(dup);
if (!this->nowidth) {
- sp_selected_path_union_skip_undo(selection, desktop);
+ sp_selected_path_union_skip_undo(selection);
}
selection->add(item);
if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-rule", "evenodd");
- sp_desktop_set_style(desktop, css);
+ sp_desktop_set_style(this->desktop, css);
sp_repr_css_attr_unref(css);
css = 0;
}
if (this->nowidth) {
- sp_selected_path_cut_skip_undo(selection, desktop);
+ sp_selected_path_cut_skip_undo(selection);
} else {
- sp_selected_path_diff_skip_undo(selection, desktop);
+ sp_selected_path_diff_skip_undo(selection);
}
workDone = true; // TODO set this only if something was cut.
bool break_apart = prefs->getBool("/tools/eraser/break_apart", false);
if(!break_apart){
- sp_selected_path_combine(desktop, true);
+ sp_selected_path_combine(this->desktop, true);
} else {
if(!this->nowidth){
- sp_selected_path_break_apart(desktop, true);
+ sp_selected_path_break_apart(this->desktop, true);
}
}
if ( !selection->isEmpty() ) {
// If the item was not completely erased, track the new remainder.
- std::vector<SPItem*> nowSel(selection->itemList());
+ std::vector<SPItem*> nowSel(selection->items().begin(), selection->items().end());
for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) {
remainingItems.push_back(*i2);
}
@@ -755,6 +750,78 @@ void EraserTool::set_to_accumulated() {
}
}
}
+ } else if (eraser_mode == ERASER_MODE_CLIP) {
+ if (!this->nowidth) {
+ remainingItems.clear();
+ for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){
+ selection->clear();
+ SPItem *item = *i;
+ Geom::OptRect bbox = item->desktopVisualBounds();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
+ Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc);
+ this->repr->parent()->appendChild(dup);
+ Inkscape::GC::release(dup); // parent takes over
+ selection->set(dup);
+ sp_selected_path_union_skip_undo(selection);
+ if (bbox && bbox->intersects(*eraserBbox)) {
+ SPClipPath *clip_path = item->clip_ref->getObject();
+ if (clip_path) {
+ std::vector<SPItem*> selected;
+ selected.push_back(SP_ITEM(clip_path->firstChild()));
+ std::vector<Inkscape::XML::Node*> to_select;
+ std::vector<SPItem*> items(selected);
+ sp_item_list_to_curves(items, selected, to_select);
+ Inkscape::XML::Node * clip_data = SP_ITEM(clip_path->firstChild())->getRepr();
+ if (!clip_data && !to_select.empty()) {
+ clip_data = *(to_select.begin());
+ }
+ if (clip_data) {
+ Inkscape::XML::Node *dup_clip = clip_data->duplicate(xml_doc);
+ 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);
+ sp_object_ref(clip_path, 0);
+ clip_path->deleteObject(true);
+ sp_object_unref(clip_path);
+ sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->add(dup_clip);
+ sp_selected_path_diff_skip_undo(selection);
+ SPItem * clip = SP_ITEM(*(selection->items().begin()));
+ }
+ }
+ }
+ } else {
+ Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect");
+ sp_desktop_apply_style_tool (this->desktop, rect_repr, "/tools/eraser", false);
+ SPRect * rect = SP_RECT(item_repr->parent->appendChildRepr(rect_repr));
+ Inkscape::GC::release(rect_repr);
+ rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height());
+ rect->transform = SP_ITEM(rect->parent)->i2dt_affine().inverse();
+ rect->updateRepr();
+ rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->add(rect);
+ sp_selected_path_diff_skip_undo(selection);
+ }
+ sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->add(item);
+ sp_selection_set_mask(this->desktop, true, false, true);
+ } else {
+ SPItem *erase_clip = selection->singleItem();
+ if (erase_clip) {
+ sp_object_ref(erase_clip, 0);
+ erase_clip->deleteObject(true);
+ sp_object_unref(erase_clip);
+ }
+ }
+ workDone = true;
+ selection->clear();
+ if (wasSelection) {
+ remainingItems.push_back(item);
+ }
+ }
+ }
} else {
for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) {
sp_object_ref( *i, 0 );
@@ -768,8 +835,8 @@ void EraserTool::set_to_accumulated() {
}
}
- if ( !eraserMode ) {
- //sp_selection_delete(desktop);
+ if (eraser_mode == ERASER_MODE_DELETE) {
+ sp_selection_delete(this->desktop);
remainingItems.clear();
}
@@ -791,12 +858,10 @@ void EraserTool::set_to_accumulated() {
this->repr = 0;
}
}
-
-
if ( workDone ) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
+ DocumentUndo::done(document, SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke"));
} else {
- DocumentUndo::cancel(desktop->getDocument());
+ DocumentUndo::cancel(document);
}
}
@@ -955,7 +1020,7 @@ void EraserTool::fit_and_split(bool release) {
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
/* Current eraser */
@@ -987,12 +1052,12 @@ void EraserTool::fit_and_split(bool release) {
g_print("[%d]Yup\n", this->npoints);
#endif
if (!release) {
- gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0;
+ gint eraser_mode = prefs->getInt("/tools/eraser/mode",2);
g_assert(!this->currentcurve->is_empty());
SPCanvasItem *cbp = sp_canvas_item_new(desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL);
SPCurve *curve = this->currentcurve->copy();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve, true);
curve->unref();
guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/eraser", true);
@@ -1009,7 +1074,7 @@ void EraserTool::fit_and_split(bool release) {
this->segments = g_slist_prepend(this->segments, cbp);
- if ( !eraserMode ) {
+ if (eraser_mode == ERASER_MODE_DELETE) {
sp_canvas_item_hide(cbp);
sp_canvas_item_hide(this->currentshape);
}
@@ -1041,7 +1106,7 @@ void EraserTool::draw_temporary_box() {
}
this->currentcurve->closepath();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true);
}
}
diff --git a/src/ui/tools/eraser-tool.h b/src/ui/tools/eraser-tool.h
index 50ce6b6e3..bd0e98057 100644
--- a/src/ui/tools/eraser-tool.h
+++ b/src/ui/tools/eraser-tool.h
@@ -31,6 +31,10 @@
#define ERC_MAX_TILT 1.0
#define ERC_DEFAULT_TILT 0.0
+#define ERASER_MODE_DELETE 0
+#define ERASER_MODE_CUT 1
+#define ERASER_MODE_CLIP 2
+
namespace Inkscape {
namespace UI {
namespace Tools {
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 748c82717..0b893a7ba 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -18,14 +18,13 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include "trace/potrace/inkscape-potrace.h"
#include <2geom/pathvector.h>
#include <gdk/gdkkeysyms.h>
#include <queue>
-#include <deque>
#include <glibmm/i18n.h>
#include "color.h"
@@ -36,7 +35,6 @@
#include "display/cairo-utils.h"
#include "display/drawing-context.h"
#include "display/drawing-image.h"
-#include "display/drawing-item.h"
#include "display/drawing.h"
#include "display/sp-canvas.h"
#include "document.h"
@@ -47,23 +45,15 @@
#include "macros.h"
#include "message-context.h"
#include "message-stack.h"
-#include "preferences.h"
#include "rubberband.h"
#include "selection.h"
#include "ui/shape-editor.h"
-#include "sp-defs.h"
-#include "sp-item.h"
#include "splivarot.h"
#include "sp-namedview.h"
-#include "sp-object.h"
-#include "sp-path.h"
-#include "sp-rect.h"
#include "sp-root.h"
#include "svg/svg.h"
#include "trace/imagemap.h"
-#include "trace/trace.h"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
#include "verbs.h"
#include "pixmaps/cursor-paintbucket.xpm"
@@ -456,7 +446,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.",
SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() );
selection->add(reprobj);
- sp_selected_path_union_skip_undo(desktop->getSelection(), desktop);
+ sp_selected_path_union_skip_undo(desktop->getSelection());
} else {
desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE,
ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.",
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 7697cd59c..067035b97 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -17,43 +17,29 @@
#define DRAW_VERBOSE
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "live_effects/lpe-bendpath.h"
#include "live_effects/lpe-patternalongpath.h"
#include "live_effects/lpe-simplify.h"
#include "display/canvas-bpath.h"
-#include "xml/repr.h"
#include "svg/svg.h"
-#include <glibmm/i18n.h>
#include "display/curve.h"
-#include "desktop.h"
#include "desktop-style.h"
-#include "document.h"
#include "ui/draw-anchor.h"
#include "macros.h"
#include "message-stack.h"
#include "ui/tools/pen-tool.h"
#include "ui/tools/lpe-tool.h"
-#include "preferences.h"
-#include "selection.h"
#include "selection-chemistry.h"
-#include "snap.h"
-#include "sp-path.h"
-#include "sp-use.h"
#include "sp-item-group.h"
-#include "sp-namedview.h"
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
-#include "util/units.h"
// clipboard support
#include "ui/clipboard.h"
-#include "ui/tools/freehand-base.h"
-
-#include <gdk/gdkkeysyms.h>
using Inkscape::DocumentUndo;
@@ -226,6 +212,10 @@ static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath,
Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE();
static_cast<LPEPatternAlongPath*>(lpe)->pattern.set_new_value(newpath,true);
+ double scale_doc = 1 / dc->desktop->doc()->getDocumentScale()[0];
+ Inkscape::SVGOStringStream os;
+ os << scale_doc;
+ lpe->getRepr()->setAttribute("prop_scale", os.str().c_str());
}
static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
@@ -342,7 +332,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
// "triangle in"
std::vector<Geom::Point> points(1);
points[0] = Geom::Point(0., swidth/2);
- points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
+ //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
spdc_apply_powerstroke_shape(points, dc, item);
shape_applied = true;
@@ -354,7 +344,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
guint curve_length = curve->get_segment_count();
std::vector<Geom::Point> points(1);
points[0] = Geom::Point(0, swidth/2);
- points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
+ //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
points[0][Geom::X] = (double)curve_length;
spdc_apply_powerstroke_shape(points, dc, item);
@@ -792,16 +782,26 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
if (!dc->white_item) {
// Attach repr
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ shapeType shape_selected = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
-
- spdc_check_for_and_apply_waiting_LPE(dc, item, c);
- if(previous_shape_type != BEND_CLIPBOARD){
- dc->selection->set(repr);
+ //Bend needs the transforms applied after, Other effects best before
+ if((previous_shape_type == BEND_CLIPBOARD && shape_selected == LAST_APPLIED) ||
+ shape_selected == BEND_CLIPBOARD)
+ {
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c);
+ previous_shape_type = BEND_CLIPBOARD;
}
Inkscape::GC::release(repr);
item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
item->updateRepr();
item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ if((previous_shape_type != BEND_CLIPBOARD || shape_selected != LAST_APPLIED) &&
+ shape_selected != BEND_CLIPBOARD)
+ {
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c);
+ dc->selection->set(repr);
+ }
if(previous_shape_type == BEND_CLIPBOARD){
repr->parent()->removeChild(repr);
}
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 9d8101cc4..16df225e0 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -13,7 +13,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
@@ -31,17 +31,10 @@
#include "ui/tools/gradient-tool.h"
#include "gradient-chemistry.h"
#include <glibmm/i18n.h>
-#include "preferences.h"
#include "gradient-drag.h"
-#include "gradient-chemistry.h"
-#include "xml/repr.h"
-#include "sp-item.h"
#include "display/sp-ctrlline.h"
-#include "sp-linear-gradient.h"
-#include "sp-radial-gradient.h"
#include "sp-stop.h"
#include "svg/css-ostringstream.h"
-#include "svg/svg-color.h"
#include "snap.h"
#include "sp-namedview.h"
#include "rubberband.h"
@@ -106,7 +99,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) {
if (selection == NULL) {
return;
}
- guint n_obj = selection->itemList().size();
+ guint n_obj = (guint) boost::distance(selection->items());
if (!drag->isNonEmpty() || selection->isEmpty())
return;
@@ -492,10 +485,10 @@ bool GradientTool::root_handler(GdkEvent* event) {
if (over_line) {
// we take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time);
+ sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time);
} else {
- std::vector<SPItem*> items=selection->itemList();
- for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i) {
+ auto items= selection->items();
+ for (auto i = items.begin();i!=items.end();++i) {
SPItem *item = *i;
SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -878,6 +871,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
return ret;
}
+// Creates a new linear or radial gradient.
static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
@@ -897,7 +891,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- std::vector<SPItem*> items(selection->itemList());
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
@@ -907,8 +901,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- std::vector<SPItem*> itemlist = selection->itemList();
- for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();++i) {
+ auto itemlist = selection->items();
+ for (auto i = itemlist.begin();i!=itemlist.end();++i) {
//FIXME: see above
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -931,7 +925,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
ec->_grdrag->local_change = true;
// give the grab out-of-bounds values of xp/yp because we're already dragging
// and therefore are already out of tolerance
- ec->_grdrag->grabKnot (selection->itemList()[0],
+ ec->_grdrag->grabKnot (selection->items().front(),
type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1,
-1, // ignore number (though it is always 1)
fill_or_stroke, 99999, 99999, etime);
@@ -940,7 +934,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = selection->itemList().size();
+ int n_objects = (int) boost::distance(selection->items());
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index 9bbc1ac20..29e4c9e74 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -15,19 +15,16 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
#endif
#include <2geom/sbasis-geometric.h>
-#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
-#include "macros.h"
#include "pixmaps/cursor-crosshairs.xpm"
#include <gtk/gtk.h>
#include "desktop.h"
#include "message-context.h"
-#include "preferences.h"
#include "ui/shape-editor.h"
#include "selection.h"
@@ -396,8 +393,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup();
gchar *arc_length;
double lengthval;
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
if (SP_IS_PATH(*i)) {
path = SP_PATH(*i);
curve = path->getCurve();
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 63e2460ec..f3185649b 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -11,11 +11,10 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm.h>
-#include <gdk/gdkkeysyms.h>
#include <boost/none_t.hpp>
#include "util/units.h"
#include "display/curve.h"
@@ -23,7 +22,6 @@
#include "display/sp-ctrlline.h"
#include "display/sp-ctrlcurve.h"
#include "display/sp-canvas.h"
-#include "display/sp-canvas-item.h"
#include "display/sp-canvas-util.h"
#include "svg/svg.h"
#include "svg/svg-color.h"
@@ -31,34 +29,20 @@
#include "ui/tools/freehand-base.h"
#include <2geom/line.h>
#include <2geom/path-intersection.h>
-#include <2geom/pathvector.h>
-#include <2geom/crossing.h>
-#include <2geom/angle.h>
-#include <2geom/transforms.h>
#include "ui/dialog/knot-properties.h"
#include "sp-namedview.h"
-#include "sp-shape.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "sp-defs.h"
-#include "sp-item.h"
#include "sp-root.h"
-#include "macros.h"
#include "svg/stringstream.h"
#include "rubberband.h"
#include "path-chemistry.h"
#include "desktop.h"
-#include "document.h"
#include "document-undo.h"
-#include "viewbox.h"
-#include "snap.h"
-#include "knot.h"
#include "text-editing.h"
#include "pixmaps/cursor-measure.xpm"
-#include "preferences.h"
#include "inkscape.h"
-#include "enums.h"
-#include "knot-enums.h"
#include "desktop-style.h"
#include "verbs.h"
#include <glibmm/i18n.h>
@@ -394,6 +378,10 @@ MeasureTool::~MeasureTool()
sp_canvas_item_destroy(measure_tmp_items[idx]);
}
measure_tmp_items.clear();
+ for (size_t idx = 0; idx < measure_item.size(); ++idx) {
+ sp_canvas_item_destroy(measure_item[idx]);
+ }
+ measure_item.clear();
for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) {
sp_canvas_item_destroy(measure_phantom_items[idx]);
}
@@ -607,6 +595,12 @@ bool MeasureTool::root_handler(GdkEvent* event)
snap_manager.preSnap(scp);
snap_manager.unSetup();
}
+ Geom::Point const motion_w(event->motion.x, event->motion.y);
+ if(event->motion.state & GDK_SHIFT_MASK) {
+ showInfoBox(motion_w, true);
+ } else {
+ showInfoBox(motion_w, false);
+ }
} else {
ret = TRUE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -1127,6 +1121,108 @@ void MeasureTool::setMeasureCanvasControlLine(Geom::Point start, Geom::Point end
}
}
+void MeasureTool::showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize)
+{
+ SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(),
+ desktop,
+ pos,
+ measure_str);
+ sp_canvastext_set_fontsize(canvas_tooltip, fontsize);
+ canvas_tooltip->rgba = 0xffffffff;
+ canvas_tooltip->outline = false;
+ canvas_tooltip->background = true;
+ canvas_tooltip->anchor_position = TEXT_ANCHOR_LEFT;
+ canvas_tooltip->rgba_background = 0x00000099;
+ measure_item.push_back(SP_CANVAS_ITEM(canvas_tooltip));
+ sp_canvas_item_show(SP_CANVAS_ITEM(canvas_tooltip));
+}
+
+void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit();
+ for (size_t idx = 0; idx < measure_item.size(); ++idx) {
+ sp_canvas_item_destroy(measure_item[idx]);
+ }
+ measure_item.clear();
+
+ SPItem *newover = desktop->getItemAtPoint(cursor, into_groups);
+ if (newover) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0);
+ double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0;
+ int precision = prefs->getInt("/tools/measure/precision", 2);
+ Glib::ustring unit_name = prefs->getString("/tools/measure/unit");
+ if (!unit_name.compare("")) {
+ unit_name = "px";
+ }
+ Geom::Scale zoom = Geom::Scale(Inkscape::Util::Quantity::convert(desktop->current_zoom(), "px", unit->abbr)).inverse();
+ if(newover != over){
+ over = newover;
+ Preferences *prefs = Preferences::get();
+ int prefs_bbox = prefs->getBool("/tools/bounding_box", 0);
+ SPItem::BBoxType bbox_type = !prefs_bbox ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
+ Geom::OptRect bbox = over->bounds(bbox_type);
+ if (bbox) {
+
+ item_width = Inkscape::Util::Quantity::convert((*bbox).width() * scale, unit->abbr, unit_name);
+ item_height = Inkscape::Util::Quantity::convert((*bbox).height() * scale, unit->abbr, unit_name);
+ item_x = Inkscape::Util::Quantity::convert((*bbox).left(), unit->abbr, unit_name);
+ Geom::Point y_point(0,Inkscape::Util::Quantity::convert((*bbox).bottom() * scale, unit->abbr, "px"));
+ y_point *= desktop->doc2dt();
+ item_y = Inkscape::Util::Quantity::convert(y_point[Geom::Y] * scale, "px", unit_name);
+ if (SP_IS_SHAPE(over)) {
+ Geom::PathVector shape = SP_SHAPE(over)->getCurve()->get_pathvector();
+ item_length = Geom::length(paths_to_pw(shape));
+ item_length = Inkscape::Util::Quantity::convert(item_length * scale, unit->abbr, unit_name);
+ }
+ }
+ }
+ gchar *measure_str = NULL;
+ std::stringstream precision_str;
+ precision_str.imbue(std::locale::classic());
+ double origin = Inkscape::Util::Quantity::convert(14, "px", unit->abbr);
+ Geom::Point rel_position = Geom::Point(origin, origin);
+ Geom::Point pos = desktop->w2d(cursor);
+ double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr);
+ if (SP_IS_SHAPE(over)) {
+ precision_str << _("Length") << ": %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+ } else if (SP_IS_GROUP(over)) {
+ measure_str = _("Shift to measure into group");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+ }
+
+ precision_str << "Y: %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_y, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+
+ precision_str << "X: %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_x, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+
+ precision_str << _("Height") << ": %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_height, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap);
+
+ precision_str << _("Width") << ": %." << precision << "f %s";
+ measure_str = g_strdup_printf(precision_str.str().c_str(), item_width, unit_name.c_str());
+ precision_str.str("");
+ showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize);
+ g_free(measure_str);
+ }
+}
+
void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, Inkscape::XML::Node *measure_repr)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
diff --git a/src/ui/tools/measure-tool.h b/src/ui/tools/measure-tool.h
index 14fc9f81a..42122dca1 100644
--- a/src/ui/tools/measure-tool.h
+++ b/src/ui/tools/measure-tool.h
@@ -54,6 +54,8 @@ public:
virtual void setMarker(bool isStart);
virtual const std::string& getPrefsPath();
Geom::Point readMeasurePoint(bool is_start);
+ void showInfoBox(Geom::Point cursor, bool into_groups);
+ void showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize);
void writeMeasurePoint(Geom::Point point, bool is_start);
void setGuide(Geom::Point origin, double angle, const char *label);
void setPoint(Geom::Point origin, Inkscape::XML::Node *measure_repr);
@@ -77,6 +79,13 @@ private:
Geom::Point end_p;
std::vector<SPCanvasItem *> measure_tmp_items;
std::vector<SPCanvasItem *> measure_phantom_items;
+ std::vector<SPCanvasItem *> measure_item;
+ double item_width;
+ double item_height;
+ double item_x;
+ double item_y;
+ double item_length;
+ SPItem *over;
sigc::connection _knot_start_moved_connection;
sigc::connection _knot_start_ungrabbed_connection;
sigc::connection _knot_start_click_connection;
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index 47927667c..aac8239f3 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
//#define DEBUG_MESH
@@ -33,7 +33,6 @@
#include "macros.h"
#include "message-context.h"
#include "message-stack.h"
-#include "preferences.h"
#include "rubberband.h"
#include "selection.h"
#include "snap.h"
@@ -48,7 +47,7 @@
// Mesh specific
#include "ui/tools/mesh-tool.h"
-#include "sp-mesh.h"
+#include "sp-mesh-gradient.h"
#include "display/sp-ctrlcurve.h"
using Inkscape::DocumentUndo;
@@ -103,7 +102,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
return;
}
- guint n_obj = selection->itemList().size();
+ guint n_obj = (guint) boost::distance(selection->items());
if (!drag->isNonEmpty() || selection->isEmpty()) {
return;
@@ -162,9 +161,9 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
// if (style && (style->fill.isPaintserver())) {
// SPPaintServer *server = item->style->getFillPaintServer();
- // if ( SP_IS_MESH(server) ) {
+ // if ( SP_IS_MESHGRADIENT(server) ) {
- // SPMesh *mg = SP_MESH(server);
+ // SPMeshGradient *mg = SP_MESHGRADIENT(server);
// guint rows = 0;//mg->array.patches.size();
// for ( guint i = 0; i < rows; ++i ) {
@@ -266,14 +265,18 @@ sp_mesh_context_select_prev (ToolBase *event_context)
Returns true if mouse cursor over mesh edge.
*/
static bool
-sp_mesh_context_is_over_line (MeshTool *rc, SPItem *item, Geom::Point event_p)
+sp_mesh_context_is_over_line (MeshTool *rc, SPCtrlLine *line, Geom::Point event_p)
{
+ if (!SP_IS_CTRLCURVE(line) ) {
+ return false;
+ }
+
SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
//Translate mouse point into proper coord system
rc->mousepoint_doc = desktop->w2d(event_p);
- SPCtrlCurve *curve = SP_CTRLCURVE(item);
+ SPCtrlCurve *curve = SP_CTRLCURVE(line);
Geom::BezierCurveN<3> b( curve->p0, curve->p1, curve->p2, curve->p3 );
Geom::Coord coord = b.nearestTime( rc->mousepoint_doc ); // Coord == double
Geom::Point nearest = b( coord );
@@ -327,8 +330,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
- std::map<SPMesh*, std::vector<guint> > points;
- std::map<SPMesh*, SPItem*> items;
+ std::map<SPMeshGradient*, std::vector<guint> > points;
+ std::map<SPMeshGradient*, SPItem*> items;
// Get list of selected draggers for each mesh.
// For all selected draggers
@@ -342,7 +345,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
if( d->point_type != POINT_MG_CORNER ) continue;
// Find the gradient
- SPMesh *gradient = SP_MESH( getGradient (d->item, d->fill_or_stroke) );
+ SPMeshGradient *gradient = SP_MESHGRADIENT( getGradient (d->item, d->fill_or_stroke) );
// Collect points together for same gradient
points[gradient].push_back( d->point_i );
@@ -351,8 +354,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
}
// Loop over meshes.
- for( std::map<SPMesh*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
- SPMesh *mg = SP_MESH( iter->first );
+ for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) {
+ SPMeshGradient *mg = SP_MESHGRADIENT( iter->first );
if( iter->second.size() > 0 ) {
guint noperation = 0;
switch (operation) {
@@ -426,6 +429,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
/**
Handles all keyboard and mouse input for meshs.
+Note: node/handle events are take care of elsewhere.
*/
bool MeshTool::root_handler(GdkEvent* event) {
static bool dragging;
@@ -455,23 +459,21 @@ bool MeshTool::root_handler(GdkEvent* event) {
if ( event->button.button == 1 ) {
// Are we over a mesh line?
bool over_line = false;
- SPCtrlCurve *line = NULL;
if (! drag->lines.empty()) {
for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) {
- line = (SPCtrlCurve*) (*l);
- over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y));
+ over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y));
}
}
if (over_line) {
// We take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time);
+ sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time);
} else {
// Create a new gradient with default coordinates.
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPItem *item = *i;
SPGradientType new_type = SP_GRADIENT_TYPE_MESH;
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -595,7 +597,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
if (!drag->lines.empty()) {
for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; ++l) {
- over_line |= sp_mesh_context_is_over_line (this, (SPItem*)(*l), Geom::Point(event->motion.x, event->motion.y));
+ over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y));
}
}
@@ -626,8 +628,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
if (!drag->lines.empty()) {
for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) {
- line = (SPCtrlLine*)(*l);
- over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y));
+ over_line = sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y));
if (over_line) {
break;
@@ -926,6 +927,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
return ret;
}
+// Creates a new mesh gradient.
static void sp_mesh_end_drag(MeshTool &rc) {
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
Inkscape::Selection *selection = desktop->getSelection();
@@ -945,7 +947,7 @@ static void sp_mesh_end_drag(MeshTool &rc) {
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- std::vector<SPItem*> items(selection->itemList());
+ std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
sort(items.begin(),items.end(),sp_item_repr_compare_position);
// take topmost
vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
@@ -955,8 +957,8 @@ static void sp_mesh_end_drag(MeshTool &rc) {
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end();++i){
//FIXME: see above
sp_repr_css_change_recursive((*i)->getRepr(), css, "style");
@@ -972,7 +974,7 @@ static void sp_mesh_end_drag(MeshTool &rc) {
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = selection->itemList().size();
+ int n_objects = (int) boost::distance(selection->items());
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle",
"<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects),
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 23aaf6bb1..2bd4fdea3 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -24,25 +24,19 @@
#include "message-context.h"
#include "selection.h"
#include "ui/shape-editor.h" // temporary!
-#include "live_effects/effect.h"
-#include "display/curve.h"
#include "snap.h"
#include "sp-namedview.h"
#include "sp-clippath.h"
#include "sp-item-group.h"
#include "sp-mask.h"
-#include "sp-object-group.h"
-#include "sp-path.h"
#include "sp-text.h"
#include "ui/control-manager.h"
#include "ui/tools/node-tool.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
-#include "ui/tool/manipulator.h"
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/path-manipulator.h"
#include "ui/tool/selector.h"
-#include "ui/tool/shape-record.h"
#include "pixmaps/cursor-node.xpm"
#include "pixmaps/cursor-node-d.xpm"
@@ -250,7 +244,6 @@ void NodeTool::setup() {
this->flash_tempitem = NULL;
this->flashed_item = NULL;
this->_last_over = NULL;
- this->helperpath_tmpitem = NULL;
// read prefs before adding items to selection to prevent momentarily showing the outline
sp_event_context_read(this, "show_handles");
@@ -311,7 +304,7 @@ void NodeTool::update_helperpath () {
cc->reset();
}
if (!c->is_empty()) {
- SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c);
+ SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath), 0x0000ff9A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath), 0, SP_WIND_RULE_NONZERO);
sp_canvas_item_affine_absolute(helperpath, selection->singleItem()->i2dt_affine());
@@ -378,8 +371,8 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape
r.role = role;
s.insert(r);
} else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) {
- for (SPObject *c = obj->children; c; c = c->next) {
- gather_items(nt, base, c, role, s);
+ for (auto& c: obj->children) {
+ gather_items(nt, base, &c, role, s);
}
} else if (SP_IS_ITEM(obj)) {
SPItem *item = static_cast<SPItem*>(obj);
@@ -407,8 +400,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
std::set<ShapeRecord> shapes;
- std::vector<SPItem*> items=sel->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ auto items= sel->items();
+ for(auto i=items.begin();i!=items.end();++i){
SPObject *obj = *i;
if (SP_IS_ITEM(obj)) {
@@ -443,8 +436,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
}
}
+ std::vector<SPItem *> vec(sel->items().begin(), sel->items().end());
_previous_selection = _current_selection;
- _current_selection = sel->itemList();
+ _current_selection = vec;
this->_multipath->setItems(shapes);
this->update_tip(NULL);
@@ -473,13 +467,10 @@ bool NodeTool::root_handler(GdkEvent* event) {
if (this->_selected_nodes->event(this, event)) {
return true;
}
-
switch (event->type)
{
case GDK_MOTION_NOTIFY: {
- this->update_helperpath();
combine_motion_events(desktop->canvas, event->motion, 0);
- this->update_helperpath();
SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button),
FALSE, TRUE);
@@ -532,7 +523,7 @@ bool NodeTool::root_handler(GdkEvent* event) {
}
c->transform(over_item->i2dt_affine());
- SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c);
+ SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash),
//prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0,
@@ -634,7 +625,6 @@ bool NodeTool::root_handler(GdkEvent* event) {
void NodeTool::update_tip(GdkEvent *event) {
using namespace Inkscape::UI;
-
if (event && (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)) {
unsigned new_state = state_after_event(event);
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 18af8e105..b7579b1fb 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -32,8 +32,6 @@
#include "ui/draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
-#include "preferences.h"
-#include "sp-path.h"
#include "display/sp-canvas.h"
#include "display/curve.h"
#include "pixmaps/cursor-pen.xpm"
@@ -46,7 +44,6 @@
#include "ui/tools-switch.h"
#include "ui/control-manager.h"
// we include the necessary files for BSpline & Spiro
-#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
@@ -54,25 +51,16 @@
#include "live_effects/lpe-spiro.h"
-#include <typeinfo>
-#include <2geom/pathvector.h>
-#include <2geom/affine.h>
#include <2geom/curves.h>
#include "helper/geom-nodetype.h"
-#include "helper/geom-curves.h"
// For handling un-continuous paths:
-#include "message-stack.h"
#include "inkscape.h"
-#include "desktop.h"
#include "live_effects/spiro.h"
#define INKSCAPE_LPE_BSPLINE_C
#include "live_effects/lpe-bspline.h"
-#include <2geom/nearest-time.h>
-
-#include "live_effects/effect.h"
using Inkscape::ControlManager;
@@ -877,7 +865,7 @@ void PenTool::_redrawAll() {
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->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);
@@ -889,7 +877,7 @@ void PenTool::_redrawAll() {
this->red_curve->reset();
this->red_curve->moveto(this->p[0]);
this->red_curve->curveto(this->p[1], this->p[2], this->p[3]);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
// handles
// hide the handlers in bspline and spiro modes
@@ -1263,10 +1251,10 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
void PenTool::_resetColors() {
// Red
this->red_curve->reset();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL, true);
// Blue
this->blue_curve->reset();
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL);
+ 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));
@@ -1289,7 +1277,7 @@ void PenTool::_setInitialPoint(Geom::Point const p) {
this->p[0] = p;
this->p[1] = p;
this->npoints = 2;
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL, true);
this->desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
@@ -1355,7 +1343,7 @@ void PenTool::_bsplineSpiroColor()
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
// one canvas bpath for all of green_curve
- SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->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);
@@ -1713,7 +1701,7 @@ void PenTool::_bsplineSpiroBuild()
}else{
this->red_curve->curveto(this->p[1],this->p[2],this->p[3]);
}
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
curve->append_continuous(this->red_curve, 0.0625);
}
@@ -1734,7 +1722,7 @@ void PenTool::_bsplineSpiroBuild()
LivePathEffect::sp_spiro_do_effect(curve);
}
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_show(this->blue_bpath);
curve->unref();
@@ -1790,7 +1778,7 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta
}
}
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
if (statusbar) {
gchar *message = is_curve ?
@@ -1830,7 +1818,7 @@ void PenTool::_setCtrl(Geom::Point const p, guint const state) {
this->red_curve->reset();
this->red_curve->moveto(this->p[0]);
this->red_curve->curveto(this->p[1], this->p[2], this->p[3]);
- sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve);
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true);
}
SP_CTRL(this->c0)->moveto(this->p[2]);
this->cl0 ->setCoords(this->p[3], this->p[2]);
@@ -1862,7 +1850,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
+ SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve, true);
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);
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index b029ca613..9e8005be8 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -27,7 +27,6 @@
#include "message-stack.h"
#include "message-context.h"
#include "sp-path.h"
-#include "preferences.h"
#include "snap.h"
#include "pixmaps/cursor-pencil.xpm"
#include <2geom/sbasis-to-bezier.h>
@@ -36,13 +35,9 @@
#include <glibmm/i18n.h>
#include "context-fns.h"
#include "sp-namedview.h"
-#include "xml/repr.h"
-#include "document.h"
#include "desktop-style.h"
-#include "macros.h"
#include "display/sp-canvas.h"
#include "display/curve.h"
-#include "livarot/Path.h"
#include "ui/tool/event-utils.h"
namespace Inkscape {
@@ -852,7 +847,7 @@ void PencilTool::_fitAndSplit() {
SPCurve *curve = this->red_curve->copy();
/// \todo fixme:
- SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve);
+ SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve, true);
curve->unref();
this->highlight_color = SP_ITEM(this->desktop->currentLayer())->highlight_color();
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 844965c4d..00330ef57 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -14,8 +14,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <gdk/gdkkeysyms.h>
#include <cstring>
#include <string>
@@ -29,16 +27,13 @@
#include "selection.h"
#include "selection-chemistry.h"
-#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-rect.xpm"
#include "ui/tools/rect-tool.h"
#include <glibmm/i18n.h>
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "preferences.h"
#include "context-fns.h"
#include "ui/shape-editor.h"
#include "verbs.h"
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index b5ec3d88e..86a2dbed3 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <cstring>
#include <string>
@@ -40,14 +40,12 @@
#include "desktop.h"
#include "sp-root.h"
-#include "preferences.h"
#include "ui/tools-switch.h"
#include "message-stack.h"
#include "selection-describer.h"
#include "seltrans.h"
#include "box3d.h"
#include "display/sp-canvas.h"
-#include "display/sp-canvas-item.h"
#include "display/drawing-item.h"
using Inkscape::DocumentUndo;
@@ -128,20 +126,12 @@ SelectTool::~SelectTool() {
this->_describer = NULL;
if (CursorSelectDragging) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(CursorSelectDragging);
-#else
- gdk_cursor_unref (CursorSelectDragging);
-#endif
CursorSelectDragging = NULL;
}
if (CursorSelectMouseover) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(CursorSelectMouseover);
-#else
- gdk_cursor_unref (CursorSelectMouseover);
-#endif
CursorSelectMouseover = NULL;
}
}
@@ -477,7 +467,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_2BUTTON_PRESS:
if (event->button.button == 1) {
if (!selection->isEmpty()) {
- SPItem *clicked_item = selection->itemList()[0];
+ SPItem *clicked_item = selection->items().front();
if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box
desktop->setCurrentLayer(clicked_item);
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index 833fef18d..0ba08853e 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -14,8 +14,6 @@
* Released under GNU GPL
*/
-#include "config.h"
-
#include <gdk/gdkkeysyms.h>
#include <cstring>
#include <string>
@@ -28,16 +26,13 @@
#include "sp-namedview.h"
#include "selection.h"
-#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-spiral.xpm"
#include "ui/tools/spiral-tool.h"
#include <glibmm/i18n.h>
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
-#include "preferences.h"
#include "context-fns.h"
#include "ui/shape-editor.h"
#include "verbs.h"
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 9adaf3879..3649008ff 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -13,21 +13,19 @@
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
* Jabiertxo Arraiza <jabier.arraiza@marker.es>
+ * Adrian Boguszewski
*
* Copyright (C) 2009 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <numeric>
#include "ui/dialog/dialog-manager.h"
#include "svg/svg.h"
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "document-undo.h"
@@ -37,10 +35,7 @@
#include "message-context.h"
#include "pixmaps/cursor-spray.xpm"
-#include <boost/optional.hpp>
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
#include "inkscape.h"
#include "splivarot.h"
@@ -57,17 +52,12 @@
#include "svg/svg-color.h"
#include "sp-text.h"
-#include "sp-root.h"
#include "sp-flowtext.h"
#include "display/sp-canvas.h"
-#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "display/curve.h"
#include "livarot/Shape.h"
#include <2geom/circle.h>
-#include <2geom/transforms.h>
-#include "preferences.h"
-#include "style.h"
#include "box3d.h"
#include "sp-item-transform.h"
#include "filter-chemistry.h"
@@ -76,9 +66,6 @@
#include "helper/action.h"
#include "verbs.h"
-#include <iostream>
-
-#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -196,6 +183,7 @@ SprayTool::SprayTool()
}
SprayTool::~SprayTool() {
+ object_set.clear();
this->enableGrDrag(false);
this->style_set_connection.disconnect();
@@ -210,7 +198,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -591,7 +579,7 @@ static bool fit_item(SPDesktop *desktop,
if (selection->isEmpty()) {
return false;
}
- std::vector<SPItem*> const items_selected(selection->itemList());
+ std::vector<SPItem*> const items_selected(selection->items().begin(), selection->items().end());
std::vector<SPItem*> items_down_erased;
for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) {
SPItem *item_down = *i;
@@ -862,7 +850,7 @@ static bool fit_item(SPDesktop *desktop,
}
static bool sp_spray_recursive(SPDesktop *desktop,
- Inkscape::Selection *selection,
+ Inkscape::ObjectSet *set,
SPItem *item,
Geom::Point p,
Geom::Point /*vector*/,
@@ -907,7 +895,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
if (box) {
// convert 3D boxes to ordinary groups before spraying their shapes
item = box3d_convert_to_group(box);
- selection->add(item);
+ set->add(item);
}
}
@@ -996,23 +984,11 @@ static bool sp_spray_recursive(SPDesktop *desktop,
}
#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
} else if (mode == SPRAY_MODE_SINGLE_PATH) {
+ long setSize = boost::distance(set->items());
+ SPItem *parent_item = setSize > 0 ? set->items().front() : nullptr; // Initial object
+ SPItem *unionResult = setSize > 1 ? *(++set->items().begin()) : nullptr; // Previous union
+ SPItem *item_copied = nullptr; // Projected object
- SPItem *parent_item = NULL; // Initial object
- SPItem *item_copied = NULL; // Projected object
- SPItem *unionResult = NULL; // Previous union
-
- int i=1;
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end(); ++it){
- SPItem *item1 = *it;
- if (i == 1) {
- parent_item = item1;
- }
- if (i == 2) {
- unionResult = item1;
- }
- i++;
- }
if (parent_item) {
SPDocument *doc = parent_item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
@@ -1045,13 +1021,13 @@ static bool sp_spray_recursive(SPDesktop *desktop,
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
// Union and duplication
- selection->clear();
- selection->add(item_copied);
+ set->clear();
+ set->add(item_copied);
if (unionResult) { // No need to add the very first item (initialized with NULL).
- selection->add(unionResult);
+ set->add(unionResult);
}
- sp_selected_path_union_skip_undo(selection, selection->desktop());
- selection->add(parent_item);
+ sp_selected_path_union_skip_undo(set);
+ set->add(parent_item);
Inkscape::GC::release(copy);
did = true;
}
@@ -1146,9 +1122,8 @@ static bool sp_spray_recursive(SPDesktop *desktop,
static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
SPDesktop *desktop = tc->desktop;
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty()) {
+ Inkscape::ObjectSet *set = tc->objectSet();
+ if (set->isEmpty()) {
return false;
}
@@ -1170,7 +1145,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
double move_standard_deviation = get_move_standard_deviation(tc);
{
- std::vector<SPItem*> const items(selection->itemList());
+ std::vector<SPItem*> const items(set->items().begin(), set->items().end());
for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
SPItem *item = *i;
@@ -1182,7 +1157,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
SPItem *item = *i;
g_assert(item != NULL);
if (sp_spray_recursive(desktop
- , selection
+ , set
, item
, p, vector
, tc->mode
@@ -1276,6 +1251,11 @@ bool SprayTool::root_handler(GdkEvent* event) {
this->is_dilating = true;
this->has_dilated = false;
+ object_set = *desktop->getSelection();
+ if (mode == SPRAY_MODE_SINGLE_PATH) {
+ desktop->getSelection()->clear();
+ }
+
if(this->is_dilating && event->button.button == 1 && !this->space_panning) {
sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event));
}
@@ -1299,7 +1279,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray."));
@@ -1384,6 +1364,8 @@ bool SprayTool::root_handler(GdkEvent* event) {
SP_VERB_CONTEXT_SPRAY, _("Spray with clones"));
break;
case SPRAY_MODE_SINGLE_PATH:
+ sp_selected_path_union_skip_undo(objectSet());
+ desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end());
DocumentUndo::done(this->desktop->getDocument(),
SP_VERB_CONTEXT_SPRAY, _("Spray in single path"));
break;
diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h
index c81110b37..d5504d565 100644
--- a/src/ui/tools/spray-tool.h
+++ b/src/ui/tools/spray-tool.h
@@ -13,6 +13,7 @@
* Vincent MONTAGNE
* Pierre BARBRY-BLOT
* Jabiertxo ARRAIZA
+ * Adrian Boguszewski
*
* Copyright (C) 2009 authors
*
@@ -120,8 +121,14 @@ public:
virtual const std::string& getPrefsPath();
-
void update_cursor(bool /*with_shift*/);
+
+ ObjectSet* objectSet() {
+ return &object_set;
+ }
+
+private:
+ ObjectSet object_set;
};
}
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index 9190ae57b..ddee08189 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <cstring>
@@ -31,14 +31,11 @@
#include "sp-namedview.h"
#include "selection.h"
-#include "snap.h"
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-star.xpm"
#include <glibmm/i18n.h>
-#include "preferences.h"
-#include "xml/repr.h"
#include "xml/node-event-vector.h"
#include "context-fns.h"
#include "ui/shape-editor.h"
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 1888551cf..559187764 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -14,7 +14,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include <config.h>
+#include <config.h>
#endif
#include <gtkmm/clipboard.h>
@@ -23,7 +23,6 @@
#include <display/sp-ctrlquadr.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
-#include <sstream>
#include "context-fns.h"
@@ -36,7 +35,6 @@
#include "message-stack.h"
#include "pixmaps/cursor-text-insert.xpm"
#include "pixmaps/cursor-text.xpm"
-#include "preferences.h"
#include "rubberband.h"
#include "selection-chemistry.h"
#include "selection.h"
@@ -50,8 +48,6 @@
#include "ui/control-manager.h"
#include "verbs.h"
#include "xml/node-event-vector.h"
-#include "xml/repr.h"
-#include <gtk/gtk.h>
using Inkscape::ControlManager;
using Inkscape::DocumentUndo;
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 72ba499de..8a35882b9 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include "widgets/desktop-widget.h"
@@ -24,12 +24,8 @@
#include "file.h"
#include "ui/tools/tool-base.h"
-#include <string.h>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtk.h>
#include <glibmm/i18n.h>
-#include <cstring>
-#include <string>
#include "display/sp-canvas.h"
#include "xml/node-event-vector.h"
@@ -43,18 +39,14 @@
#include "ui/interface.h"
#include "macros.h"
#include "ui/tools-switch.h"
-#include "preferences.h"
#include "message-context.h"
#include "gradient-drag.h"
-#include "attributes.h"
#include "rubberband.h"
#include "selcue.h"
#include "ui/tools/lpe-tool.h"
#include "ui/tool/control-point.h"
#include "ui/shape-editor.h"
#include "sp-guide.h"
-#include "color.h"
-#include "knot.h"
#include "knot-ptr.h"
// globals for temporary switching to selector by space
@@ -118,11 +110,7 @@ ToolBase::~ToolBase() {
}
if (this->cursor != NULL) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor);
-#else
- gdk_cursor_unref(this->cursor);
-#endif
this->cursor = NULL;
}
@@ -149,16 +137,10 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) {
GdkDisplay *display = gdk_display_get_default();
GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type);
-#if WITH_GTKMM_3_0
if (cursor) {
gdk_window_set_cursor (gtk_widget_get_window (w), cursor);
g_object_unref (cursor);
}
-#else
- gdk_window_set_cursor (gtk_widget_get_window (w), cursor);
- gdk_cursor_unref (cursor);
-#endif
-
}
/**
@@ -188,11 +170,7 @@ void ToolBase::sp_event_context_update_cursor() {
);
if (pixbuf != NULL) {
if (this->cursor) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor);
-#else
- gdk_cursor_unref(this->cursor);
-#endif
}
this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y);
g_object_unref(pixbuf);
@@ -202,11 +180,7 @@ void ToolBase::sp_event_context_update_cursor() {
if (pixbuf) {
if (this->cursor) {
-#if GTK_CHECK_VERSION(3,0,0)
g_object_unref(this->cursor);
-#else
- gdk_cursor_unref(this->cursor);
-#endif
}
this->cursor = gdk_cursor_new_from_pixbuf(display,
pixbuf, this->hot_x, this->hot_y);
@@ -777,11 +751,9 @@ bool ToolBase::root_handler(GdkEvent* event) {
int const wheel_scroll = prefs->getIntLimited(
"/options/wheelscroll/value", 40, 0, 1000);
-#if GTK_CHECK_VERSION(3,0,0)
// Size of smooth-scrolls (only used in GTK+ 3)
gdouble delta_x = 0;
gdouble delta_y = 0;
-#endif
/* shift + wheel, pan left--right */
if (event->scroll.state & GDK_SHIFT_MASK) {
@@ -842,12 +814,10 @@ bool ToolBase::root_handler(GdkEvent* event) {
desktop->scroll_world(-wheel_scroll, 0);
break;
-#if GTK_CHECK_VERSION(3,0,0)
case GDK_SCROLL_SMOOTH:
gdk_event_get_scroll_deltas(event, &delta_x, &delta_y);
desktop->scroll_world(delta_x, delta_y);
break;
-#endif
}
}
break;
@@ -1081,9 +1051,8 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
item = sp_event_context_find_item (desktop,
Geom::Point(event->button.x, event->button.y), FALSE, FALSE);
- /* fixme: This is not what I want but works for now (Lauris) */
- if (event->type == GDK_KEY_PRESS) {
- item = desktop->getSelection()->itemList().front();
+ if (event->type == GDK_KEY_PRESS && !desktop->getSelection()->isEmpty()) {
+ item = desktop->getSelection()->items().front();
}
ContextMenu* CM = new ContextMenu(desktop, item);
@@ -1157,8 +1126,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p,
SPItem *item = 0;
if (select_under) {
- SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(
- desktop->selection->itemList(), p);
+ auto tmp = desktop->selection->items();
+ std::vector<SPItem *> vec(tmp.begin(), tmp.end());
+ SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(vec, p);
item = desktop->getItemAtPoint(p, into_groups, selected_at_point);
if (item == NULL) { // we may have reached bottom, flip over to the top
item = desktop->getItemAtPoint(p, into_groups, NULL);
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 39a7a3f0b..a0394ecd4 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -11,8 +11,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
-
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glibmm/i18n.h>
@@ -21,7 +19,6 @@
#include "svg/svg.h"
-#include <glib.h>
#include "macros.h"
#include "document.h"
#include "document-undo.h"
@@ -48,19 +45,13 @@
#include "pixmaps/cursor-push.xpm"
#include "pixmaps/cursor-roughen.xpm"
#include "pixmaps/cursor-color.xpm"
-#include <boost/optional.hpp>
-#include "xml/repr.h"
#include "context-fns.h"
-#include "sp-item.h"
#include "inkscape.h"
-#include "color.h"
-#include "svg/svg-color.h"
#include "splivarot.h"
#include "sp-item-group.h"
#include "sp-shape.h"
#include "sp-path.h"
#include "path-chemistry.h"
-#include "sp-gradient.h"
#include "sp-stop.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient.h"
@@ -69,13 +60,10 @@
#include "sp-text.h"
#include "sp-flowtext.h"
#include "display/sp-canvas.h"
-#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
#include "display/curve.h"
#include "livarot/Shape.h"
-#include <2geom/transforms.h>
#include <2geom/circle.h>
-#include "preferences.h"
#include "style.h"
#include "box3d.h"
#include "sp-item-transform.h"
@@ -153,7 +141,7 @@ void TweakTool::update_cursor (bool with_shift) {
gchar *sel_message = NULL;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num);
} else {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
@@ -385,9 +373,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) {
GSList *children = NULL;
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- if (dynamic_cast<SPItem *>(static_cast<SPObject *>(child))) {
- children = g_slist_prepend(children, child);
+ for (auto& child: item->children) {
+ if (dynamic_cast<SPItem *>(static_cast<SPObject *>(&child))) {
+ children = g_slist_prepend(children, &child);
}
}
@@ -832,8 +820,8 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
double offset_l = 0;
double offset_h = 0;
SPObject *child_prev = NULL;
- for (SPObject *child = vector->firstChild(); child; child = child->getNext()) {
- SPStop *stop = dynamic_cast<SPStop *>(child);
+ for (auto& child: vector->children) {
+ SPStop *stop = dynamic_cast<SPStop *>(&child);
if (!stop) {
continue;
}
@@ -878,7 +866,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or
}
offset_l = offset_h;
- child_prev = child;
+ child_prev = &child;
}
}
@@ -894,8 +882,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
bool did = false;
if (dynamic_cast<SPGroup *>(item)) {
- for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) {
- SPItem *childItem = dynamic_cast<SPItem *>(child);
+ for (auto& child: item->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
if (childItem) {
if (sp_tweak_color_recursive (mode, childItem, item_at_point,
fill_goal, do_fill,
@@ -951,9 +939,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
Geom::Affine i2dt = item->i2dt_affine ();
if (style->filter.set && style->getFilter()) {
//cycle through filter primitives
- SPObject *primitive_obj = style->getFilter()->children;
- while (primitive_obj) {
- SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj);
+ for (auto& primitive_obj: style->getFilter()->children) {
+ SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj);
if (primitive) {
//if primitive is gaussianblur
SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive);
@@ -962,7 +949,6 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
blur_now += num * i2dt.descrim(); // sum all blurs in the filter
}
}
- primitive_obj = primitive_obj->next;
}
}
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y];
@@ -1076,8 +1062,8 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point
double move_force = get_move_force(tc);
double color_force = MIN(sqrt(path_force)/20.0, 1);
- std::vector<SPItem*> items=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){
+ auto items= selection->items();
+ for(auto i=items.begin();i!=items.end(); ++i){
SPItem *item = *i;
if (is_color_mode (tc->mode)) {
@@ -1185,7 +1171,7 @@ bool TweakTool::root_handler(GdkEvent* event) {
guint num = 0;
if (!desktop->selection->isEmpty()) {
- num = desktop->selection->itemList().size();
+ num = (guint) boost::distance(desktop->selection->items());
}
if (num == 0) {
this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak."));
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index 13e097c18..ca42d2d6f 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -21,7 +21,6 @@
#include "desktop.h"
#include "pixmaps/cursor-zoom.xpm"
#include "pixmaps/cursor-zoom-out.xpm"
-#include "preferences.h"
#include "selection-chemistry.h"
#include "ui/tools/zoom-tool.h"