From ff2c8039c77b58341e28cf90953cdd1f0fe68a16 Mon Sep 17 00:00:00 2001 From: cilix42 Date: Thu, 14 Aug 2008 21:35:32 +0000 Subject: [PATCH] Removal of SP_ACTIVE_DESKTOP, next take --- src/eraser-context.cpp | 14 +++++++------- src/event-context.cpp | 10 +++++----- src/flood-context.cpp | 12 ++++++------ src/gradient-context.cpp | 10 +++++----- src/node-context.cpp | 16 ++++++++-------- src/rubberband.cpp | 9 ++++----- src/rubberband.h | 4 ++-- src/select-context.cpp | 28 ++++++++++++++-------------- src/text-context.cpp | 12 ++++++------ src/zoom-context.cpp | 10 +++++----- 10 files changed, 62 insertions(+), 63 deletions(-) diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 9a8e07e66..bec3326d6 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -492,8 +492,8 @@ sp_eraser_context_root_handler(SPEventContext *event_context, dc->repr = NULL; } - Inkscape::Rubberband::get()->start(desktop, button_dt); - Inkscape::Rubberband::get()->setMode(RUBBERBAND_MODE_TOUCHPATH); + Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); + Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); /* initialize first point */ dc->npoints = 0; @@ -538,7 +538,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context, } ret = TRUE; } - Inkscape::Rubberband::get()->move(motion_dt); + Inkscape::Rubberband::get(desktop)->move(motion_dt); } break; @@ -555,7 +555,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context, if (dc->dragging && event->button.button == 1 && !event_context->space_panning) { dc->dragging = FALSE; - boost::optional const b = Inkscape::Rubberband::get()->getRectangle(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); sp_eraser_apply(dc, motion_dt); @@ -578,7 +578,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context, dc->repr = NULL; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); dc->_message_context->clear(); ret = TRUE; } @@ -647,7 +647,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context, } break; case GDK_Escape: - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); if (dc->is_drawing) { // if drawing, cancel, otherwise pass it up for deselecting eraser_cancel (dc); @@ -749,7 +749,7 @@ set_to_accumulated(SPEraserContext *dc) if ( eraserMode ) { toWorkOn = sp_document_partial_items_in_box(sp_desktop_document(desktop), desktop->dkey, bounds); } else { - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(); + Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); } toWorkOn = g_slist_remove( toWorkOn, acid ); diff --git a/src/event-context.cpp b/src/event-context.cpp index 22c91e450..450d1994d 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -457,10 +457,10 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context, // motion notify coordinates as given (no snapping back to origin) within_tolerance = false; - if (Inkscape::Rubberband::get()->is_started()) { - Inkscape::Rubberband::get()->move(motion_dt); + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->move(motion_dt); } else { - Inkscape::Rubberband::get()->start(desktop, motion_dt); + Inkscape::Rubberband::get(desktop)->start(desktop, motion_dt); } if (zoom_rb == 2) gobble_motion_events(GDK_BUTTON2_MASK); @@ -497,8 +497,8 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context, ret = TRUE; } else if (zoom_rb == event->button.button) { zoom_rb = 0; - boost::optional const b = Inkscape::Rubberband::get()->getRectangle(); - Inkscape::Rubberband::get()->stop(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); + Inkscape::Rubberband::get(desktop)->stop(); if (b && !within_tolerance) { desktop->set_display_area(*b, 10); } diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 634ee4732..a9ca7073f 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -922,7 +922,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even if (is_point_fill) { fill_points.push_back(NR::Point(event->button.x, event->button.y)); } else { - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(); + Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); fill_points = r->getPoints(); } @@ -1199,8 +1199,8 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven dragging = true; NR::Point const p(desktop->w2d(button_w)); - Inkscape::Rubberband::get()->setMode(RUBBERBAND_MODE_TOUCHPATH); - Inkscape::Rubberband::get()->start(desktop, p); + Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); + Inkscape::Rubberband::get(desktop)->start(desktop, p); } } } @@ -1218,8 +1218,8 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven NR::Point const motion_pt(event->motion.x, event->motion.y); NR::Point const p(desktop->w2d(motion_pt)); - if (Inkscape::Rubberband::get()->is_started()) { - Inkscape::Rubberband::get()->move(p); + 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")); gobble_motion_events(GDK_BUTTON1_MASK); } @@ -1228,7 +1228,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(); + Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); if (r->is_started()) { // set "busy" cursor desktop->setWaitingCursor(); diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index f2cd9e03a..e6932c710 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -544,7 +544,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) Geom::Point button_dt = to_2geom(desktop->w2d(button_w)); if (event->button.state & GDK_SHIFT_MASK) { - Inkscape::Rubberband::get()->start(desktop, from_2geom(button_dt)); + Inkscape::Rubberband::get(desktop)->start(desktop, from_2geom(button_dt)); } else { // remember clicked item, disregarding groups, honoring Alt; do nothing with Crtl to // enable Ctrl+doubleclick of exactly the selected item(s) @@ -579,8 +579,8 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) event->motion.y); NR::Point const motion_dt = event_context->desktop->w2d(motion_w); - if (Inkscape::Rubberband::get()->is_started()) { - Inkscape::Rubberband::get()->move(motion_dt); + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->move(motion_dt); event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Draw around handles to select them")); } else { sp_gradient_drag(*rc, motion_dt, event->motion.state, event->motion.time); @@ -637,7 +637,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (!event_context->within_tolerance) { // we've been dragging, either do nothing (grdrag handles that), // or rubberband-select if we have rubberband - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(); + Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); if (r->is_started() && !event_context->within_tolerance) { // this was a rubberband drag if (r->getMode() == RUBBERBAND_MODE_RECT) { @@ -665,7 +665,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) event_context->item_to_select = NULL; ret = TRUE; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); } break; case GDK_KEY_PRESS: diff --git a/src/node-context.cpp b/src/node-context.cpp index b205b86d5..9f026c3f2 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -296,7 +296,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) NR::Point const button_w(event->button.x, event->button.y); NR::Point const button_dt(desktop->w2d(button_w)); - Inkscape::Rubberband::get()->start(desktop, button_dt); + Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); nc->current_state = SP_NODE_CONTEXT_INACTIVE; desktop->updateNow(); ret = TRUE; @@ -343,11 +343,11 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; } case SP_NODE_CONTEXT_RUBBERBAND_DRAGGING: - if (Inkscape::Rubberband::get()->is_started()) { + if (Inkscape::Rubberband::get(desktop)->is_started()) { NR::Point const motion_w(event->motion.x, event->motion.y); NR::Point const motion_dt(desktop->w2d(motion_w)); - Inkscape::Rubberband::get()->move(motion_dt); + Inkscape::Rubberband::get(desktop)->move(motion_dt); } break; } @@ -429,7 +429,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) selection->set(item_clicked); desktop->updateNow(); } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); ret = TRUE; break; } @@ -437,7 +437,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (event->type == GDK_BUTTON_RELEASE) { event_context->xp = event_context->yp = 0; if (event->button.button == 1) { - boost::optional b = Inkscape::Rubberband::get()->getRectangle(); + boost::optional b = Inkscape::Rubberband::get(desktop)->getRectangle(); if (nc->shape_editor->hits_curve() && !event_context->within_tolerance) { //drag curve nc->shape_editor->finish_drag(); @@ -452,7 +452,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) } } ret = TRUE; - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); desktop->updateNow(); nc->rb_escaped = false; nc->drag = FALSE; @@ -620,9 +620,9 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_Escape: { - boost::optional const b = Inkscape::Rubberband::get()->getRectangle(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); if (b) { - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); nc->current_state = SP_NODE_CONTEXT_INACTIVE; nc->rb_escaped = true; } else { diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 73333a555..bfe73a43d 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -14,7 +14,6 @@ #include "display/sodipodi-ctrlrect.h" #include "desktop.h" -#include "inkscape.h" #include "desktop-handles.h" #include "rubberband.h" #include "display/canvas-bpath.h" @@ -23,8 +22,8 @@ Inkscape::Rubberband *Inkscape::Rubberband::_instance = NULL; -Inkscape::Rubberband::Rubberband() - : _desktop(SP_ACTIVE_DESKTOP), _rect(NULL), _touchpath(NULL), _started(false) +Inkscape::Rubberband::Rubberband(SPDesktop *dt) + : _desktop(dt), _rect(NULL), _touchpath(NULL), _started(false) { _points.clear(); _mode = RUBBERBAND_MODE_RECT; @@ -135,10 +134,10 @@ boost::optional Inkscape::Rubberband::getRectangle() const return NR::Rect(_start, _end); } -Inkscape::Rubberband *Inkscape::Rubberband::get() +Inkscape::Rubberband *Inkscape::Rubberband::get(SPDesktop *desktop) { if (_instance == NULL) { - _instance = new Inkscape::Rubberband; + _instance = new Inkscape::Rubberband(desktop); } return _instance; diff --git a/src/rubberband.h b/src/rubberband.h index 7734a65fa..f9adc7b3b 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -49,11 +49,11 @@ public: void setMode(int mode); - static Rubberband* get(); + static Rubberband* get(SPDesktop *desktop); private: - Rubberband(); + Rubberband(SPDesktop *desktop); static Rubberband* _instance; SPDesktop *_desktop; diff --git a/src/select-context.cpp b/src/select-context.cpp index 22b358dc7..7c966c9b9 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -231,8 +231,8 @@ sp_select_context_abort(SPEventContext *event_context) return true; } } else { - if (Inkscape::Rubberband::get()->is_started()) { - Inkscape::Rubberband::get()->stop(); + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->stop(); rb_escaped = 1; SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear(); SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selection canceled.")); @@ -441,8 +441,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) NR::Point const button_pt(event->button.x, event->button.y); NR::Point const p(desktop->w2d(button_pt)); if (event->button.state & GDK_MOD1_MASK) - Inkscape::Rubberband::get()->setMode(RUBBERBAND_MODE_TOUCHPATH); - Inkscape::Rubberband::get()->start(desktop, p); + Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); + Inkscape::Rubberband::get(desktop)->start(desktop, p); if (sc->grabbed) { sp_canvas_item_ungrab(sc->grabbed, event->button.time); sc->grabbed = NULL; @@ -495,7 +495,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) /* User has dragged fast, so we get events on root (lauris)*/ // not only that; we will end up here when ctrl-dragging as well // and also when we started within tolerance, but trespassed tolerance outside of item - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear(); item_at_point = desktop->item_at_point(NR::Point(event->button.x, event->button.y), FALSE); if (!item_at_point) // if no item at this point, try at the click point (bug 1012200) @@ -539,9 +539,9 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) sp_canvas_end_forced_full_redraws(desktop->canvas); } } else { - if (Inkscape::Rubberband::get()->is_started()) { - Inkscape::Rubberband::get()->move(p); - if (Inkscape::Rubberband::get()->getMode() == RUBBERBAND_MODE_TOUCHPATH) { + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->move(p); + if (Inkscape::Rubberband::get(desktop)->getMode() == RUBBERBAND_MODE_TOUCHPATH) { event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Draw over objects to select them; release Alt to switch to rubberband selection")); } else { event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag around objects to select them; press Alt to switch to touch selection")); @@ -589,7 +589,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } sc->item = NULL; } else { - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(); + Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); if (r->is_started() && !within_tolerance) { // this was a rubberband drag GSList *items = NULL; @@ -672,7 +672,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) desktop->updateNow(); } if (event->button.button == 1) { - Inkscape::Rubberband::get()->stop(); // might have been started in another tool! + Inkscape::Rubberband::get(desktop)->stop(); // might have been started in another tool! } sc->button_press_shift = false; sc->button_press_ctrl = false; @@ -692,10 +692,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (!key_is_a_modifier (keyval)) { event_context->defaultMessageContext()->clear(); } else if (sc->grabbed || seltrans->isGrabbed()) { - if (Inkscape::Rubberband::get()->is_started()) { + if (Inkscape::Rubberband::get(desktop)->is_started()) { // if Alt then change cursor to moving cursor: if (alt) { - Inkscape::Rubberband::get()->setMode(RUBBERBAND_MODE_TOUCHPATH); + Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); } } else { // do not change the statusbar text when mousekey is down to move or transform the object, @@ -922,10 +922,10 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) || (keyval == GDK_Meta_L) || (keyval == GDK_Meta_R)); - if (Inkscape::Rubberband::get()->is_started()) { + if (Inkscape::Rubberband::get(desktop)->is_started()) { // if Alt then change cursor to moving cursor: if (alt) { - Inkscape::Rubberband::get()->setMode(RUBBERBAND_MODE_RECT); + Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_RECT); } } } diff --git a/src/text-context.cpp b/src/text-context.cpp index 6d26bee2b..4c3329fb7 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -182,7 +182,7 @@ sp_text_context_dispose(GObject *obj) tc->grabbed = NULL; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(ec->desktop)->stop(); if (ec->shape_knot_holder) { delete ec->shape_knot_holder; @@ -613,7 +613,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons NR::Point const button_pt(event->button.x, event->button.y); tc->p0 = desktop->w2d(button_pt); - Inkscape::Rubberband::get()->start(desktop, tc->p0); + Inkscape::Rubberband::get(desktop)->start(desktop, tc->p0); sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK, NULL, event->button.time); @@ -649,7 +649,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons NR::Point const motion_pt(event->motion.x, event->motion.y); NR::Point const p = desktop->w2d(motion_pt); - Inkscape::Rubberband::get()->move(p); + Inkscape::Rubberband::get(desktop)->move(p); gobble_motion_events(GDK_BUTTON1_MASK); // status text @@ -669,7 +669,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons tc->grabbed = NULL; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); if (tc->creating && event_context->within_tolerance) { /* Button 1, set X & Y & new item */ @@ -1151,7 +1151,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons sp_canvas_item_ungrab(tc->grabbed, GDK_CURRENT_TIME); tc->grabbed = NULL; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); } else { sp_desktop_selection(desktop)->clear(); } @@ -1283,7 +1283,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons sp_canvas_item_ungrab(tc->grabbed, GDK_CURRENT_TIME); tc->grabbed = NULL; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); } } } diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 56eeb69cb..8c6400189 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -133,7 +133,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent yp = (gint) event->button.y; within_tolerance = true; - Inkscape::Rubberband::get()->start(desktop, button_dt); + Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); escaped = false; @@ -164,7 +164,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent NR::Point const motion_w(event->motion.x, event->motion.y); NR::Point const motion_dt(desktop->w2d(motion_w)); - Inkscape::Rubberband::get()->move(motion_dt); + Inkscape::Rubberband::get(desktop)->move(motion_dt); gobble_motion_events(GDK_BUTTON1_MASK); } break; @@ -174,7 +174,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent NR::Point const button_w(event->button.x, event->button.y); NR::Point const button_dt(desktop->w2d(button_w)); if ( event->button.button == 1 && !event_context->space_panning) { - boost::optional const b = Inkscape::Rubberband::get()->getRectangle(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); if (b && !within_tolerance) { desktop->set_display_area(*b, 10); } else if (!escaped) { @@ -185,7 +185,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent } ret = TRUE; } - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); xp = yp = 0; escaped = false; break; @@ -193,7 +193,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { case GDK_Escape: - Inkscape::Rubberband::get()->stop(); + Inkscape::Rubberband::get(desktop)->stop(); xp = yp = 0; escaped = true; ret = TRUE; -- 2.30.2