From e58cac52b258e64c2cc88b0044bf9cfbaecedce2 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 00:23:07 +0200 Subject: Started conversion of SPEventContext tree; added virtual pads to all classes. (bzr r11608.1.89) --- src/flood-context.cpp | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index a62be624c..d8f9a2624 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -98,8 +98,16 @@ static void sp_flood_context_class_init(SPFloodContextClass *klass) event_context_class->item_handler = sp_flood_context_item_handler; } +CFloodContext::CFloodContext(SPFloodContext* floodcontext) : CEventContext(floodcontext) { + this->spfloodcontext = floodcontext; +} + static void sp_flood_context_init(SPFloodContext *flood_context) { + flood_context->cfloodcontext = new CFloodContext(flood_context); + delete flood_context->ceventcontext; + flood_context->ceventcontext = flood_context->cfloodcontext; + SPEventContext *event_context = SP_EVENT_CONTEXT(flood_context); event_context->cursor_shape = cursor_paintbucket_xpm; @@ -155,11 +163,18 @@ static void sp_flood_context_selection_changed(Inkscape::Selection *selection, g static void sp_flood_context_setup(SPEventContext *ec) { + ec->ceventcontext->setup(); +} + +void CFloodContext::setup() { + SPEventContext* ec = this->speventcontext; + SPFloodContext *rc = SP_FLOOD_CONTEXT(ec); - if (((SPEventContextClass *) sp_flood_context_parent_class)->setup) { - ((SPEventContextClass *) sp_flood_context_parent_class)->setup(ec); - } +// if (((SPEventContextClass *) sp_flood_context_parent_class)->setup) { +// ((SPEventContextClass *) sp_flood_context_parent_class)->setup(ec); +// } + CEventContext::setup(); ec->shape_editor = new ShapeEditor(ec->desktop); @@ -181,6 +196,7 @@ static void sp_flood_context_setup(SPEventContext *ec) } } + // Changes from 0.48 -> 0.49 (Cairo) // 0.49: Ignores alpha in background // 0.48: RGBA, 0.49 ARGB @@ -1120,6 +1136,12 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) { + return event_context->ceventcontext->item_handler(item, event); +} + +gint CFloodContext::item_handler(SPItem* item, GdkEvent* event) { + SPEventContext* event_context = this->speventcontext; + gint ret = FALSE; SPDesktop *desktop = event_context->desktop; @@ -1142,15 +1164,23 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem break; } - if (((SPEventContextClass *) sp_flood_context_parent_class)->item_handler) { - ret = ((SPEventContextClass *) sp_flood_context_parent_class)->item_handler(event_context, item, event); - } +// if (((SPEventContextClass *) sp_flood_context_parent_class)->item_handler) { +// ret = ((SPEventContextClass *) sp_flood_context_parent_class)->item_handler(event_context, item, event); +// } + // CPPIFY: ret is overwritten... + ret = CEventContext::item_handler(item, event); return ret; } static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEvent *event) { + return event_context->ceventcontext->root_handler(event); +} + +gint CFloodContext::root_handler(GdkEvent* event) { + SPEventContext* event_context = this->speventcontext; + static bool dragging; gint ret = FALSE; @@ -1250,9 +1280,10 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven } if (!ret) { - if (((SPEventContextClass *) sp_flood_context_parent_class)->root_handler) { - ret = ((SPEventContextClass *) sp_flood_context_parent_class)->root_handler(event_context, event); - } +// if (((SPEventContextClass *) sp_flood_context_parent_class)->root_handler) { +// ret = ((SPEventContextClass *) sp_flood_context_parent_class)->root_handler(event_context, event); +// } + ret = CEventContext::root_handler(event); } return ret; -- cgit v1.2.3 From 1d8f1753cd8cab38d19fcc26a4ad70ba2e794ac8 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 22:12:07 +0200 Subject: Added constructors to EventContext tree / some missing virtual pads. (bzr r11608.1.90) --- src/flood-context.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index d8f9a2624..39002d39a 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -93,21 +93,24 @@ static void sp_flood_context_class_init(SPFloodContextClass *klass) object_class->dispose = sp_flood_context_dispose; - event_context_class->setup = sp_flood_context_setup; - event_context_class->root_handler = sp_flood_context_root_handler; - event_context_class->item_handler = sp_flood_context_item_handler; +// event_context_class->setup = sp_flood_context_setup; +// event_context_class->root_handler = sp_flood_context_root_handler; +// event_context_class->item_handler = sp_flood_context_item_handler; } CFloodContext::CFloodContext(SPFloodContext* floodcontext) : CEventContext(floodcontext) { this->spfloodcontext = floodcontext; } -static void sp_flood_context_init(SPFloodContext *flood_context) -{ +SPFloodContext::SPFloodContext() : SPEventContext() { + SPFloodContext* flood_context = this; + flood_context->cfloodcontext = new CFloodContext(flood_context); delete flood_context->ceventcontext; flood_context->ceventcontext = flood_context->cfloodcontext; + flood_context->_message_context = 0; + SPEventContext *event_context = SP_EVENT_CONTEXT(flood_context); event_context->cursor_shape = cursor_paintbucket_xpm; @@ -124,6 +127,11 @@ static void sp_flood_context_init(SPFloodContext *flood_context) new (&flood_context->sel_changed_connection) sigc::connection(); } +static void sp_flood_context_init(SPFloodContext *flood_context) +{ + new (flood_context) SPFloodContext(); +} + static void sp_flood_context_dispose(GObject *object) { SPFloodContext *rc = SP_FLOOD_CONTEXT(object); -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/flood-context.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 39002d39a..fedd51a4b 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -84,6 +84,8 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem static void sp_flood_finish(SPFloodContext *rc); +const std::string SPFloodContext::prefsPath = "/tools/paintbucket"; + G_DEFINE_TYPE(SPFloodContext, sp_flood_context, SP_TYPE_EVENT_CONTEXT); static void sp_flood_context_class_init(SPFloodContextClass *klass) -- cgit v1.2.3 From fbdc8b84ff670c684dafc7d7d403ed01e7077e70 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 18:13:17 +0200 Subject: Replaced casting macros for EventContext tree; added contructors. (bzr r11608.1.96) --- src/flood-context.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index fedd51a4b..333be207e 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -84,6 +84,20 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem static void sp_flood_finish(SPFloodContext *rc); +#include "sp-factory.h" + +namespace { + SPEventContext* createPaintbucketContext() { + return new SPFloodContext(); + } + + bool paintbucketContextRegistered = ToolFactory::instance().registerObject("/tools/paintbucket", createPaintbucketContext); +} + +const std::string& CFloodContext::getPrefsPath() { + return SPFloodContext::prefsPath; +} + const std::string SPFloodContext::prefsPath = "/tools/paintbucket"; G_DEFINE_TYPE(SPFloodContext, sp_flood_context, SP_TYPE_EVENT_CONTEXT); @@ -110,6 +124,7 @@ SPFloodContext::SPFloodContext() : SPEventContext() { flood_context->cfloodcontext = new CFloodContext(flood_context); delete flood_context->ceventcontext; flood_context->ceventcontext = flood_context->cfloodcontext; + types.insert(typeid(SPFloodContext)); flood_context->_message_context = 0; -- cgit v1.2.3 From 65ba6ad9a82f8f47974eb10665478fd783692bb5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:19:46 +0200 Subject: Merging of EventContext classes complete. (bzr r11608.1.98) --- src/flood-context.cpp | 84 ++++++++++----------------------------------------- 1 file changed, 16 insertions(+), 68 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 333be207e..14cf58501 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -75,13 +75,6 @@ using Inkscape::Display::ExtractARGB32; using Inkscape::Display::ExtractRGB32; using Inkscape::Display::AssembleARGB32; -static void sp_flood_context_dispose(GObject *object); - -static void sp_flood_context_setup(SPEventContext *ec); - -static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEvent *event); -static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); - static void sp_flood_finish(SPFloodContext *rc); #include "sp-factory.h" @@ -94,38 +87,15 @@ namespace { bool paintbucketContextRegistered = ToolFactory::instance().registerObject("/tools/paintbucket", createPaintbucketContext); } -const std::string& CFloodContext::getPrefsPath() { +const std::string& SPFloodContext::getPrefsPath() { return SPFloodContext::prefsPath; } const std::string SPFloodContext::prefsPath = "/tools/paintbucket"; -G_DEFINE_TYPE(SPFloodContext, sp_flood_context, SP_TYPE_EVENT_CONTEXT); - -static void sp_flood_context_class_init(SPFloodContextClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - SPEventContextClass *event_context_class = (SPEventContextClass *) klass; - - object_class->dispose = sp_flood_context_dispose; - -// event_context_class->setup = sp_flood_context_setup; -// event_context_class->root_handler = sp_flood_context_root_handler; -// event_context_class->item_handler = sp_flood_context_item_handler; -} - -CFloodContext::CFloodContext(SPFloodContext* floodcontext) : CEventContext(floodcontext) { - this->spfloodcontext = floodcontext; -} - SPFloodContext::SPFloodContext() : SPEventContext() { SPFloodContext* flood_context = this; - flood_context->cfloodcontext = new CFloodContext(flood_context); - delete flood_context->ceventcontext; - flood_context->ceventcontext = flood_context->cfloodcontext; - types.insert(typeid(SPFloodContext)); - flood_context->_message_context = 0; SPEventContext *event_context = SP_EVENT_CONTEXT(flood_context); @@ -141,21 +111,15 @@ SPFloodContext::SPFloodContext() : SPEventContext() { flood_context->item = NULL; - new (&flood_context->sel_changed_connection) sigc::connection(); -} - -static void sp_flood_context_init(SPFloodContext *flood_context) -{ - new (flood_context) SPFloodContext(); + //new (&flood_context->sel_changed_connection) sigc::connection(); } -static void sp_flood_context_dispose(GObject *object) -{ - SPFloodContext *rc = SP_FLOOD_CONTEXT(object); - SPEventContext *ec = SP_EVENT_CONTEXT(object); +SPFloodContext::~SPFloodContext() { + SPFloodContext *rc = SP_FLOOD_CONTEXT(this); + SPEventContext *ec = SP_EVENT_CONTEXT(this); rc->sel_changed_connection.disconnect(); - rc->sel_changed_connection.~connection(); + //rc->sel_changed_connection.~connection(); delete ec->shape_editor; ec->shape_editor = NULL; @@ -169,7 +133,7 @@ static void sp_flood_context_dispose(GObject *object) delete rc->_message_context; } - G_OBJECT_CLASS(sp_flood_context_parent_class)->dispose(object); + //G_OBJECT_CLASS(sp_flood_context_parent_class)->dispose(object); } /** @@ -186,20 +150,15 @@ static void sp_flood_context_selection_changed(Inkscape::Selection *selection, g ec->shape_editor->set_item(item, SH_KNOTHOLDER); } -static void sp_flood_context_setup(SPEventContext *ec) -{ - ec->ceventcontext->setup(); -} - -void CFloodContext::setup() { - SPEventContext* ec = this->speventcontext; +void SPFloodContext::setup() { + SPEventContext* ec = this; SPFloodContext *rc = SP_FLOOD_CONTEXT(ec); // if (((SPEventContextClass *) sp_flood_context_parent_class)->setup) { // ((SPEventContextClass *) sp_flood_context_parent_class)->setup(ec); // } - CEventContext::setup(); + SPEventContext::setup(); ec->shape_editor = new ShapeEditor(ec->desktop); @@ -1159,13 +1118,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even DocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); } -static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) -{ - return event_context->ceventcontext->item_handler(item, event); -} - -gint CFloodContext::item_handler(SPItem* item, GdkEvent* event) { - SPEventContext* event_context = this->speventcontext; +gint SPFloodContext::item_handler(SPItem* item, GdkEvent* event) { + SPEventContext* event_context = this; gint ret = FALSE; @@ -1193,18 +1147,13 @@ gint CFloodContext::item_handler(SPItem* item, GdkEvent* event) { // ret = ((SPEventContextClass *) sp_flood_context_parent_class)->item_handler(event_context, item, event); // } // CPPIFY: ret is overwritten... - ret = CEventContext::item_handler(item, event); + ret = SPEventContext::item_handler(item, event); return ret; } -static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEvent *event) -{ - return event_context->ceventcontext->root_handler(event); -} - -gint CFloodContext::root_handler(GdkEvent* event) { - SPEventContext* event_context = this->speventcontext; +gint SPFloodContext::root_handler(GdkEvent* event) { + SPEventContext* event_context = this; static bool dragging; @@ -1308,13 +1257,12 @@ gint CFloodContext::root_handler(GdkEvent* event) { // if (((SPEventContextClass *) sp_flood_context_parent_class)->root_handler) { // ret = ((SPEventContextClass *) sp_flood_context_parent_class)->root_handler(event_context, event); // } - ret = CEventContext::root_handler(event); + ret = SPEventContext::root_handler(event); } return ret; } - static void sp_flood_finish(SPFloodContext *rc) { rc->_message_context->clear(); -- cgit v1.2.3 From 5512f857e2f33f1aa40124dc82b353e5f2e5a0b0 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:58:53 +0200 Subject: Moved factories to different files. (bzr r11608.1.100) --- src/flood-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 14cf58501..fccf9c24c 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -77,7 +77,7 @@ using Inkscape::Display::AssembleARGB32; static void sp_flood_finish(SPFloodContext *rc); -#include "sp-factory.h" +#include "tool-factory.h" namespace { SPEventContext* createPaintbucketContext() { -- cgit v1.2.3 From 389b871cdea29ace85567863c439eb0537a36f54 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 21 Apr 2013 20:45:27 +0200 Subject: Cleaned up a bit. (bzr r11608.1.102) --- src/flood-context.cpp | 173 +++++++++++++++++++------------------------------- 1 file changed, 67 insertions(+), 106 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index fccf9c24c..367597532 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -75,8 +75,6 @@ using Inkscape::Display::ExtractARGB32; using Inkscape::Display::ExtractRGB32; using Inkscape::Display::AssembleARGB32; -static void sp_flood_finish(SPFloodContext *rc); - #include "tool-factory.h" namespace { @@ -94,89 +92,65 @@ const std::string& SPFloodContext::getPrefsPath() { const std::string SPFloodContext::prefsPath = "/tools/paintbucket"; SPFloodContext::SPFloodContext() : SPEventContext() { - SPFloodContext* flood_context = this; - - flood_context->_message_context = 0; - - SPEventContext *event_context = SP_EVENT_CONTEXT(flood_context); - - event_context->cursor_shape = cursor_paintbucket_xpm; - event_context->hot_x = 11; - event_context->hot_y = 30; - event_context->xp = 0; - event_context->yp = 0; - event_context->tolerance = 4; - event_context->within_tolerance = false; - event_context->item_to_select = NULL; - - flood_context->item = NULL; - - //new (&flood_context->sel_changed_connection) sigc::connection(); + this->_message_context = 0; + this->cursor_shape = cursor_paintbucket_xpm; + this->hot_x = 11; + this->hot_y = 30; + this->xp = 0; + this->yp = 0; + this->tolerance = 4; + this->within_tolerance = false; + this->item_to_select = NULL; + + this->item = NULL; } SPFloodContext::~SPFloodContext() { - SPFloodContext *rc = SP_FLOOD_CONTEXT(this); - SPEventContext *ec = SP_EVENT_CONTEXT(this); + this->sel_changed_connection.disconnect(); - rc->sel_changed_connection.disconnect(); - //rc->sel_changed_connection.~connection(); - - delete ec->shape_editor; - ec->shape_editor = NULL; + delete this->shape_editor; + this->shape_editor = NULL; /* fixme: This is necessary because we do not grab */ - if (rc->item) { - sp_flood_finish(rc); + if (this->item) { + this->finishItem(); } - if (rc->_message_context) { - delete rc->_message_context; + if (this->_message_context) { + delete this->_message_context; } - - //G_OBJECT_CLASS(sp_flood_context_parent_class)->dispose(object); } /** * Callback that processes the "changed" signal on the selection; * destroys old and creates new knotholder. */ -static void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer data) -{ - SPFloodContext *rc = SP_FLOOD_CONTEXT(data); - SPEventContext *ec = SP_EVENT_CONTEXT(rc); - - ec->shape_editor->unset_item(SH_KNOTHOLDER); - SPItem *item = selection->singleItem(); - ec->shape_editor->set_item(item, SH_KNOTHOLDER); +void SPFloodContext::selection_changed(Inkscape::Selection* selection) { + this->shape_editor->unset_item(SH_KNOTHOLDER); + this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER); } void SPFloodContext::setup() { - SPEventContext* ec = this; - - SPFloodContext *rc = SP_FLOOD_CONTEXT(ec); - -// if (((SPEventContextClass *) sp_flood_context_parent_class)->setup) { -// ((SPEventContextClass *) sp_flood_context_parent_class)->setup(ec); -// } SPEventContext::setup(); - ec->shape_editor = new ShapeEditor(ec->desktop); + this->shape_editor = new ShapeEditor(this->desktop); - SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); + SPItem *item = sp_desktop_selection(this->desktop)->singleItem(); if (item) { - ec->shape_editor->set_item(item, SH_KNOTHOLDER); + this->shape_editor->set_item(item, SH_KNOTHOLDER); } - rc->sel_changed_connection.disconnect(); - rc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged( - sigc::bind(sigc::ptr_fun(&sp_flood_context_selection_changed), (gpointer)rc) + this->sel_changed_connection.disconnect(); + this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged( + sigc::mem_fun(this, &SPFloodContext::selection_changed) ); - rc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); + this->_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/tools/paintbucket/selcue")) { - rc->enableSelectionCue(); + this->enableSelectionCue(); } } @@ -1119,26 +1093,24 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even } gint SPFloodContext::item_handler(SPItem* item, GdkEvent* event) { - SPEventContext* event_context = this; - gint ret = FALSE; - SPDesktop *desktop = event_context->desktop; - switch (event->type) { case GDK_BUTTON_PRESS: - if ((event->button.state & GDK_CONTROL_MASK) && event->button.button == 1 && !event_context->space_panning) { - Geom::Point const button_w(event->button.x, - event->button.y); + if ((event->button.state & GDK_CONTROL_MASK) && event->button.button == 1 && !this->space_panning) { + Geom::Point const button_w(event->button.x, event->button.y); SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE); // 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; + default: break; } @@ -1153,25 +1125,21 @@ gint SPFloodContext::item_handler(SPItem* item, GdkEvent* event) { } gint SPFloodContext::root_handler(GdkEvent* event) { - SPEventContext* event_context = this; - static bool dragging; gint ret = FALSE; - SPDesktop *desktop = event_context->desktop; switch (event->type) { case GDK_BUTTON_PRESS: - if (event->button.button == 1 && !event_context->space_panning) { + if (event->button.button == 1 && !this->space_panning) { if (!(event->button.state & GDK_CONTROL_MASK)) { - Geom::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())) { + if (Inkscape::have_viable_layer(desktop, this->defaultMessageContext())) { // save drag origin - event_context->xp = (gint) button_w[Geom::X]; - event_context->yp = (gint) button_w[Geom::Y]; - event_context->within_tolerance = true; + this->xp = (gint) button_w[Geom::X]; + this->yp = (gint) button_w[Geom::Y]; + this->within_tolerance = true; dragging = true; @@ -1181,44 +1149,45 @@ gint SPFloodContext::root_handler(GdkEvent* event) { } } } + case GDK_MOTION_NOTIFY: - if ( dragging - && ( event->motion.state & GDK_BUTTON1_MASK ) && !event_context->space_panning) - { - if ( event_context->within_tolerance - && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance ) - && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) { + if ( dragging && ( event->motion.state & GDK_BUTTON1_MASK ) && !this->space_panning) { + if ( this->within_tolerance + && ( abs( (gint) event->motion.x - this->xp ) < this->tolerance ) + && ( abs( (gint) event->motion.y - this->yp ) < this->tolerance ) ) { break; // do not drag if we're within tolerance from origin } - event_context->within_tolerance = false; + this->within_tolerance = false; 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")); + this->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Draw over areas to add to fill, hold Alt for touch fill")); gobble_motion_events(GDK_BUTTON1_MASK); } } break; case GDK_BUTTON_RELEASE: - if (event->button.button == 1 && !event_context->space_panning) { + if (event->button.button == 1 && !this->space_panning) { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); + if (r->is_started()) { // set "busy" cursor desktop->setWaitingCursor(); - if (SP_IS_EVENT_CONTEXT(event_context)) { + if (SP_IS_EVENT_CONTEXT(this)) { // Since setWaitingCursor runs main loop iterations, we may have already left this tool! // So check if the tool is valid before doing anything dragging = false; - bool is_point_fill = event_context->within_tolerance; + bool is_point_fill = this->within_tolerance; bool is_touch_fill = event->button.state & GDK_MOD1_MASK; - sp_flood_do_flood_fill(event_context, event, event->button.state & GDK_SHIFT_MASK, is_point_fill, is_touch_fill); + sp_flood_do_flood_fill(this, event, event->button.state & GDK_SHIFT_MASK, is_point_fill, is_touch_fill); desktop->clearWaitingCursor(); // restore cursor when done; note that it may already be different if e.g. user @@ -1229,9 +1198,9 @@ gint SPFloodContext::root_handler(GdkEvent* event) { r->stop(); - if (SP_IS_EVENT_CONTEXT(event_context)) { - event_context->defaultMessageContext()->clear(); - } + //if (SP_IS_EVENT_CONTEXT(this)) { + this->defaultMessageContext()->clear(); + //} } } break; @@ -1249,43 +1218,35 @@ gint SPFloodContext::root_handler(GdkEvent* event) { break; } break; + default: break; } if (!ret) { -// if (((SPEventContextClass *) sp_flood_context_parent_class)->root_handler) { -// ret = ((SPEventContextClass *) sp_flood_context_parent_class)->root_handler(event_context, event); -// } ret = SPEventContext::root_handler(event); } return ret; } -static void sp_flood_finish(SPFloodContext *rc) -{ - rc->_message_context->clear(); - - if ( rc->item != NULL ) { - SPDesktop * desktop; - - desktop = SP_EVENT_CONTEXT_DESKTOP(rc); +void SPFloodContext::finishItem() { + this->_message_context->clear(); - SP_OBJECT(rc->item)->updateRepr(); + if (this->item != NULL) { + this->item->updateRepr(); desktop->canvas->endForcedFullRedraws(); - sp_desktop_selection(desktop)->set(rc->item); - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, - _("Fill bounded area")); + sp_desktop_selection(desktop)->set(this->item); - rc->item = NULL; + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); + + this->item = NULL; } } -void flood_channels_set_channels( gint channels ) -{ +void SPFloodContext::set_channels(gint channels) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/tools/paintbucket/channels", channels); } -- cgit v1.2.3 From b2dd3583e7372d23d18bbc6e861f4f645ec3dc37 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 30 Jul 2013 23:17:21 +0200 Subject: Further refactoring of EventContexts. (bzr r11608.1.109) --- src/flood-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 3d2975e41..824c6e329 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -1092,7 +1092,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even DocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area")); } -gint SPFloodContext::item_handler(SPItem* item, GdkEvent* event) { +bool SPFloodContext::item_handler(SPItem* item, GdkEvent* event) { gint ret = FALSE; switch (event->type) { @@ -1124,7 +1124,7 @@ gint SPFloodContext::item_handler(SPItem* item, GdkEvent* event) { return ret; } -gint SPFloodContext::root_handler(GdkEvent* event) { +bool SPFloodContext::root_handler(GdkEvent* event) { static bool dragging; gint ret = FALSE; -- cgit v1.2.3 From 989abbac025a8b3349748d19a613a08586c5fdcd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 21:11:20 +0200 Subject: Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes. (bzr r11608.1.110) --- src/flood-context.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/flood-context.cpp') diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 824c6e329..09a1d5742 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -92,7 +92,6 @@ const std::string& SPFloodContext::getPrefsPath() { const std::string SPFloodContext::prefsPath = "/tools/paintbucket"; SPFloodContext::SPFloodContext() : SPEventContext() { - this->_message_context = 0; this->cursor_shape = cursor_paintbucket_xpm; this->hot_x = 11; this->hot_y = 30; @@ -115,10 +114,6 @@ SPFloodContext::~SPFloodContext() { if (this->item) { this->finishItem(); } - - if (this->_message_context) { - delete this->_message_context; - } } /** @@ -145,8 +140,6 @@ void SPFloodContext::setup() { sigc::mem_fun(this, &SPFloodContext::selection_changed) ); - this->_message_context = new Inkscape::MessageContext((this->desktop)->messageStack()); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/paintbucket/selcue")) { @@ -1231,7 +1224,7 @@ bool SPFloodContext::root_handler(GdkEvent* event) { } void SPFloodContext::finishItem() { - this->_message_context->clear(); + this->message_context->clear(); if (this->item != NULL) { this->item->updateRepr(); -- cgit v1.2.3