summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-04 16:19:41 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-04 16:19:41 +0000
commit63b2f0cd146c1abbb9c93977273f2b3cf457d8a4 (patch)
tree4b623f8e0bd6dd0f76ee0750eed42990cc362112 /src
parentFixed some redraw problems moving nodes in bspline mode (diff)
parentAllow editing of fill and stroke patterns simultaneously. Fixes #601336, #604... (diff)
downloadinkscape-63b2f0cd146c1abbb9c93977273f2b3cf457d8a4.tar.gz
inkscape-63b2f0cd146c1abbb9c93977273f2b3cf457d8a4.zip
Update to trunk r13489
(bzr r13341.1.116)
Diffstat (limited to 'src')
-rw-r--r--src/knot-holder-entity.cpp18
-rw-r--r--src/knot-holder-entity.h10
-rw-r--r--src/knotholder.cpp32
-rw-r--r--src/object-edit.cpp4
-rw-r--r--src/object-snapper.cpp4
-rw-r--r--src/seltrans.cpp1
-rw-r--r--src/sp-item.cpp8
-rw-r--r--src/sp-item.h9
-rw-r--r--src/style-internal.cpp3
-rw-r--r--src/ui/tools/node-tool.cpp13
-rw-r--r--src/ui/tools/node-tool.h2
11 files changed, 79 insertions, 25 deletions
diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp
index 6af5c6a56..b66156b09 100644
--- a/src/knot-holder-entity.cpp
+++ b/src/knot-holder-entity.cpp
@@ -158,7 +158,7 @@ static Geom::Point sp_pattern_extract_trans(SPPattern const *pat)
void
PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state)
{
- SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer());
// FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used.
Geom::Point p_snapped = snap_knot_position(p, state);
@@ -173,7 +173,7 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
if (state) {
Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat);
- item->adjust_pattern(Geom::Affine(Geom::Translate(q)));
+ item->adjust_pattern(Geom::Translate(q), false, _fill ? TRANSFORM_FILL : TRANSFORM_STROKE);
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -182,14 +182,14 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
Geom::Point
PatternKnotHolderEntityXY::knot_get() const
{
- SPPattern const *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer());
return sp_pattern_extract_trans(pat);
}
Geom::Point
PatternKnotHolderEntityAngle::knot_get() const
{
- SPPattern const *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer());
gdouble x = pattern_width(pat);
gdouble y = 0;
@@ -207,7 +207,7 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
- SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer());
// get the angle from pattern 0,0 to the cursor pos
Geom::Point delta = p - sp_pattern_extract_trans(pat);
@@ -223,14 +223,14 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &
Geom::Point const t = sp_pattern_extract_trans(pat);
rot[4] = t[Geom::X];
rot[5] = t[Geom::Y];
- item->adjust_pattern(rot, true);
+ item->adjust_pattern(rot, true, _fill ? TRANSFORM_FILL : TRANSFORM_STROKE);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
void
PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
{
- SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer());
// FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used.
Geom::Point p_snapped = snap_knot_position(p, state);
@@ -257,7 +257,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
Geom::Point const t = sp_pattern_extract_trans(pat);
rot[4] = t[Geom::X];
rot[5] = t[Geom::Y];
- item->adjust_pattern(rot, true);
+ item->adjust_pattern(rot, true, _fill ? TRANSFORM_FILL : TRANSFORM_STROKE);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
@@ -265,7 +265,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
Geom::Point
PatternKnotHolderEntityScale::knot_get() const
{
- SPPattern const *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style));
+ SPPattern *pat = _fill ? SP_PATTERN(item->style->getFillPaintServer()) : SP_PATTERN(item->style->getStrokePaintServer());
gdouble x = pattern_width(pat);
gdouble y = pattern_height(pat);
diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h
index a9268d396..dde60f515 100644
--- a/src/knot-holder-entity.h
+++ b/src/knot-holder-entity.h
@@ -101,20 +101,30 @@ protected:
class PatternKnotHolderEntityXY : public KnotHolderEntity {
public:
+ PatternKnotHolderEntityXY(bool fill) : KnotHolderEntity(), _fill(fill) {}
virtual Geom::Point knot_get() const;
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+private:
+ // true if the entity tracks fill, false for stroke
+ bool _fill;
};
class PatternKnotHolderEntityAngle : public KnotHolderEntity {
public:
+ PatternKnotHolderEntityAngle(bool fill) : KnotHolderEntity(), _fill(fill) {}
virtual Geom::Point knot_get() const;
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+private:
+ bool _fill;
};
class PatternKnotHolderEntityScale : public KnotHolderEntity {
public:
+ PatternKnotHolderEntityScale(bool fill) : KnotHolderEntity(), _fill(fill) {}
virtual Geom::Point knot_get() const;
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
+private:
+ bool _fill;
};
#endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index cf87423d4..f0e69716b 100644
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
@@ -247,12 +247,32 @@ void KnotHolder::add(KnotHolderEntity *e)
void KnotHolder::add_pattern_knotholder()
{
- if ((item->style->fill.isPaintserver())
- && SP_IS_PATTERN(item->style->getFillPaintServer()))
- {
- PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY();
- PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle();
- PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale();
+ if ((item->style->fill.isPaintserver()) && SP_IS_PATTERN(item->style->getFillPaintServer())) {
+ PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(true);
+ PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(true);
+ PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(true);
+ entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT,
+ // TRANSLATORS: This refers to the pattern that's inside the object
+ _("<b>Move</b> the pattern fill inside the object"),
+ SP_KNOT_SHAPE_CROSS);
+
+ entity_scale->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER,
+ _("<b>Scale</b> the pattern fill; uniformly if with <b>Ctrl</b>"),
+ SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR);
+
+ entity_angle->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE,
+ _("<b>Rotate</b> the pattern fill; with <b>Ctrl</b> to snap angle"),
+ SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR);
+
+ entity.push_back(entity_xy);
+ entity.push_back(entity_angle);
+ entity.push_back(entity_scale);
+ }
+
+ if ((item->style->stroke.isPaintserver()) && SP_IS_PATTERN(item->style->getStrokePaintServer())) {
+ PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(false);
+ PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(false);
+ PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(false);
entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT,
// TRANSLATORS: This refers to the pattern that's inside the object
_("<b>Move</b> the pattern fill inside the object"),
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index e9b183eca..fe22f6c1c 100644
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -79,8 +79,8 @@ KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop)
knotholder = new OffsetKnotHolder(desktop, item, NULL);
} else if (SP_IS_FLOWTEXT(item) && SP_FLOWTEXT(item)->has_internal_frame()) {
knotholder = new FlowtextKnotHolder(desktop, SP_FLOWTEXT(item)->get_frame(NULL), NULL);
- } else if ((item->style->fill.isPaintserver())
- && SP_IS_PATTERN(item->style->getFillPaintServer())) {
+ } else if ((item->style->fill.isPaintserver() && SP_IS_PATTERN(item->style->getFillPaintServer())) ||
+ (item->style->stroke.isPaintserver() && SP_IS_PATTERN(item->style->getStrokePaintServer()))) {
knotholder = new KnotHolder(desktop, item, NULL);
knotholder->add_pattern_knotholder();
}
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 3b8956bc8..0f7aa6368 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -147,6 +147,10 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
// For debugging: print the id of the candidate to the console
// SPObject *obj = (SPObject*)item;
// std::cout << "Snap candidate added: " << obj->getId() << std::endl;
+ if (_candidates->size() > 200) { // This makes Inkscape crawl already
+ std::cout << "Warning: limit of 200 snap target paths reached, some will be ignored" << std::endl;
+ break;
+ }
}
}
}
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 4b1a3a5fa..6b8cd19bb 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -304,6 +304,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
/* Snapping a huge number of nodes will take way too long, so limit the number of snappable nodes
A typical user would rarely ever try to snap such a large number of nodes anyway, because
(s)he would hardly be able to discern which node would be snapping */
+ std::cout << "Warning: limit of 200 snap sources reached, some will be ignored" << std::endl;
_snap_points.resize(200);
// Unfortunately, by now we will have lost the font-baseline snappoints :-(
}
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 6c2ada9d7..780845deb 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -1109,9 +1109,10 @@ void SPItem::invoke_hide(unsigned key)
// Adjusters
-void SPItem::adjust_pattern (Geom::Affine const &postmul, bool set)
+void SPItem::adjust_pattern(Geom::Affine const &postmul, bool set, PatternTransform pt)
{
- if (style && (style->fill.isPaintserver())) {
+ bool fill = (pt == TRANSFORM_FILL || pt == TRANSFORM_BOTH);
+ if (fill && style && (style->fill.isPaintserver())) {
SPObject *server = style->getFillPaintServer();
if ( SP_IS_PATTERN(server) ) {
SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "fill");
@@ -1119,7 +1120,8 @@ void SPItem::adjust_pattern (Geom::Affine const &postmul, bool set)
}
}
- if (style && (style->stroke.isPaintserver())) {
+ bool stroke = (pt == TRANSFORM_STROKE || pt == TRANSFORM_BOTH);
+ if (stroke && style && (style->stroke.isPaintserver())) {
SPObject *server = style->getStrokePaintServer();
if ( SP_IS_PATTERN(server) ) {
SPPattern *pattern = sp_pattern_clone_if_necessary(this, SP_PATTERN(server), "stroke");
diff --git a/src/sp-item.h b/src/sp-item.h
index ce93b1d40..2880f4a8e 100644
--- a/src/sp-item.h
+++ b/src/sp-item.h
@@ -51,6 +51,13 @@ enum {
SP_EVENT_MOUSEOUT
};
+// TODO fix this
+enum PatternTransform {
+ TRANSFORM_BOTH,
+ TRANSFORM_FILL,
+ TRANSFORM_STROKE
+};
+
/**
* Event structure.
*
@@ -199,7 +206,7 @@ public:
Inkscape::DrawingItem *invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
void invoke_hide(unsigned int key);
void getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs=0) const;
- void adjust_pattern(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false);
+ void adjust_pattern(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false, PatternTransform = TRANSFORM_BOTH);
void adjust_gradient(/* Geom::Affine const &premul, */ Geom::Affine const &postmul, bool set = false);
void adjust_stroke(gdouble ex);
void adjust_stroke_width_recursive(gdouble ex);
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index ae70fc10d..2212f8fff 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -1395,7 +1395,8 @@ const Glib::ustring SPIFilter::write( guint const flags, SPIBase const *const /*
// TODO: fix base
//SPILength const *const my_base = dynamic_cast<const SPILength*>(base);
if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
- ((flags & SP_STYLE_FLAG_IFSET) && this->set))
+ ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
+ ((flags & SP_STYLE_FLAG_IFDIFF) && this->set))
{
if (this->inherit) {
return (name + ":inherit;");
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 36f33e478..d2584ee74 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -19,6 +19,7 @@
#include "display/curve.h"
#include "display/sp-canvas.h"
#include "document.h"
+#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "message-context.h"
#include "selection.h"
@@ -168,6 +169,9 @@ NodeTool::~NodeTool() {
if (this->flash_tempitem) {
this->desktop->remove_temporary_canvasitem(this->flash_tempitem);
}
+ if (this->helperpath_tmpitem) {
+ this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem);
+ }
if (this->helperpath_tmpitem) {
this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem);
@@ -252,6 +256,7 @@ void NodeTool::setup() {
)))
);
+ this->helperpath_tmpitem = NULL;
this->cursor_drag = false;
this->show_transform_handles = true;
this->single_node_transform_handles = false;
@@ -288,12 +293,15 @@ void NodeTool::setup() {
this->update_helperpath();
}
-void NodeTool::update_helperpath(){
+// show helper paths of the applied LPE, if any
+void NodeTool::update_helperpath () {
Inkscape::Selection *selection = sp_desktop_selection (this->desktop);
+
if (this->helperpath_tmpitem) {
this->desktop->remove_temporary_canvasitem(this->helperpath_tmpitem);
this->helperpath_tmpitem = NULL;
}
+
if (SP_IS_LPE_ITEM(selection->singleItem())) {
Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE();
if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) {
@@ -310,7 +318,7 @@ void NodeTool::update_helperpath(){
c->transform(selection->singleItem()->i2dt_affine());
SPCanvasItem *helperpath = sp_canvas_bpath_new(sp_desktop_tempgroup(this->desktop), c);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath),
- 0x0000ff9A, 1.0,
+ 0x0000ff9A, 1.0,
SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath), 0, SP_WIND_RULE_NONZERO);
this->helperpath_tmpitem = this->desktop->add_temporary_canvasitem(helperpath,0);
@@ -474,6 +482,7 @@ bool NodeTool::root_handler(GdkEvent* event) {
switch (event->type)
{
case GDK_MOTION_NOTIFY: {
+ this->update_helperpath();
combine_motion_events(desktop->canvas, event->motion, 0);
this->update_helperpath();
SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button),
diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h
index 9f0c40aa8..ab72f3632 100644
--- a/src/ui/tools/node-tool.h
+++ b/src/ui/tools/node-tool.h
@@ -66,8 +66,8 @@ private:
sigc::connection _sizeUpdatedConn;
SPItem *flashed_item;
- Inkscape::Display::TemporaryItem *flash_tempitem;
Inkscape::Display::TemporaryItem *helperpath_tmpitem;
+ Inkscape::Display::TemporaryItem *flash_tempitem;
Inkscape::UI::Selector* _selector;
Inkscape::UI::PathSharedData* _path_data;
SPCanvasGroup *_transform_handle_group;