From: johncoswell Date: Sat, 31 Mar 2007 12:42:17 +0000 (+0000) Subject: Change paint bucket path union to properly create only one undo event, rather than two X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=044cd1c8a0a9ead9d3eb83e76b2d24da26a1909a;p=inkscape.git Change paint bucket path union to properly create only one undo event, rather than two --- 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 *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 %d nodes created."), sp_nodes_in_path(SP_PATH(reprobj))); + if (union_with_selection) { + desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, _("Area filled, path with %d 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 %d 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 * 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 @@ -66,6 +66,12 @@ sp_selected_path_union() sp_selected_path_boolop(bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); } +void +sp_selected_path_union_skip_undo() +{ + sp_selected_path_boolop(bool_op_union, SP_VERB_NONE, _("Union")); +} + void sp_selected_path_intersect() { @@ -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 ();