From 2a3581c9a5e6d18b3cd0ea2fe523063a116af8f8 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 2 May 2016 09:47:14 +0200 Subject: Working on clip erase basic work done but broken (bzr r14865.1.1) --- src/ui/tools/eraser-tool.cpp | 109 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 15 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 6b32b5901..38e599c05 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -58,6 +58,8 @@ #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 "display/canvas-bpath.h" #include "display/canvas-arena.h" @@ -69,6 +71,7 @@ #include <2geom/math-utils.h> #include <2geom/pathvector.h> #include "path-chemistry.h" +#include "selection-chemistry.h" #include "display/curve.h" #include "ui/tools/eraser-tool.h" @@ -380,7 +383,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 +403,7 @@ bool EraserTool::root_handler(GdkEvent* event) { if (this->repr) { this->repr = NULL; } - if ( ! eraserMode ) { + if ( eraser_mode == 0 ) { Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); } @@ -448,7 +451,7 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } - if ( !eraserMode ) { + if ( eraser_mode == 0 ) { this->accumulated->reset(); Inkscape::Rubberband::get(desktop)->move(motion_dt); } @@ -491,7 +494,7 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } - if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) { + if (eraser_mode == 0 && Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->stop(); } @@ -578,7 +581,7 @@ bool EraserTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if ( !eraserMode ) { + if ( eraser_mode == 0 ) { Inkscape::Rubberband::get(desktop)->stop(); } if (this->is_drawing) { @@ -640,7 +643,9 @@ void EraserTool::clear_current() { void EraserTool::set_to_accumulated() { bool workDone = false; - + SPDocument *document = this->desktop->doc(); +// bool has_undo_sensitive = DocumentUndo::getUndoSensitive(document); +// DocumentUndo::setUndoSensitive(document, false); if (!this->accumulated->is_empty()) { if (!this->repr) { /* Create object */ @@ -666,7 +671,7 @@ void EraserTool::set_to_accumulated() { bool wasSelection = false; Inkscape::Selection *selection = desktop->getSelection(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; + gint eraser_mode = prefs->getInt("/tools/eraser/mode", 2); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr)); @@ -674,7 +679,7 @@ void EraserTool::set_to_accumulated() { std::vector remainingItems; std::vector toWorkOn; if (selection->isEmpty()) { - if ( eraserMode ) { + if ( eraser_mode == 1 || eraser_mode == 2) { toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox); } else { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); @@ -682,7 +687,7 @@ void EraserTool::set_to_accumulated() { } toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end()); } else { - if ( !eraserMode ) { + if ( eraser_mode == 0 ) { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); std::vector touched; touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); @@ -698,7 +703,7 @@ void EraserTool::set_to_accumulated() { } if ( !toWorkOn.empty() ) { - if ( eraserMode ) { + if ( eraser_mode == 1 ) { for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ SPItem *item = *i; SPUse *use = dynamic_cast(item); @@ -708,7 +713,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 { @@ -755,6 +759,81 @@ void EraserTool::set_to_accumulated() { } } } + } else if ( eraser_mode == 2 ) { + for (std::vector::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 *rect_repr = xml_doc->createElement("svg:rect"); + SPRect * rect = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr)); + rect->updateRepr(); + rect->setPosition (bbox.min()[Geom::X], bbox.min()[Geom::Y], bbox.dimensions()[Geom::X], bbox.dimensions()[Geom::Y]); + rect->doWriteTransform(rect_repr, SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse() * this->desktop->dt2doc()); + Inkscape::GC::release(rect_repr); + + + Inkscape::XML::Node *rect_repr2 = xml_doc->createElement("svg:rect"); + SPRect * rect2 = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr2)); + rect2->updateRepr(); + sp_desktop_apply_style_tool (desktop, rect_repr2, "/tools/shapes/rect", false); + rect2->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); + rect->doWriteTransform(rect_repr, SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse() * this->desktop->dt2doc()); + Inkscape::GC::release(rect_repr2); + + + Inkscape::XML::Node *rect_repr3 = xml_doc->createElement("svg:rect"); + SPRect * rect3 = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr3)); + rect3->updateRepr(); + sp_desktop_apply_style_tool (desktop, rect_repr3, "/tools/shapes/rect", false); + rect3->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); + rect->doWriteTransform(rect_repr3, SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse() * this->desktop->doc2dt()); + Inkscape::GC::release(rect_repr3); + + + + + + 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, this->desktop); + sp_selection_raise_to_top(selection, this->desktop); + if (bbox && bbox->intersects(*eraserBbox)) { + SPClipPath *clip_path = item->clip_ref->getObject(); + if (clip_path) { + SPObject *clip_data = clip_path->firstChild(); + Inkscape::XML::Node *dup_clip = clip_data->getRepr()->duplicate(xml_doc); + if (dup_clip) { + this->repr->parent()->appendChild(dup_clip); + sp_object_ref(clip_data, 0); + clip_data->deleteObject(true); + sp_object_unref(clip_data); + sp_selection_raise_to_top(selection, this->desktop); + selection->add(dup_clip); + } + } else { + selection->add(rect); + } + sp_selected_path_diff_skip_undo(selection, this->desktop); + sp_selection_raise_to_top(selection, this->desktop); + selection->add(item); + sp_selection_set_mask(this->desktop, true, false); + } 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) { + selection->setList(toWorkOn); + } } else { for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) { sp_object_ref( *i, 0 ); @@ -768,7 +847,7 @@ void EraserTool::set_to_accumulated() { } } - if ( !eraserMode ) { + if ( eraser_mode == 0 ) { //sp_selection_delete(desktop); remainingItems.clear(); } @@ -792,7 +871,7 @@ void EraserTool::set_to_accumulated() { } } - +// DocumentUndo::setUndoSensitive(document, has_undo_sensitive); if ( workDone ) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); } else { @@ -987,7 +1066,7 @@ 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); @@ -1009,7 +1088,7 @@ void EraserTool::fit_and_split(bool release) { this->segments = g_slist_prepend(this->segments, cbp); - if ( !eraserMode ) { + if ( eraser_mode == 0 ) { sp_canvas_item_hide(cbp); sp_canvas_item_hide(this->currentshape); } -- cgit v1.2.3 From c425407979c2eca1a6fe6858923619de18c8d058 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 6 May 2016 22:56:57 +0200 Subject: Finishing eraser tool. TODO undo work (bzr r14865.1.2) --- src/ui/tools/eraser-tool.cpp | 90 ++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 38e599c05..f1c7306b4 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -644,8 +644,6 @@ void EraserTool::clear_current() { void EraserTool::set_to_accumulated() { bool workDone = false; SPDocument *document = this->desktop->doc(); -// bool has_undo_sensitive = DocumentUndo::getUndoSensitive(document); -// DocumentUndo::setUndoSensitive(document, false); if (!this->accumulated->is_empty()) { if (!this->repr) { /* Create object */ @@ -657,11 +655,11 @@ void EraserTool::set_to_accumulated() { this->repr = repr; } - SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); + SPItem *item_repr = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); Inkscape::GC::release(this->repr); - item->updateRepr(); + item_repr->updateRepr(); Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc(); - pathv *= item->i2doc_affine().inverse(); + pathv *= item_repr->i2doc_affine().inverse(); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); this->repr->setAttribute("d", str); @@ -760,66 +758,68 @@ void EraserTool::set_to_accumulated() { } } } else if ( eraser_mode == 2 ) { + remainingItems.clear(); for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ selection->clear(); + size_t n_undo = 0; SPItem *item = *i; Geom::OptRect bbox = item->desktopVisualBounds(); Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); + sp_desktop_apply_style_tool (desktop, rect_repr, "/tools/eraser", false); SPRect * rect = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr)); - rect->updateRepr(); - rect->setPosition (bbox.min()[Geom::X], bbox.min()[Geom::Y], bbox.dimensions()[Geom::X], bbox.dimensions()[Geom::Y]); - rect->doWriteTransform(rect_repr, SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse() * this->desktop->dt2doc()); Inkscape::GC::release(rect_repr); - - Inkscape::XML::Node *rect_repr2 = xml_doc->createElement("svg:rect"); - SPRect * rect2 = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr2)); - rect2->updateRepr(); - sp_desktop_apply_style_tool (desktop, rect_repr2, "/tools/shapes/rect", false); - rect2->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); - rect->doWriteTransform(rect_repr, SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse() * this->desktop->dt2doc()); - Inkscape::GC::release(rect_repr2); - - - Inkscape::XML::Node *rect_repr3 = xml_doc->createElement("svg:rect"); - SPRect * rect3 = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr3)); - rect3->updateRepr(); - sp_desktop_apply_style_tool (desktop, rect_repr3, "/tools/shapes/rect", false); - rect3->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); - rect->doWriteTransform(rect_repr3, SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse() * this->desktop->doc2dt()); - Inkscape::GC::release(rect_repr3); - - - - - + rect->updateRepr(); + rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); + rect->transform = SP_ITEM(desktop->currentLayer())->i2dt_affine().inverse(); + 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, this->desktop); sp_selection_raise_to_top(selection, this->desktop); + n_undo++; if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { - SPObject *clip_data = clip_path->firstChild(); - Inkscape::XML::Node *dup_clip = clip_data->getRepr()->duplicate(xml_doc); - if (dup_clip) { - this->repr->parent()->appendChild(dup_clip); - sp_object_ref(clip_data, 0); - clip_data->deleteObject(true); - sp_object_unref(clip_data); - sp_selection_raise_to_top(selection, this->desktop); - selection->add(dup_clip); + SPPath *clip_data = SP_PATH(clip_path->firstChild()); + if (clip_data) { + Inkscape::XML::Node *dup_clip = SP_OBJECT(clip_data)->getRepr()->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_data, 0); + clip_data->deleteObject(true); + sp_object_unref(clip_data); + sp_object_ref(clip_path, 0); + clip_path->deleteObject(true); + sp_object_unref(clip_path); + sp_object_ref(rect, 0); + rect->deleteObject(true); + sp_object_unref(rect); + sp_selection_raise_to_top(selection, this->desktop); + n_undo++; + selection->add(dup_clip); + sp_selected_path_diff_skip_undo(selection, this->desktop); + n_undo++; + SPItem * clip = SP_ITEM(selection->itemList()[0]); + } + } } } else { selection->add(rect); + sp_selected_path_diff_skip_undo(selection, this->desktop); + n_undo++; } - sp_selected_path_diff_skip_undo(selection, this->desktop); sp_selection_raise_to_top(selection, this->desktop); + n_undo++; selection->add(item); sp_selection_set_mask(this->desktop, true, false); + n_undo++; + DocumentUndo::clearUndo(document, n_undo); } else { SPItem *erase_clip = selection->singleItem(); if (erase_clip) { @@ -829,11 +829,12 @@ void EraserTool::set_to_accumulated() { } } workDone = true; + selection->clear(); + if (wasSelection) { + remainingItems.push_back(item); + } } - selection->clear(); - if (wasSelection) { - selection->setList(toWorkOn); - } + } else { for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) { sp_object_ref( *i, 0 ); @@ -871,7 +872,6 @@ void EraserTool::set_to_accumulated() { } } -// DocumentUndo::setUndoSensitive(document, has_undo_sensitive); if ( workDone ) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); } else { -- cgit v1.2.3 From 72610e6bbd79b3a3e9a980980ebc2f533ea8056d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 7 May 2016 01:37:50 +0200 Subject: working on undo (bzr r14865.1.4) --- src/ui/tools/eraser-tool.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index f1c7306b4..b62f68a5f 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -721,7 +721,7 @@ 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(selection, desktop); } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ @@ -732,9 +732,9 @@ void EraserTool::set_to_accumulated() { css = 0; } if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection, desktop); + sp_selected_path_cut(selection, desktop); } else { - sp_selected_path_diff_skip_undo(selection, desktop); + sp_selected_path_diff(selection, desktop); } workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); @@ -761,7 +761,6 @@ void EraserTool::set_to_accumulated() { remainingItems.clear(); for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ selection->clear(); - size_t n_undo = 0; SPItem *item = *i; Geom::OptRect bbox = item->desktopVisualBounds(); Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); @@ -778,9 +777,8 @@ void EraserTool::set_to_accumulated() { this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(dup); - sp_selected_path_union_skip_undo(selection, this->desktop); + sp_selected_path_union(selection, this->desktop); sp_selection_raise_to_top(selection, this->desktop); - n_undo++; if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { @@ -801,25 +799,19 @@ void EraserTool::set_to_accumulated() { rect->deleteObject(true); sp_object_unref(rect); sp_selection_raise_to_top(selection, this->desktop); - n_undo++; selection->add(dup_clip); - sp_selected_path_diff_skip_undo(selection, this->desktop); - n_undo++; + sp_selected_path_diff(selection, this->desktop); SPItem * clip = SP_ITEM(selection->itemList()[0]); } } } } else { selection->add(rect); - sp_selected_path_diff_skip_undo(selection, this->desktop); - n_undo++; + sp_selected_path_diff(selection, this->desktop); } sp_selection_raise_to_top(selection, this->desktop); - n_undo++; selection->add(item); sp_selection_set_mask(this->desktop, true, false); - n_undo++; - DocumentUndo::clearUndo(document, n_undo); } else { SPItem *erase_clip = selection->singleItem(); if (erase_clip) { @@ -871,7 +863,6 @@ void EraserTool::set_to_accumulated() { this->repr = 0; } } - if ( workDone ) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); } else { -- cgit v1.2.3 From 2d2718e48ee56f975342f0329b98f892f118d85e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 00:03:52 +0200 Subject: Fixing undo thing (bzr r14865.1.5) --- src/ui/tools/eraser-tool.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b62f68a5f..60b8c2792 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -644,6 +644,8 @@ void EraserTool::clear_current() { void EraserTool::set_to_accumulated() { bool workDone = false; SPDocument *document = this->desktop->doc(); + bool saved = DocumentUndo::getUndoSensitive(document); + DocumentUndo::setUndoSensitive(document, false); if (!this->accumulated->is_empty()) { if (!this->repr) { /* Create object */ @@ -721,7 +723,9 @@ void EraserTool::set_to_accumulated() { Inkscape::GC::release(dup); // parent takes over selection->set(dup); if (!this->nowidth) { - sp_selected_path_union(selection, desktop); + DocumentUndo::setUndoSensitive(document, saved); + sp_selected_path_union_skip_undo(selection, desktop); + DocumentUndo::setUndoSensitive(document, false); } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ @@ -731,13 +735,16 @@ void EraserTool::set_to_accumulated() { sp_repr_css_attr_unref(css); css = 0; } + DocumentUndo::setUndoSensitive(document, saved); if (this->nowidth) { - sp_selected_path_cut(selection, desktop); + sp_selected_path_cut_skip_undo(selection, desktop); } else { - sp_selected_path_diff(selection, desktop); + sp_selected_path_diff_skip_undo(selection, desktop); } + DocumentUndo::setUndoSensitive(document, saved); workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); + DocumentUndo::setUndoSensitive(document, saved); if(!break_apart){ sp_selected_path_combine(desktop, true); } else { @@ -745,6 +752,7 @@ void EraserTool::set_to_accumulated() { sp_selected_path_break_apart(desktop, true); } } + DocumentUndo::setUndoSensitive(document, saved); if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); @@ -777,7 +785,9 @@ void EraserTool::set_to_accumulated() { this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(dup); - sp_selected_path_union(selection, this->desktop); + DocumentUndo::setUndoSensitive(document, saved); + sp_selected_path_union_skip_undo(selection, this->desktop); + DocumentUndo::setUndoSensitive(document, false); sp_selection_raise_to_top(selection, this->desktop); if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); @@ -800,14 +810,19 @@ void EraserTool::set_to_accumulated() { sp_object_unref(rect); sp_selection_raise_to_top(selection, this->desktop); selection->add(dup_clip); - sp_selected_path_diff(selection, this->desktop); + DocumentUndo::setUndoSensitive(document, saved); + sp_selected_path_diff_skip_undo(selection, this->desktop); + DocumentUndo::setUndoSensitive(document, saved); SPItem * clip = SP_ITEM(selection->itemList()[0]); + DocumentUndo::setUndoSensitive(document, false); } } } } else { selection->add(rect); - sp_selected_path_diff(selection, this->desktop); + DocumentUndo::setUndoSensitive(document, saved); + sp_selected_path_diff_skip_undo(selection, this->desktop); + DocumentUndo::setUndoSensitive(document, false); } sp_selection_raise_to_top(selection, this->desktop); selection->add(item); @@ -863,6 +878,8 @@ void EraserTool::set_to_accumulated() { this->repr = 0; } } + document->setModifiedSinceSave(); + DocumentUndo::setUndoSensitive(document, saved); if ( workDone ) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); } else { -- cgit v1.2.3 From 3fcae9b041aae2e79732277cbcd20fc13a92d453 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 00:13:36 +0200 Subject: Fixing undo thing (bzr r14865.1.7) --- src/ui/tools/eraser-tool.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 60b8c2792..2896e7b3e 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -723,10 +723,8 @@ void EraserTool::set_to_accumulated() { Inkscape::GC::release(dup); // parent takes over selection->set(dup); if (!this->nowidth) { - DocumentUndo::setUndoSensitive(document, saved); sp_selected_path_union_skip_undo(selection, desktop); - DocumentUndo::setUndoSensitive(document, false); - } + } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ SPCSSAttr *css = sp_repr_css_attr_new(); @@ -735,16 +733,13 @@ void EraserTool::set_to_accumulated() { sp_repr_css_attr_unref(css); css = 0; } - DocumentUndo::setUndoSensitive(document, saved); if (this->nowidth) { sp_selected_path_cut_skip_undo(selection, desktop); } else { sp_selected_path_diff_skip_undo(selection, desktop); } - DocumentUndo::setUndoSensitive(document, saved); workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); - DocumentUndo::setUndoSensitive(document, saved); if(!break_apart){ sp_selected_path_combine(desktop, true); } else { @@ -752,7 +747,6 @@ void EraserTool::set_to_accumulated() { sp_selected_path_break_apart(desktop, true); } } - DocumentUndo::setUndoSensitive(document, saved); if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); @@ -785,10 +779,8 @@ void EraserTool::set_to_accumulated() { this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(dup); - DocumentUndo::setUndoSensitive(document, saved); sp_selected_path_union_skip_undo(selection, this->desktop); - DocumentUndo::setUndoSensitive(document, false); - sp_selection_raise_to_top(selection, this->desktop); + sp_selection_raise_to_top(selection, this->desktop, true); if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { @@ -808,23 +800,18 @@ void EraserTool::set_to_accumulated() { sp_object_ref(rect, 0); rect->deleteObject(true); sp_object_unref(rect); - sp_selection_raise_to_top(selection, this->desktop); + sp_selection_raise_to_top(selection, this->desktop, true); selection->add(dup_clip); - DocumentUndo::setUndoSensitive(document, saved); sp_selected_path_diff_skip_undo(selection, this->desktop); - DocumentUndo::setUndoSensitive(document, saved); SPItem * clip = SP_ITEM(selection->itemList()[0]); - DocumentUndo::setUndoSensitive(document, false); } } } } else { selection->add(rect); - DocumentUndo::setUndoSensitive(document, saved); sp_selected_path_diff_skip_undo(selection, this->desktop); - DocumentUndo::setUndoSensitive(document, false); } - sp_selection_raise_to_top(selection, this->desktop); + sp_selection_raise_to_top(selection, this->desktop, true); selection->add(item); sp_selection_set_mask(this->desktop, true, false); } else { -- cgit v1.2.3 From e2f3d8631f30db820029835ecc6cdc68d339cdc0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 01:33:30 +0200 Subject: Working undo (bzr r14865.1.8) --- src/ui/tools/eraser-tool.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 2896e7b3e..40e13a9cd 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -644,8 +644,6 @@ void EraserTool::clear_current() { void EraserTool::set_to_accumulated() { bool workDone = false; SPDocument *document = this->desktop->doc(); - bool saved = DocumentUndo::getUndoSensitive(document); - DocumentUndo::setUndoSensitive(document, false); if (!this->accumulated->is_empty()) { if (!this->repr) { /* Create object */ @@ -680,17 +678,17 @@ void EraserTool::set_to_accumulated() { std::vector toWorkOn; if (selection->isEmpty()) { if ( eraser_mode == 1 || eraser_mode == 2) { - toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox); + toWorkOn = document->getItemsPartiallyInBox(desktop->dkey, *eraserBbox); } else { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); - toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); + toWorkOn = document->getItemsAtPoints(desktop->dkey, r->getPoints()); } toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end()); } else { if ( eraser_mode == 0 ) { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); std::vector touched; - touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); + touched = document->getItemsAtPoints(desktop->dkey, r->getPoints()); for (std::vector::const_iterator i = touched.begin();i!=touched.end();++i) { if(selection->includes(*i)){ toWorkOn.push_back((*i)); @@ -779,8 +777,8 @@ void EraserTool::set_to_accumulated() { this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(dup); - sp_selected_path_union_skip_undo(selection, this->desktop); - sp_selection_raise_to_top(selection, this->desktop, true); + sp_selected_path_union_skip_undo(selection, desktop); + sp_selection_raise_to_top(selection, desktop, true); if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { @@ -800,20 +798,21 @@ void EraserTool::set_to_accumulated() { sp_object_ref(rect, 0); rect->deleteObject(true); sp_object_unref(rect); - sp_selection_raise_to_top(selection, this->desktop, true); + sp_selection_raise_to_top(selection, desktop, true); selection->add(dup_clip); - sp_selected_path_diff_skip_undo(selection, this->desktop); + sp_selected_path_diff_skip_undo(selection, desktop); SPItem * clip = SP_ITEM(selection->itemList()[0]); } } } } else { selection->add(rect); - sp_selected_path_diff_skip_undo(selection, this->desktop); + std::cout << "asasgfasfasfasfasfasf\n"; + sp_selected_path_diff_skip_undo(selection, desktop); } - sp_selection_raise_to_top(selection, this->desktop, true); + sp_selection_raise_to_top(selection, desktop, true); selection->add(item); - sp_selection_set_mask(this->desktop, true, false); + sp_selection_set_mask(desktop, true, false, true); } else { SPItem *erase_clip = selection->singleItem(); if (erase_clip) { @@ -843,7 +842,7 @@ void EraserTool::set_to_accumulated() { } if ( eraser_mode == 0 ) { - //sp_selection_delete(desktop); + sp_selection_delete(desktop); remainingItems.clear(); } @@ -865,12 +864,10 @@ void EraserTool::set_to_accumulated() { this->repr = 0; } } - document->setModifiedSinceSave(); - DocumentUndo::setUndoSensitive(document, saved); 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); } } -- cgit v1.2.3 From 331336b5f924ad3200a343f571178e19b55532a1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 04:13:59 +0200 Subject: Clip eraser done! Thanks Doctormon! (bzr r14865.1.9) --- src/ui/tools/eraser-tool.cpp | 165 +++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 83 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 40e13a9cd..c5a068dfc 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -647,48 +647,48 @@ void EraserTool::set_to_accumulated() { 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_repr = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); + SPItem *item_repr = SP_ITEM(this->desktop->currentLayer()->appendChildRepr(this->repr)); Inkscape::GC::release(this->repr); item_repr->updateRepr(); - Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc(); + 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 eraser_mode = prefs->getInt("/tools/eraser/mode", 2); - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + 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 remainingItems; std::vector toWorkOn; if (selection->isEmpty()) { if ( eraser_mode == 1 || eraser_mode == 2) { - toWorkOn = document->getItemsPartiallyInBox(desktop->dkey, *eraserBbox); + toWorkOn = document->getItemsPartiallyInBox(this->desktop->dkey, *eraserBbox); } else { - Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); - toWorkOn = document->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 ( eraser_mode == 0 ) { - Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); + Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop); std::vector touched; - touched = document->getItemsAtPoints(desktop->dkey, r->getPoints()); + touched = document->getItemsAtPoints(this->desktop->dkey, r->getPoints()); for (std::vector::const_iterator i = touched.begin();i!=touched.end();++i) { if(selection->includes(*i)){ toWorkOn.push_back((*i)); @@ -721,28 +721,28 @@ 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, this->desktop); } 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, this->desktop); } else { - sp_selected_path_diff_skip_undo(selection, desktop); + sp_selected_path_diff_skip_undo(selection, this->desktop); } 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() ) { @@ -758,76 +758,75 @@ void EraserTool::set_to_accumulated() { } } } else if ( eraser_mode == 2 ) { - remainingItems.clear(); - for (std::vector::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 *rect_repr = xml_doc->createElement("svg:rect"); - sp_desktop_apply_style_tool (desktop, rect_repr, "/tools/eraser", false); - SPRect * rect = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr)); - Inkscape::GC::release(rect_repr); - - rect->updateRepr(); - rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); - rect->transform = SP_ITEM(desktop->currentLayer())->i2dt_affine().inverse(); - - 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, desktop); - sp_selection_raise_to_top(selection, desktop, true); - if (bbox && bbox->intersects(*eraserBbox)) { - SPClipPath *clip_path = item->clip_ref->getObject(); - if (clip_path) { - SPPath *clip_data = SP_PATH(clip_path->firstChild()); - if (clip_data) { - Inkscape::XML::Node *dup_clip = SP_OBJECT(clip_data)->getRepr()->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_data, 0); - clip_data->deleteObject(true); - sp_object_unref(clip_data); - sp_object_ref(clip_path, 0); - clip_path->deleteObject(true); - sp_object_unref(clip_path); - sp_object_ref(rect, 0); - rect->deleteObject(true); - sp_object_unref(rect); - sp_selection_raise_to_top(selection, desktop, true); - selection->add(dup_clip); - sp_selected_path_diff_skip_undo(selection, desktop); - SPItem * clip = SP_ITEM(selection->itemList()[0]); + if (!this->nowidth) { + remainingItems.clear(); + for (std::vector::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 *rect_repr = xml_doc->createElement("svg:rect"); + sp_desktop_apply_style_tool (this->desktop, rect_repr, "/tools/eraser", false); + SPRect * rect = SP_RECT(this->desktop->currentLayer()->appendChildRepr(rect_repr)); + Inkscape::GC::release(rect_repr); + rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); + rect->transform = SP_ITEM(this->desktop->currentLayer())->i2dt_affine().inverse(); + rect->updateRepr(); + this->desktop->canvas->endForcedFullRedraws(); + 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, this->desktop); + sp_selection_raise_to_top(selection, this->desktop, true); + if (bbox && bbox->intersects(*eraserBbox)) { + SPClipPath *clip_path = item->clip_ref->getObject(); + if (clip_path) { + SPPath *clip_data = SP_PATH(clip_path->firstChild()); + if (clip_data) { + Inkscape::XML::Node *dup_clip = SP_OBJECT(clip_data)->getRepr()->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_data, 0); + clip_data->deleteObject(true); + sp_object_unref(clip_data); + sp_object_ref(clip_path, 0); + clip_path->deleteObject(true); + sp_object_unref(clip_path); + sp_object_ref(rect, 0); + rect->deleteObject(true); + sp_object_unref(rect); + sp_selection_raise_to_top(selection, this->desktop, true); + selection->add(dup_clip); + sp_selected_path_diff_skip_undo(selection, this->desktop); + SPItem * clip = SP_ITEM(selection->itemList()[0]); + } } } + } else { + selection->add(rect); + sp_selected_path_diff_skip_undo(selection, this->desktop); } + sp_selection_raise_to_top(selection, this->desktop, true); + selection->add(item); + sp_selection_set_mask(this->desktop, true, false, true); } else { - selection->add(rect); - std::cout << "asasgfasfasfasfasfasf\n"; - sp_selected_path_diff_skip_undo(selection, desktop); + SPItem *erase_clip = selection->singleItem(); + if (erase_clip) { + sp_object_ref(erase_clip, 0); + erase_clip->deleteObject(true); + sp_object_unref(erase_clip); + } } - sp_selection_raise_to_top(selection, desktop, true); - selection->add(item); - sp_selection_set_mask(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); } } - workDone = true; - selection->clear(); - if (wasSelection) { - remainingItems.push_back(item); - } } - } else { for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) { sp_object_ref( *i, 0 ); @@ -842,7 +841,7 @@ void EraserTool::set_to_accumulated() { } if ( eraser_mode == 0 ) { - sp_selection_delete(desktop); + sp_selection_delete(this->desktop); remainingItems.clear(); } -- cgit v1.2.3 From c230ee02c2732c7eb55c5bdc6ef846f88550eea3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 17:44:25 +0200 Subject: first attem to work throught layers (bzr r14865.1.11) --- src/ui/tools/eraser-tool.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index c5a068dfc..02908fdf9 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -61,6 +61,7 @@ #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" @@ -655,7 +656,7 @@ void EraserTool::set_to_accumulated() { this->repr = repr; } - SPItem *item_repr = SP_ITEM(this->desktop->currentLayer()->appendChildRepr(this->repr)); + SPItem *item_repr = SP_ITEM(SP_OBJECT(document->getRoot())->appendChildRepr(this->repr)); Inkscape::GC::release(this->repr); item_repr->updateRepr(); Geom::PathVector pathv = this->accumulated->get_pathvector() * this->desktop->dt2doc(); @@ -722,7 +723,7 @@ void EraserTool::set_to_accumulated() { selection->set(dup); if (!this->nowidth) { sp_selected_path_union_skip_undo(selection, this->desktop); - } + } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ SPCSSAttr *css = sp_repr_css_attr_new(); @@ -767,10 +768,10 @@ void EraserTool::set_to_accumulated() { Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); 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(this->desktop->currentLayer()->appendChildRepr(rect_repr)); + 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(this->desktop->currentLayer())->i2dt_affine().inverse(); + rect->transform = SP_ITEM(rect->parent)->i2dt_affine().inverse(); rect->updateRepr(); this->desktop->canvas->endForcedFullRedraws(); Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); -- cgit v1.2.3 From 2d1b3b926c94db73a3f5cb73071027b9ee348154 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 18:17:49 +0200 Subject: Speed improvements (bzr r14865.1.12) --- src/ui/tools/eraser-tool.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 02908fdf9..5cd04fa6f 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -766,20 +766,11 @@ void EraserTool::set_to_accumulated() { SPItem *item = *i; Geom::OptRect bbox = item->desktopVisualBounds(); Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); - 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(); - this->desktop->canvas->endForcedFullRedraws(); 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, this->desktop); - sp_selection_raise_to_top(selection, this->desktop, true); if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { @@ -790,15 +781,9 @@ void EraserTool::set_to_accumulated() { 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_data, 0); - clip_data->deleteObject(true); - sp_object_unref(clip_data); sp_object_ref(clip_path, 0); clip_path->deleteObject(true); sp_object_unref(clip_path); - sp_object_ref(rect, 0); - rect->deleteObject(true); - sp_object_unref(rect); sp_selection_raise_to_top(selection, this->desktop, true); selection->add(dup_clip); sp_selected_path_diff_skip_undo(selection, this->desktop); @@ -807,6 +792,15 @@ void EraserTool::set_to_accumulated() { } } } 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, this->desktop); } -- cgit v1.2.3 From ac25f7827cc250eb47eedf1bd3aa5ec8438fc0e5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 7 Jun 2016 01:35:26 +0200 Subject: Add measure Over Item by a vlada idea on IRC (bzr r14957.1.1) --- src/ui/tools/measure-tool.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++ src/ui/tools/measure-tool.h | 9 ++++ 2 files changed, 121 insertions(+) (limited to 'src/ui/tools') diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 287828d32..8b2a734ff 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -394,6 +394,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]); } @@ -608,6 +612,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(); @@ -1128,6 +1138,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 << _("Lenght") << ": %." << 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 measure_tmp_items; std::vector measure_phantom_items; + std::vector 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; -- cgit v1.2.3 From 6d5d7e5421a5ac585814bde11866d796d81653cd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 11 Jun 2016 14:04:09 +0200 Subject: Fix a typo pointed by CR (bzr r14957.1.2) --- src/ui/tools/measure-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 8b2a734ff..900274afc 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1203,7 +1203,7 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) Geom::Point pos = desktop->w2d(cursor); double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr); if (SP_IS_SHAPE(over)) { - precision_str << _("Lenght") << ": %." << precision << "f %s"; + 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); -- cgit v1.2.3 From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 4 ++-- src/ui/tools/gradient-tool.cpp | 14 +++++++------- src/ui/tools/lpe-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 12 ++++++------ src/ui/tools/node-tool.cpp | 4 ++-- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 10 +++++----- src/ui/tools/tool-base.cpp | 2 +- src/ui/tools/tweak-tool.cpp | 6 +++--- 10 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 74f2664fe..52ddd589c 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1306,7 +1306,7 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - std::vector l = selection->itemList(); + std::vector l = selection->items(); for(std::vector::const_iterator i=l.begin();i!=l.end(); ++i) { SPItem *item = *i; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index cb7747b2b..a81161ea9 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,7 +692,7 @@ void EraserTool::set_to_accumulated() { } } } else { - toWorkOn = selection->itemList(); + toWorkOn = selection->items(); } wasSelection = true; } @@ -744,7 +744,7 @@ void EraserTool::set_to_accumulated() { } if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - std::vector nowSel(selection->itemList()); + std::vector nowSel(selection->items()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { remainingItems.push_back(*i2); } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 9d8101cc4..e2bb0dc07 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -106,7 +106,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = selection->items().size(); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -492,9 +492,9 @@ 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 items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_iterator i = items.begin();i!=items.end();++i) { SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); @@ -897,7 +897,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 items(selection->itemList()); + std::vector items(selection->items()); 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,7 +907,7 @@ 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 itemlist = selection->itemList(); + std::vector itemlist = selection->items(); for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();++i) { //FIXME: see above @@ -931,7 +931,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()[0], 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 +940,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 = selection->items().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 9bbc1ac20..ebcac2279 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -396,7 +396,7 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 47927667c..9aaa0c14e 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -103,7 +103,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = selection->items().size(); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -467,10 +467,10 @@ bool MeshTool::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_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->items()[0], this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; @@ -945,7 +945,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector items(selection->itemList()); + std::vector items(selection->items()); 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,7 +955,7 @@ 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 items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ //FIXME: see above @@ -972,7 +972,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 = selection->items().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 23aaf6bb1..f7a725794 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -407,7 +407,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - std::vector items=sel->itemList(); + std::vector items= sel->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *obj = *i; @@ -444,7 +444,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } _previous_selection = _current_selection; - _current_selection = sel->itemList(); + _current_selection = sel->items(); this->_multipath->setItems(shapes); this->update_tip(NULL); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index b5ec3d88e..676a41eaa 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -477,7 +477,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()[0]; if (dynamic_cast(clicked_item) && !dynamic_cast(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 9adaf3879..4f36a827f 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -210,7 +210,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -591,7 +591,7 @@ static bool fit_item(SPDesktop *desktop, if (selection->isEmpty()) { return false; } - std::vector const items_selected(selection->itemList()); + std::vector const items_selected(selection->items()); std::vector items_down_erased; for (std::vector::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) { SPItem *item_down = *i; @@ -1002,7 +1002,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator it=items.begin();it!=items.end(); ++it){ SPItem *item1 = *it; if (i == 1) { @@ -1170,7 +1170,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 const items(selection->itemList()); + std::vector const items(selection->items()); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1299,7 +1299,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 36fe26e76..6da6526bc 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1158,7 +1158,7 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, if (select_under) { SPItem *selected_at_point = desktop->getItemFromListAtPointBottom( - desktop->selection->itemList(), p); + desktop->selection->items(), 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..4da8060e2 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -153,7 +153,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -1076,7 +1076,7 @@ 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 items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1185,7 +1185,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to tweak.")); -- cgit v1.2.3 From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/ui/tools/box3d-tool.cpp | 4 ++-- src/ui/tools/connector-tool.cpp | 6 +++--- src/ui/tools/tweak-tool.cpp | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 27e755add..2adba38c5 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -118,8 +118,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/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index b81a630e2..be8ce6d0c 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1114,9 +1114,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); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 658cf4617..d048c318b 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -385,9 +385,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast(item) && !dynamic_cast(item)) { GSList *children = NULL; - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - if (dynamic_cast(static_cast(child))) { - children = g_slist_prepend(children, child); + for (auto& child: item->_children) { + if (dynamic_cast(static_cast(&child))) { + children = g_slist_prepend(children, &child); } } @@ -832,8 +832,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(child); + for (auto& child: vector->_children) { + SPStop *stop = dynamic_cast(&child); if (!stop) { continue; } @@ -878,7 +878,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 +894,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast(item)) { - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - SPItem *childItem = dynamic_cast(child); + for (auto& child: item->_children) { + SPItem *childItem = dynamic_cast(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, fill_goal, do_fill, -- cgit v1.2.3 From 9e210a6d1333c3366681547e3e81593ef69ff73e Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 12:56:49 +0200 Subject: Last part of new SPObject children list (bzr r14954.1.20) --- src/ui/tools/node-tool.cpp | 4 ++-- src/ui/tools/tweak-tool.cpp | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 736dafa50..3dfac5e3d 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -378,8 +378,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(obj); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index d048c318b..7da0973d5 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -951,9 +951,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(primitive_obj); + for (auto& primitive_obj: style->getFilter()->_children) { + SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur SPGaussianBlur * spblur = dynamic_cast(primitive); @@ -962,7 +961,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]; -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/ui/tools/box3d-tool.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/node-tool.cpp | 2 +- src/ui/tools/tweak-tool.cpp | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 2adba38c5..9a0b37913 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -118,7 +118,7 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = document->getDefs(); bool has_persp = false; - for (auto& child: defs->_children) { + for (auto& child: defs->children) { if (SP_IS_PERSP3D(&child)) { has_persp = true; break; diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index be8ce6d0c..11752726b 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1114,7 +1114,7 @@ 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 (auto& child: item->_children) { + for (auto& child: item->children) { if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) { this->_activeShapeAddKnot((SPItem *) &child); } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 3dfac5e3d..87b7bf7e3 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -378,7 +378,7 @@ 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 (auto& c: obj->_children) { + for (auto& c: obj->children) { gather_items(nt, base, &c, role, s); } } else if (SP_IS_ITEM(obj)) { diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 7da0973d5..361986d0c 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -385,7 +385,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast(item) && !dynamic_cast(item)) { GSList *children = NULL; - for (auto& child: item->_children) { + for (auto& child: item->children) { if (dynamic_cast(static_cast(&child))) { children = g_slist_prepend(children, &child); } @@ -832,7 +832,7 @@ 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 (auto& child: vector->_children) { + for (auto& child: vector->children) { SPStop *stop = dynamic_cast(&child); if (!stop) { continue; @@ -894,7 +894,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast(item)) { - for (auto& child: item->_children) { + for (auto& child: item->children) { SPItem *childItem = dynamic_cast(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, @@ -951,7 +951,7 @@ 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 - for (auto& primitive_obj: style->getFilter()->_children) { + for (auto& primitive_obj: style->getFilter()->children) { SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur -- cgit v1.2.3 From a227e8d45e7eaa6bf25d8ab65fbd404bc4597306 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 20 Jul 2016 13:45:05 +0200 Subject: Changed signatures of boolean functions (bzr r14954.1.24) --- src/ui/tools/calligraphic-tool.cpp | 4 ++-- src/ui/tools/eraser-tool.cpp | 6 +++--- src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 28195eb75..12dcedd21 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -930,10 +930,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); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 534123e90..8ed75fbdb 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -718,7 +718,7 @@ 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){ @@ -729,9 +729,9 @@ void EraserTool::set_to_accumulated() { 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); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 748c82717..b5a2fd871 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -456,7 +456,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto ngettext("Area filled, path with %d node created and unioned with selection.","Area filled, path with %d 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 %d node created.","Area filled, path with %d nodes created.", diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 5d804a9bd..a95e5aa96 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -1050,7 +1050,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (unionResult) { // No need to add the very first item (initialized with NULL). selection->add(unionResult); } - sp_selected_path_union_skip_undo(selection, selection->desktop()); + sp_selected_path_union_skip_undo(selection); selection->add(parent_item); Inkscape::GC::release(copy); did = true; -- cgit v1.2.3 From d31923a399f3c7cde85aae8406191e37ad877eb7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 22 Jul 2016 11:32:35 +0200 Subject: Improved spray tool, changed selection to object set (bzr r14954.1.25) --- src/ui/tools/spray-tool.cpp | 54 +++++++++++++++++++++------------------------ src/ui/tools/spray-tool.h | 9 +++++++- 2 files changed, 33 insertions(+), 30 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a95e5aa96..49ff50428 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -13,6 +13,7 @@ * Jon A. Cruz * Abhishek Sharma * Jabiertxo Arraiza + * Adrian Boguszewski * * Copyright (C) 2009 authors * @@ -196,6 +197,7 @@ SprayTool::SprayTool() } SprayTool::~SprayTool() { + object_set.clear(); this->enableGrDrag(false); this->style_set_connection.disconnect(); @@ -862,7 +864,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 +909,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 +998,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; - auto items= selection->items(); - for(auto 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 +1035,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->add(parent_item); + sp_selected_path_union_skip_undo(set); + set->add(parent_item); Inkscape::GC::release(copy); did = true; } @@ -1146,9 +1136,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 +1159,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 const items(selection->items().begin(), selection->items().end()); + std::vector const items(set->items().begin(), set->items().end()); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1182,7 +1171,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 +1265,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 +1293,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = boost::distance(desktop->selection->items() ); + num = (guint) boost::distance(desktop->selection->items()); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); @@ -1384,6 +1378,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; }; } -- cgit v1.2.3 From a83543fbf553fb141ec68386ecc77e2bffe36b10 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 22 Jul 2016 17:22:19 +0200 Subject: Fixed null when selection contains more than one item Fixed bugs: - https://launchpad.net/bugs/1591390 (bzr r15018) --- src/ui/tools/tool-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 36fe26e76..72ba499de 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1083,7 +1083,7 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event) /* fixme: This is not what I want but works for now (Lauris) */ if (event->type == GDK_KEY_PRESS) { - item = desktop->getSelection()->singleItem(); + item = desktop->getSelection()->itemList().front(); } ContextMenu* CM = new ContextMenu(desktop, item); -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/ui/tools/arc-tool.cpp | 3 +-- src/ui/tools/box3d-tool.cpp | 9 --------- src/ui/tools/calligraphic-tool.cpp | 9 --------- src/ui/tools/connector-tool.cpp | 7 ------- src/ui/tools/dropper-tool.cpp | 5 +---- src/ui/tools/dynamic-base.cpp | 6 ------ src/ui/tools/eraser-tool.cpp | 11 ----------- src/ui/tools/flood-tool.cpp | 12 +----------- src/ui/tools/freehand-base.cpp | 16 +--------------- src/ui/tools/gradient-tool.cpp | 9 +-------- src/ui/tools/lpe-tool.cpp | 5 +---- src/ui/tools/measure-tool.cpp | 18 +----------------- src/ui/tools/mesh-tool.cpp | 3 +-- src/ui/tools/node-tool.cpp | 6 ------ src/ui/tools/pen-tool.cpp | 12 ------------ src/ui/tools/pencil-tool.cpp | 5 ----- src/ui/tools/rect-tool.cpp | 5 ----- src/ui/tools/select-tool.cpp | 4 +--- src/ui/tools/spiral-tool.cpp | 5 ----- src/ui/tools/spray-tool.cpp | 14 -------------- src/ui/tools/star-tool.cpp | 5 +---- src/ui/tools/text-tool.cpp | 6 +----- src/ui/tools/tool-base.cpp | 10 +--------- src/ui/tools/tweak-tool.cpp | 12 ------------ src/ui/tools/zoom-tool.cpp | 1 - 25 files changed, 12 insertions(+), 186 deletions(-) (limited to 'src/ui/tools') 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 +#include #endif #include @@ -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..9b5b264bc 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 #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 -#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" diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 28195eb75..84c4adc89 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 #include #include @@ -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 #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" diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 74f2664fe..605b573d7 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 #include #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" diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index c838c27d5..4db720686 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -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; 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 - -#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..838522b34 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 #include #include @@ -38,7 +36,6 @@ #include "display/canvas-bpath.h" #include <2geom/bezier-utils.h> -#include #include "macros.h" #include "document.h" #include "selection.h" @@ -47,26 +44,18 @@ #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-text.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 "display/curve.h" diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 748c82717..2f125e6ed 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 #endif #include "trace/potrace/inkscape-potrace.h" #include <2geom/pathvector.h> #include #include -#include #include #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" diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 7697cd59c..eb29ed88d 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 #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 #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 using Inkscape::DocumentUndo; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 9d8101cc4..e4814c3de 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 #endif @@ -31,17 +31,10 @@ #include "ui/tools/gradient-tool.h" #include "gradient-chemistry.h" #include -#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" diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 9bbc1ac20..ee85dd28c 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 #endif #include <2geom/sbasis-geometric.h> -#include #include -#include "macros.h" #include "pixmaps/cursor-crosshairs.xpm" #include #include "desktop.h" #include "message-context.h" -#include "preferences.h" #include "ui/shape-editor.h" #include "selection.h" diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 63e2460ec..c941b9bee 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 +#include #endif #include -#include #include #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 diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 47927667c..32e70bc19 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 #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" diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 23aaf6bb1..bf18d4a2e 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" diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 18af8e105..49f28ad2c 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 -#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; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index b029ca613..7cc695040 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 #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 { 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 #include #include @@ -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 -#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..5d802d4da 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 #endif #include #include @@ -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; 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 #include #include @@ -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 -#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..3fafac2a7 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -19,15 +19,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include #include "ui/dialog/dialog-manager.h" #include "svg/svg.h" -#include #include "macros.h" #include "document.h" #include "document-undo.h" @@ -37,10 +34,7 @@ #include "message-context.h" #include "pixmaps/cursor-spray.xpm" -#include -#include "xml/repr.h" #include "context-fns.h" -#include "sp-item.h" #include "inkscape.h" #include "splivarot.h" @@ -57,17 +51,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 +65,6 @@ #include "helper/action.h" #include "verbs.h" -#include - -#include #include #include 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 #endif #include @@ -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 -#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 +#include #endif #include @@ -23,7 +23,6 @@ #include #include #include -#include #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 using Inkscape::ControlManager; using Inkscape::DocumentUndo; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 72ba499de..735f5bd42 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 #endif #include "widgets/desktop-widget.h" @@ -24,12 +24,8 @@ #include "file.h" #include "ui/tools/tool-base.h" -#include #include -#include #include -#include -#include #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 diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 39a7a3f0b..fbf1b2a0b 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 #include #include @@ -21,7 +19,6 @@ #include "svg/svg.h" -#include #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 -#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" 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" -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/ui/tools/arc-tool.cpp | 3 ++- src/ui/tools/box3d-tool.cpp | 9 +++++++++ src/ui/tools/calligraphic-tool.cpp | 9 +++++++++ src/ui/tools/connector-tool.cpp | 7 +++++++ src/ui/tools/dropper-tool.cpp | 5 ++++- src/ui/tools/dynamic-base.cpp | 6 ++++++ src/ui/tools/eraser-tool.cpp | 11 +++++++++++ src/ui/tools/flood-tool.cpp | 12 +++++++++++- src/ui/tools/freehand-base.cpp | 16 +++++++++++++++- src/ui/tools/gradient-tool.cpp | 9 ++++++++- src/ui/tools/lpe-tool.cpp | 5 ++++- src/ui/tools/measure-tool.cpp | 18 +++++++++++++++++- src/ui/tools/mesh-tool.cpp | 3 ++- src/ui/tools/node-tool.cpp | 6 ++++++ src/ui/tools/pen-tool.cpp | 12 ++++++++++++ src/ui/tools/pencil-tool.cpp | 5 +++++ src/ui/tools/rect-tool.cpp | 5 +++++ src/ui/tools/select-tool.cpp | 4 +++- src/ui/tools/spiral-tool.cpp | 5 +++++ src/ui/tools/spray-tool.cpp | 14 ++++++++++++++ src/ui/tools/star-tool.cpp | 5 ++++- src/ui/tools/text-tool.cpp | 6 +++++- src/ui/tools/tool-base.cpp | 10 +++++++++- src/ui/tools/tweak-tool.cpp | 12 ++++++++++++ src/ui/tools/zoom-tool.cpp | 1 + 25 files changed, 186 insertions(+), 12 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index 6652f7ab5..c6a9bb23a 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -17,7 +17,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include #endif #include @@ -30,6 +30,7 @@ #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 9b5b264bc..27e755add 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -15,6 +15,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "config.h" + #include #include "macros.h" @@ -25,6 +27,8 @@ #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" @@ -32,12 +36,17 @@ #include "box3d.h" #include "ui/tools/box3d-tool.h" #include +#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" diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 84c4adc89..28195eb75 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -23,6 +23,8 @@ #define noDYNA_DRAW_VERBOSE +#include "config.h" + #include #include #include @@ -33,10 +35,12 @@ #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 #include "macros.h" #include "document.h" #include "document-undo.h" @@ -46,15 +50,20 @@ #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" diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 605b573d7..74f2664fe 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -75,6 +75,7 @@ #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" @@ -85,13 +86,19 @@ #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 #include #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" diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 4db720686..c838c27d5 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include #endif #include @@ -27,6 +27,7 @@ #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" @@ -35,6 +36,7 @@ #include "desktop.h" #include "selection.h" +#include "document.h" #include "document-undo.h" #include "pixmaps/cursor-dropper-f.xpm" @@ -43,6 +45,7 @@ #include "ui/tools/dropper-tool.h" #include "message-context.h" #include "verbs.h" +#include "ui/tools/tool-base.h" using Inkscape::DocumentUndo; diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp index 6627a470e..eb789d850 100644 --- a/src/ui/tools/dynamic-base.cpp +++ b/src/ui/tools/dynamic-base.cpp @@ -1,7 +1,13 @@ #include "ui/tools/dynamic-base.h" +#include + +#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 838522b34..6b32b5901 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -24,6 +24,8 @@ #define noERASER_VERBOSE +#include "config.h" + #include #include #include @@ -36,6 +38,7 @@ #include "display/canvas-bpath.h" #include <2geom/bezier-utils.h> +#include #include "macros.h" #include "document.h" #include "selection.h" @@ -44,18 +47,26 @@ #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-text.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 "display/curve.h" diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 2f125e6ed..748c82717 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -18,13 +18,14 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include "trace/potrace/inkscape-potrace.h" #include <2geom/pathvector.h> #include #include +#include #include #include "color.h" @@ -35,6 +36,7 @@ #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" @@ -45,15 +47,23 @@ #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" diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index eb29ed88d..7697cd59c 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -17,29 +17,43 @@ #define DRAW_VERBOSE #ifdef HAVE_CONFIG_H -#include +# 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 #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 using Inkscape::DocumentUndo; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index e4814c3de..9d8101cc4 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif @@ -31,10 +31,17 @@ #include "ui/tools/gradient-tool.h" #include "gradient-chemistry.h" #include +#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" diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index ee85dd28c..9bbc1ac20 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -15,16 +15,19 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include <2geom/sbasis-geometric.h> +#include #include +#include "macros.h" #include "pixmaps/cursor-crosshairs.xpm" #include #include "desktop.h" #include "message-context.h" +#include "preferences.h" #include "ui/shape-editor.h" #include "selection.h" diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index c941b9bee..63e2460ec 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -11,10 +11,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -#include +# include #endif #include +#include #include #include "util/units.h" #include "display/curve.h" @@ -22,6 +23,7 @@ #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" @@ -29,20 +31,34 @@ #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 diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 32e70bc19..47927667c 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif //#define DEBUG_MESH @@ -33,6 +33,7 @@ #include "macros.h" #include "message-context.h" #include "message-stack.h" +#include "preferences.h" #include "rubberband.h" #include "selection.h" #include "snap.h" diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index bf18d4a2e..23aaf6bb1 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -24,19 +24,25 @@ #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" diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 49f28ad2c..18af8e105 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -32,6 +32,8 @@ #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" @@ -44,6 +46,7 @@ #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" @@ -51,16 +54,25 @@ #include "live_effects/lpe-spiro.h" +#include +#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; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 7cc695040..b029ca613 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -27,6 +27,7 @@ #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> @@ -35,9 +36,13 @@ #include #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 { diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 00330ef57..844965c4d 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -14,6 +14,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "config.h" + #include #include #include @@ -27,13 +29,16 @@ #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 +#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 5d802d4da..b5ec3d88e 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #include #include @@ -40,12 +40,14 @@ #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; diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 0ba08853e..833fef18d 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -14,6 +14,8 @@ * Released under GNU GPL */ +#include "config.h" + #include #include #include @@ -26,13 +28,16 @@ #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 +#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 3fafac2a7..9adaf3879 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -19,12 +19,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "config.h" + #include #include "ui/dialog/dialog-manager.h" #include "svg/svg.h" +#include #include "macros.h" #include "document.h" #include "document-undo.h" @@ -34,7 +37,10 @@ #include "message-context.h" #include "pixmaps/cursor-spray.xpm" +#include +#include "xml/repr.h" #include "context-fns.h" +#include "sp-item.h" #include "inkscape.h" #include "splivarot.h" @@ -51,12 +57,17 @@ #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" @@ -65,6 +76,9 @@ #include "helper/action.h" #include "verbs.h" +#include + +#include #include #include diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index ddee08189..9190ae57b 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #include @@ -31,11 +31,14 @@ #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 +#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 559187764..1888551cf 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include #endif #include @@ -23,6 +23,7 @@ #include #include #include +#include #include "context-fns.h" @@ -35,6 +36,7 @@ #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" @@ -48,6 +50,8 @@ #include "ui/control-manager.h" #include "verbs.h" #include "xml/node-event-vector.h" +#include "xml/repr.h" +#include using Inkscape::ControlManager; using Inkscape::DocumentUndo; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 735f5bd42..72ba499de 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #include "widgets/desktop-widget.h" @@ -24,8 +24,12 @@ #include "file.h" #include "ui/tools/tool-base.h" +#include #include +#include #include +#include +#include #include "display/sp-canvas.h" #include "xml/node-event-vector.h" @@ -39,14 +43,18 @@ #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 diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index fbf1b2a0b..39a7a3f0b 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -11,6 +11,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "config.h" + #include #include #include @@ -19,6 +21,7 @@ #include "svg/svg.h" +#include #include "macros.h" #include "document.h" #include "document-undo.h" @@ -45,13 +48,19 @@ #include "pixmaps/cursor-push.xpm" #include "pixmaps/cursor-roughen.xpm" #include "pixmaps/cursor-color.xpm" +#include +#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" @@ -60,10 +69,13 @@ #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" diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index ca42d2d6f..13e097c18 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -21,6 +21,7 @@ #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" -- cgit v1.2.3 From dcd91f59f597ab4af07cee5929ce0e2e1f9104d5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 16:16:18 +0100 Subject: Drop remaining GTKMM 2 fallback support (bzr r15023.2.7) --- src/ui/tools/tool-base.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 72ba499de..17debb59c 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -149,16 +149,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 - } /** -- cgit v1.2.3 From 49a7927ecf31ace696e9e5770e8d6543c356db7a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 19:15:34 +0100 Subject: Finish removing GTK+ 2 fallbacks (bzr r15023.2.8) --- src/ui/tools/dropper-tool.cpp | 8 -------- src/ui/tools/select-tool.cpp | 8 -------- src/ui/tools/tool-base.cpp | 16 ---------------- 3 files changed, 32 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index c838c27d5..fbc5f088c 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -121,20 +121,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/select-tool.cpp b/src/ui/tools/select-tool.cpp index b5ec3d88e..b29fb6979 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -128,20 +128,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; } } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 17debb59c..d504d82eb 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -118,11 +118,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; } @@ -182,11 +178,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); @@ -196,11 +188,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); @@ -771,11 +759,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) { @@ -836,12 +822,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; -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/ui/tools/arc-tool.cpp | 3 +-- src/ui/tools/box3d-tool.cpp | 9 --------- src/ui/tools/calligraphic-tool.cpp | 9 --------- src/ui/tools/connector-tool.cpp | 7 ------- src/ui/tools/dropper-tool.cpp | 5 +---- src/ui/tools/dynamic-base.cpp | 6 ------ src/ui/tools/eraser-tool.cpp | 11 ----------- src/ui/tools/flood-tool.cpp | 12 +----------- src/ui/tools/freehand-base.cpp | 16 +--------------- src/ui/tools/gradient-tool.cpp | 9 +-------- src/ui/tools/lpe-tool.cpp | 5 +---- src/ui/tools/measure-tool.cpp | 18 +----------------- src/ui/tools/mesh-tool.cpp | 3 +-- src/ui/tools/node-tool.cpp | 6 ------ src/ui/tools/pen-tool.cpp | 12 ------------ src/ui/tools/pencil-tool.cpp | 5 ----- src/ui/tools/rect-tool.cpp | 5 ----- src/ui/tools/select-tool.cpp | 4 +--- src/ui/tools/spiral-tool.cpp | 5 ----- src/ui/tools/spray-tool.cpp | 14 -------------- src/ui/tools/star-tool.cpp | 5 +---- src/ui/tools/text-tool.cpp | 6 +----- src/ui/tools/tool-base.cpp | 10 +--------- src/ui/tools/tweak-tool.cpp | 12 ------------ src/ui/tools/zoom-tool.cpp | 1 - 25 files changed, 12 insertions(+), 186 deletions(-) (limited to 'src/ui/tools') 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 +#include #endif #include @@ -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..9b5b264bc 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 #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 -#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" diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 28195eb75..84c4adc89 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 #include #include @@ -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 #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" diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 74f2664fe..605b573d7 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 #include #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" diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index c838c27d5..4db720686 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include @@ -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; 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 - -#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..838522b34 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 #include #include @@ -38,7 +36,6 @@ #include "display/canvas-bpath.h" #include <2geom/bezier-utils.h> -#include #include "macros.h" #include "document.h" #include "selection.h" @@ -47,26 +44,18 @@ #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-text.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 "display/curve.h" diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 748c82717..2f125e6ed 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 #endif #include "trace/potrace/inkscape-potrace.h" #include <2geom/pathvector.h> #include #include -#include #include #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" diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 7697cd59c..eb29ed88d 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 #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 #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 using Inkscape::DocumentUndo; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 9d8101cc4..e4814c3de 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 #endif @@ -31,17 +31,10 @@ #include "ui/tools/gradient-tool.h" #include "gradient-chemistry.h" #include -#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" diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 9bbc1ac20..ee85dd28c 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 #endif #include <2geom/sbasis-geometric.h> -#include #include -#include "macros.h" #include "pixmaps/cursor-crosshairs.xpm" #include #include "desktop.h" #include "message-context.h" -#include "preferences.h" #include "ui/shape-editor.h" #include "selection.h" diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 63e2460ec..c941b9bee 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 +#include #endif #include -#include #include #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 diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 47927667c..32e70bc19 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 #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" diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 23aaf6bb1..bf18d4a2e 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" diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 18af8e105..49f28ad2c 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 -#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; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index b029ca613..7cc695040 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 #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 { 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 #include #include @@ -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 -#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..5d802d4da 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 #endif #include #include @@ -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; 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 #include #include @@ -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 -#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..3fafac2a7 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -19,15 +19,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include #include "ui/dialog/dialog-manager.h" #include "svg/svg.h" -#include #include "macros.h" #include "document.h" #include "document-undo.h" @@ -37,10 +34,7 @@ #include "message-context.h" #include "pixmaps/cursor-spray.xpm" -#include -#include "xml/repr.h" #include "context-fns.h" -#include "sp-item.h" #include "inkscape.h" #include "splivarot.h" @@ -57,17 +51,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 +65,6 @@ #include "helper/action.h" #include "verbs.h" -#include - -#include #include #include 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 #endif #include @@ -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 -#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 +#include #endif #include @@ -23,7 +23,6 @@ #include #include #include -#include #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 using Inkscape::ControlManager; using Inkscape::DocumentUndo; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 72ba499de..735f5bd42 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 #endif #include "widgets/desktop-widget.h" @@ -24,12 +24,8 @@ #include "file.h" #include "ui/tools/tool-base.h" -#include #include -#include #include -#include -#include #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 diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 39a7a3f0b..fbf1b2a0b 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 #include #include @@ -21,7 +19,6 @@ #include "svg/svg.h" -#include #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 -#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" 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" -- cgit v1.2.3 From e471a664f923f517b68071f2e33fbb6ce070f8b7 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 8 Aug 2016 13:56:40 +0100 Subject: Remove deprecated Autotools and btool files. Please use CMake instead (bzr r15046) --- src/ui/tools/Makefile_insert | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 src/ui/tools/Makefile_insert (limited to 'src/ui/tools') 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 -- cgit v1.2.3 From e1a84ff6c44588f7847258b5eb5266365e0738e1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 Aug 2016 15:27:55 +0200 Subject: Fixes to helper paths. evaluate backport to 0.92.x (bzr r15086) --- src/ui/tools/node-tool.cpp | 20 ++++++++++++++------ src/ui/tools/node-tool.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index f7f09610c..99c98476f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -158,6 +158,9 @@ NodeTool::~NodeTool() { if (this->helperpath_tmpitem) { this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); } + if (this->helperpath_tmpitem_highlight) { + this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem_highlight); + } this->_selection_changed_connection.disconnect(); //this->_selection_modified_connection.disconnect(); this->_mouseover_changed_connection.disconnect(); @@ -238,13 +241,13 @@ void NodeTool::setup() { ); this->helperpath_tmpitem = NULL; + this->helperpath_tmpitem_highlight = NULL; this->cursor_drag = false; this->show_transform_handles = true; this->single_node_transform_handles = false; 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"); @@ -271,7 +274,7 @@ void NodeTool::setup() { } this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive - this->update_helperpath(); + update_helperpath(); } // show helper paths of the applied LPE, if any @@ -282,6 +285,10 @@ void NodeTool::update_helperpath () { this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); this->helperpath_tmpitem = NULL; } + if (this->helperpath_tmpitem_highlight) { + this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem_highlight); + this->helperpath_tmpitem_highlight = NULL; + } if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); @@ -305,6 +312,11 @@ void NodeTool::update_helperpath () { cc->reset(); } if (!c->is_empty()) { + SPCanvasItem *helperpath_highlight = sp_canvas_bpath_new(this->desktop->getTempGroup(), c); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath_highlight), 0xffffff9A, 2.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath_highlight), 0, SP_WIND_RULE_NONZERO); + sp_canvas_item_affine_absolute(helperpath_highlight, selection->singleItem()->i2dt_affine()); + this->helperpath_tmpitem_highlight = this->desktop->add_temporary_canvasitem(helperpath_highlight, 0); SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c); 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); @@ -468,13 +480,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); @@ -629,7 +638,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/node-tool.h b/src/ui/tools/node-tool.h index 8342d66a6..bebb26dfc 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -69,6 +69,7 @@ private: SPItem *flashed_item; Inkscape::Display::TemporaryItem *helperpath_tmpitem; + Inkscape::Display::TemporaryItem *helperpath_tmpitem_highlight; Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; Inkscape::UI::PathSharedData* _path_data; -- cgit v1.2.3 From 3a70c702b97414c4508c6871462d1fa4f1433ad7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 Aug 2016 18:15:30 +0200 Subject: Add comment and fix in helper paths (bzr r15087) --- src/ui/tools/node-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 99c98476f..c266db05c 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -274,7 +274,7 @@ void NodeTool::setup() { } this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive - update_helperpath(); + this->update_helperpath(); } // show helper paths of the applied LPE, if any -- cgit v1.2.3 From 0e90df42ad8299b0a42435fb4445f83bc4ddbbfd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 Aug 2016 19:35:32 +0200 Subject: Fix a bug in pattern along path at first edit node after applied. Backport it to 0.92 (bzr r15089) --- src/ui/tools/freehand-base.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index eb29ed88d..7382c37ea 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -212,6 +212,19 @@ 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(lpe)->pattern.set_new_value(newpath,true); + + // write pattern along path parameters: + lpe->getRepr()->setAttribute("copytype", "single_stretched"); + lpe->getRepr()->setAttribute("fuse_tolerance", "0"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("normal_offset", "0"); + lpe->getRepr()->setAttribute("prop_scale", "1"); + lpe->getRepr()->setAttribute("prop_units", "false"); + lpe->getRepr()->setAttribute("scale_y_rel", "false"); + lpe->getRepr()->setAttribute("spacing", "0"); + lpe->getRepr()->setAttribute("tang_offset", "0"); + lpe->getRepr()->setAttribute("vertical_pattern", "false"); + } static void spdc_apply_powerstroke_shape(const std::vector & points, FreehandBase *dc, SPItem *item) -- cgit v1.2.3 From 1b8b972f1e0d6ee32c1f85514ec334c654d1e29c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 Aug 2016 22:39:07 +0200 Subject: Partial fix for bug 172063 while we find a better solution for XOR in helper lines (bzr r15090) --- src/ui/tools/calligraphic-tool.cpp | 8 ++++---- src/ui/tools/connector-tool.cpp | 6 +++--- src/ui/tools/eraser-tool.cpp | 6 +++--- src/ui/tools/node-tool.cpp | 15 +-------------- src/ui/tools/node-tool.h | 1 - src/ui/tools/pen-tool.cpp | 22 +++++++++++----------- src/ui/tools/pencil-tool.cpp | 2 +- 7 files changed, 23 insertions(+), 37 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index d623035d9..9b4dbb1a2 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -135,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(); @@ -1090,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 */ @@ -1126,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); @@ -1170,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 84f7f318c..7e6fb4b72 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -620,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; } @@ -811,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); } @@ -1035,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); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index d18db8266..4b40262cd 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -943,7 +943,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 */ @@ -980,7 +980,7 @@ void EraserTool::fit_and_split(bool release) { 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); @@ -1029,7 +1029,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/node-tool.cpp b/src/ui/tools/node-tool.cpp index c266db05c..b4fc569bb 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -158,9 +158,6 @@ NodeTool::~NodeTool() { if (this->helperpath_tmpitem) { this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); } - if (this->helperpath_tmpitem_highlight) { - this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem_highlight); - } this->_selection_changed_connection.disconnect(); //this->_selection_modified_connection.disconnect(); this->_mouseover_changed_connection.disconnect(); @@ -241,7 +238,6 @@ void NodeTool::setup() { ); this->helperpath_tmpitem = NULL; - this->helperpath_tmpitem_highlight = NULL; this->cursor_drag = false; this->show_transform_handles = true; this->single_node_transform_handles = false; @@ -285,10 +281,6 @@ void NodeTool::update_helperpath () { this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); this->helperpath_tmpitem = NULL; } - if (this->helperpath_tmpitem_highlight) { - this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem_highlight); - this->helperpath_tmpitem_highlight = NULL; - } if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); @@ -312,12 +304,7 @@ void NodeTool::update_helperpath () { cc->reset(); } if (!c->is_empty()) { - SPCanvasItem *helperpath_highlight = sp_canvas_bpath_new(this->desktop->getTempGroup(), c); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath_highlight), 0xffffff9A, 2.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath_highlight), 0, SP_WIND_RULE_NONZERO); - sp_canvas_item_affine_absolute(helperpath_highlight, selection->singleItem()->i2dt_affine()); - this->helperpath_tmpitem_highlight = this->desktop->add_temporary_canvasitem(helperpath_highlight, 0); - 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()); diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index bebb26dfc..8342d66a6 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -69,7 +69,6 @@ private: SPItem *flashed_item; Inkscape::Display::TemporaryItem *helperpath_tmpitem; - Inkscape::Display::TemporaryItem *helperpath_tmpitem_highlight; Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; Inkscape::UI::PathSharedData* _path_data; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 49f28ad2c..b7579b1fb 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -865,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); @@ -877,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 @@ -1251,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)); @@ -1277,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); } @@ -1343,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); @@ -1701,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); } @@ -1722,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(); @@ -1778,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 ? @@ -1818,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]); @@ -1850,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 7cc695040..9e8005be8 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -847,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(); -- cgit v1.2.3 From 5cb8c080df223593fbae945178da3e500fe762c6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 29 Aug 2016 23:13:26 +0200 Subject: Add phantom bpath to helper (bzr r15092) --- src/ui/tools/node-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index b4fc569bb..2bd4fdea3 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -523,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, -- cgit v1.2.3 From d16ce258120800e84bfca5c3c687c25177a3137c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 11 Sep 2016 12:10:44 +0200 Subject: Fix bugs: #1621234 and #172137 Fixed bugs: - https://launchpad.net/bugs/172137 - https://launchpad.net/bugs/1621234 (bzr r15111) --- src/ui/tools/freehand-base.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 7382c37ea..e42336113 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -212,19 +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(lpe)->pattern.set_new_value(newpath,true); - - // write pattern along path parameters: - lpe->getRepr()->setAttribute("copytype", "single_stretched"); - lpe->getRepr()->setAttribute("fuse_tolerance", "0"); - lpe->getRepr()->setAttribute("is_visible", "true"); - lpe->getRepr()->setAttribute("normal_offset", "0"); - lpe->getRepr()->setAttribute("prop_scale", "1"); - lpe->getRepr()->setAttribute("prop_units", "false"); - lpe->getRepr()->setAttribute("scale_y_rel", "false"); - lpe->getRepr()->setAttribute("spacing", "0"); - lpe->getRepr()->setAttribute("tang_offset", "0"); - lpe->getRepr()->setAttribute("vertical_pattern", "false"); - + 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 & points, FreehandBase *dc, SPItem *item) @@ -341,7 +332,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, // "triangle in" std::vector points(1); points[0] = Geom::Point(0., swidth/2); - points[0] *= i2anc_affine(static_cast(item->parent), NULL).inverse(); + //points[0] *= i2anc_affine(static_cast(item->parent), NULL).inverse(); spdc_apply_powerstroke_shape(points, dc, item); shape_applied = true; @@ -353,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 points(1); points[0] = Geom::Point(0, swidth/2); - points[0] *= i2anc_affine(static_cast(item->parent), NULL).inverse(); + //points[0] *= i2anc_affine(static_cast(item->parent), NULL).inverse(); points[0][Geom::X] = (double)curve_length; spdc_apply_powerstroke_shape(points, dc, item); @@ -791,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); } -- cgit v1.2.3 From c4bd2a99c8d32c8051a2a36aa5ff4594cacdc195 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 11 Sep 2016 12:57:01 +0200 Subject: Fix compiler warning (bzr r15112) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index e42336113..067035b97 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -790,7 +790,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) shape_selected == BEND_CLIPBOARD) { spdc_check_for_and_apply_waiting_LPE(dc, item, c); - previous_shape_type == BEND_CLIPBOARD; + previous_shape_type = BEND_CLIPBOARD; } Inkscape::GC::release(repr); item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); -- cgit v1.2.3 From 4988026d95aab5928246ebae4d04f41ae72bc2cf Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 15 Sep 2016 20:20:36 +0300 Subject: Remove "== true"s (bzr r15100.1.19) --- src/ui/tools/freehand-base.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 067035b97..a7cd39a89 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -372,7 +372,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { // take shape from clipboard; Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ + if(cm->paste(SP_ACTIVE_DESKTOP,true)){ SPItem * pasted_clipboard = dc->selection->singleItem(); if(pasted_clipboard){ Inkscape::XML::Node *pasted_clipboard_root = pasted_clipboard->getRepr(); @@ -401,7 +401,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, case BEND_CLIPBOARD: { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ + if(cm->paste(SP_ACTIVE_DESKTOP,true)){ gchar const *svgd = item->getRepr()->attribute("d"); bend_item = dc->selection->singleItem(); if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){ -- cgit v1.2.3 From 7d4ed3c86099e3326c33f6202efec74b3e109756 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 26 Sep 2016 12:18:39 +0200 Subject: Fix Gtk type error, code cleanup, and documentation. (bzr r15133) --- src/ui/tools/gradient-tool.cpp | 1 + src/ui/tools/mesh-tool.cpp | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index a084a8fd9..16df225e0 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -871,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; diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index f2cf8c4a2..168e26b4c 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -265,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 ); @@ -425,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; @@ -458,8 +463,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (! drag->lines.empty()) { for (std::vector::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)); } } @@ -594,7 +598,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (!drag->lines.empty()) { for (std::vector::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)); } } @@ -625,8 +629,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (!drag->lines.empty()) { for (std::vector::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; @@ -925,6 +928,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(); -- cgit v1.2.3 From f2dd0550fc1a2d4deac985d28055f305b3ad7f64 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 26 Sep 2016 14:21:26 +0200 Subject: Remove unused variable. (bzr r15136) --- src/ui/tools/mesh-tool.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 168e26b4c..763685a0c 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -459,7 +459,6 @@ 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::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { -- cgit v1.2.3 From f9ec83dbb254701f39d3b7a30c0bacb5eaae9ee9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 27 Sep 2016 10:51:26 +0200 Subject: Rename to per SVG 2 CR specificiation. Note: has been repurposed to be a special shape that tightly wraps a mesh gradient. (bzr r15137) --- src/ui/tools/mesh-tool.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 763685a0c..aac8239f3 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -47,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; @@ -161,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 ) { @@ -330,8 +330,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) SPDocument *doc = NULL; GrDrag *drag = rc->_grdrag; - std::map > points; - std::map items; + std::map > points; + std::map items; // Get list of selected draggers for each mesh. // For all selected draggers @@ -345,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 ); @@ -354,8 +354,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) } // Loop over meshes. - for( std::map >::const_iterator iter = points.begin(); iter != points.end(); ++iter) { - SPMesh *mg = SP_MESH( iter->first ); + for( std::map >::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) { -- cgit v1.2.3 From e1d0c1cb00f84b66b38af6eec563cf60df7ba726 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 3 Oct 2016 18:08:29 +0200 Subject: Fix a bug on eraser mode when previous clip are shapes not paths (bzr r15145) --- src/ui/tools/eraser-tool.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 38c72cac0..12686160b 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -766,9 +766,17 @@ void EraserTool::set_to_accumulated() { if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { - SPPath *clip_data = SP_PATH(clip_path->firstChild()); + std::vector selected; + selected.push_back(SP_ITEM(clip_path->firstChild())); + std::vector to_select; + std::vector 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 = SP_OBJECT(clip_data)->getRepr()->duplicate(xml_doc); + 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) { -- cgit v1.2.3 From eb4b3b8d4823f7a9cef4e623080e3d1e4b7426eb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 7 Oct 2016 20:03:23 +0200 Subject: Fix bug:1630821 on LPE selected nodes Fixed bugs: - https://launchpad.net/bugs/1630821 (bzr r15149) --- src/ui/tools/node-tool.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 2bd4fdea3..f3679b40f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -285,13 +285,11 @@ void NodeTool::update_helperpath () { if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { - Inkscape::UI::ControlPointSelection::Set &selectionNodes = _selected_nodes->allPoints(); + Inkscape::UI::ControlPointSelection *selectionNodes = _selected_nodes; std::vector selectedNodesPositions; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selectionNodes.begin(); i != selectionNodes.end(); ++i) { - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast(*i); - selectedNodesPositions.push_back(n->position()); - } + for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { + Inkscape::UI::Node *n = dynamic_cast(*i); + selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); lpe->setCurrentZoom(this->desktop->current_zoom()); @@ -470,6 +468,7 @@ bool NodeTool::root_handler(GdkEvent* event) { switch (event->type) { case GDK_MOTION_NOTIFY: { + update_helperpath(); combine_motion_events(desktop->canvas, event->motion, 0); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); -- cgit v1.2.3 From 7be3086bf70ba9bf28c5cfe06fd7a8e28e719bcc Mon Sep 17 00:00:00 2001 From: sandra-snan Date: Sat, 8 Oct 2016 08:16:53 +0200 Subject: [Bug #770681] KEY MAPPING: Comma and period hijacked by scaling. Fixed bugs: - https://launchpad.net/bugs/770681 (bzr r15155) --- src/ui/tools/select-tool.cpp | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 86a2dbed3..0cdeda0b6 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -1045,37 +1045,7 @@ bool SelectTool::root_handler(GdkEvent* event) { ret = TRUE; break; - - case GDK_KEY_less: - case GDK_KEY_comma: - if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale_screen(selection, -2*mul); - } else if (MOD__CTRL(event)) { - sp_selection_scale_times(selection, 0.5); - } else { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale(selection, -offset*mul); - } - - ret = TRUE; - break; - - case GDK_KEY_greater: - case GDK_KEY_period: - if (MOD__ALT(event)) { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale_screen(selection, 2*mul); - } else if (MOD__CTRL(event)) { - sp_selection_scale_times(selection, 2); - } else { - gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask - sp_selection_scale(selection, offset*mul); - } - - ret = TRUE; - break; - + case GDK_KEY_Return: if (MOD__CTRL_ONLY(event)) { if (selection->singleItem()) { -- cgit v1.2.3 From 2715ea15f1574bf2efc00610ac3c930dcfb30621 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 14 Oct 2016 10:39:17 +0200 Subject: Do not create unused "vector" gradient when creating mesh gradient. (bzr r15168) --- src/ui/tools/mesh-tool.cpp | 48 +++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index aac8239f3..5e88e26b3 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -38,6 +38,9 @@ #include "snap.h" #include "sp-namedview.h" #include "verbs.h" +#include "sp-text.h" +#include "sp-defs.h" +#include "style.h" // Gradient specific #include "gradient-drag.h" @@ -937,37 +940,42 @@ static void sp_mesh_end_drag(MeshTool &rc) { if (!selection->isEmpty()) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - int type = SP_GRADIENT_TYPE_MESH; - Inkscape::PaintTarget fill_or_stroke = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; + Inkscape::PaintTarget fill_or_stroke = + (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? + Inkscape::FOR_FILL : Inkscape::FOR_STROKE; - SPGradient *vector; - if (ec->item_to_select) { - // pick color from the object where drag started - vector = sp_gradient_vector_for_object(document, desktop, ec->item_to_select, fill_or_stroke); - } else { - // Starting from empty space: - // Sort items so that the topmost comes last - std::vector 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); - } - - // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs +// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + SPDefs *defs = document->getDefs(); + 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"); - sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); + // Create mesh element + Inkscape::XML::Node *repr = xml_doc->createElement("svg:meshgradient"); - // We don't need to do anything. Mesh is already sized appropriately. - - (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); + // privates are garbage-collectable + repr->setAttribute("inkscape:collect", "always"); + + // Attach to document + defs->getRepr()->appendChild(repr); + Inkscape::GC::release(repr); + + // Get corresponding object + SPMeshGradient *mg = static_cast(document->getObjectByRepr(repr)); + mg->array.create(mg, *i, (*i)->visualBounds()); + + bool isText = SP_IS_TEXT(*i); + sp_style_set_property_url (*i, ((fill_or_stroke == Inkscape::FOR_FILL) ? "fill":"stroke"), + mg, isText); + + (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG|SP_OBJECT_STYLE_MODIFIED_FLAG); } DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, _("Create mesh")); -- cgit v1.2.3 From 32442aec84cc13f0a22fa1f07f3de701c6938e5d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 14 Oct 2016 22:01:57 +0200 Subject: Implement copying of objects with mesh gradients. (bzr r15171) --- src/ui/tools/mesh-tool.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 5e88e26b3..33cdc3bda 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -59,7 +59,7 @@ namespace Inkscape { namespace UI { namespace Tools { -static void sp_mesh_end_drag(MeshTool &rc); +static void sp_mesh_new_default(MeshTool &rc); const std::string& MeshTool::getPrefsPath() { return MeshTool::prefsPath; @@ -474,24 +474,25 @@ bool MeshTool::root_handler(GdkEvent* event) { // always resets selection to the single object under cursor sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time); } else { + sp_mesh_new_default(*this); // Create a new gradient with default coordinates. - 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; - -#ifdef DEBUG_MESH - std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl; -#endif - SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode); - - SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode); - sp_gradient_reset_to_userspace(priv, item); - } - - DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, - _("Create default mesh")); +// 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; + +// #ifdef DEBUG_MESH +// std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl; +// #endif +// SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode); + +// SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode); +// sp_gradient_reset_to_userspace(priv, item); +// } + +// DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, +// _("Create default mesh")); } ret = TRUE; @@ -666,7 +667,7 @@ bool MeshTool::root_handler(GdkEvent* event) { } } else { // Create a new mesh gradient - sp_mesh_end_drag(*this); + sp_mesh_new_default(*this); } } else if (this->item_to_select) { if (over_line && line) { @@ -931,7 +932,7 @@ bool MeshTool::root_handler(GdkEvent* event) { } // Creates a new mesh gradient. -static void sp_mesh_end_drag(MeshTool &rc) { +static void sp_mesh_new_default(MeshTool &rc) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; Inkscape::Selection *selection = desktop->getSelection(); SPDocument *document = desktop->getDocument(); -- cgit v1.2.3 From 619f8b5d9173f2bcc9d9aefccee832d686724e79 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 17 Oct 2016 15:04:09 +0200 Subject: Add option to scale mesh to fit in bounding box. (bzr r15173) --- src/ui/tools/mesh-tool.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/ui/tools/mesh-tool.h | 1 + 2 files changed, 67 insertions(+) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 33cdc3bda..cea508782 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -52,6 +52,7 @@ #include "ui/tools/mesh-tool.h" #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" +#include "display/curve.h" using Inkscape::DocumentUndo; @@ -430,6 +431,71 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) } +/** + * Scale mesh to just fit into bbox of selected items. + */ +void +sp_mesh_context_fit_mesh_in_bbox (MeshTool *rc) +{ + +#ifdef DEBUG_MESH + std::cout << "sp_mesh_context_fit_mesh_in_bbox: entrance: Entrance"<< std::endl; +#endif + + SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop; + + Inkscape::Selection *selection = desktop->getSelection(); + if (selection == NULL) { + return; + } + + bool changed = false; + auto itemlist = selection->items(); + for (auto i=itemlist.begin(); i!=itemlist.end(); ++i) { + + SPItem *item = *i; + SPStyle *style = item->style; + + if (style && (style->fill.isPaintserver())) { + SPPaintServer *server = item->style->getFillPaintServer(); + if ( SP_IS_MESHGRADIENT(server) ) { + + SPMeshGradient *gradient = SP_MESHGRADIENT(server); + SPCurve * outline = gradient->array.outline_path(); + Geom::OptRect mesh_bbox = outline->get_pathvector().boundsExact(); + outline->unref(); + Geom::OptRect item_bbox = item->geometricBounds(); + + if ((*mesh_bbox).width() == 0) { + continue; + } + if ((*mesh_bbox).height() == 0) { + continue; + } + double scale_x = (*item_bbox).width() /(*mesh_bbox).width() ; + double scale_y = (*item_bbox).height()/(*mesh_bbox).height(); + + Geom::Translate t1(-(*mesh_bbox).min()); + Geom::Scale scale(scale_x,scale_y); + Geom::Translate t2((*item_bbox).min()); + Geom::Affine transform = t1 * scale * t2; + if (!transform.isIdentity() ) { + gradient->array.transform(transform); + gradient->array.write( gradient ); + gradient->requestModified(SP_OBJECT_MODIFIED_FLAG); + changed = true; + } + } + } + + } + if (changed) { + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, + _("Fit mesh inside bounding box.")); + } +} + + /** Handles all keyboard and mouse input for meshs. Note: node/handle events are take care of elsewhere. diff --git a/src/ui/tools/mesh-tool.h b/src/ui/tools/mesh-tool.h index 91b35b3af..f142bfd9c 100644 --- a/src/ui/tools/mesh-tool.h +++ b/src/ui/tools/mesh-tool.h @@ -59,6 +59,7 @@ private: void sp_mesh_context_select_next(ToolBase *event_context); void sp_mesh_context_select_prev(ToolBase *event_context); void sp_mesh_context_corner_operation(MeshTool *event_context, MeshCornerOperation operation ); +void sp_mesh_context_fit_mesh_in_bbox(MeshTool *event_context); } } -- cgit v1.2.3 From 5a528acc28fee968aee4d79373625ed7d0fa553d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 18 Oct 2016 19:07:20 +0200 Subject: Use geometric bounding box for fill, visual for stroke in creating mesh. (bzr r15175) --- src/ui/tools/mesh-tool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index cea508782..c6983b94a 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -1036,7 +1036,8 @@ static void sp_mesh_new_default(MeshTool &rc) { // Get corresponding object SPMeshGradient *mg = static_cast(document->getObjectByRepr(repr)); - mg->array.create(mg, *i, (*i)->visualBounds()); + mg->array.create(mg, *i, (fill_or_stroke == Inkscape::FOR_FILL) ? + (*i)->geometricBounds() : (*i)->visualBounds()); bool isText = SP_IS_TEXT(*i); sp_style_set_property_url (*i, ((fill_or_stroke == Inkscape::FOR_FILL) ? "fill":"stroke"), @@ -1045,6 +1046,11 @@ static void sp_mesh_new_default(MeshTool &rc) { (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG|SP_OBJECT_STYLE_MODIFIED_FLAG); } + if (css) { + sp_repr_css_attr_unref(css); + css = 0; + } + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, _("Create mesh")); // status text; we do not track coords because this branch is run once, not all the time -- cgit v1.2.3 From 532f77b14a76fc04e6bdeca3625f9a55b5f11bdf Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 25 Oct 2016 00:58:43 +0200 Subject: CPPification: almost all sp_object_set_whatever and sp_selection_whatever global functions are now methods of ObjectSet*, with these additional benefits: - They can now act on any SelectionSet, not just the current selection; - Whenever possible, they don't need a desktop anymore and can run if called from GUI. I hope I did not break too many things in the process. *: So instead of callink sp_selection_move(desktop,x,y), you call myobjectset->move(x,y) (bzr r15189) --- src/ui/tools/box3d-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 14 ++++++------- src/ui/tools/freehand-base.cpp | 2 +- src/ui/tools/pen-tool.cpp | 2 +- src/ui/tools/pencil-tool.cpp | 2 +- src/ui/tools/rect-tool.cpp | 2 +- src/ui/tools/select-tool.cpp | 46 +++++++++++++++++++++--------------------- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 94488a700..425695a2c 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -400,7 +400,7 @@ bool Box3dTool::root_handler(GdkEvent* event) { case GDK_KEY_g: case GDK_KEY_G: if (MOD__SHIFT_ONLY(event)) { - sp_selection_to_guides(desktop); + desktop->selection->toGuides(); ret = true; } break; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 12686160b..4f941e534 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -732,10 +732,10 @@ void EraserTool::set_to_accumulated() { 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(this->desktop, true); + selection->combine(true); } else { if(!this->nowidth){ - sp_selected_path_break_apart(this->desktop, true); + selection->breakApart(true); } } if ( !selection->isEmpty() ) { @@ -784,7 +784,7 @@ void EraserTool::set_to_accumulated() { 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->raiseToTop(true); selection->add(dup_clip); sp_selected_path_diff_skip_undo(selection); SPItem * clip = SP_ITEM(*(selection->items().begin())); @@ -800,13 +800,13 @@ void EraserTool::set_to_accumulated() { 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->raiseToTop(true); selection->add(rect); sp_selected_path_diff_skip_undo(selection); } - sp_selection_raise_to_top(selection, this->desktop, true); + selection->raiseToTop(true); selection->add(item); - sp_selection_set_mask(this->desktop, true, false, true); + selection->setMask(true, false, true); } else { SPItem *erase_clip = selection->singleItem(); if (erase_clip) { @@ -836,7 +836,7 @@ void EraserTool::set_to_accumulated() { } if (eraser_mode == ERASER_MODE_DELETE) { - sp_selection_delete(this->desktop); + selection->deleteItems(); remainingItems.clear(); } diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index a7cd39a89..300324467 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -435,7 +435,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if(bend_item != NULL && bend_item->getRepr() != NULL){ gchar const *svgd = item->getRepr()->attribute("d"); dc->selection->add(SP_OBJECT(bend_item)); - sp_selection_duplicate(dc->desktop); + dc->selection->duplicate(); dc->selection->remove(SP_OBJECT(bend_item)); bend_item = dc->selection->singleItem(); if(bend_item){ diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index b7579b1fb..312338882 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1233,7 +1233,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { case GDK_KEY_g: case GDK_KEY_G: if (MOD__SHIFT_ONLY(event)) { - sp_selection_to_guides(this->desktop); + this->desktop->selection->toGuides(); ret = true; } break; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 9e8005be8..54106437c 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -487,7 +487,7 @@ bool PencilTool::_handleKeyPress(GdkEventKey const &event) { case GDK_KEY_g: case GDK_KEY_G: if (Inkscape::UI::held_only_shift(event)) { - sp_selection_to_guides(this->desktop); + this->desktop->selection->toGuides(); ret = true; } break; diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 00330ef57..272531945 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -294,7 +294,7 @@ bool RectTool::root_handler(GdkEvent* event) { case GDK_KEY_g: case GDK_KEY_G: if (MOD__SHIFT_ONLY(event)) { - sp_selection_to_guides(desktop); + desktop->selection->toGuides(); ret = true; } break; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 0cdeda0b6..6c450b3dc 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -902,15 +902,15 @@ bool SelectTool::root_handler(GdkEvent* event) { if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { - sp_selection_move_screen(desktop->getSelection(), mul*-10, 0); // shift + desktop->getSelection()->moveScreen(mul*-10, 0); // shift } else { - sp_selection_move_screen(desktop->getSelection(), mul*-1, 0); // no shift + desktop->getSelection()->moveScreen(mul*-1, 0); // no shift } } else { // no alt if (MOD__SHIFT(event)) { - sp_selection_move(desktop->getSelection(), mul*-10*nudge, 0); // shift + desktop->getSelection()->move(mul*-10*nudge, 0); // shift } else { - sp_selection_move(desktop->getSelection(), mul*-nudge, 0); // no shift + desktop->getSelection()->move(mul*-nudge, 0); // no shift } } @@ -925,15 +925,15 @@ bool SelectTool::root_handler(GdkEvent* event) { if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { - sp_selection_move_screen(desktop->getSelection(), 0, mul*10); // shift + desktop->getSelection()->moveScreen(0, mul*10); // shift } else { - sp_selection_move_screen(desktop->getSelection(), 0, mul*1); // no shift + desktop->getSelection()->moveScreen(0, mul*1); // no shift } } else { // no alt if (MOD__SHIFT(event)) { - sp_selection_move(desktop->getSelection(), 0, mul*10*nudge); // shift + desktop->getSelection()->move(0, mul*10*nudge); // shift } else { - sp_selection_move(desktop->getSelection(), 0, mul*nudge); // no shift + desktop->getSelection()->move(0, mul*nudge); // no shift } } @@ -948,15 +948,15 @@ bool SelectTool::root_handler(GdkEvent* event) { if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { - sp_selection_move_screen(desktop->getSelection(), mul*10, 0); // shift + desktop->getSelection()->moveScreen(mul*10, 0); // shift } else { - sp_selection_move_screen(desktop->getSelection(), mul*1, 0); // no shift + desktop->getSelection()->moveScreen(mul*1, 0); // no shift } } else { // no alt if (MOD__SHIFT(event)) { - sp_selection_move(desktop->getSelection(), mul*10*nudge, 0); // shift + desktop->getSelection()->move(mul*10*nudge, 0); // shift } else { - sp_selection_move(desktop->getSelection(), mul*nudge, 0); // no shift + desktop->getSelection()->move(mul*nudge, 0); // no shift } } @@ -971,15 +971,15 @@ bool SelectTool::root_handler(GdkEvent* event) { if (MOD__ALT(event)) { // alt if (MOD__SHIFT(event)) { - sp_selection_move_screen(desktop->getSelection(), 0, mul*-10); // shift + desktop->getSelection()->moveScreen(0, mul*-10); // shift } else { - sp_selection_move_screen(desktop->getSelection(), 0, mul*-1); // no shift + desktop->getSelection()->moveScreen(0, mul*-1); // no shift } } else { // no alt if (MOD__SHIFT(event)) { - sp_selection_move(desktop->getSelection(), 0, mul*-10*nudge); // shift + desktop->getSelection()->move(0, mul*-10*nudge); // shift } else { - sp_selection_move(desktop->getSelection(), 0, mul*-nudge); // no shift + desktop->getSelection()->move(0, mul*-nudge); // no shift } } @@ -1023,11 +1023,11 @@ 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 - sp_selection_rotate_screen(selection, mul*1); + selection->rotateScreen(mul*1); } else if (MOD__CTRL(event)) { - sp_selection_rotate(selection, 90); + selection->rotate(90); } else if (snaps) { - sp_selection_rotate(selection, 180.0/snaps); + selection->rotate(180.0/snaps); } ret = TRUE; @@ -1036,11 +1036,11 @@ 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 - sp_selection_rotate_screen(selection, -1*mul); + selection->rotateScreen(-1*mul); } else if (MOD__CTRL(event)) { - sp_selection_rotate(selection, -90); + selection->rotate(-90); } else if (snaps) { - sp_selection_rotate(selection, -180.0/snaps); + selection->rotate(-180.0/snaps); } ret = TRUE; @@ -1084,7 +1084,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_KEY_g: case GDK_KEY_G: if (MOD__SHIFT_ONLY(event)) { - sp_selection_to_guides(desktop); + desktop->selection->toGuides(); ret = true; } break; -- cgit v1.2.3 From 05d344828f919fad7846d2d76534eb02b554dc00 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Nov 2016 03:32:30 +0100 Subject: Fix bug:1639083 crach closing segment with shortcut LPE Fixed bugs: - https://launchpad.net/bugs/1639083 (bzr r15210) --- src/ui/tools/pen-tool.cpp | 48 ++++++++++++++++++++++---------------------- src/ui/tools/pencil-tool.cpp | 4 ++-- 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 312338882..caf6faec2 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -367,7 +367,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) { //with this we avoid creating a new point over the existing one if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ - if( anchor && anchor == this->sa && this->green_curve->is_empty()){ + if( anchor && anchor == this->sa && this->green_curve->is_unset()){ //remove the following line to avoid having one node on top of another _finishSegment(event_dt, bevent.state); _finish(true); @@ -919,7 +919,7 @@ void PenTool::_lastpointMove(gdouble x, gdouble y) { return; // green - if (!this->green_curve->is_empty()) { + if (!this->green_curve->is_unset()) { this->green_curve->last_point_additive_move( Geom::Point(x,y) ); } else { // start anchor too @@ -947,7 +947,7 @@ void PenTool::_lastpointToCurve() { this->p[1] = this->red_curve->last_segment()->initialPoint() + (1./3.)*(this->red_curve->last_segment()->finalPoint() - this->red_curve->last_segment()->initialPoint()); //modificate the last segment of the green curve so it creates the type of node we need if (this->spiro||this->bspline) { - if (!this->green_curve->is_empty()) { + if (!this->green_curve->is_unset()) { Geom::Point A(0,0); Geom::Point B(0,0); Geom::Point C(0,0); @@ -986,7 +986,7 @@ void PenTool::_lastpointToCurve() { } } //if the last node is an union with another curve - if (this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()) { + if (this->green_curve->is_unset() && this->sa && !this->sa->curve->is_unset()) { this->_bsplineSpiroStartAnchor(false); } } @@ -1002,7 +1002,7 @@ void PenTool::_lastpointToLine() { // modify the last segment of the green curve so the type of node we want is created. if(this->spiro || this->bspline){ - if(!this->green_curve->is_empty()){ + if(!this->green_curve->is_unset()){ Geom::Point A(0,0); Geom::Point B(0,0); Geom::Point C(0,0); @@ -1033,7 +1033,7 @@ void PenTool::_lastpointToLine() { } } // if the last node is an union with another curve - if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ + if(this->green_curve->is_unset() && this->sa && !this->sa->curve->is_unset()){ this->_bsplineSpiroStartAnchor(true); } } @@ -1212,7 +1212,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { // All this is needed to stop the last control // point dispeating and stop making an n-1 shape. Geom::Point const p(0, 0); - if(this->red_curve->is_empty()) { + if(this->red_curve->is_unset()) { this->red_curve->moveto(p); } this->_finishSegment(p, 0); @@ -1364,7 +1364,7 @@ void PenTool::_bsplineSpiro(bool shift) void PenTool::_bsplineSpiroOn() { - if(!this->red_curve->is_empty()){ + if(!this->red_curve->is_unset()){ using Geom::X; using Geom::Y; this->npoints = 5; @@ -1377,7 +1377,7 @@ void PenTool::_bsplineSpiroOn() void PenTool::_bsplineSpiroOff() { - if(!this->red_curve->is_empty()){ + if(!this->red_curve->is_unset()){ this->npoints = 5; this->p[0] = this->red_curve->first_segment()->initialPoint(); this->p[3] = this->red_curve->first_segment()->finalPoint(); @@ -1387,7 +1387,7 @@ void PenTool::_bsplineSpiroOff() void PenTool::_bsplineSpiroStartAnchor(bool shift) { - if(this->sa->curve->is_empty()){ + if(this->sa->curve->is_unset()){ return; } @@ -1497,18 +1497,18 @@ void PenTool::_bsplineSpiroMotion(bool shift){ } using Geom::X; using Geom::Y; - if(this->red_curve->is_empty()) return; + if(this->red_curve->is_unset()) return; this->npoints = 5; SPCurve *tmp_curve = new SPCurve(); this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]); this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP); - if(this->green_curve->is_empty() && !this->sa){ + if(this->green_curve->is_unset() && !this->sa){ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); this->p[1] = Geom::Point(this->p[1][X] + HANDLE_CUBIC_GAP,this->p[1][Y] + HANDLE_CUBIC_GAP); if(shift){ this->p[2] = this->p[3]; } - }else if(!this->green_curve->is_empty()){ + }else if(!this->green_curve->is_unset()){ tmp_curve = this->green_curve->copy(); }else{ tmp_curve = this->overwrite_curve->copy(); @@ -1516,7 +1516,7 @@ void PenTool::_bsplineSpiroMotion(bool shift){ tmp_curve = tmp_curve ->create_reverse(); } - if(!tmp_curve ->is_empty()){ + if(!tmp_curve ->is_unset()){ Geom::CubicBezier const * cubic = dynamic_cast(&*tmp_curve ->last_segment()); if(cubic){ if(this->bspline){ @@ -1548,7 +1548,7 @@ void PenTool::_bsplineSpiroMotion(bool shift){ } } - if(this->anchor_statusbar && !this->red_curve->is_empty()){ + if(this->anchor_statusbar && !this->red_curve->is_unset()){ if(shift){ this->_bsplineSpiroEndAnchorOff(); }else{ @@ -1681,19 +1681,19 @@ void PenTool::_bsplineSpiroBuild() //We create the base curve SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start - if(this->sa && !this->sa->curve->is_empty()){ + if(this->sa && !this->sa->curve->is_unset()){ curve = this->overwrite_curve->copy(); if (this->sa->start) { curve = curve->create_reverse(); } } - if (!this->green_curve->is_empty()){ + if (!this->green_curve->is_unset()){ curve->append_continuous(this->green_curve, 0.0625); } //and the red one - if (!this->red_curve->is_empty()){ + if (!this->red_curve->is_unset()){ this->red_curve->reset(); this->red_curve->moveto(this->p[0]); if(this->anchor_statusbar && !this->sa && !(this->green_anchor && this->green_anchor->active)){ @@ -1705,7 +1705,7 @@ void PenTool::_bsplineSpiroBuild() curve->append_continuous(this->red_curve, 0.0625); } - if(!curve->is_empty()){ + if(!curve->is_unset()){ // close the curve if the final points of the curve are close enough if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); @@ -1844,7 +1844,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { ++num_clicks; - if (!this->red_curve->is_empty()) { + if (!this->red_curve->is_unset()) { this->_bsplineSpiro(state & GDK_SHIFT_MASK); this->green_curve->append_continuous(this->red_curve, 0.0625); SPCurve *curve = this->red_curve->copy(); @@ -1869,8 +1869,8 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { bool PenTool::_undoLastPoint() { bool ret = false; - if ( this->green_curve->is_empty() || (this->green_curve->last_segment() == NULL) ) { - if (!this->red_curve->is_empty()) { + if ( this->green_curve->is_unset() || (this->green_curve->last_segment() == NULL) ) { + if (!this->red_curve->is_unset()) { this->_cancel (); ret = true; } else { @@ -1887,7 +1887,7 @@ bool PenTool::_undoLastPoint() { this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); } // Get last segment - if ( this->green_curve->is_empty() ) { + if ( this->green_curve->is_unset() ) { g_warning("pen_handle_key_press, case GDK_KP_Delete: Green curve is empty"); return false; } @@ -2019,7 +2019,7 @@ int PenTool::nextParaxialDirection(Geom::Point const &pt, Geom::Point const &ori // (on first mouse release), in which case num_clicks immediately becomes 1. // if (this->num_clicks == 0) { - if (this->green_curve->is_empty()) { + if (this->green_curve->is_unset()) { // first mouse click double dist_h = fabs(pt[Geom::X] - origin[Geom::X]); double dist_v = fabs(pt[Geom::Y] - origin[Geom::Y]); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 54106437c..ec2874823 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -588,8 +588,8 @@ void PencilTool::_setEndpoint(Geom::Point const &p) { * Still not sure, how it will make most sense. */ void PencilTool::_finishEndpoint() { - if ( ( this->red_curve->is_empty() ) - || ( *(this->red_curve->first_point()) == *(this->red_curve->second_point()) ) ) + if (this->red_curve->is_unset() || + this->red_curve->first_point() == this->red_curve->second_point()) { this->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL); -- cgit v1.2.3 From dd38575e29e544156915a4400ad9cb4a412c9fe6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Nov 2016 03:38:01 +0100 Subject: Fix bug:1639098 Fixed bugs: - https://launchpad.net/bugs/1639098 (bzr r15211) --- src/ui/tools/freehand-base.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 300324467..deb89b874 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -642,7 +642,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) } // Step A - test, whether we ended on green anchor - if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) { + if ( (forceclosed && + (!dc->sa || (dc->sa && dc->sa->curve->is_empty()))) || + ( dc->green_anchor && dc->green_anchor->active)) + { // We hit green anchor, closing Green-Blue-Red dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); c->closepath_current(); @@ -724,7 +727,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) e->unref(); } - + if (forceclosed) + { + dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); + c->closepath_current(); + } spdc_flush_white(dc, c); c->unref(); -- cgit v1.2.3 From bd0e1bc73283c9e0488b9f71d7ff7da43db57baa Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Nov 2016 02:12:00 +0100 Subject: Fix bug on apply bend LPE from pen/cil without cliboard, nothin happends previously (bzr r15216) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index deb89b874..36962fe9a 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -794,7 +794,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(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) + shape_selected == BEND_CLIPBOARD && previous_shape_type != NONE) { spdc_check_for_and_apply_waiting_LPE(dc, item, c); previous_shape_type = BEND_CLIPBOARD; -- cgit v1.2.3 From 64eaf40029c6c0e530fdbe3d80335fc97ae93507 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Nov 2016 02:15:41 +0100 Subject: Minor tweak (bzr r15217) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 36962fe9a..46c3255ca 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -794,7 +794,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(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 && previous_shape_type != NONE) + (shape_selected == BEND_CLIPBOARD && previous_shape_type != NONE)) { spdc_check_for_and_apply_waiting_LPE(dc, item, c); previous_shape_type = BEND_CLIPBOARD; -- cgit v1.2.3 From 08475cfe743c5996bd21e34d373921a760f26f6d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Nov 2016 17:39:10 +0100 Subject: Fix some bugs on pen/cil dropdown shapes (bzr r15219) --- src/ui/tools/freehand-base.cpp | 84 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 46c3255ca..056c723ee 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -273,12 +273,42 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem enum shapeType { NONE, TRIANGLE_IN, TRIANGLE_OUT, ELLIPSE, CLIPBOARD, BEND_CLIPBOARD, LAST_APPLIED }; static shapeType previous_shape_type = NONE; -static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) +static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve, bool is_bend) { using namespace Inkscape::LivePathEffect; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (item && SP_IS_LPE_ITEM(item)) { + //Store the clipboard path to apply in the future without the use of clipboard + static Geom::PathVector previous_shape_pathv; + static SPItem *bend_item; + shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); + if (previous_shape_type == NONE) { + previous_shape_type = shape; + } + if(shape == LAST_APPLIED){ + + shape = previous_shape_type; + if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){ + shape = LAST_APPLIED; + } + } + Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); + if (is_bend && + (shape == BEND_CLIPBOARD || (shape == LAST_APPLIED && previous_shape_type != CLIPBOARD)) && + cm->paste(SP_ACTIVE_DESKTOP,true)) + { + bend_item = dc->selection->singleItem(); + if(!bend_item || (!SP_IS_SHAPE(bend_item) && !SP_IS_GROUP(bend_item))){ + previous_shape_type = NONE; + return; + } + } else if(is_bend) { + return; + } + if (!is_bend && previous_shape_type == BEND_CLIPBOARD && shape == BEND_CLIPBOARD) { + return; + } bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0); if(simplify){ double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); @@ -300,29 +330,16 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, curve = sp_shape->getCurve(); } - //Store the clipboard path to apply in the future without the use of clipboard - static Geom::PathVector previous_shape_pathv; - - shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); bool shape_applied = false; SPCSSAttr *css_item = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS); const char *cstroke = sp_repr_css_property(css_item, "stroke", "none"); const char *stroke_width = sp_repr_css_property(css_item, "stroke-width", "0"); double swidth; sp_svg_number_read_d(stroke_width, &swidth); - static SPItem *bend_item; #define SHAPE_LENGTH 10 #define SHAPE_HEIGHT 10 - if(shape == LAST_APPLIED){ - - shape = previous_shape_type; - if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){ - shape = LAST_APPLIED; - } - } - switch (shape) { case NONE: // don't apply any shape @@ -400,21 +417,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, } case BEND_CLIPBOARD: { - Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if(cm->paste(SP_ACTIVE_DESKTOP,true)){ - gchar const *svgd = item->getRepr()->attribute("d"); - bend_item = dc->selection->singleItem(); - if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){ - bend_item->moveTo(item,false); - bend_item->transform.setTranslation(Geom::Point()); - spdc_apply_bend_shape(svgd, dc, bend_item); - dc->selection->add(SP_OBJECT(bend_item)); - - shape = BEND_CLIPBOARD; - } else { - bend_item = NULL; - shape = NONE; - } + gchar const *svgd = item->getRepr()->attribute("d"); + if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){ + bend_item->moveTo(item,false); + bend_item->transform.setTranslation(Geom::Point()); + spdc_apply_bend_shape(svgd, dc, bend_item); + dc->selection->add(SP_OBJECT(bend_item)); + + shape = BEND_CLIPBOARD; } else { bend_item = NULL; shape = NONE; @@ -790,25 +800,15 @@ 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)); //Bend needs the transforms applied after, Other effects best before - if((previous_shape_type == BEND_CLIPBOARD && shape_selected == LAST_APPLIED) || - (shape_selected == BEND_CLIPBOARD && previous_shape_type != NONE)) - { - spdc_check_for_and_apply_waiting_LPE(dc, item, c); - previous_shape_type = BEND_CLIPBOARD; - } + spdc_check_for_and_apply_waiting_LPE(dc, item, c, true); 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); - } + spdc_check_for_and_apply_waiting_LPE(dc, item, c, false); + dc->selection->set(repr); if(previous_shape_type == BEND_CLIPBOARD){ repr->parent()->removeChild(repr); } -- cgit v1.2.3 From 430533b9a259eb3dac44755306dfb0fddb34951d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 8 Nov 2016 15:05:30 +0100 Subject: Improve mesh handling in Fill and Stroke dialog. Create new meshes with alternating color/white pattern (makes it more obvious a mesh has been created). (bzr r15229) --- src/ui/tools/mesh-tool.cpp | 70 ++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 46 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index c6983b94a..87cbeef16 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -456,38 +456,33 @@ sp_mesh_context_fit_mesh_in_bbox (MeshTool *rc) SPItem *item = *i; SPStyle *style = item->style; - if (style && (style->fill.isPaintserver())) { - SPPaintServer *server = item->style->getFillPaintServer(); - if ( SP_IS_MESHGRADIENT(server) ) { - - SPMeshGradient *gradient = SP_MESHGRADIENT(server); - SPCurve * outline = gradient->array.outline_path(); - Geom::OptRect mesh_bbox = outline->get_pathvector().boundsExact(); - outline->unref(); - Geom::OptRect item_bbox = item->geometricBounds(); - - if ((*mesh_bbox).width() == 0) { - continue; - } - if ((*mesh_bbox).height() == 0) { - continue; + if (style) { + + if (style->fill.isPaintserver()) { + SPPaintServer *server = item->style->getFillPaintServer(); + if ( SP_IS_MESHGRADIENT(server) ) { + + Geom::OptRect item_bbox = item->geometricBounds(); + SPMeshGradient *gradient = SP_MESHGRADIENT(server); + if (gradient->array.fill_box( item_bbox )) { + changed = true; + } } - double scale_x = (*item_bbox).width() /(*mesh_bbox).width() ; - double scale_y = (*item_bbox).height()/(*mesh_bbox).height(); - - Geom::Translate t1(-(*mesh_bbox).min()); - Geom::Scale scale(scale_x,scale_y); - Geom::Translate t2((*item_bbox).min()); - Geom::Affine transform = t1 * scale * t2; - if (!transform.isIdentity() ) { - gradient->array.transform(transform); - gradient->array.write( gradient ); - gradient->requestModified(SP_OBJECT_MODIFIED_FLAG); - changed = true; + } + + if (style->stroke.isPaintserver()) { + SPPaintServer *server = item->style->getStrokePaintServer(); + if ( SP_IS_MESHGRADIENT(server) ) { + + Geom::OptRect item_bbox = item->visualBounds(); + SPMeshGradient *gradient = SP_MESHGRADIENT(server); + if (gradient->array.fill_box( item_bbox )) { + changed = true; + } } } + } - } if (changed) { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, @@ -540,25 +535,8 @@ bool MeshTool::root_handler(GdkEvent* event) { // always resets selection to the single object under cursor sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time); } else { - sp_mesh_new_default(*this); // Create a new gradient with default coordinates. -// 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; - -// #ifdef DEBUG_MESH -// std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl; -// #endif -// SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode); - -// SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode); -// sp_gradient_reset_to_userspace(priv, item); -// } - -// DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, -// _("Create default mesh")); + sp_mesh_new_default(*this); } ret = TRUE; -- cgit v1.2.3 From 07a86951a15301ccb7eb1446cc1e6d3ca7a68f9b Mon Sep 17 00:00:00 2001 From: Alexander Brock Date: Wed, 9 Nov 2016 01:23:41 +0100 Subject: Move boolop functions from sp_selected_path_ to ObjectSet::path (bzr r15223.1.1) --- src/ui/tools/calligraphic-tool.cpp | 4 ++-- src/ui/tools/eraser-tool.cpp | 12 ++++++------ src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 9b4dbb1a2..c2b86b538 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -921,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->getSelection()->pathUnion(true); } else if (subtract) { desktop->getSelection()->add(this->repr); - sp_selected_path_diff_skip_undo(desktop->getSelection()); + desktop->getSelection()->pathDiff(true); } else { if (this->keep_selected) { desktop->getSelection()->set(this->repr); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 4f941e534..ae312e054 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -714,7 +714,7 @@ 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); + selection->pathUnion(true); } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ @@ -725,9 +725,9 @@ void EraserTool::set_to_accumulated() { css = 0; } if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection); + selection->pathCut(true); } else { - sp_selected_path_diff_skip_undo(selection); + selection->pathDiff(true); } workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); @@ -762,7 +762,7 @@ void EraserTool::set_to_accumulated() { this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(dup); - sp_selected_path_union_skip_undo(selection); + selection->pathUnion(true); if (bbox && bbox->intersects(*eraserBbox)) { SPClipPath *clip_path = item->clip_ref->getObject(); if (clip_path) { @@ -786,7 +786,7 @@ void EraserTool::set_to_accumulated() { sp_object_unref(clip_path); selection->raiseToTop(true); selection->add(dup_clip); - sp_selected_path_diff_skip_undo(selection); + selection->pathDiff(true); SPItem * clip = SP_ITEM(*(selection->items().begin())); } } @@ -802,7 +802,7 @@ void EraserTool::set_to_accumulated() { rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); selection->raiseToTop(true); selection->add(rect); - sp_selected_path_diff_skip_undo(selection); + selection->pathDiff(true); } selection->raiseToTop(true); selection->add(item); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 0b893a7ba..b01b8ad52 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -446,7 +446,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto ngettext("Area filled, path with %d node created and unioned with selection.","Area filled, path with %d 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()); + selection->pathUnion(true); } else { desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with %d node created.","Area filled, path with %d nodes created.", diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 3649008ff..ad006627c 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -1026,7 +1026,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (unionResult) { // No need to add the very first item (initialized with NULL). set->add(unionResult); } - sp_selected_path_union_skip_undo(set); + set->pathUnion(true); set->add(parent_item); Inkscape::GC::release(copy); did = true; @@ -1364,7 +1364,7 @@ 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()); + objectSet()->pathUnion(true); desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end()); DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); -- cgit v1.2.3 From 40c68a138368ffa620e91d7b3908e2593e424a8f Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 9 Nov 2016 10:17:03 +0100 Subject: Click-drag selects nodes rather than creates new mesh if mesh already exists. (bzr r15231) --- src/ui/tools/mesh-tool.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 87cbeef16..61793b8b3 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -561,8 +561,25 @@ bool MeshTool::root_handler(GdkEvent* event) { dragging = true; + // Check if object already has mesh... if it does, don't create new mesh with click-drag. + bool has_mesh = false; + if (!selection->isEmpty()) { + SPStyle *style = selection->items().front()->style; + if (style) { + Inkscape::PaintTarget fill_or_stroke = + (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? + Inkscape::FOR_FILL : Inkscape::FOR_STROKE; + SPPaintServer *server = + (fill_or_stroke == Inkscape::FOR_FILL) ? + style->getFillPaintServer(): + style->getStrokePaintServer(); + if (server && SP_IS_MESHGRADIENT(server)) + has_mesh = true; + } + } + Geom::Point button_dt = desktop->w2d(button_w); - if (event->button.state & GDK_SHIFT_MASK) { + if (event->button.state & GDK_SHIFT_MASK || has_mesh) { Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); } else { // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to -- cgit v1.2.3 From 07af9d2a20fd6455a0965e3840b50ffd8f0a09ee Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 14 Nov 2016 15:00:26 +0100 Subject: Implement tweaking of mesh handle colors. (bzr r15250) --- src/ui/tools/tweak-tool.cpp | 182 +++++++++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 80 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index a0394ecd4..56939cc30 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -56,6 +56,8 @@ #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" +#include "sp-mesh-gradient.h" +#include "sp-mesh-array.h" #include "gradient-chemistry.h" #include "sp-text.h" #include "sp-flowtext.h" @@ -761,112 +763,132 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or p *= (gradient->gradientTransform).inverse(); // now p is in gradient's original coordinates - double pos = 0; - double r = 0; - SPLinearGradient *lg = dynamic_cast(gradient); - if (lg) { - Geom::Point p1(lg->x1.computed, lg->y1.computed); - Geom::Point p2(lg->x2.computed, lg->y2.computed); - Geom::Point pdiff(p2 - p1); - double vl = Geom::L2(pdiff); + SPRadialGradient *rg = dynamic_cast(gradient); + if (lg || rg) { - // This is the matrix which moves and rotates the gradient line - // so it's oriented along the X axis: - Geom::Affine norm = Geom::Affine(Geom::Translate(-p1)) * Geom::Affine(Geom::Rotate(-atan2(pdiff[Geom::Y], pdiff[Geom::X]))); + double pos = 0; + double r = 0; - // Transform the mouse point by it to find out its projection onto the gradient line: - Geom::Point pnorm = p * norm; + if (lg) { + Geom::Point p1(lg->x1.computed, lg->y1.computed); + Geom::Point p2(lg->x2.computed, lg->y2.computed); + Geom::Point pdiff(p2 - p1); + double vl = Geom::L2(pdiff); - // Scale its X coordinate to match the length of the gradient line: - pos = pnorm[Geom::X] / vl; - // Calculate radius in lenfth-of-gradient-line units - r = radius / vl; + // This is the matrix which moves and rotates the gradient line + // so it's oriented along the X axis: + Geom::Affine norm = Geom::Affine(Geom::Translate(-p1)) * + Geom::Affine(Geom::Rotate(-atan2(pdiff[Geom::Y], pdiff[Geom::X]))); - } else { - SPRadialGradient *rg = dynamic_cast(gradient); + // Transform the mouse point by it to find out its projection onto the gradient line: + Geom::Point pnorm = p * norm; + + // Scale its X coordinate to match the length of the gradient line: + pos = pnorm[Geom::X] / vl; + // Calculate radius in lenfth-of-gradient-line units + r = radius / vl; + + } if (rg) { Geom::Point c (rg->cx.computed, rg->cy.computed); pos = Geom::L2(p - c) / rg->r.computed; r = radius / rg->r.computed; } - } - // Normalize pos to 0..1, taking into accound gradient spread: - double pos_e = pos; - if (gradient->getSpread() == SP_GRADIENT_SPREAD_PAD) { - if (pos > 1) { - pos_e = 1; - } - if (pos < 0) { - pos_e = 0; - } - } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REPEAT) { - if (pos > 1 || pos < 0) { - pos_e = pos - floor(pos); - } - } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REFLECT) { - if (pos > 1 || pos < 0) { - bool odd = ((int)(floor(pos)) % 2 == 1); - pos_e = pos - floor(pos); - if (odd) { - pos_e = 1 - pos_e; + // Normalize pos to 0..1, taking into accound gradient spread: + double pos_e = pos; + if (gradient->getSpread() == SP_GRADIENT_SPREAD_PAD) { + if (pos > 1) { + pos_e = 1; + } + if (pos < 0) { + pos_e = 0; + } + } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REPEAT) { + if (pos > 1 || pos < 0) { + pos_e = pos - floor(pos); + } + } else if (gradient->getSpread() == SP_GRADIENT_SPREAD_REFLECT) { + if (pos > 1 || pos < 0) { + bool odd = ((int)(floor(pos)) % 2 == 1); + pos_e = pos - floor(pos); + if (odd) { + pos_e = 1 - pos_e; + } } } - } - SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(gradient, false); + SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(gradient, false); - double offset_l = 0; - double offset_h = 0; - SPObject *child_prev = NULL; - for (auto& child: vector->children) { - SPStop *stop = dynamic_cast(&child); - if (!stop) { - continue; - } + double offset_l = 0; + double offset_h = 0; + SPObject *child_prev = NULL; + for (auto& child: vector->children) { + SPStop *stop = dynamic_cast(&child); + if (!stop) { + continue; + } - offset_h = stop->offset; - - if (child_prev) { - SPStop *prevStop = dynamic_cast(child_prev); - g_assert(prevStop != NULL); - - if (offset_h - offset_l > r && pos_e >= offset_l && pos_e <= offset_h) { - // the summit falls in this interstop, and the radius is small, - // so it only affects the ends of this interstop; - // distribute the force between the two endstops so that they - // get all the painting even if they are not touched by the brush - tweak_color (mode, stop->specified_color.v.c, rgb_goal, - force * (pos_e - offset_l) / (offset_h - offset_l), - do_h, do_s, do_l); - tweak_color(mode, prevStop->specified_color.v.c, rgb_goal, - force * (offset_h - pos_e) / (offset_h - offset_l), - do_h, do_s, do_l); - stop->updateRepr(); - child_prev->updateRepr(); - break; - } else { - // wide brush, may affect more than 2 stops, - // paint each stop by the force from the profile curve - if (offset_l <= pos_e && offset_l > pos_e - r) { + offset_h = stop->offset; + + if (child_prev) { + SPStop *prevStop = dynamic_cast(child_prev); + g_assert(prevStop != NULL); + + if (offset_h - offset_l > r && pos_e >= offset_l && pos_e <= offset_h) { + // the summit falls in this interstop, and the radius is small, + // so it only affects the ends of this interstop; + // distribute the force between the two endstops so that they + // get all the painting even if they are not touched by the brush + tweak_color (mode, stop->specified_color.v.c, rgb_goal, + force * (pos_e - offset_l) / (offset_h - offset_l), + do_h, do_s, do_l); tweak_color(mode, prevStop->specified_color.v.c, rgb_goal, - force * tweak_profile (fabs (pos_e - offset_l), r), + force * (offset_h - pos_e) / (offset_h - offset_l), do_h, do_s, do_l); + stop->updateRepr(); child_prev->updateRepr(); + break; + } else { + // wide brush, may affect more than 2 stops, + // paint each stop by the force from the profile curve + if (offset_l <= pos_e && offset_l > pos_e - r) { + tweak_color(mode, prevStop->specified_color.v.c, rgb_goal, + force * tweak_profile (fabs (pos_e - offset_l), r), + do_h, do_s, do_l); + child_prev->updateRepr(); + } + + if (offset_h >= pos_e && offset_h < pos_e + r) { + tweak_color (mode, stop->specified_color.v.c, rgb_goal, + force * tweak_profile (fabs (pos_e - offset_h), r), + do_h, do_s, do_l); + stop->updateRepr(); + } } + } - if (offset_h >= pos_e && offset_h < pos_e + r) { + offset_l = offset_h; + child_prev = &child; + } + } else { + // Mesh + SPMeshGradient *mg = dynamic_cast(gradient); + if (mg) { + SPMeshGradient *mg_array = dynamic_cast(mg->getArray()); + SPMeshNodeArray *array = &(mg_array->array); + // Every third node is a corner node + for( unsigned i=0; i < array->nodes.size(); i+=3 ) { + for( unsigned j=0; j < array->nodes[i].size(); j+=3 ) { + SPStop *stop = array->nodes[i][j]->stop; + double distance = Geom::L2(Geom::Point(p - array->nodes[i][j]->p)); tweak_color (mode, stop->specified_color.v.c, rgb_goal, - force * tweak_profile (fabs (pos_e - offset_h), r), - do_h, do_s, do_l); + force * tweak_profile (distance, radius), do_h, do_s, do_l); stop->updateRepr(); } } } - - offset_l = offset_h; - child_prev = &child; } } -- cgit v1.2.3 From 09d3ef953448a73c20dc1a70c2f96e0ac5019f45 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 16 Nov 2016 16:22:39 +0100 Subject: Split selected rows/columns in half using Insert key. (bzr r15251) --- src/ui/tools/mesh-tool.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 61793b8b3..1f6e6ed87 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -389,6 +389,11 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) noperation += mg->array.color_pick( iter->second, items[iter->first] ); break; + case MG_CORNER_INSERT: + // std::cout << "INSERT" << std::endl; + noperation += mg->array.insert( iter->second ); + break; + default: std::cout << "sp_mesh_corner_operation: unknown operation" << std::endl; } @@ -420,6 +425,10 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Picked mesh corner color.")); break; + case MG_CORNER_INSERT: + DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Inserted new row or column.")); + break; + default: std::cout << "sp_mesh_corner_operation: unknown operation" << std::endl; } @@ -896,11 +905,12 @@ bool MeshTool::root_handler(GdkEvent* event) { } break; + // Mesh Operations -------------------------------------------- + case GDK_KEY_Insert: case GDK_KEY_KP_Insert: // with any modifiers: - //sp_gradient_context_add_stops_between_selected_stops (rc); - std::cout << "Inserting stops between selected stops not implemented yet" << std::endl; + sp_mesh_context_corner_operation ( this, MG_CORNER_INSERT ); ret = TRUE; break; @@ -913,8 +923,6 @@ bool MeshTool::root_handler(GdkEvent* event) { } break; - // Mesh Operations -------------------------------------------- - case GDK_KEY_b: // Toggle mesh side between lineto and curveto. case GDK_KEY_B: if (MOD__ALT(event) && drag->isNonEmpty() && drag->hasSelection()) { -- cgit v1.2.3 From 776e4475404033912ed3b9d93d4ce2aeda62336c Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 17 Nov 2016 15:30:21 +0100 Subject: Fix status bar messages for meshes and gradients. (bzr r15256) --- src/ui/tools/gradient-tool.cpp | 8 +++++++- src/ui/tools/mesh-tool.cpp | 22 ++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 16df225e0..2a728b085 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -79,6 +79,9 @@ GradientTool::~GradientTool() { delete this->subselcon; } +// This must match GrPointType enum sp-gradient.h +// We should move this to a shared header (can't simply move to gradient.h since that would require +// including which messes up "N_" in extensions... argh!). const gchar *gr_handle_descr [] = { N_("Linear gradient start"), //POINT_LG_BEGIN N_("Linear gradient end"), @@ -88,7 +91,10 @@ const gchar *gr_handle_descr [] = { N_("Radial gradient radius"), N_("Radial gradient focus"), // POINT_RG_FOCUS N_("Radial gradient mid stop"), - N_("Radial gradient mid stop") + N_("Radial gradient mid stop"), + N_("Mesh gradient corner"), + N_("Mesh gradient handle"), + N_("Mesh gradient tensor") }; void GradientTool::selection_changed(Inkscape::Selection*) { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 1f6e6ed87..6b1bfb88f 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -92,7 +92,19 @@ MeshTool::~MeshTool() { delete this->subselcon; } +// This must match GrPointType enum sp-gradient.h +// We should move this to a shared header (can't simply move to gradient.h since that would require +// including which messes up "N_" in extensions... argh!). const gchar *ms_handle_descr [] = { + N_("Linear gradient start"), //POINT_LG_BEGIN + N_("Linear gradient end"), + N_("Linear gradient mid stop"), + N_("Radial gradient center"), + N_("Radial gradient radius"), + N_("Radial gradient radius"), + N_("Radial gradient focus"), // POINT_RG_FOCUS + N_("Radial gradient mid stop"), + N_("Radial gradient mid stop"), N_("Mesh gradient corner"), N_("Mesh gradient handle"), N_("Mesh gradient tensor") @@ -124,6 +136,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { //TRANSLATORS: Mind the space in front. This is part of a compound message ngettext(" out of %d mesh handle"," out of %d mesh handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); + std::cout << " type: " << drag->singleSelectedDraggerSingleDraggableType() << std::endl; this->message_context->setF(Inkscape::NORMAL_MESSAGE, message,_(ms_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); } else { @@ -784,10 +797,11 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_Shift_R: case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine) case GDK_KEY_Meta_R: - sp_event_show_modifier_tip (this->defaultMessageContext(), event, - _("FIXMECtrl: snap mesh angle"), - _("FIXMEShift: draw mesh around the starting point"), - NULL); + + // sp_event_show_modifier_tip (this->defaultMessageContext(), event, + // _("FIXMECtrl: snap mesh angle"), + // _("FIXMEShift: draw mesh around the starting point"), + // NULL); break; case GDK_KEY_A: -- cgit v1.2.3 From b6b5dbc76fe07238f1bbd259a8d8934c3c757eb7 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 17 Nov 2016 15:33:25 +0100 Subject: Remove debug line from last commit. (bzr r15257) --- src/ui/tools/mesh-tool.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 6b1bfb88f..0d2aafafc 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -136,7 +136,6 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { //TRANSLATORS: Mind the space in front. This is part of a compound message ngettext(" out of %d mesh handle"," out of %d mesh handles",n_tot), ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - std::cout << " type: " << drag->singleSelectedDraggerSingleDraggableType() << std::endl; this->message_context->setF(Inkscape::NORMAL_MESSAGE, message,_(ms_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); } else { -- cgit v1.2.3 From 7aa5bd6f04cbc26d79239b07c6a91fbabf3015d1 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 18 Nov 2016 20:29:57 +0100 Subject: Improve mouse handling for mesh: * Double clicking an object will create a new mesh if one does not exist, otherwise clicking a line should now reliably divide the row/column. * Click-dragging will create a new mesh if one does not exist, otherwise it will do a rubberband selection of corner nodes. With Shift will add nodes, without will replace selected nodes. (bzr r15260) --- src/ui/tools/mesh-tool.cpp | 196 +++++++++++++++++++++++++++------------------ 1 file changed, 117 insertions(+), 79 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 0d2aafafc..fbde37856 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -278,32 +278,39 @@ sp_mesh_context_select_prev (ToolBase *event_context) } /** -Returns true if mouse cursor over mesh edge. +Returns vector of control lines mouse is over. Returns only first if 'first' is true. */ -static bool -sp_mesh_context_is_over_line (MeshTool *rc, SPCtrlLine *line, Geom::Point event_p) +static std::vector +sp_mesh_context_over_line (MeshTool *rc, Geom::Point event_p, bool first = true) { - 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(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 ); + double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance; - double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); + GrDrag *drag = rc->_grdrag; - double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance; + std::vector selected; + + for (std::vector::const_iterator l = drag->lines.begin(); l != drag->lines.end(); ++l) { + if (!SP_IS_CTRLCURVE(*l)) continue; - bool close = (dist_screen < tolerance); + SPCtrlCurve *curve = SP_CTRLCURVE(*l); + 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 ); - return close; + double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); + if (dist_screen < tolerance) { + selected.push_back(*l); + if (first) { + break; + } + } + } + return selected; } @@ -539,25 +546,42 @@ bool MeshTool::root_handler(GdkEvent* event) { // Double click: // If over a mesh line, divide mesh row/column - // If not over a line, create new gradients for selected objects. + // If not over a line and no mesh, create new mesh for top selected object. if ( event->button.button == 1 ) { - // Are we over a mesh line? - bool over_line = false; - if (! drag->lines.empty()) { - for (std::vector::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { - over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); - } - } + // Are we over a mesh line? + std::vector over_line = + sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y)); - if (over_line) { + if (!over_line.empty()) { // 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->items().front(), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - sp_mesh_new_default(*this); + + // Check if object already has mesh... if it does, + // don't create new mesh with click-drag. + bool has_mesh = false; + if (!selection->isEmpty()) { + SPStyle *style = selection->items().front()->style; + if (style) { + Inkscape::PaintTarget fill_or_stroke = + (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? + Inkscape::FOR_FILL : Inkscape::FOR_STROKE; + SPPaintServer *server = + (fill_or_stroke == Inkscape::FOR_FILL) ? + style->getFillPaintServer(): + style->getStrokePaintServer(); + if (server && SP_IS_MESHGRADIENT(server)) + has_mesh = true; + } + } + + if (!has_mesh) { + sp_mesh_new_default(*this); + } } ret = TRUE; @@ -569,9 +593,10 @@ bool MeshTool::root_handler(GdkEvent* event) { #ifdef DEBUG_MESH std::cout << "sp_mesh_context_root_handler: GDK_BUTTON_PRESS" << std::endl; #endif + // Button down - // If Shift key down: do rubber band selection - // Else set origin for drag. A drag creates a new gradient if one does not exist + // If mesh already exists, do rubber band selection. + // Else set origin for drag which will create a new gradient. if ( event->button.button == 1 && !this->space_panning ) { Geom::Point button_w(event->button.x, event->button.y); @@ -582,7 +607,9 @@ bool MeshTool::root_handler(GdkEvent* event) { dragging = true; - // Check if object already has mesh... if it does, don't create new mesh with click-drag. + Geom::Point button_dt = desktop->w2d(button_w); + // Check if object already has mesh... if it does, + // don't create new mesh with click-drag. bool has_mesh = false; if (!selection->isEmpty()) { SPStyle *style = selection->items().front()->style; @@ -599,26 +626,25 @@ bool MeshTool::root_handler(GdkEvent* event) { } } - Geom::Point button_dt = desktop->w2d(button_w); - if (event->button.state & GDK_SHIFT_MASK || has_mesh) { + if (has_mesh) { Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); - } else { - // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to - // enable Ctrl+doubleclick of exactly the selected item(s) - if (!(event->button.state & GDK_CONTROL_MASK)) { - this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE); - } + } - if (!selection->isEmpty()) { - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); - m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); - m.unSetup(); - } + // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to + // enable Ctrl+doubleclick of exactly the selected item(s) + if (!(event->button.state & GDK_CONTROL_MASK)) { + this->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE); + } - this->origin = button_dt; + if (!selection->isEmpty()) { + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); + m.unSetup(); } + this->origin = button_dt; + ret = TRUE; } break; @@ -679,19 +705,14 @@ bool MeshTool::root_handler(GdkEvent* event) { } // Change cursor shape if over line - bool over_line = false; + std::vector over_line = + sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y)); - if (!drag->lines.empty()) { - for (std::vector::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; ++l) { - over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); - } - } - - if (this->cursor_addnode && !over_line) { + if (this->cursor_addnode && over_line.empty()) { this->cursor_shape = cursor_gradient_xpm; this->sp_event_context_update_cursor(); this->cursor_addnode = false; - } else if (!this->cursor_addnode && over_line) { + } else if (!this->cursor_addnode && !over_line.empty()) { this->cursor_shape = cursor_gradient_add_xpm; this->sp_event_context_update_cursor(); this->cursor_addnode = true; @@ -708,23 +729,15 @@ bool MeshTool::root_handler(GdkEvent* event) { this->xp = this->yp = 0; if ( event->button.button == 1 && !this->space_panning ) { - // Check if over line - bool over_line = false; - SPCtrlLine *line = NULL; - - if (!drag->lines.empty()) { - for (std::vector::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { - over_line = sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); - if (over_line) { - break; - } - } - } + // Check if over line + std::vector over_line = + sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y)); if ( (event->button.state & GDK_CONTROL_MASK) && (event->button.state & GDK_MOD1_MASK ) ) { - if (over_line && line) { - sp_mesh_context_split_near_point(this, line->item, this->mousepoint_doc, 0); + if (!over_line.empty()) { + sp_mesh_context_split_near_point(this, over_line[0]->item, + this->mousepoint_doc, 0); ret = TRUE; } } else { @@ -737,22 +750,47 @@ bool MeshTool::root_handler(GdkEvent* event) { } if (!this->within_tolerance) { - // we've been dragging, either create a new gradient - // or rubberband-select if we have rubberband - Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); - - if (r->is_started() && !this->within_tolerance) { - // this was a rubberband drag - if (r->getMode() == RUBBERBAND_MODE_RECT) { - Geom::OptRect const b = r->getRectangle(); - drag->selectRect(*b); + + // Check if object already has mesh... if it does, + // don't create new mesh with click-drag. + bool has_mesh = false; + if (!selection->isEmpty()) { + SPStyle *style = selection->items().front()->style; + if (style) { + Inkscape::PaintTarget fill_or_stroke = + (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? + Inkscape::FOR_FILL : Inkscape::FOR_STROKE; + SPPaintServer *server = + (fill_or_stroke == Inkscape::FOR_FILL) ? + style->getFillPaintServer(): + style->getStrokePaintServer(); + if (server && SP_IS_MESHGRADIENT(server)) + has_mesh = true; } - } else { - // Create a new mesh gradient + } + + if (!has_mesh) { sp_mesh_new_default(*this); + } else { + + // we've been dragging, either create a new gradient + // or rubberband-select if we have rubberband + Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); + + if (r->is_started() && !this->within_tolerance) { + // this was a rubberband drag + if (r->getMode() == RUBBERBAND_MODE_RECT) { + Geom::OptRect const b = r->getRectangle(); + if (!(event->button.state & GDK_SHIFT_MASK)) { + drag->deselectAll(); + } + drag->selectRect(*b); + } + } } + } else if (this->item_to_select) { - if (over_line && line) { + if (!over_line.empty()) { // Clicked on an existing mesh line, don't change selection. This stops // possible change in selection during a double click with overlapping objects } else { @@ -760,6 +798,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (event->button.state & GDK_SHIFT_MASK) { selection->toggle(this->item_to_select); } else { + drag->deselectAll(); selection->set(this->item_to_select); } } @@ -1081,7 +1120,6 @@ static void sp_mesh_new_default(MeshTool &rc) { } } - } } } -- cgit v1.2.3 From e0e832245260d040f12bcebdf5b5e58763448e73 Mon Sep 17 00:00:00 2001 From: su_v <> Date: Sat, 19 Nov 2016 11:47:09 +0100 Subject: Add Shift-I shortcut for insert node. (bzr r15261) --- src/ui/tools/gradient-tool.cpp | 10 ++++++++++ src/ui/tools/mesh-tool.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) (limited to 'src/ui/tools') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 2a728b085..750596808 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -837,6 +837,16 @@ bool GradientTool::root_handler(GdkEvent* event) { ret = TRUE; break; + case GDK_KEY_i: + case GDK_KEY_I: + if (MOD__SHIFT_ONLY(event)) { + // Shift+I - insert stops (alternate keybinding for keyboards + // that don't have the Insert key) + sp_gradient_context_add_stops_between_selected_stops (this); + ret = TRUE; + } + break; + case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index fbde37856..0bcbd8572 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -966,6 +966,16 @@ bool MeshTool::root_handler(GdkEvent* event) { ret = TRUE; break; + case GDK_KEY_i: + case GDK_KEY_I: + if (MOD__SHIFT_ONLY(event)) { + // Shift+I - insert corners (alternate keybinding for keyboards + // that don't have the Insert key) + sp_mesh_context_corner_operation ( this, MG_CORNER_INSERT ); + ret = TRUE; + } + break; + case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: -- cgit v1.2.3 From 03eabec553f7938b674a28ef8abe9b39e149fdb9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sun, 20 Nov 2016 11:36:40 +0100 Subject: Preserve selection of corner nodes for some corner operations. (bzr r15262) --- src/ui/tools/mesh-tool.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 0bcbd8572..d01837c49 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -430,6 +430,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) case MG_CORNER_SIDE_ARC: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Approximated arc for mesh side.")); + drag->local_change = true; // Don't create new draggers. break; case MG_CORNER_TENSOR_TOGGLE: @@ -438,10 +439,12 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) case MG_CORNER_COLOR_SMOOTH: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Smoothed mesh corner color.")); + drag->local_change = true; break; case MG_CORNER_COLOR_PICK: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Picked mesh corner color.")); + drag->local_change = true; break; case MG_CORNER_INSERT: @@ -454,7 +457,9 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) } } } - drag->updateDraggers(); + + // Not needed. Update is done via gr_drag_sel_modified(). + // drag->updateDraggers(); } -- cgit v1.2.3 From b045203981fee53df04a760039ed2730d854f8fd Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 21 Nov 2016 12:34:27 +0100 Subject: Keep corner nodes selected when possible for corner operations. (bzr r15264) --- src/ui/tools/mesh-tool.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index d01837c49..7f05906f4 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -355,12 +355,13 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) std::map > points; std::map items; - + std::map fill_or_stroke; + // Get list of selected draggers for each mesh. - // For all selected draggers + // For all selected draggers (a dragger may include draggerables from different meshes). for (std::set::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { GrDragger *dragger = *i; - // For all draggables of dragger + // For all draggables of dragger (a draggable corresponds to a unique mesh). for (std::vector::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) { GrDraggable *d = *j; @@ -373,6 +374,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) // Collect points together for same gradient points[gradient].push_back( d->point_i ); items[gradient] = d->item; + fill_or_stroke[gradient] = d->fill_or_stroke ? Inkscape::FOR_FILL: Inkscape::FOR_STROKE; } } @@ -426,6 +428,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) case MG_CORNER_SIDE_TOGGLE: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Toggled mesh path type.")); + drag->local_change = true; // Don't create new draggers. break; case MG_CORNER_SIDE_ARC: @@ -435,16 +438,17 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) case MG_CORNER_TENSOR_TOGGLE: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Toggled mesh tensors.")); + drag->local_change = true; // Don't create new draggers. break; case MG_CORNER_COLOR_SMOOTH: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Smoothed mesh corner color.")); - drag->local_change = true; + drag->local_change = true; // Don't create new draggers. break; case MG_CORNER_COLOR_PICK: DocumentUndo::done(doc, SP_VERB_CONTEXT_MESH, _("Picked mesh corner color.")); - drag->local_change = true; + drag->local_change = true; // Don't create new draggers. break; case MG_CORNER_INSERT: -- cgit v1.2.3 From c4922f5c1b54802623bc43f04191495e2338fc24 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 23 Nov 2016 10:23:22 +0100 Subject: Select mesh nodes by clicking on control lines. (bzr r15267) --- src/ui/tools/mesh-tool.cpp | 52 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 7f05906f4..61232fb2c 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -41,6 +41,7 @@ #include "sp-text.h" #include "sp-defs.h" #include "style.h" +#include "ui/control-manager.h" // Gradient specific #include "gradient-drag.h" @@ -280,7 +281,7 @@ sp_mesh_context_select_prev (ToolBase *event_context) /** Returns vector of control lines mouse is over. Returns only first if 'first' is true. */ -static std::vector +static std::vector sp_mesh_context_over_line (MeshTool *rc, Geom::Point event_p, bool first = true) { SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop; @@ -292,7 +293,7 @@ sp_mesh_context_over_line (MeshTool *rc, Geom::Point event_p, bool first = true) GrDrag *drag = rc->_grdrag; - std::vector selected; + std::vector selected; for (std::vector::const_iterator l = drag->lines.begin(); l != drag->lines.end(); ++l) { if (!SP_IS_CTRLCURVE(*l)) continue; @@ -304,7 +305,7 @@ sp_mesh_context_over_line (MeshTool *rc, Geom::Point event_p, bool first = true) double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); if (dist_screen < tolerance) { - selected.push_back(*l); + selected.push_back(curve); if (first) { break; } @@ -560,7 +561,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if ( event->button.button == 1 ) { // Are we over a mesh line? - std::vector over_line = + std::vector over_line = sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y)); if (!over_line.empty()) { @@ -607,6 +608,31 @@ bool MeshTool::root_handler(GdkEvent* event) { // If mesh already exists, do rubber band selection. // Else set origin for drag which will create a new gradient. if ( event->button.button == 1 && !this->space_panning ) { + + // Are we over a mesh line? + std::vector over_line = + sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y), false); + + if (!over_line.empty()) { + for (std::vector::const_iterator it = over_line.begin(); + it != over_line.end(); ++it ) { + SPItem *item = (*it)->item; + Inkscape::PaintTarget fill_or_stroke = + (*it)->is_fill ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; + GrDragger* dragger0 = drag->getDraggerFor(item, POINT_MG_CORNER, (*it)->corner0, fill_or_stroke); + GrDragger* dragger1 = drag->getDraggerFor(item, POINT_MG_CORNER, (*it)->corner1, fill_or_stroke); + bool add = (event->button.state & GDK_SHIFT_MASK); + bool toggle = (event->button.state & GDK_CONTROL_MASK); + if ( !add && !toggle ) { + drag->deselectAll(); + } + drag->setSelected( dragger0, true, !toggle ); + drag->setSelected( dragger1, true, !toggle ); + } + ret = true; + break; // To avoid putting the following code in an else block. + } + Geom::Point button_w(event->button.x, event->button.y); // save drag origin @@ -714,7 +740,7 @@ bool MeshTool::root_handler(GdkEvent* event) { } // Change cursor shape if over line - std::vector over_line = + std::vector over_line = sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y)); if (this->cursor_addnode && over_line.empty()) { @@ -740,7 +766,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if ( event->button.button == 1 && !this->space_panning ) { // Check if over line - std::vector over_line = + std::vector over_line = sp_mesh_context_over_line(this, Geom::Point(event->motion.x, event->motion.y)); if ( (event->button.state & GDK_CONTROL_MASK) && (event->button.state & GDK_MOD1_MASK ) ) { @@ -812,11 +838,16 @@ bool MeshTool::root_handler(GdkEvent* event) { } } } else { - // click in an empty space; do the same as Esc - if (!drag->selected.empty()) { - drag->deselectAll(); + if (!over_line.empty()) { + // Clicked on an existing mesh line, don't change selection. This stops + // possible change in selection during a double click with overlapping objects } else { - selection->clear(); + // click in an empty space; do the same as Esc + if (!drag->selected.empty()) { + drag->deselectAll(); + } else { + selection->clear(); + } } } @@ -989,7 +1020,6 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: if ( !drag->selected.empty() ) { - std::cout << "Deleting mesh stops not implemented yet" << std::endl; ret = TRUE; } break; -- cgit v1.2.3 From d87cfa4971963dfb8118ce31e169854fce85bccd Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 1 Dec 2016 14:05:02 +0100 Subject: Add toggles for handle visibility, editing fill, and editing stroke. (bzr r15289) --- src/ui/tools/mesh-tool.cpp | 21 +++++++++++++++++++++ src/ui/tools/mesh-tool.h | 27 ++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 61232fb2c..b05caf43a 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -75,6 +75,9 @@ MeshTool::MeshTool() : ToolBase(cursor_gradient_xpm, 4, 4) , cursor_addnode(false) , node_added(false) + , show_handles(true) + , edit_fill(true) + , edit_stroke(true) // TODO: Why are these connections stored as pointers? , selcon(NULL) , subselcon(NULL) @@ -253,7 +256,25 @@ void MeshTool::setup() { ) )); + sp_event_context_read(this, "show_handles"); + sp_event_context_read(this, "edit_fill"); + sp_event_context_read(this, "edit_stroke"); + this->selection_changed(selection); + +} + +void MeshTool::set(const Inkscape::Preferences::Entry& value) { + Glib::ustring entry_name = value.getEntryName(); + if (entry_name == "show_handles") { + this->show_handles = value.getBool(true); + } else if (entry_name == "edit_fill") { + this->edit_fill = value.getBool(true); + } else if (entry_name == "edit_stroke") { + this->edit_stroke = value.getBool(true); + } else { + ToolBase::set(value); + } } void diff --git a/src/ui/tools/mesh-tool.h b/src/ui/tools/mesh-tool.h index f142bfd9c..1f012dc53 100644 --- a/src/ui/tools/mesh-tool.h +++ b/src/ui/tools/mesh-tool.h @@ -31,29 +31,34 @@ namespace Tools { class MeshTool : public ToolBase { public: - MeshTool(); - virtual ~MeshTool(); + MeshTool(); + virtual ~MeshTool(); Geom::Point origin; - bool cursor_addnode; - - bool node_added; - Geom::Point mousepoint_doc; // stores mousepoint when over_line in doc coords sigc::connection *selcon; sigc::connection *subselcon; - static const std::string prefsPath; + static const std::string prefsPath; - virtual void setup(); - virtual bool root_handler(GdkEvent* event); + virtual void setup(); + virtual void set(const Inkscape::Preferences::Entry& val); + virtual bool root_handler(GdkEvent* event); - virtual const std::string& getPrefsPath(); + virtual const std::string& getPrefsPath(); private: - void selection_changed(Inkscape::Selection* sel); + void selection_changed(Inkscape::Selection* sel); + + bool cursor_addnode; + bool node_added; + bool show_handles; + bool edit_fill; + bool edit_stroke; + + }; void sp_mesh_context_select_next(ToolBase *event_context); -- cgit v1.2.3 From c0895d809dfa89df7242e9bdc838755ed63c9218 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 2 Dec 2016 10:15:24 +0100 Subject: Ensure new mesh is immediately editable. (bzr r15290) --- src/ui/tools/mesh-tool.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ui/tools') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index b05caf43a..e628094d9 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -1136,6 +1136,16 @@ static void sp_mesh_new_default(MeshTool &rc) { (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; + // Ensure mesh is immediately editable. + // Editting both fill and stroke at same time doesn't work well so avoid. + if (fill_or_stroke == Inkscape::FOR_FILL) { + prefs->setBool("/tools/mesh/edit_fill", true ); + prefs->setBool("/tools/mesh/edit_stroke", false); + } else { + prefs->setBool("/tools/mesh/edit_fill", false); + prefs->setBool("/tools/mesh/edit_stroke", true ); + } + // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); -- cgit v1.2.3 From 5a8c4695e3c2d3916d88bc77d80d427aad622fdd Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 15 Dec 2016 19:18:43 +0100 Subject: Prevent crash when iterator invalidated after converting shape to path. (bzr r15328) --- src/ui/tools/tweak-tool.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 56939cc30..ff5d623c2 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1084,7 +1084,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); - auto items= selection->items(); +// auto items= selection->items(); + std::vector items(selection->items().begin(), selection->items().end()); for(auto i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; -- cgit v1.2.3 From 5ba49eaa5621b2e232f8df179798a1b2b282890c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Dec 2016 19:00:54 +0100 Subject: Add update_helperpaths not member of nodetool class to easy call from outside (bzr r15335) --- src/ui/tools/node-tool.cpp | 40 +++++++++++++++++++++++----------------- src/ui/tools/node-tool.h | 4 ++-- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index f3679b40f..668ebda27 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -32,6 +32,8 @@ #include "sp-text.h" #include "ui/control-manager.h" #include "ui/tools/node-tool.h" +#include "ui/tools-switch.h" +#include "ui/tools/tool-base.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" #include "ui/tool/multi-path-manipulator.h" @@ -155,9 +157,7 @@ NodeTool::~NodeTool() { if (this->flash_tempitem) { this->desktop->remove_temporary_canvasitem(this->flash_tempitem); } - if (this->helperpath_tmpitem) { - this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); - } + sp_update_helperpath(true); this->_selection_changed_connection.disconnect(); //this->_selection_modified_connection.disconnect(); this->_mouseover_changed_connection.disconnect(); @@ -237,7 +237,6 @@ void NodeTool::setup() { ))) ); - this->helperpath_tmpitem = NULL; this->cursor_drag = false; this->show_transform_handles = true; this->single_node_transform_handles = false; @@ -270,29 +269,36 @@ void NodeTool::setup() { } this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive - this->update_helperpath(); + sp_update_helperpath(); } // show helper paths of the applied LPE, if any -void NodeTool::update_helperpath () { - Inkscape::Selection *selection = this->desktop->getSelection(); - - if (this->helperpath_tmpitem) { - this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); - this->helperpath_tmpitem = NULL; +void sp_update_helperpath(bool remove) { + SPDesktop * desktop = SP_ACTIVE_DESKTOP; + if (!desktop || !tools_isactive(desktop, TOOLS_NODES)) { + return; + } + Inkscape::Selection *selection = desktop->getSelection(); + static Inkscape::Display::TemporaryItem * helperpath_tmpitem; + if (helperpath_tmpitem) { + desktop->remove_temporary_canvasitem(helperpath_tmpitem); + helperpath_tmpitem = NULL; + } + if (remove) { + return; } - if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { - Inkscape::UI::ControlPointSelection *selectionNodes = _selected_nodes; + Inkscape::UI::Tools::NodeTool *nt = static_cast(desktop->event_context); + Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector selectedNodesPositions; for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { Inkscape::UI::Node *n = dynamic_cast(*i); selectedNodesPositions.push_back(n->position()); } lpe->setSelectedNodePoints(selectedNodesPositions); - lpe->setCurrentZoom(this->desktop->current_zoom()); + lpe->setCurrentZoom(desktop->current_zoom()); SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); std::vector cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem())); @@ -302,11 +308,11 @@ void NodeTool::update_helperpath () { cc->reset(); } if (!c->is_empty()) { - SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c, true); + SPCanvasItem *helperpath = sp_canvas_bpath_new(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()); - this->helperpath_tmpitem = this->desktop->add_temporary_canvasitem(helperpath, 0); + helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0); } c->unref(); cc->unref(); @@ -468,7 +474,7 @@ bool NodeTool::root_handler(GdkEvent* event) { switch (event->type) { case GDK_MOTION_NOTIFY: { - update_helperpath(); + sp_update_helperpath(); combine_motion_events(desktop->canvas, event->motion, 0); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 8342d66a6..8517c54fe 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -56,7 +56,6 @@ public: static const std::string prefsPath; virtual void setup(); - virtual void update_helperpath(); virtual void set(const Inkscape::Preferences::Entry& val); virtual bool root_handler(GdkEvent* event); @@ -68,7 +67,6 @@ private: sigc::connection _sizeUpdatedConn; SPItem *flashed_item; - Inkscape::Display::TemporaryItem *helperpath_tmpitem; Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; Inkscape::UI::PathSharedData* _path_data; @@ -97,7 +95,9 @@ private: void handleControlUiStyleChange(); }; +void sp_update_helperpath(bool remove = false); } + } } -- cgit v1.2.3 From c5b33e5041c6bd1f62ef550ac2b8e1bc739a40e2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Dec 2016 19:14:56 +0100 Subject: Remove unneeded static var from previous commit (bzr r15336) --- src/ui/tools/node-tool.cpp | 24 ++++++++++++------------ src/ui/tools/node-tool.h | 7 ++++--- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 668ebda27..0c948c91c 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -157,7 +157,9 @@ NodeTool::~NodeTool() { if (this->flash_tempitem) { this->desktop->remove_temporary_canvasitem(this->flash_tempitem); } - sp_update_helperpath(true); + if (this->helperpath_tmpitem) { + this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem); + } this->_selection_changed_connection.disconnect(); //this->_selection_modified_connection.disconnect(); this->_mouseover_changed_connection.disconnect(); @@ -209,7 +211,7 @@ void NodeTool::setup() { this->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged( sigc::mem_fun(this, &NodeTool::handleControlUiStyleChange) ); - + this->helperpath_tmpitem = NULL; this->_selected_nodes = new Inkscape::UI::ControlPointSelection(this->desktop, this->_transform_handle_group); data.node_data.selection = this->_selected_nodes; @@ -273,24 +275,22 @@ void NodeTool::setup() { } // show helper paths of the applied LPE, if any -void sp_update_helperpath(bool remove) { +void sp_update_helperpath() { SPDesktop * desktop = SP_ACTIVE_DESKTOP; if (!desktop || !tools_isactive(desktop, TOOLS_NODES)) { return; } + Inkscape::UI::Tools::NodeTool *nt = static_cast(desktop->event_context); Inkscape::Selection *selection = desktop->getSelection(); - static Inkscape::Display::TemporaryItem * helperpath_tmpitem; - if (helperpath_tmpitem) { - desktop->remove_temporary_canvasitem(helperpath_tmpitem); - helperpath_tmpitem = NULL; - } - if (remove) { - return; + if (nt->helperpath_tmpitem) { + desktop->remove_temporary_canvasitem(nt->helperpath_tmpitem); + nt->helperpath_tmpitem = NULL; } + if (SP_IS_LPE_ITEM(selection->singleItem())) { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { - Inkscape::UI::Tools::NodeTool *nt = static_cast(desktop->event_context); + Inkscape::UI::ControlPointSelection *selectionNodes = nt->_selected_nodes; std::vector selectedNodesPositions; for (Inkscape::UI::ControlPointSelection::iterator i = selectionNodes->begin(); i != selectionNodes->end(); ++i) { @@ -312,7 +312,7 @@ void sp_update_helperpath(bool remove) { 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()); - helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0); + nt->helperpath_tmpitem = desktop->add_temporary_canvasitem(helperpath, 0); } c->unref(); cc->unref(); diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 8517c54fe..983ba6cee 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -49,7 +49,8 @@ public: Inkscape::UI::ControlPointSelection* _selected_nodes; Inkscape::UI::MultiPathManipulator* _multipath; - + Inkscape::Display::TemporaryItem *helperpath_tmpitem; + bool edit_clipping_paths; bool edit_masks; @@ -67,6 +68,7 @@ private: sigc::connection _sizeUpdatedConn; SPItem *flashed_item; + Inkscape::Display::TemporaryItem *flash_tempitem; Inkscape::UI::Selector* _selector; Inkscape::UI::PathSharedData* _path_data; @@ -94,8 +96,7 @@ private: void update_tip(GdkEvent *event); void handleControlUiStyleChange(); }; - -void sp_update_helperpath(bool remove = false); + void sp_update_helperpath(); } } -- cgit v1.2.3 From 7d524286a0b613a5a5126884f3fb4f674446096e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 24 Dec 2016 07:59:17 +0100 Subject: i18n. Flood autogap list not correctly translated at runtime. (bzr r15351) --- src/ui/tools/flood-tool.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index b01b8ad52..1801a0ea0 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -89,10 +89,10 @@ Glib::ustring ch_init[8] = { const std::vector FloodTool::channel_list( ch_init, ch_init+8 ); Glib::ustring gap_init[4] = { - C_("Flood autogap", "None"), - C_("Flood autogap", "Small"), - C_("Flood autogap", "Medium"), - C_("Flood autogap", "Large") + NC_("Flood autogap", "None"), + NC_("Flood autogap", "Small"), + NC_("Flood autogap", "Medium"), + NC_("Flood autogap", "Large") }; const std::vector FloodTool::gap_list( gap_init, gap_init+4 ); -- cgit v1.2.3