summaryrefslogtreecommitdiffstats
path: root/src/draw-context.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-07-03 09:40:20 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-07-03 09:40:20 +0000
commitea7e97bada72126b47c60cd846c168f111bae4a7 (patch)
tree0c56c305b1fed699334464efb21c0630c1e8c7c8 /src/draw-context.cpp
parentNew LPE: Offset (diff)
downloadinkscape-ea7e97bada72126b47c60cd846c168f111bae4a7.tar.gz
inkscape-ea7e97bada72126b47c60cd846c168f111bae4a7.zip
First shot at a dropdown selector for various shapes in pen/pencil tool, along the lines of Valerie's blueprint.
TODO: more paths for the dropdown, read them from a separate file; show images for the choices, not text (bzr r6127)
Diffstat (limited to 'src/draw-context.cpp')
-rw-r--r--src/draw-context.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index ce6ccc0e4..d54ccc778 100644
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -41,6 +41,7 @@
#include "snap.h"
#include "sp-path.h"
#include "sp-namedview.h"
+#include "live_effects/lpe-patternalongpath.h"
static void sp_draw_context_class_init(SPDrawContextClass *klass);
static void sp_draw_context_init(SPDrawContext *dc);
@@ -245,6 +246,19 @@ sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event)
return ret;
}
+static void
+spdc_paste_curve_as_param_path(const SPCurve *c, SPDrawContext *dc, SPItem *item)
+{
+ using namespace Inkscape::LivePathEffect;
+
+ // TODO: Don't paste path if nothing is on the clipboard
+
+ Effect::createAndApply(Inkscape::LivePathEffect::PATTERN_ALONG_PATH, dc->desktop->doc(), item);
+ Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
+ gchar *svgd = sp_svg_write_path(c->get_pathvector());
+ static_cast<LPEPatternAlongPath*>(lpe)->pattern.paste_param_path(svgd);
+}
+
/*
* If we have an item and a waiting LPE, apply the effect to the item
* (spiro spline mode is treated separately)
@@ -255,6 +269,35 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
using namespace Inkscape::LivePathEffect;
if (item) {
+ int shape = prefs_get_int_attribute("tools.freehand", "shape", 0);
+
+ switch (shape) {
+ case 0:
+ break;
+ case 1:
+ {
+ Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
+ Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
+ static_cast<LPEPatternAlongPath*>(lpe)->pattern.on_paste_button_click();
+ return;
+ }
+ case 2:
+ {
+ // TODO: this is only for illustration (we create a "decrescendo"-shaped path
+ // manually; eventually we should read the path from a separate file)
+ SPCurve *c = new SPCurve();
+ c->moveto(0,0);
+ c->lineto(0,10);
+ c->lineto(200,5);
+ c->closepath();
+ spdc_paste_curve_as_param_path(c, dc, item);
+ c->unref();
+ return;
+ }
+ default:
+ break;
+ }
+
if (prefs_get_int_attribute("tools.freehand", "spiro-spline-mode", 0)) {
Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
return;
@@ -276,8 +319,8 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
static void
spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc)
{
- // note: in draw context, selection_changed() is only called when a new item was created;
- // otherwise the following function call would yield wrong results
+ // note: in draw context, selection_changed() is only called with a valid item as argument when
+ // a new item was created; otherwise the following function call would yield wrong results
spdc_check_for_and_apply_waiting_LPE(dc, sel->singleItem());
if (dc->attach) {