From 0953296ad36af782e4f0eadbea0e25d12ecaaf25 Mon Sep 17 00:00:00 2001 From: cilix42 Date: Mon, 18 Aug 2008 00:43:27 +0000 Subject: [PATCH] Switch back to all_inactive mode after applying a geometric LPE --- src/draw-context.cpp | 6 ++++++ src/lpe-tool-context.cpp | 25 ++++++++++++++++++++++++- src/lpe-tool-context.h | 3 ++- src/widgets/toolbox.cpp | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index c8ce44872..6e641196b 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -34,6 +34,7 @@ #include "macros.h" #include "message-stack.h" #include "pen-context.h" +#include "lpe-tool-context.h" #include "prefs-utils.h" #include "selection.h" #include "selection-chemistry.h" @@ -381,6 +382,11 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item) if (dc->waiting_LPE_type != INVALID_LPE) { Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); dc->waiting_LPE_type = INVALID_LPE; + + if (SP_IS_LPETOOL_CONTEXT(dc)) { + // since a geometric LPE was applied, we switch back to "inactive" mode + lpetool_context_switch_mode(SP_LPETOOL_CONTEXT(dc), Inkscape::LivePathEffect::INVALID_LPE); + } } if (SP_IS_PEN_CONTEXT(dc)) { sp_pen_context_set_polyline_mode(SP_PEN_CONTEXT(dc)); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 881aa47e9..6902d1bd3 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -137,9 +137,9 @@ sp_lpetool_context_setup(SPEventContext *ec) lc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_lpetool_context_selection_changed), (gpointer)lc)); - //lc->my_nc = new NodeContextCpp(lc->desktop, lc->prefs_repr, lc->key); lc->shape_editor = new ShapeEditor(ec->desktop); + lpetool_context_switch_mode(lc, Inkscape::LivePathEffect::INVALID_LPE); lpetool_context_reset_limiting_bbox(lc); // TODO temp force: @@ -299,6 +299,29 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) return ret; } +static int +lpetool_mode_to_index(Inkscape::LivePathEffect::EffectType const type) { + for (int i = 0; i < num_subtools; ++i) { + if (lpesubtools[i] == type) { + return i; + } + } + return -1; +} + +void +lpetool_context_switch_mode(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectType const type) +{ + int index = lpetool_mode_to_index(type); + if (index != -1) { + lc->mode = type; + lc->desktop->setToolboxSelectOneValue ("lpetool_mode_action", index); + } else { + g_warning ("Invalid mode selected: %d", type); + return; + } +} + /* * Reads the limiting bounding box from preferences and draws it on the screen */ diff --git a/src/lpe-tool-context.h b/src/lpe-tool-context.h index 86976442f..54716cddf 100644 --- a/src/lpe-tool-context.h +++ b/src/lpe-tool-context.h @@ -40,14 +40,15 @@ class ShapeEditor; struct SPLPEToolContext : public SPPenContext { ShapeEditor* shape_editor; - SPCanvasItem *canvas_bbox; + Inkscape::LivePathEffect::EffectType mode; sigc::connection sel_changed_connection; }; struct SPLPEToolContextClass : public SPEventContextClass{}; +void lpetool_context_switch_mode(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectType const type); void lpetool_context_reset_limiting_bbox(SPLPEToolContext *lc); GType sp_lpetool_context_get_type(void); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 71c797bff..5ed6feb2e 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -4788,6 +4788,7 @@ static void sp_dropper_toolbox_prep(SPDesktop */*desktop*/, GtkActionGroup* main // the subtools from which the toolbar is built automatically are listed in lpe-tool-context.h +// this is called when the mode is changed via the toolbar (i.e., one of the subtool buttons is pressed) static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl) { using namespace Inkscape::LivePathEffect; -- 2.30.2