summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Jeanmougin <marc.jeanmougin@telecom-paristech.fr>2018-04-28 09:59:33 +0000
committerMarc Jeanmougin <marc.jeanmougin@telecom-paristech.fr>2018-04-28 09:59:33 +0000
commit2a37d214a84b9dad43f447a09a65846d07e96f44 (patch)
tree843b2ce041124c0dde7b548205ec626e483769b9 /src
parentFix bug when converting to paths cliped and masked LPE elemets (diff)
downloadinkscape-2a37d214a84b9dad43f447a09a65846d07e96f44.tar.gz
inkscape-2a37d214a84b9dad43f447a09a65846d07e96f44.zip
Allow FER edition on canvas
Diffstat (limited to 'src')
-rw-r--r--src/knot-holder-entity.cpp52
-rw-r--r--src/knot-holder-entity.h10
-rw-r--r--src/knotholder.cpp12
-rw-r--r--src/knotholder.h1
-rw-r--r--src/ui/shape-editor-knotholders.cpp2
5 files changed, 77 insertions, 0 deletions
diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp
index 1f5eb872f..38ae9f92d 100644
--- a/src/knot-holder-entity.cpp
+++ b/src/knot-holder-entity.cpp
@@ -282,6 +282,58 @@ PatternKnotHolderEntityScale::knot_get() const
return delta;
}
+/* Filter manipulation */
+void FilterKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state)
+{
+ // 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);
+
+ if ( state & GDK_CONTROL_MASK ) {
+ if (fabs((p - origin)[Geom::X]) > fabs((p - origin)[Geom::Y])) {
+ p_snapped[Geom::Y] = origin[Geom::Y];
+ } else {
+ p_snapped[Geom::X] = origin[Geom::X];
+ }
+ }
+
+ if (state) {
+ SPFilter *filter = (item->style && item->style->filter.href) ? dynamic_cast<SPFilter *>(item->style->getFilter()) : NULL;
+ if(!filter) return;
+ Geom::OptRect orig_bbox = item->visualBounds();
+ Geom::Rect *new_bbox = _topleft ? new Geom::Rect(p,orig_bbox->max()) : new Geom::Rect(orig_bbox->min(), p);
+ if(_topleft) {
+ float x_a = filter->width.computed;
+ float y_a = filter->height.computed;
+ filter->height.scale(new_bbox->height()/orig_bbox->height());
+ filter->width.scale(new_bbox->width()/orig_bbox->width());
+ float x_b = filter->width.computed;
+ float y_b = filter->height.computed;
+ filter->x.set(filter->x.unit, filter->x.computed + x_a - x_b);
+ filter->y.set(filter->y.unit, filter->y.computed + y_a - y_b);
+ } else {
+ filter->height.scale(new_bbox->height()/orig_bbox->height());
+ filter->width.scale(new_bbox->width()/orig_bbox->width());
+ }
+ filter->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+
+ //filter->
+
+ //item-> //adjust FER
+ }
+
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+
+}
+
+Geom::Point FilterKnotHolderEntity::knot_get() const
+{
+ SPFilter *filter = (item->style && item->style->filter.href) ? dynamic_cast<SPFilter *>(item->style->getFilter()) : NULL;
+ if(!filter) return Geom::Point(Geom::infinity(), Geom::infinity());
+ Geom::OptRect r = item->visualBounds();
+ if (_topleft) return Geom::Point(r->min());
+ else return Geom::Point(r->max());
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h
index 63a068cab..043da4cd9 100644
--- a/src/knot-holder-entity.h
+++ b/src/knot-holder-entity.h
@@ -130,6 +130,16 @@ private:
bool _fill;
};
+/* Filter manipulation */
+class FilterKnotHolderEntity : public KnotHolderEntity {
+public:
+ FilterKnotHolderEntity(bool topleft) : KnotHolderEntity(), _topleft(topleft) {}
+ virtual Geom::Point knot_get() const;
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned int state);
+private:
+ bool _topleft; // true for topleft point, false for bottomright
+};
+
#endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
/*
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index 58469107d..982e73747 100644
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
@@ -387,6 +387,18 @@ void KnotHolder::add_pattern_knotholder()
updateControlSizes();
}
+void KnotHolder::add_filter_knotholder() {
+ FilterKnotHolderEntity *entity_tl = new FilterKnotHolderEntity(true);
+ FilterKnotHolderEntity *entity_br = new FilterKnotHolderEntity(false);
+ entity_tl->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT,
+ _("<b>Resize</b> the filter effect region"), SP_KNOT_SHAPE_DIAMOND);
+ entity_br->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT,
+ _("<b>Resize</b> the filter effect region"), SP_KNOT_SHAPE_DIAMOND);
+ entity.push_back(entity_tl);
+ entity.push_back(entity_br);
+ updateControlSizes();
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/knotholder.h b/src/knotholder.h
index 01e81c845..f03eea3ea 100644
--- a/src/knotholder.h
+++ b/src/knotholder.h
@@ -58,6 +58,7 @@ public:
void add(KnotHolderEntity *e);
void add_pattern_knotholder();
+ void add_filter_knotholder();
void setEditTransform(Geom::Affine edit_transform);
Geom::Affine getEditTransform() const { return _edit_transform; }
diff --git a/src/ui/shape-editor-knotholders.cpp b/src/ui/shape-editor-knotholders.cpp
index 885f3ef40..1027dea7f 100644
--- a/src/ui/shape-editor-knotholders.cpp
+++ b/src/ui/shape-editor-knotholders.cpp
@@ -129,6 +129,8 @@ KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop)
knotholder->add_pattern_knotholder();
}
}
+ if (!knotholder) knotholder = new KnotHolder(desktop, item, NULL);
+ knotholder->add_filter_knotholder();
return knotholder;
}