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/sp-lpe-item.cpp | 36 ++++++++------ src/ui/tools/eraser-tool.cpp | 109 +++++++++++++++++++++++++++++++++++------ src/widgets/eraser-toolbar.cpp | 30 +++++++----- 3 files changed, 134 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index fdc2949d5..5753e9307 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -349,10 +349,10 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) { sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); } - SPClipPath * clipPath = lpeitem->clip_ref->getObject(); - if(clipPath) + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { - sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); } if (SP_IS_GROUP(lpeitem)) { std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); @@ -383,10 +383,10 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); } - SPClipPath * clipPath = lpeitem->clip_ref->getObject(); - if(clipPath) + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); } } std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); @@ -405,10 +405,10 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); } - SPClipPath * clipPath = lpeitem->clip_ref->getObject(); - if(clipPath) + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); } repr->setAttribute("d", repr->attribute("inkscape:original-d")); repr->setAttribute("inkscape:original-d", NULL); @@ -640,10 +640,13 @@ bool SPLPEItem::hasPathEffectRecursive() const void SPLPEItem::apply_to_clippath(SPItem *item) { - SPClipPath *clipPath = item->clip_ref->getObject(); - if(clipPath) { - SPObject * clip_data = clipPath->firstChild(); - apply_to_clip_or_mask(SP_ITEM(clip_data), item); + SPClipPath *clip_path = item->clip_ref->getObject(); + if(clip_path) { + std::vector clip_path_list = clip_path->childList(true); + for ( std::vector::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { + SPObject * clip_data = *iter; + apply_to_clip_or_mask(SP_ITEM(clip_data), item); + } } if(SP_IS_GROUP(item)){ std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); @@ -659,8 +662,11 @@ SPLPEItem::apply_to_mask(SPItem *item) { SPMask *mask = item->mask_ref->getObject(); if(mask) { - SPObject *mask_data = mask->firstChild(); - apply_to_clip_or_mask(SP_ITEM(mask_data), item); + std::vector mask_list = mask->childList(true); + for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPObject * mask_data = *iter; + apply_to_clip_or_mask(SP_ITEM(mask_data), item); + } } if(SP_IS_GROUP(item)){ std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); 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); } diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp index 45989936f..5b883905b 100644 --- a/src/widgets/eraser-toolbar.cpp +++ b/src/widgets/eraser-toolbar.cpp @@ -67,15 +67,15 @@ static void sp_erc_mass_value_changed( GtkAdjustment *adj, GObject* tbl ) static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) { SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); - bool eraserMode = ege_select_one_action_get_active( act ) != 0; + guint eraser_mode = ege_select_one_action_get_active( act ); if (DocumentUndo::getUndoSensitive(desktop->getDocument())) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool( "/tools/eraser/mode", eraserMode ); + prefs->setInt( "/tools/eraser/mode", eraser_mode ); } GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") ); GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") ); - if(eraserMode == TRUE){ + if(eraser_mode != 0){ gtk_action_set_visible( split, TRUE ); gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); @@ -90,7 +90,7 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); /* - if ( eraserMode != 0 ) { + if ( eraser_mode != 0 ) { } else { } */ @@ -111,7 +111,7 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb { Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint eraserMode = FALSE; + gint eraser_mode = FALSE; { GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); GtkTreeIter iter; @@ -125,10 +125,17 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Cut"), - 1, _("Cut out from objects"), + 1, _("Cut out from paths and shapes"), 2, INKSCAPE_ICON("path-difference"), -1 ); + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("Clip"), + 1, _("Clip from objects"), + 2, INKSCAPE_ICON("path-intersection"), + -1 ); + EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); g_object_set( act, "short_label", _("Mode:"), NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); @@ -137,12 +144,13 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb ege_select_one_action_set_appearance( act, "full" ); ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); - ege_select_one_action_set_icon_column( act, 2 ); - ege_select_one_action_set_tooltip_column( act, 1 ); + ege_select_one_action_set_icon_column( act, 2); + ege_select_one_action_set_icon_size( act, secondarySize ); + ege_select_one_action_set_tooltip_column( act, 1); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - eraserMode = prefs->getBool("/tools/eraser/mode") ? TRUE : FALSE; - ege_select_one_action_set_active( act, eraserMode ); + eraser_mode = prefs->getInt("/tools/eraser/mode", 2); + ege_select_one_action_set_active( act, eraser_mode ); g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder ); } @@ -195,7 +203,7 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") ); GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") ); - if(eraserMode == TRUE){ + if (eraser_mode != 0) { gtk_action_set_visible( split, TRUE ); gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); -- 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/document-undo.cpp | 21 +++++++---- src/document-undo.h | 4 +- src/ui/tools/eraser-tool.cpp | 90 ++++++++++++++++++++++---------------------- 3 files changed, 61 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/document-undo.cpp b/src/document-undo.cpp index eb0ac7707..f6bcf3ab2 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -328,28 +328,35 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) return ret; } -void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) +void Inkscape::DocumentUndo::clearUndo(SPDocument *doc, size_t limit) { if (! doc->priv->undo.empty()) doc->priv->undoStackObservers.notifyClearUndoEvent(); - while (! doc->priv->undo.empty()) { + if (limit == 0) { + limit = doc->priv->undo.size(); + } + while (! doc->priv->undo.empty() && limit > 0) { Inkscape::Event *e = doc->priv->undo.back(); doc->priv->undo.pop_back(); delete e; doc->priv->history_size--; + limit--; } } -void Inkscape::DocumentUndo::clearRedo(SPDocument *doc) +void Inkscape::DocumentUndo::clearRedo(SPDocument *doc, size_t limit) { - if (!doc->priv->redo.empty()) - doc->priv->undoStackObservers.notifyClearRedoEvent(); - - while (! doc->priv->redo.empty()) { + if (!doc->priv->redo.empty()) + doc->priv->undoStackObservers.notifyClearRedoEvent(); + if (limit == 0) { + limit = doc->priv->undo.size(); + } + while (! doc->priv->redo.empty() && limit > 0) { Inkscape::Event *e = doc->priv->redo.back(); doc->priv->redo.pop_back(); delete e; doc->priv->history_size--; + limit--; } } diff --git a/src/document-undo.h b/src/document-undo.h index 85b44d562..559036458 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -33,9 +33,9 @@ public: static bool getUndoSensitive(SPDocument const *document); - static void clearUndo(SPDocument *document); + static void clearUndo(SPDocument *document, size_t limit = 0); - static void clearRedo(SPDocument *document); + static void clearRedo(SPDocument *document, size_t limit = 0); static void done(SPDocument *document, unsigned int event_type, Glib::ustring const &event_description); 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/document-undo.cpp | 23 ++++++++--------------- src/document-undo.h | 4 ++-- src/ui/tools/eraser-tool.cpp | 21 ++++++--------------- 3 files changed, 16 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/document-undo.cpp b/src/document-undo.cpp index f6bcf3ab2..7e6fe5df1 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -141,7 +141,7 @@ void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const { g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + //g_assert (doc->priv->sensitive); if ( key && !*key ) { g_warning("Blank undo key specified."); } @@ -328,35 +328,28 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) return ret; } -void Inkscape::DocumentUndo::clearUndo(SPDocument *doc, size_t limit) +void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) { if (! doc->priv->undo.empty()) doc->priv->undoStackObservers.notifyClearUndoEvent(); - if (limit == 0) { - limit = doc->priv->undo.size(); - } - while (! doc->priv->undo.empty() && limit > 0) { + while (! doc->priv->undo.empty()) { Inkscape::Event *e = doc->priv->undo.back(); doc->priv->undo.pop_back(); delete e; doc->priv->history_size--; - limit--; } } -void Inkscape::DocumentUndo::clearRedo(SPDocument *doc, size_t limit) +void Inkscape::DocumentUndo::clearRedo(SPDocument *doc) { - if (!doc->priv->redo.empty()) - doc->priv->undoStackObservers.notifyClearRedoEvent(); - if (limit == 0) { - limit = doc->priv->undo.size(); - } - while (! doc->priv->redo.empty() && limit > 0) { + if (!doc->priv->redo.empty()) + doc->priv->undoStackObservers.notifyClearRedoEvent(); + + while (! doc->priv->redo.empty()) { Inkscape::Event *e = doc->priv->redo.back(); doc->priv->redo.pop_back(); delete e; doc->priv->history_size--; - limit--; } } diff --git a/src/document-undo.h b/src/document-undo.h index 559036458..85b44d562 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -33,9 +33,9 @@ public: static bool getUndoSensitive(SPDocument const *document); - static void clearUndo(SPDocument *document, size_t limit = 0); + static void clearUndo(SPDocument *document); - static void clearRedo(SPDocument *document, size_t limit = 0); + static void clearRedo(SPDocument *document); static void done(SPDocument *document, unsigned int event_type, Glib::ustring const &event_description); 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/document-private.h | 57 +++++---- src/document-undo.cpp | 298 ++++++++++++++++++++++++------------------- src/document-undo.h | 4 + src/document.cpp | 1 + src/selection-chemistry.cpp | 31 +++-- src/selection-chemistry.h | 6 +- src/ui/tools/eraser-tool.cpp | 29 ++++- 7 files changed, 243 insertions(+), 183 deletions(-) (limited to 'src') diff --git a/src/document-private.h b/src/document-private.h index eaed0020e..6ec535b87 100644 --- a/src/document-private.h +++ b/src/document-private.h @@ -37,43 +37,44 @@ class Event; } struct SPDocumentPrivate { - typedef std::map IDChangedSignalMap; - typedef std::map ResourcesChangedSignalMap; + typedef std::map IDChangedSignalMap; + typedef std::map ResourcesChangedSignalMap; - std::map iddef; - std::map reprdef; + std::map iddef; + std::map reprdef; - unsigned long serial; + unsigned long serial; - /** Dictionary of signals for id changes */ - IDChangedSignalMap id_changed_signals; + /** Dictionary of signals for id changes */ + IDChangedSignalMap id_changed_signals; - /* Resources */ - std::map > resources; - ResourcesChangedSignalMap resources_changed_signals; + /* Resources */ + std::map > resources; + ResourcesChangedSignalMap resources_changed_signals; - sigc::signal destroySignal; - SPDocument::ModifiedSignal modified_signal; - SPDocument::URISetSignal uri_set_signal; - SPDocument::ResizedSignal resized_signal; - SPDocument::ReconstructionStart _reconstruction_start_signal; - SPDocument::ReconstructionFinish _reconstruction_finish_signal; - SPDocument::CommitSignal commit_signal; + sigc::signal destroySignal; + SPDocument::ModifiedSignal modified_signal; + SPDocument::URISetSignal uri_set_signal; + SPDocument::ResizedSignal resized_signal; + SPDocument::ReconstructionStart _reconstruction_start_signal; + SPDocument::ReconstructionFinish _reconstruction_finish_signal; + SPDocument::CommitSignal commit_signal; - /* Undo/Redo state */ - bool sensitive; /* If we save actions to undo stack */ - Inkscape::XML::Event * partial; /* partial undo log when interrupted */ - int history_size; - std::vector undo; /* Undo stack of reprs */ - std::vector redo; /* Redo stack of reprs */ + /* Undo/Redo state */ + bool sensitive; /* If we save actions to undo stack */ + bool join_undo; /* If we group actions to one undo stack */ + Inkscape::XML::Event * partial; /* partial undo log when interrupted */ + int history_size; + std::vector undo; /* Undo stack of reprs */ + std::vector redo; /* Redo stack of reprs */ - /* Undo listener */ - Inkscape::CompositeUndoStackObserver undoStackObservers; + /* Undo listener */ + Inkscape::CompositeUndoStackObserver undoStackObservers; - // XXX only for testing! - Inkscape::ConsoleOutputUndoObserver console_output_undo_observer; + // XXX only for testing! + Inkscape::ConsoleOutputUndoObserver console_output_undo_observer; - bool seeking; + bool seeking; sigc::connection selChangeConnection; sigc::connection desktopActivatedConnection; }; diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 7e6fe5df1..1707fb6fa 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -62,22 +62,22 @@ void Inkscape::DocumentUndo::setUndoSensitive(SPDocument *doc, bool sensitive) { - g_assert (doc != NULL); - g_assert (doc->priv != NULL); - - if ( sensitive == doc->priv->sensitive ) - return; - - if (sensitive) { - sp_repr_begin_transaction (doc->rdoc); - } else { - doc->priv->partial = sp_repr_coalesce_log ( - doc->priv->partial, - sp_repr_commit_undoable (doc->rdoc) - ); - } - - doc->priv->sensitive = sensitive; + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + + if ( sensitive == doc->priv->sensitive ) + return; + + if (sensitive) { + sp_repr_begin_transaction (doc->rdoc); + } else { + doc->priv->partial = sp_repr_coalesce_log ( + doc->priv->partial, + sp_repr_commit_undoable (doc->rdoc) + ); + } + + doc->priv->sensitive = sensitive; } /*TODO: Throughout the inkscape code tree set/get_undo_sensitive are used for @@ -88,15 +88,49 @@ void Inkscape::DocumentUndo::setUndoSensitive(SPDocument *doc, bool sensitive) */ bool Inkscape::DocumentUndo::getUndoSensitive(SPDocument const *document) { - g_assert(document != NULL); - g_assert(document->priv != NULL); + g_assert(document != NULL); + g_assert(document->priv != NULL); + + return document->priv->sensitive; +} + +void Inkscape::DocumentUndo::setUndoJoined(SPDocument *doc, bool join_undo) +{ + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + if (join_undo) { + doc->collectOrphans(); + doc->ensureUpToDate(); + DocumentUndo::clearRedo(doc); + Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc)); + doc->priv->partial = NULL; + if (!log) { + sp_repr_begin_transaction (doc->rdoc); + doc->priv->join_undo = join_undo; + return; + } + doc->virgin = FALSE; + doc->setModifiedSinceSave(); + sp_repr_begin_transaction (doc->rdoc); + doc->priv->commit_signal.emit(); + } + doc->priv->join_undo = join_undo; +} - return document->priv->sensitive; +bool Inkscape::DocumentUndo::getUndoJoined(SPDocument *doc) +{ + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + return doc->priv->join_undo; } void Inkscape::DocumentUndo::done(SPDocument *doc, const unsigned int event_type, Glib::ustring const &event_description) { - maybeDone(doc, NULL, event_type, event_description); + if (!getUndoJoined(doc)) { + maybeDone(doc, NULL, event_type, event_description); + } else { + sp_repr_commit_undoable (doc->rdoc); + } } void Inkscape::DocumentUndo::resetKey( SPDocument *doc ) @@ -139,82 +173,81 @@ public: void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const unsigned int event_type, Glib::ustring const &event_description) { - g_assert (doc != NULL); - g_assert (doc->priv != NULL); - //g_assert (doc->priv->sensitive); - if ( key && !*key ) { - g_warning("Blank undo key specified."); - } + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + g_assert (doc->priv->sensitive); + if ( key && !*key ) { + g_warning("Blank undo key specified."); + } - Inkscape::Debug::EventTracker tracker(doc, key, event_type); + Inkscape::Debug::EventTracker tracker(doc, key, event_type); - doc->collectOrphans(); + doc->collectOrphans(); - doc->ensureUpToDate(); + doc->ensureUpToDate(); - DocumentUndo::clearRedo(doc); + DocumentUndo::clearRedo(doc); - Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc)); - doc->priv->partial = NULL; + Inkscape::XML::Event *log = sp_repr_coalesce_log (doc->priv->partial, sp_repr_commit_undoable (doc->rdoc)); + doc->priv->partial = NULL; - if (!log) { - sp_repr_begin_transaction (doc->rdoc); - return; - } + if (!log) { + sp_repr_begin_transaction (doc->rdoc); + return; + } - if (key && !doc->actionkey.empty() && (doc->actionkey == key) && !doc->priv->undo.empty()) { - (doc->priv->undo.back())->event = - sp_repr_coalesce_log ((doc->priv->undo.back())->event, log); - } else { - Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description); - doc->priv->undo.push_back(event); - doc->priv->history_size++; - doc->priv->undoStackObservers.notifyUndoCommitEvent(event); - } + if (key && !doc->actionkey.empty() && (doc->actionkey == key) && !doc->priv->undo.empty()) { + (doc->priv->undo.back())->event = sp_repr_coalesce_log ((doc->priv->undo.back())->event, log); + } else { + Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description); + doc->priv->undo.push_back(event); + doc->priv->history_size++; + doc->priv->undoStackObservers.notifyUndoCommitEvent(event); + } - if ( key ) { - doc->actionkey = key; - } else { - doc->actionkey.clear(); - } + if ( key ) { + doc->actionkey = key; + } else { + doc->actionkey.clear(); + } - doc->virgin = FALSE; - doc->setModifiedSinceSave(); + doc->virgin = FALSE; + doc->setModifiedSinceSave(); - sp_repr_begin_transaction (doc->rdoc); + sp_repr_begin_transaction (doc->rdoc); - doc->priv->commit_signal.emit(); + doc->priv->commit_signal.emit(); } void Inkscape::DocumentUndo::cancel(SPDocument *doc) { - g_assert (doc != NULL); - g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + g_assert (doc->priv->sensitive); - sp_repr_rollback (doc->rdoc); + sp_repr_rollback (doc->rdoc); - if (doc->priv->partial) { - sp_repr_undo_log (doc->priv->partial); - sp_repr_free_log (doc->priv->partial); - doc->priv->partial = NULL; - } + if (doc->priv->partial) { + sp_repr_undo_log (doc->priv->partial); + sp_repr_free_log (doc->priv->partial); + doc->priv->partial = NULL; + } - sp_repr_begin_transaction (doc->rdoc); + sp_repr_begin_transaction (doc->rdoc); } static void finish_incomplete_transaction(SPDocument &doc) { - SPDocumentPrivate &priv=*doc.priv; - Inkscape::XML::Event *log=sp_repr_commit_undoable(doc.rdoc); - if (log || priv.partial) { - g_warning ("Incomplete undo transaction:"); - priv.partial = sp_repr_coalesce_log(priv.partial, log); - sp_repr_debug_print_log(priv.partial); + SPDocumentPrivate &priv=*doc.priv; + Inkscape::XML::Event *log=sp_repr_commit_undoable(doc.rdoc); + if (log || priv.partial) { + g_warning ("Incomplete undo transaction:"); + priv.partial = sp_repr_coalesce_log(priv.partial, log); + sp_repr_debug_print_log(priv.partial); Inkscape::Event *event = new Inkscape::Event(priv.partial); - priv.undo.push_back(event); + priv.undo.push_back(event); priv.undoStackObservers.notifyUndoCommitEvent(event); - priv.partial = NULL; - } + priv.partial = NULL; + } } static void perform_document_update(SPDocument &doc) { @@ -238,100 +271,101 @@ static void perform_document_update(SPDocument &doc) { gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) { - using Inkscape::Debug::EventTracker; - using Inkscape::Debug::SimpleEvent; + using Inkscape::Debug::EventTracker; + using Inkscape::Debug::SimpleEvent; - gboolean ret; + gboolean ret; - EventTracker > tracker("undo"); + EventTracker > tracker("undo"); - g_assert (doc != NULL); - g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + g_assert (doc->priv->sensitive); - doc->priv->sensitive = FALSE; - doc->priv->seeking = true; + doc->priv->sensitive = FALSE; + doc->priv->seeking = true; - doc->actionkey.clear(); + doc->actionkey.clear(); - finish_incomplete_transaction(*doc); + finish_incomplete_transaction(*doc); - if (! doc->priv->undo.empty()) { - Inkscape::Event *log = doc->priv->undo.back(); - doc->priv->undo.pop_back(); - sp_repr_undo_log (log->event); - perform_document_update(*doc); + if (! doc->priv->undo.empty()) { + Inkscape::Event *log = doc->priv->undo.back(); + doc->priv->undo.pop_back(); + sp_repr_undo_log (log->event); + perform_document_update(*doc); - doc->priv->redo.push_back(log); + doc->priv->redo.push_back(log); - doc->setModifiedSinceSave(); - doc->priv->undoStackObservers.notifyUndoEvent(log); + doc->setModifiedSinceSave(); + doc->priv->undoStackObservers.notifyUndoEvent(log); - ret = TRUE; - } else { - ret = FALSE; - } + ret = TRUE; + } else { + ret = FALSE; + } - sp_repr_begin_transaction (doc->rdoc); + sp_repr_begin_transaction (doc->rdoc); - doc->priv->sensitive = TRUE; - doc->priv->seeking = false; + doc->priv->sensitive = TRUE; + doc->priv->seeking = false; - if (ret) - INKSCAPE.external_change(); + if (ret) + INKSCAPE.external_change(); - return ret; + return ret; } gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) { - using Inkscape::Debug::EventTracker; - using Inkscape::Debug::SimpleEvent; + using Inkscape::Debug::EventTracker; + using Inkscape::Debug::SimpleEvent; - gboolean ret; + gboolean ret; - EventTracker > tracker("redo"); + EventTracker > tracker("redo"); - g_assert (doc != NULL); - g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_assert (doc != NULL); + g_assert (doc->priv != NULL); + g_assert (doc->priv->sensitive); - doc->priv->sensitive = FALSE; - doc->priv->seeking = true; + doc->priv->sensitive = FALSE; + doc->priv->seeking = true; - doc->actionkey.clear(); + doc->actionkey.clear(); - finish_incomplete_transaction(*doc); + finish_incomplete_transaction(*doc); - if (! doc->priv->redo.empty()) { - Inkscape::Event *log = doc->priv->redo.back(); - doc->priv->redo.pop_back(); - sp_repr_replay_log (log->event); - doc->priv->undo.push_back(log); + if (! doc->priv->redo.empty()) { + Inkscape::Event *log = doc->priv->redo.back(); + doc->priv->redo.pop_back(); + sp_repr_replay_log (log->event); + doc->priv->undo.push_back(log); - doc->setModifiedSinceSave(); - doc->priv->undoStackObservers.notifyRedoEvent(log); + doc->setModifiedSinceSave(); + doc->priv->undoStackObservers.notifyRedoEvent(log); - ret = TRUE; - } else { - ret = FALSE; - } + ret = TRUE; + } else { + ret = FALSE; + } - sp_repr_begin_transaction (doc->rdoc); + sp_repr_begin_transaction (doc->rdoc); - doc->priv->sensitive = TRUE; - doc->priv->seeking = false; + doc->priv->sensitive = TRUE; + doc->priv->seeking = false; - if (ret) - INKSCAPE.external_change(); + if (ret) + INKSCAPE.external_change(); - return ret; + return ret; } void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) { if (! doc->priv->undo.empty()) doc->priv->undoStackObservers.notifyClearUndoEvent(); + while (! doc->priv->undo.empty()) { Inkscape::Event *e = doc->priv->undo.back(); doc->priv->undo.pop_back(); @@ -342,8 +376,8 @@ void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) void Inkscape::DocumentUndo::clearRedo(SPDocument *doc) { - if (!doc->priv->redo.empty()) - doc->priv->undoStackObservers.notifyClearRedoEvent(); + if (!doc->priv->redo.empty()) + doc->priv->undoStackObservers.notifyClearRedoEvent(); while (! doc->priv->redo.empty()) { Inkscape::Event *e = doc->priv->redo.back(); diff --git a/src/document-undo.h b/src/document-undo.h index 85b44d562..b80b176d3 100644 --- a/src/document-undo.h +++ b/src/document-undo.h @@ -33,6 +33,10 @@ public: static bool getUndoSensitive(SPDocument const *document); + static void setUndoJoined(SPDocument *doc, bool join_undo); + + static bool getUndoJoined(SPDocument *doc); + static void clearUndo(SPDocument *document); static void clearRedo(SPDocument *document); diff --git a/src/document.cpp b/src/document.cpp index 7086fc0be..87f13f749 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -121,6 +121,7 @@ SPDocument::SPDocument() : p->serial = next_serial++; p->sensitive = false; + p->join_undo = false; p->partial = NULL; p->history_size = 0; p->seeking = false; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7d32477a1..2c93c5496 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1031,7 +1031,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) C_("Undo action", "Raise")); } -void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo) { SPDocument *document = selection->layers()->getDocument(); @@ -1055,9 +1055,10 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto Inkscape::XML::Node *repr =(*l); repr->setPosition(-1); } - - DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, - _("Raise to top")); + if (!skip_undo) { + DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, + _("Raise to top")); + } } void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) @@ -1115,7 +1116,7 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) C_("Undo action", "Lower")); } -void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo) { SPDocument *document = selection->layers()->getDocument(); @@ -1149,9 +1150,10 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des } repr->setPosition(minpos); } - - DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, - _("Lower to bottom")); + if (!skip_undo) { + DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, + _("Lower to bottom")); + } } void @@ -3859,7 +3861,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) * If \a apply_clip_path parameter is true, clipPath is created, otherwise mask * */ -void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer) +void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer, bool skip_undo) { if (desktop == NULL) { return; @@ -4021,11 +4023,12 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ } selection->addList(items_to_select); - - if (apply_clip_path) { - DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); - } else { - DocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); + if (!skip_undo) { + if (apply_clip_path) { + DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); + } else { + DocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); + } } } diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 82b91c617..31c160bf9 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -79,9 +79,9 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo = false); void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo = false); SPCSSAttr *take_style_from_item (SPObject *object); @@ -157,7 +157,7 @@ void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, fl void sp_selection_create_bitmap_copy (SPDesktop *desktop); void sp_selection_set_clipgroup(SPDesktop *desktop); -void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer); +void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer, bool skip_undo = false); void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path); bool fit_canvas_to_selection(SPDesktop *, bool with_margins = false); 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') 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') 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 ++++++++++++++++++++--------------------- src/widgets/eraser-toolbar.cpp | 12 ++- src/widgets/toolbox.cpp | 3 +- 3 files changed, 94 insertions(+), 86 deletions(-) (limited to 'src') 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(); } diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp index f69ac633f..482075dc6 100644 --- a/src/widgets/eraser-toolbar.cpp +++ b/src/widgets/eraser-toolbar.cpp @@ -76,7 +76,11 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") ); if(eraser_mode != 0){ - gtk_action_set_visible( split, TRUE ); + if(eraser_mode == 1) { + gtk_action_set_visible( split, TRUE ); + } else { + gtk_action_set_visible( split, FALSE ); + } gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); } else { @@ -204,7 +208,11 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") ); if (eraser_mode != 0) { - gtk_action_set_visible( split, TRUE ); + if(eraser_mode == 1) { + gtk_action_set_visible( split, TRUE ); + } else { + gtk_action_set_visible( split, FALSE ); + } gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); } else { diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f7b5e585f..8113c9619 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -499,9 +499,10 @@ static gchar const * ui_descr = " " " " " " - " " " " " " + " " + " " " " " " -- 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') 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') 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 d7887bf24bbb703739e56fa9056e1c67d8483b4c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 22 May 2016 20:44:21 +0200 Subject: Added some widgets from caligraphic tool (bzr r14865.1.13) --- src/widgets/eraser-toolbar.cpp | 113 ++++++++++++++++++++++++++++++++++++++++- src/widgets/toolbox.cpp | 7 +++ 2 files changed, 119 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp index 482075dc6..ddfe31d72 100644 --- a/src/widgets/eraser-toolbar.cpp +++ b/src/widgets/eraser-toolbar.cpp @@ -64,6 +64,28 @@ static void sp_erc_mass_value_changed( GtkAdjustment *adj, GObject* tbl ) update_presets_list(tbl); } +static void sp_erc_velthin_value_changed( GtkAdjustment *adj, GObject* tbl ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/tools/eraser/thinning", gtk_adjustment_get_value(adj) ); + update_presets_list(tbl); +} + +static void sp_erc_cap_rounding_value_changed( GtkAdjustment *adj, GObject* tbl ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble( "/tools/eraser/cap_rounding", gtk_adjustment_get_value(adj) ); + update_presets_list(tbl); +} + +static void sp_erc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble( "/tools/eraser/tremor", gtk_adjustment_get_value(adj) ); + update_presets_list(tbl); +} + + static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) { SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); @@ -75,15 +97,27 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") ); GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") ); - if(eraser_mode != 0){ + GtkAction *usepressure = GTK_ACTION( g_object_get_data(tbl, "usepressure") ); + GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(tbl, "cap_rounding") ); + GtkAction *thinning = GTK_ACTION( g_object_get_data(tbl, "thinning") ); + GtkAction *tremor = GTK_ACTION( g_object_get_data(tbl, "tremor") ); + if (eraser_mode != 0) { if(eraser_mode == 1) { gtk_action_set_visible( split, TRUE ); } else { gtk_action_set_visible( split, FALSE ); } + gtk_action_set_visible(usepressure, TRUE ); + gtk_action_set_visible(tremor, TRUE ); + gtk_action_set_visible(cap_rounding, TRUE ); + gtk_action_set_visible(thinning, TRUE ); gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); } else { + gtk_action_set_visible(usepressure, FALSE ); + gtk_action_set_visible(tremor, FALSE ); + gtk_action_set_visible(cap_rounding, FALSE ); + gtk_action_set_visible(thinning, FALSE ); gtk_action_set_visible( split, FALSE ); gtk_action_set_visible( mass, FALSE ); gtk_action_set_visible( width, FALSE ); @@ -175,6 +209,71 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_object_set_data( holder, "width", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } + /* Use Pressure button */ + { + InkToggleAction* act = ink_toggle_action_new( "EraserPressureAction", + _("Eraser Pressure"), + _("Use the pressure of the input device to alter the width of the pen"), + INKSCAPE_ICON("draw-use-pressure"), + Inkscape::ICON_SIZE_DECORATION ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/eraser/usepressure", update_presets_list, holder); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + g_object_set_data( holder, "usepressure", act ); + } + { + + /* Thinning */ + gchar const* labels[] = {_("(speed blows up stroke)"), 0, 0, _("(slight widening)"), _("(constant width)"), _("(slight thinning, default)"), 0, 0, _("(speed deflates stroke)")}; + gdouble values[] = {-100, -40, -20, -10, 0, 10, 20, 40, 100}; + EgeAdjustmentAction* eact = create_adjustment_action( "EraserThinningAction", + _("Eraser Stroke Thinning"), _("Thinning:"), + _("How much velocity thins the stroke (> 0 makes fast strokes thinner, < 0 makes them broader, 0 makes width independent of velocity)"), + "/tools/eraser/thinning", 10, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, + -100, 100, 1, 10.0, + labels, values, G_N_ELEMENTS(labels), + sp_erc_velthin_value_changed, NULL /*unit tracker*/, 1, 0); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + g_object_set_data( holder, "thinning", eact ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } + { + /* Cap Rounding */ + gchar const* labels[] = {_("(blunt caps, default)"), _("(slightly bulging)"), 0, 0, _("(approximately round)"), _("(long protruding caps)")}; + gdouble values[] = {0, 0.3, 0.5, 1.0, 1.4, 5.0}; + // TRANSLATORS: "cap" means "end" (both start and finish) here + EgeAdjustmentAction* eact = create_adjustment_action( "EraserCapRoundingAction", + _("Eraser Cap rounding"), _("Caps:"), + _("Increase to make caps at the ends of strokes protrude more (0 = no caps, 1 = round caps)"), + "/tools/eraser/cap_rounding", 0.0, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, + 0.0, 5.0, 0.01, 0.1, + labels, values, G_N_ELEMENTS(labels), + sp_erc_cap_rounding_value_changed, NULL /*unit tracker*/, 0.01, 2 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + g_object_set_data( holder, "cap_rounding", eact ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } + + { + /* Tremor */ + gchar const* labels[] = {_("(smooth line)"), _("(slight tremor)"), _("(noticeable tremor)"), 0, 0, _("(maximum tremor)")}; + gdouble values[] = {0, 10, 20, 40, 60, 100}; + EgeAdjustmentAction* eact = create_adjustment_action( "EraserTremorAction", + _("EraserStroke Tremor"), _("Tremor:"), + _("Increase to make strokes rugged and trembling"), + "/tools/eraser/tremor", 0.0, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, + 0.0, 100, 1, 10.0, + labels, values, G_N_ELEMENTS(labels), + sp_erc_tremor_value_changed, NULL /*unit tracker*/, 1, 0); + + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); + g_object_set_data( holder, "tremor", eact ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } { /* Mass */ gchar const* labels[] = {_("(no inertia)"), _("(slight smoothing, default)"), _("(noticeable lagging)"), 0, 0, _("(maximum inertia)")}; @@ -207,15 +306,27 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") ); GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") ); + GtkAction *usepressure = GTK_ACTION( g_object_get_data(holder, "usepressure") ); + GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(holder, "cap_rounding") ); + GtkAction *thinning = GTK_ACTION( g_object_get_data(holder, "thinning") ); + GtkAction *tremor = GTK_ACTION( g_object_get_data(holder, "tremor") ); if (eraser_mode != 0) { if(eraser_mode == 1) { gtk_action_set_visible( split, TRUE ); } else { gtk_action_set_visible( split, FALSE ); } + gtk_action_set_visible(usepressure, TRUE ); + gtk_action_set_visible(tremor, TRUE ); + gtk_action_set_visible(cap_rounding, TRUE ); + gtk_action_set_visible(thinning, TRUE ); gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); } else { + gtk_action_set_visible(usepressure, FALSE ); + gtk_action_set_visible(tremor, FALSE ); + gtk_action_set_visible(cap_rounding, FALSE ); + gtk_action_set_visible(thinning, FALSE ); gtk_action_set_visible( split, FALSE ); gtk_action_set_visible( mass, FALSE ); gtk_action_set_visible( width, FALSE ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 8113c9619..52b31e4c5 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -499,6 +499,13 @@ static gchar const * ui_descr = " " " " " " + " " + " " + " " + " " + " " + " " + " " " " " " " " -- cgit v1.2.3