summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-06-16 15:45:16 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-06-16 15:45:16 +0000
commit2fe578b9f375c9d63576c59356f621a5a92e12a6 (patch)
tree13c1dfc60377a88df3cec3d492cca0e7a2591bab /src/live_effects
parentminor tweak for portability. linux compile was broken (diff)
downloadinkscape-2fe578b9f375c9d63576c59356f621a5a92e12a6.tar.gz
inkscape-2fe578b9f375c9d63576c59356f621a5a92e12a6.zip
First step towards making helper paths for LPE items work better
(bzr r5954)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp28
-rw-r--r--src/live_effects/effect.h13
-rw-r--r--src/live_effects/lpe-mirror_reflect.cpp2
-rw-r--r--src/live_effects/lpe-perp_bisector.cpp2
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp2
5 files changed, 45 insertions, 2 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 551b23a1d..0497d0e37 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -21,6 +21,9 @@
#include <glibmm/i18n.h>
#include "pen-context.h"
#include "tools-switch.h"
+#include "message-stack.h"
+#include "desktop.h"
+#include "nodepath.h"
#include "live_effects/lpeobject.h"
#include "live_effects/parameter/parameter.h"
@@ -55,8 +58,6 @@
#include "live_effects/lpe-mirror_reflect.h"
// end of includes
-#include "nodepath.h"
-
namespace Inkscape {
namespace LivePathEffect {
@@ -186,6 +187,8 @@ 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),
+ provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
+ show_orig_path(false),
lpeobj(lpeobject),
concatenate_before_pwd2(false)
{
@@ -400,6 +403,27 @@ Effect::addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem
}
}
+void
+Effect::addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop)
+{
+ g_return_if_fail(SP_IS_PATH(lpeitem));
+
+ if (show_orig_path) {
+ SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, SP_PATH(lpeitem));
+ // TODO: Make sure the tempitem doesn't get destroyed when the mouse leaves the item
+ Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0);
+ lpeitem->lpe_helperpaths.push_back(tmpitem);
+ }
+ addHelperPathsImpl(lpeitem, desktop);
+}
+
+void
+Effect::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop)
+{
+ // if this method is overloaded in derived classes, provides_own_flash_paths will be true
+ provides_own_flash_paths = false;
+}
+
/**
* This *creates* a new widget, management of deletion should be done by the caller
*/
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index f1241c54b..32917f8c8 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -27,6 +27,7 @@
struct SPDocument;
struct SPDesktop;
struct SPItem;
+class SPNodeContext;
class NArtBpath;
struct LivePathEffectObject;
@@ -119,6 +120,11 @@ public:
virtual LPEPathFlashType pathFlashType() { return DEFAULT; }
void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ void addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop);
+ inline bool providesOwnFlashPaths() {
+ return provides_own_flash_paths || show_orig_path;
+ }
+
Glib::ustring getName();
Inkscape::XML::Node * getRepr();
SPDocument * getSPDoc();
@@ -150,12 +156,17 @@ protected:
void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
Parameter * getNextOncanvasEditableParam();
+ virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
+
std::vector<Parameter *> param_vector;
std::vector<std::pair<KnotHolderEntity*, const char*> > 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
+
Inkscape::UI::Widget::Registry wr;
LivePathEffectObject *lpeobj;
@@ -165,6 +176,8 @@ protected:
bool concatenate_before_pwd2;
private:
+ bool provides_own_flash_paths; // if true, the standard flash path is suppressed
+
Effect(const Effect&);
Effect& operator=(const Effect&);
};
diff --git a/src/live_effects/lpe-mirror_reflect.cpp b/src/live_effects/lpe-mirror_reflect.cpp
index 093841c8d..6a149dfc5 100644
--- a/src/live_effects/lpe-mirror_reflect.cpp
+++ b/src/live_effects/lpe-mirror_reflect.cpp
@@ -29,6 +29,8 @@ LPEMirrorReflect::LPEMirrorReflect(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
reflection_line(_("Reflection line"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L100,100")
{
+ show_orig_path = true;
+
registerParameter( dynamic_cast<Parameter *>(&reflection_line) );
}
diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp
index 7c08bdb08..bcfe57614 100644
--- a/src/live_effects/lpe-perp_bisector.cpp
+++ b/src/live_effects/lpe-perp_bisector.cpp
@@ -157,6 +157,8 @@ LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200),
A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0)
{
+ show_orig_path = true;
+
// register all your parameters here, so Inkscape knows which parameters this effect has:
registerParameter( dynamic_cast<Parameter *>(&length_left) );
registerParameter( dynamic_cast<Parameter *>(&length_right) );
diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp
index 6ca785001..9e63ef4a4 100644
--- a/src/live_effects/lpe-tangent_to_curve.cpp
+++ b/src/live_effects/lpe-tangent_to_curve.cpp
@@ -65,6 +65,8 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150),
length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150)
{
+ show_orig_path = true;
+
registerParameter( dynamic_cast<Parameter *>(&angle) );
registerParameter( dynamic_cast<Parameter *>(&t_attach) );
registerParameter( dynamic_cast<Parameter *>(&length_left) );