diff options
| author | John Bintz <me@johnbintz.com> | 2007-03-31 12:42:17 +0000 |
|---|---|---|
| committer | johncoswell <johncoswell@users.sourceforge.net> | 2007-03-31 12:42:17 +0000 |
| commit | c52b5ee650dd80490a3d13e3072de5e9186acfc6 (patch) | |
| tree | c85ef360180fba5756d779e962370320eb6da8b1 | |
| parent | Change tool switch message for paint bucket (diff) | |
| download | inkscape-c52b5ee650dd80490a3d13e3072de5e9186acfc6.tar.gz inkscape-c52b5ee650dd80490a3d13e3072de5e9186acfc6.zip | |
Change paint bucket path union to properly create only one undo event, rather than two
(bzr r2792)
| -rw-r--r-- | src/flood-context.cpp | 30 | ||||
| -rw-r--r-- | src/splivarot.cpp | 10 | ||||
| -rw-r--r-- | src/splivarot.h | 1 |
3 files changed, 25 insertions, 16 deletions
diff --git a/src/flood-context.cpp b/src/flood-context.cpp index f377d6b94..3d6bc1272 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -324,7 +324,7 @@ static bool try_add_to_queue(std::queue<NR::Point> *fill_queue, guchar *px, guch return true; } -static void do_trace(GdkPixbuf *px, SPDesktop *desktop, NR::Matrix transform) { +static void do_trace(GdkPixbuf *px, SPDesktop *desktop, NR::Matrix transform, bool union_with_selection) { SPDocument *document = sp_desktop_document(desktop); Inkscape::Trace::Potrace::PotraceTracingEngine pte; @@ -420,12 +420,20 @@ static void do_trace(GdkPixbuf *px, SPDesktop *desktop, NR::Matrix transform) { } Inkscape::Selection *selection = sp_desktop_selection(desktop); - selection->set(reprobj); + pathRepr->setPosition(-1); - desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, _("Area filled, path with <b>%d</b> nodes created."), sp_nodes_in_path(SP_PATH(reprobj))); + if (union_with_selection) { + desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, _("Area filled, path with <b>%d</b> nodes created and unioned with selection."), sp_nodes_in_path(SP_PATH(reprobj))); + selection->add(reprobj); + sp_selected_path_union_skip_undo(); + } else { + desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, _("Area filled, path with <b>%d</b> nodes created."), sp_nodes_in_path(SP_PATH(reprobj))); + selection->set(reprobj); + } + } - + Inkscape::GC::release(pathRepr); } @@ -501,7 +509,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::queue<NR::Point> * return SCANLINE_CHECK_OK; } -static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *event) { +static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *event, bool union_with_selection) { SPDesktop *desktop = event_context->desktop; SPDocument *document = sp_desktop_document(desktop); @@ -730,7 +738,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even NR::Matrix inverted_affine = NR::Matrix(affine).inverse(); - do_trace(pixbuf, desktop, inverted_affine); + do_trace(pixbuf, desktop, inverted_affine, union_with_selection); g_free(trace_px); @@ -784,15 +792,7 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven // Since setWaitingCursor runs main loop iterations, we may have already left this tool! // So check if the tool is valid before doing anything - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList *items = g_slist_copy((GSList *) selection->itemList()); - - sp_flood_do_flood_fill(event_context, event); - - if (event->button.state & GDK_SHIFT_MASK) { - selection->addList(items); - sp_selected_path_union(); - } + sp_flood_do_flood_fill(event_context, event, event->button.state & GDK_SHIFT_MASK); // restore cursor when done; note that it may already be different if e.g. user // switched to another tool during interruptible tracing or drawing, in which case do nothing diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 3035cb1a7..f1ce029f4 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -67,6 +67,12 @@ sp_selected_path_union() } void +sp_selected_path_union_skip_undo() +{ + sp_selected_path_boolop(bool_op_union, SP_VERB_NONE, _("Union")); +} + +void sp_selected_path_intersect() { sp_selected_path_boolop(bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); @@ -573,7 +579,9 @@ sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustrin g_free(transform); - sp_document_done(sp_desktop_document(desktop), verb, description); + if (verb != SP_VERB_NONE) { + sp_document_done(sp_desktop_document(desktop), verb, description); + } delete res; } diff --git a/src/splivarot.h b/src/splivarot.h index cf1ebcd94..3d01f41e0 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -13,6 +13,7 @@ // work on the current selection // selection has 2 contain exactly 2 items void sp_selected_path_union (); +void sp_selected_path_union_skip_undo (); void sp_selected_path_intersect (); void sp_selected_path_diff (); void sp_selected_path_symdiff (); |
