X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fflood-context.cpp;h=dd26782a37897239b14882be3fad5febee95c517;hb=42382dfb4164b919ffcdf03766da9f8be4e43b42;hp=a9ca7073f906669c637a05a654d6c6a1e548bd2f;hpb=ff2c8039c77b58341e28cf90953cdd1f0fe68a16;p=inkscape.git diff --git a/src/flood-context.cpp b/src/flood-context.cpp index a9ca7073f..dd26782a3 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -1,21 +1,24 @@ -#define __SP_FLOOD_CONTEXT_C__ - -/** \file -* Bucket fill drawing context, works by bitmap filling an area on a rendered version of the current display and then tracing the result using potrace. -* -* Author: -* Lauris Kaplinski -* bulia byak -* John Bintz -* -* Copyright (C) 2006 Johan Engelen -* Copyright (C) 2000-2005 authors -* Copyright (C) 2000-2001 Ximian, Inc. -* -* Released under GNU GPL, read the file 'COPYING' for more information -*/ +/** @file + * @brief Bucket fill drawing context, works by bitmap filling an area on a rendered version + * of the current display and then tracing the result using potrace. + */ +/* Author: + * Lauris Kaplinski + * bulia byak + * John Bintz + * Jon A. Cruz + * Abhishek Sharma + * + * Copyright (C) 2006 Johan Engelen + * Copyright (C) 2000-2005 authors + * Copyright (C) 2000-2001 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#ifdef HAVE_CONFIG_H #include "config.h" +#endif #include #include @@ -40,9 +43,10 @@ #include "object-edit.h" #include "xml/repr.h" #include "xml/node-event-vector.h" -#include "prefs-utils.h" +#include "preferences.h" #include "context-fns.h" #include "rubberband.h" +#include "shape-editor.h" #include "display/nr-arena-item.h" #include "display/nr-arena.h" @@ -70,6 +74,8 @@ #include "trace/imagemap.h" #include "trace/potrace/inkscape-potrace.h" +using Inkscape::DocumentUndo; + static void sp_flood_context_class_init(SPFloodContextClass *klass); static void sp_flood_context_init(SPFloodContext *flood_context); static void sp_flood_context_dispose(GObject *object); @@ -130,9 +136,6 @@ static void sp_flood_context_init(SPFloodContext *flood_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - flood_context->item = NULL; new (&flood_context->sel_changed_connection) sigc::connection(); @@ -146,17 +149,14 @@ static void sp_flood_context_dispose(GObject *object) rc->sel_changed_connection.disconnect(); rc->sel_changed_connection.~connection(); + delete ec->shape_editor; + ec->shape_editor = NULL; + /* fixme: This is necessary because we do not grab */ if (rc->item) { sp_flood_finish(rc); } - if (ec->shape_repr) { // remove old listener - sp_repr_remove_listener_by_data(ec->shape_repr, ec); - Inkscape::GC::release(ec->shape_repr); - ec->shape_repr = 0; - } - if (rc->_message_context) { delete rc->_message_context; } @@ -164,14 +164,6 @@ static void sp_flood_context_dispose(GObject *object) G_OBJECT_CLASS(parent_class)->dispose(object); } -static Inkscape::XML::NodeEventVector ec_shape_repr_events = { - NULL, /* child_added */ - NULL, /* child_removed */ - ec_shape_event_attr_changed, - NULL, /* content_changed */ - NULL /* order_changed */ -}; - /** \brief Callback that processes the "changed" signal on the selection; destroys old and creates new knotholder @@ -181,21 +173,9 @@ void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer SPFloodContext *rc = SP_FLOOD_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(rc); - if (ec->shape_repr) { // remove old listener - sp_repr_remove_listener_by_data(ec->shape_repr, ec); - Inkscape::GC::release(ec->shape_repr); - ec->shape_repr = 0; - } - - SPItem *item = selection->singleItem(); - if (item) { - Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item); - if (shape_repr) { - ec->shape_repr = shape_repr; - Inkscape::GC::anchor(shape_repr); - sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec); - } - } + ec->shape_editor->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void sp_flood_context_setup(SPEventContext *ec) @@ -206,14 +186,11 @@ static void sp_flood_context_setup(SPEventContext *ec) ((SPEventContextClass *) parent_class)->setup(ec); } + ec->shape_editor = new ShapeEditor(ec->desktop); + SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); if (item) { - Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item); - if (shape_repr) { - ec->shape_repr = shape_repr; - Inkscape::GC::anchor(shape_repr); - sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec); - } + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } rc->sel_changed_connection.disconnect(); @@ -223,7 +200,8 @@ static void sp_flood_context_setup(SPEventContext *ec) rc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); - if (prefs_get_int_attribute("tools.paintbucket", "selcue", 0) != 0) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/tools/paintbucket/selcue")) { rc->enableSelectionCue(); } } @@ -285,10 +263,10 @@ GList * flood_channels_dropdown_items_list() { GList * flood_autogap_dropdown_items_list() { GList *glist = NULL; - glist = g_list_append (glist, _("None")); - glist = g_list_append (glist, _("Small")); - glist = g_list_append (glist, _("Medium")); - glist = g_list_append (glist, _("Large")); + glist = g_list_append (glist, (void*) C_("Flood autogap", "None")); + glist = g_list_append (glist, (void*) C_("Flood autogap", "Small")); + glist = g_list_append (glist, (void*) C_("Flood autogap", "Medium")); + glist = g_list_append (glist, (void*) C_("Flood autogap", "Large")); return glist; } @@ -380,8 +358,8 @@ struct bitmap_coords_info { PaintBucketChannels method; unsigned char *dtc; unsigned char *merged_orig_pixel; - NR::Rect bbox; - NR::Rect screen; + Geom::Rect bbox; + Geom::Rect screen; unsigned int max_queue_size; unsigned int current_step; }; @@ -417,7 +395,7 @@ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_ * \param transform The transform to apply to the final SVG path. * \param union_with_selection If true, merge the final SVG path with the current selection. */ -static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, NR::Matrix transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) { +static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, Geom::Matrix transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) { SPDocument *document = sp_desktop_document(desktop); unsigned char *trace_t; @@ -437,15 +415,17 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto } Inkscape::Trace::Potrace::PotraceTracingEngine pte; + pte.keepGoing = 1; std::vector results = pte.traceGrayMap(gray_map); gray_map->destroy(gray_map); - Inkscape::XML::Node *layer_repr = SP_GROUP(desktop->currentLayer())->repr; - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + //XML Tree being used here directly while it shouldn't be...." + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); long totalNodeCount = 0L; - double offset = prefs_get_double_attribute("tools.paintbucket", "offset", 0.0); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double offset = prefs->getDouble("/tools/paintbucket/offset", 0.0); for (unsigned int i=0 ; icreateElement("svg:path"); /* Set style */ - sp_desktop_apply_style_tool (desktop, pathRepr, "tools.paintbucket", false); + sp_desktop_apply_style_tool (desktop, pathRepr, "/tools/paintbucket", false); Geom::PathVector pathv = sp_svg_read_pathv(result.getPathData().c_str()); Path *path = new Path; @@ -503,17 +483,17 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto g_free(str); } - layer_repr->addChild(pathRepr, NULL); + desktop->currentLayer()->addChild(pathRepr,NULL); SPObject *reprobj = document->getObjectByRepr(pathRepr); if (reprobj) { - sp_item_write_transform(SP_ITEM(reprobj), pathRepr, transform, NULL); + SP_ITEM(reprobj)->doWriteTransform(pathRepr, transform, NULL); // premultiply the item transform by the accumulated parent transform in the paste layer - NR::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer()))); - if (!local.test_identity()) { + Geom::Matrix local (SP_GROUP(desktop->currentLayer())->i2doc_affine()); + if (!local.isIdentity()) { gchar const *t_str = pathRepr->attribute("transform"); - NR::Matrix item_t (NR::identity()); + Geom::Matrix item_t (Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); item_t *= local.inverse(); @@ -530,7 +510,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto if (union_with_selection) { desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with %d node created and unioned with selection.","Area filled, path with %d nodes created and unioned with selection.",sp_nodes_in_path(SP_PATH(reprobj))), sp_nodes_in_path(SP_PATH(reprobj))); selection->add(reprobj); - sp_selected_path_union_skip_undo(); + sp_selected_path_union_skip_undo(desktop); } else { desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with %d node created.","Area filled, path with %d nodes created.",sp_nodes_in_path(SP_PATH(reprobj))), sp_nodes_in_path(SP_PATH(reprobj))); selection->set(reprobj); @@ -625,10 +605,10 @@ inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, unsigned ch * \param x The X coordinate. * \param y The Y coordinate. */ -static void push_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { +static void push_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { if (!is_pixel_queued(trace_t)) { if ((fill_queue->size() < max_queue_size)) { - fill_queue->push_back(NR::Point(x, y)); + fill_queue->push_back(Geom::Point(x, y)); mark_pixel_queued(trace_t); } } @@ -642,10 +622,10 @@ static void push_point_onto_queue(std::deque *fill_queue, unsigned in * \param x The X coordinate. * \param y The Y coordinate. */ -static void shift_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { +static void shift_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { if (!is_pixel_queued(trace_t)) { if ((fill_queue->size() < max_queue_size)) { - fill_queue->push_front(NR::Point(x, y)); + fill_queue->push_front(Geom::Point(x, y)); mark_pixel_queued(trace_t); } } @@ -659,7 +639,7 @@ static void shift_point_onto_queue(std::deque *fill_queue, unsigned i * \param orig_color The original selected pixel to use as the fill target color. * \param bci The bitmap_coords_info structure. */ -static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { +static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { bool aborted = false; bool reached_screen_boundary = false; bool ok; @@ -679,7 +659,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * bool can_paint_top = (top_ty > 0); bool can_paint_bottom = (bottom_ty < bci.height); - NR::Point t = fill_queue->front(); + Geom::Point t = fill_queue->front(); do { ok = false; @@ -697,7 +677,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * paint_directions = paint_pixel(px, trace_px, orig_color, bci, current_trace_t); if (bci.radius == 0) { mark_pixel_checked(current_trace_t); - if ((t[NR::X] == bci.x) && (t[NR::Y] == bci.y)) { + if ((t[Geom::X] == bci.x) && (t[Geom::Y] == bci.y)) { fill_queue->pop_front(); t = fill_queue->front(); } } @@ -755,7 +735,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * initial_paint = false; } } else { - if (bci.bbox.min()[NR::X] > bci.screen.min()[NR::X]) { + if (bci.bbox.min()[Geom::X] > bci.screen.min()[Geom::X]) { aborted = true; break; } else { reached_screen_boundary = true; @@ -771,15 +751,15 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * /** * \brief Sort the rendered pixel buffer check queue vertically. */ -static bool sort_fill_queue_vertical(NR::Point a, NR::Point b) { - return a[NR::Y] > b[NR::Y]; +static bool sort_fill_queue_vertical(Geom::Point a, Geom::Point b) { + return a[Geom::Y] > b[Geom::Y]; } /** * \brief Sort the rendered pixel buffer check queue horizontally. */ -static bool sort_fill_queue_horizontal(NR::Point a, NR::Point b) { - return a[NR::X] > b[NR::X]; +static bool sort_fill_queue_horizontal(Geom::Point a, Geom::Point b) { + return a[Geom::X] > b[Geom::X]; } /** @@ -796,12 +776,12 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even /* Create new arena */ NRArena *arena = NRArena::create(); - unsigned dkey = sp_item_display_key_new(1); + unsigned dkey = SPItem::display_key_new(1); - sp_document_ensure_up_to_date (document); + document->ensureUpToDate(); - SPItem *document_root = SP_ITEM(SP_DOCUMENT_ROOT(document)); - boost::optional bbox = document_root->getBounds(NR::identity()); + SPItem *document_root = SP_ITEM(document->getRoot()); + Geom::OptRect bbox = document_root->getBounds(Geom::identity()); if (!bbox) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Area is not bounded, cannot fill.")); @@ -814,26 +794,26 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even // fill areas off the screen can be included in the fill. double padding = 1.6; - NR::Rect screen = desktop->get_display_area(); + Geom::Rect screen = desktop->get_display_area(); - unsigned int width = (int)ceil(screen.extent(NR::X) * zoom_scale * padding); - unsigned int height = (int)ceil(screen.extent(NR::Y) * zoom_scale * padding); + unsigned int width = (int)ceil(screen.width() * zoom_scale * padding); + unsigned int height = (int)ceil(screen.height() * zoom_scale * padding); - NR::Point origin(screen.min()[NR::X], - sp_document_height(document) - screen.extent(NR::Y) - screen.min()[NR::Y]); + Geom::Point origin(screen.min()[Geom::X], + document->getHeight() - screen.height() - screen.min()[Geom::Y]); - origin[NR::X] = origin[NR::X] + (screen.extent(NR::X) * ((1 - padding) / 2)); - origin[NR::Y] = origin[NR::Y] + (screen.extent(NR::Y) * ((1 - padding) / 2)); + origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2)); + origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2)); - NR::scale scale(zoom_scale, zoom_scale); - NR::Matrix affine = scale * NR::translate(-origin * scale); + Geom::Scale scale(zoom_scale, zoom_scale); + Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ - NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(document)), arena, dkey, SP_ITEM_SHOW_DISPLAY); + NRArenaItem *root = SP_ITEM(document->getRoot())->invoke_show( arena, dkey, SP_ITEM_SHOW_DISPLAY); nr_arena_item_set_transform(NR_ARENA_ITEM(root), affine); NRGC gc(NULL); - gc.transform.set_identity(); + gc.transform.setIdentity(); NRRectL final_bbox; final_bbox.x0 = 0; @@ -872,24 +852,24 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even nr_pixblock_release(&B); // Hide items - sp_item_invoke_hide(SP_ITEM(sp_document_root(document)), dkey); + SP_ITEM(document->getRoot())->invoke_hide(dkey); - nr_arena_item_unref(root); nr_object_unref((NRObject *) arena); guchar *trace_px = g_new(guchar, width * height); memset(trace_px, 0x00, width * height); - std::deque fill_queue; - std::queue color_queue; + std::deque fill_queue; + std::queue color_queue; - std::vector fill_points; + std::vector fill_points; bool aborted = false; int y_limit = height - 1; - PaintBucketChannels method = (PaintBucketChannels)prefs_get_int_attribute("tools.paintbucket", "channels", 0); - int threshold = prefs_get_int_attribute_limited("tools.paintbucket", "threshold", 1, 0, 100); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + PaintBucketChannels method = (PaintBucketChannels) prefs->getInt("/tools/paintbucket/channels", 0); + int threshold = prefs->getIntLimited("/tools/paintbucket/threshold", 1, 0, 100); switch(method) { case FLOOD_CHANNELS_ALPHA: @@ -915,29 +895,29 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even bci.bbox = *bbox; bci.screen = screen; bci.dtc = dtc; - bci.radius = prefs_get_int_attribute_limited("tools.paintbucket", "autogap", 0, 0, 3); + bci.radius = prefs->getIntLimited("/tools/paintbucket/autogap", 0, 0, 3); bci.max_queue_size = (width * height) / 4; bci.current_step = 0; if (is_point_fill) { - fill_points.push_back(NR::Point(event->button.x, event->button.y)); + fill_points.push_back(Geom::Point(event->button.x, event->button.y)); } else { - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); + Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); fill_points = r->getPoints(); } for (unsigned int i = 0; i < fill_points.size(); i++) { - NR::Point pw = NR::Point(fill_points[i][NR::X] / zoom_scale, sp_document_height(document) + (fill_points[i][NR::Y] / zoom_scale)) * affine; + Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, document->getHeight() + (fill_points[i][Geom::Y] / zoom_scale)) * affine; - pw[NR::X] = (int)MIN(width - 1, MAX(0, pw[NR::X])); - pw[NR::Y] = (int)MIN(height - 1, MAX(0, pw[NR::Y])); + pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X])); + pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[Geom::Y])); if (is_touch_fill) { if (i == 0) { color_queue.push(pw); } else { - unsigned char *trace_t = get_trace_pixel(trace_px, (int)pw[NR::X], (int)pw[NR::Y], width); - push_point_onto_queue(&fill_queue, bci.max_queue_size, trace_t, (int)pw[NR::X], (int)pw[NR::Y]); + unsigned char *trace_t = get_trace_pixel(trace_px, (int)pw[Geom::X], (int)pw[Geom::Y], width); + push_point_onto_queue(&fill_queue, bci.max_queue_size, trace_t, (int)pw[Geom::X], (int)pw[Geom::Y]); } } else { color_queue.push(pw); @@ -956,11 +936,11 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even unsigned int max_x = 0; while (!color_queue.empty() && !aborted) { - NR::Point color_point = color_queue.front(); + Geom::Point color_point = color_queue.front(); color_queue.pop(); - int cx = (int)color_point[NR::X]; - int cy = (int)color_point[NR::Y]; + int cx = (int)color_point[Geom::X]; + int cy = (int)color_point[Geom::Y]; unsigned char *orig_px = get_pixel(px, cx, cy, width); unsigned char orig_color[4]; @@ -993,7 +973,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even unsigned long old_fill_queue_size = fill_queue.size(); while (!fill_queue.empty() && !aborted) { - NR::Point cp = fill_queue.front(); + Geom::Point cp = fill_queue.front(); if (bci.radius == 0) { unsigned long new_fill_queue_size = fill_queue.size(); @@ -1010,14 +990,14 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even if (new_fill_queue_size > old_fill_queue_size) { std::sort(fill_queue.begin(), fill_queue.end(), sort_fill_queue_vertical); - std::deque::iterator start_sort = fill_queue.begin(); - std::deque::iterator end_sort = fill_queue.begin(); - unsigned int sort_y = (unsigned int)cp[NR::Y]; + std::deque::iterator start_sort = fill_queue.begin(); + std::deque::iterator end_sort = fill_queue.begin(); + unsigned int sort_y = (unsigned int)cp[Geom::Y]; unsigned int current_y = sort_y; - for (std::deque::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) { - NR::Point current = *i; - current_y = (unsigned int)current[NR::Y]; + for (std::deque::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) { + Geom::Point current = *i; + current_y = (unsigned int)current[Geom::Y]; if (current_y != sort_y) { if (start_sort != end_sort) { std::sort(start_sort, end_sort, sort_fill_queue_horizontal); @@ -1040,8 +1020,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even fill_queue.pop_front(); - int x = (int)cp[NR::X]; - int y = (int)cp[NR::Y]; + int x = (int)cp[Geom::X]; + int y = (int)cp[Geom::Y]; min_y = MIN((unsigned int)y, min_y); max_y = MAX((unsigned int)y, max_y); @@ -1051,7 +1031,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even mark_pixel_checked(trace_t); if (y == 0) { - if (bbox->min()[NR::Y] > screen.min()[NR::Y]) { + if (bbox->min()[Geom::Y] > screen.min()[Geom::Y]) { aborted = true; break; } else { reached_screen_boundary = true; @@ -1059,7 +1039,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even } if (y == y_limit) { - if (bbox->max()[NR::Y] < screen.max()[NR::Y]) { + if (bbox->max()[Geom::Y] < screen.max()[Geom::Y]) { aborted = true; break; } else { reached_screen_boundary = true; @@ -1132,16 +1112,16 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even if (min_x > trace_padding) { min_x -= trace_padding; } if (max_x < (width - 1 - trace_padding)) { max_x += trace_padding; } - NR::Point min_start = NR::Point(min_x, min_y); + Geom::Point min_start = Geom::Point(min_x, min_y); - affine = scale * NR::translate(-origin * scale - min_start); - NR::Matrix inverted_affine = NR::Matrix(affine).inverse(); + affine = scale * Geom::Translate(-origin * scale - min_start); + Geom::Matrix inverted_affine = Geom::Matrix(affine).inverse(); do_trace(bci, trace_px, desktop, inverted_affine, min_x, max_x, min_y, max_y, union_with_selection); g_free(trace_px); - sp_document_done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); + DocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); } static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) @@ -1153,15 +1133,14 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem switch (event->type) { case GDK_BUTTON_PRESS: if ((event->button.state & GDK_CONTROL_MASK) && event->button.button == 1 && !event_context->space_panning) { - NR::Point const button_w(event->button.x, - event->button.y); + Geom::Point const button_w(event->button.x, + event->button.y); SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE); - Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item); - /* Set style */ - sp_desktop_apply_style_tool (desktop, pathRepr, "tools.paintbucket", false); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); + // Set style + desktop->applyCurrentOrToolStyle(item, "/tools/paintbucket", false); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Set style on object")); ret = TRUE; } break; @@ -1187,18 +1166,18 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven case GDK_BUTTON_PRESS: if (event->button.button == 1 && !event_context->space_panning) { if (!(event->button.state & GDK_CONTROL_MASK)) { - NR::Point const button_w(event->button.x, - event->button.y); + Geom::Point const button_w(event->button.x, + event->button.y); if (Inkscape::have_viable_layer(desktop, event_context->defaultMessageContext())) { // save drag origin - event_context->xp = (gint) button_w[NR::X]; - event_context->yp = (gint) button_w[NR::Y]; + event_context->xp = (gint) button_w[Geom::X]; + event_context->yp = (gint) button_w[Geom::Y]; event_context->within_tolerance = true; dragging = true; - NR::Point const p(desktop->w2d(button_w)); + Geom::Point const p(desktop->w2d(button_w)); Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); Inkscape::Rubberband::get(desktop)->start(desktop, p); } @@ -1216,8 +1195,8 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven event_context->within_tolerance = false; - NR::Point const motion_pt(event->motion.x, event->motion.y); - NR::Point const p(desktop->w2d(motion_pt)); + Geom::Point const motion_pt(event->motion.x, event->motion.y); + Geom::Point const p(desktop->w2d(motion_pt)); if (Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->move(p); event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Draw over areas to add to fill, hold Alt for touch fill")); @@ -1228,7 +1207,7 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven case GDK_BUTTON_RELEASE: if (event->button.button == 1 && !event_context->space_panning) { - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); + Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); if (r->is_started()) { // set "busy" cursor desktop->setWaitingCursor(); @@ -1300,7 +1279,7 @@ static void sp_flood_finish(SPFloodContext *rc) sp_canvas_end_forced_full_redraws(desktop->canvas); sp_desktop_selection(desktop)->set(rc->item); - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); rc->item = NULL; @@ -1309,7 +1288,8 @@ static void sp_flood_finish(SPFloodContext *rc) void flood_channels_set_channels( gint channels ) { - prefs_set_int_attribute("tools.paintbucket", "channels", channels); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt("/tools/paintbucket/channels", channels); } /* @@ -1321,4 +1301,4 @@ void flood_channels_set_channels( gint channels ) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :