From c27006137a3ad49e074b97b3297db753e1ac8eef Mon Sep 17 00:00:00 2001 From: cilix42 Date: Mon, 18 Aug 2008 00:33:13 +0000 Subject: [PATCH] Remove done_pathparam_set and friends because it currently isn't used any more anyway; reimplement its intended functionality by using isReady() --- src/draw-context.cpp | 2 -- src/live_effects/effect.cpp | 8 ++++---- src/live_effects/effect.h | 11 +++++++++-- src/pen-context.cpp | 7 +++++-- src/sp-lpe-item.cpp | 9 +++------ 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index fd854caec..9717c0aa1 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -157,8 +157,6 @@ sp_draw_context_dispose(GObject *object) dc->selection = NULL; } - dc->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE; - spdc_free_colors(dc); G_OBJECT_CLASS(draw_parent_class)->dispose(object); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 1308a1860..7d01f63dd 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -251,11 +251,11 @@ Effect::createAndApply(EffectType type, SPDocument *doc, SPItem *item) Effect::Effect(LivePathEffectObject *lpeobject) : oncanvasedit_it(0), is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true), - done_pathparam_set(false), show_orig_path(false), lpeobj(lpeobject), concatenate_before_pwd2(false), - provides_own_flash_paths(true) // is automatically set to false if providesOwnFlashPaths() is not overridden + provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden + is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden { registerParameter( dynamic_cast(&is_visible) ); } @@ -332,11 +332,11 @@ Effect::writeParamsToSVG() { /** * If the effect expects a path parameter (specified by a number of mouse clicks) before it is * applied, this is the method that processes the resulting path. Override it to customize it for - * your LPE. But don't forget to call the parent method so that done_pathparam_set is set to true! + * your LPE. But don't forget to call the parent method so that is_ready is set to true! */ void Effect::acceptParamPath (SPPath */*param_path*/) { - done_pathparam_set = true; + setReady(); } /* diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 1bc3988ab..e703c888b 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -113,7 +113,13 @@ public: int acceptsNumParams() { return acceptsNumParams(effectType()); } void doAcceptPathPreparations(SPLPEItem *lpeitem); - inline bool pathParamAccepted() { return done_pathparam_set; } + /* + * isReady() indicates whether all preparations which are necessary to apply the LPE are done, + * e.g., waiting for a parameter path either before the effect is created or when it needs a + * path as argument. This is set in sp_lpe_item_add_path_effect(). + */ + inline bool isReady() { return is_ready; } + inline void setReady(bool ready = true) { is_ready = ready; } virtual void doEffect (SPCurve * curve); @@ -179,7 +185,6 @@ protected: std::vector > kh_entity_vector; int oncanvasedit_it; BoolParam is_visible; - bool done_pathparam_set; bool show_orig_path; // set this to true in derived effects to automatically have the original // path displayed as helperpath @@ -195,6 +200,8 @@ protected: private: bool provides_own_flash_paths; // if true, the standard flash path is suppressed + bool is_ready; + Effect(const Effect&); Effect& operator=(const Effect&); }; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 3cc7cc0d6..8e1f6947b 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -152,6 +152,7 @@ sp_pen_context_init(SPPenContext *pc) pc->num_clicks = 0; pc->waiting_LPE = NULL; + pc->waiting_item = NULL; } /** @@ -564,7 +565,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const } } - if (pc->expecting_clicks_for_LPE) { + if (pc->expecting_clicks_for_LPE > 0) { --pc->expecting_clicks_for_LPE; } @@ -1383,10 +1384,12 @@ sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEff { g_print ("Now waiting for %s to be applied\n", Inkscape::LivePathEffect::LPETypeConverter.get_label(effect_type).c_str()); + g_return_if_fail(effect_type != Inkscape::LivePathEffect::INVALID_LPE); + + pc->waiting_LPE_type = effect_type; pc->expecting_clicks_for_LPE = num_clicks; pc->polylines_only = use_polylines; pc->polylines_paraxial = false; // TODO: think if this is correct for all cases - pc->waiting_LPE_type = effect_type; } static int pen_next_paraxial_direction(const SPPenContext *const pc, diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index f3620ab2f..7ff5a7f4b 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -314,7 +314,7 @@ void sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) { Inkscape::LivePathEffect::Effect *lpe = lpeobj->lpe; if (lpe->isVisible()) { - if (lpe->acceptsNumParams() > 0 && !lpe->pathParamAccepted()) { + if (lpe->acceptsNumParams() > 0 && !lpe->isReady()) { // if the effect expects mouse input before being applied and the input is not finished // yet, we don't alter the path return; @@ -480,11 +480,8 @@ void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, gchar *value, bool reset) // perform this once when the effect is applied lpe->doOnApply(SP_LPE_ITEM(lpeitem)); - // if the effect expects a number of mouse clicks to set a parameter path, perform the - // necessary preparations - if (lpe->acceptsNumParams() > 0) { - lpe->doAcceptPathPreparations(lpeitem); - } + // indicate that all necessary preparations are done and the effect can be performed + lpe->setReady(); } //Enable the path effects now that everything is ready to apply the new path effect -- 2.30.2