diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-06-01 06:39:07 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-06-01 06:39:07 +0000 |
| commit | 174908a7e0d4fec3657da94d243ef30b14b8f30b (patch) | |
| tree | 05d3b49c31ddd3fd1754b6a42de8192ba0119560 /src | |
| parent | Include more feature libraries (diff) | |
| download | inkscape-174908a7e0d4fec3657da94d243ef30b14b8f30b.tar.gz inkscape-174908a7e0d4fec3657da94d243ef30b14b8f30b.zip | |
Allow rects be LPE like other primitives
Diffstat (limited to 'src')
| -rw-r--r-- | src/object/sp-rect.cpp | 48 | ||||
| -rw-r--r-- | src/object/sp-rect.h | 2 | ||||
| -rw-r--r-- | src/ui/clipboard.cpp | 3 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.cpp | 23 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.h | 1 |
5 files changed, 41 insertions, 36 deletions
diff --git a/src/object/sp-rect.cpp b/src/object/sp-rect.cpp index 207d2fc5a..1ecfab558 100644 --- a/src/object/sp-rect.cpp +++ b/src/object/sp-rect.cpp @@ -19,9 +19,10 @@ #include "attributes.h" #include "style.h" #include "sp-rect.h" -#include <glibmm/i18n.h> #include "sp-guide.h" #include "preferences.h" +#include "svg/svg.h" +#include <glibmm/i18n.h> #define noRECT_VERBOSE @@ -193,6 +194,20 @@ const char* SPRect::displayName() const { #define C1 0.554 void SPRect::set_shape() { + if (hasBrokenPathEffect()) { + g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE"); + + if (this->getRepr()->attribute("d")) { + // unconditionally read the curve from d, if any, to preserve appearance + Geom::PathVector pv = sp_svg_read_pathv(this->getRepr()->attribute("d")); + SPCurve *cold = new SPCurve(pv); + this->setCurveInsync(cold); + this->setCurveBeforeLPE( cold ); + cold->unref(); + } + + return; + } if ((this->height.computed < 1e-18) || (this->width.computed < 1e-18)) { this->setCurveInsync(nullptr); this->setCurveBeforeLPE(nullptr); @@ -259,13 +274,26 @@ void SPRect::set_shape() { c->lineto(x + w, y + h); c->lineto(x + 0.0, y + h); } - - c->closepath(); - this->setCurveInsync(c); - this->setCurveBeforeLPE(c); - - // LPE is not applied because result can generally not be represented as SPRect - + /* Reset the shape's curve to the "original_curve" + * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ + SPCurve * before = this->getCurveBeforeLPE(); + bool haslpe = this->hasPathEffectOnClipOrMaskRecursive(this); + if (before || haslpe) { + if (c && before && before->get_pathvector() != c->get_pathvector()){ + this->setCurveBeforeLPE(c); + sp_lpe_item_update_patheffect(this, true, false); + } else if(haslpe) { + this->setCurveBeforeLPE(c); + } else { + //This happends on undo, fix bug:#1791784 + this->setCurveInsync(c); + } + } else { + this->setCurveInsync(c); + } + if (before) { + before->unref(); + } c->unref(); } @@ -300,6 +328,10 @@ void SPRect::setRy(bool set, gdouble value) { this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } +void SPRect::update_patheffect(bool write) { + SPShape::update_patheffect(write); +} + Geom::Affine SPRect::set_transform(Geom::Affine const& xform) { /* Calculate rect start in parent coords. */ Geom::Point pos(Geom::Point(this->x.computed, this->y.computed) * xform); diff --git a/src/object/sp-rect.h b/src/object/sp-rect.h index 39fac16f9..bbc9d3c69 100644 --- a/src/object/sp-rect.h +++ b/src/object/sp-rect.h @@ -57,7 +57,7 @@ public: Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override; const char* displayName() const override; - + void update_patheffect(bool write) override; void set_shape() override; Geom::Affine set_transform(Geom::Affine const& xform) override; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index f96fa607e..7460822c9 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -1100,9 +1100,6 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta if ( item == nullptr ) { return; } - if ( dynamic_cast<SPRect *>(item) ) { - return; - } SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item); if (lpeitem) diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 097078e56..8767a109f 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -35,7 +35,6 @@ #include "object/sp-item-group.h" #include "object/sp-path.h" -#include "object/sp-rect.h" #include "object/sp-use.h" #include "object/sp-text.h" @@ -407,27 +406,6 @@ LivePathEffectEditor::setDesktop(SPDesktop *desktop) } } -void -LivePathEffectEditor::rectsToCurves(SPItem* topitem, SPItem *item) -{ - Inkscape::Selection *sel = _getSelection(); - if ( dynamic_cast<SPRect *>(item) ) { - sel->clear(); - sel->set(item); - sel->toCurves(); - if (topitem == item) { - return; - } - } else if( SPGroup *group = dynamic_cast<SPGroup *>(item)){ - std::vector<SPItem*> const item_list = sp_item_group_item_list(group); - for (auto sub_item : item_list) { - rectsToCurves(topitem, sub_item); - } - } - sel->set(topitem); -} - - /*######################################################################## # BUTTON CLICK HANDLERS (callbacks) ########################################################################*/ @@ -455,7 +433,6 @@ LivePathEffectEditor::onAdd() if (!data) { return; } - rectsToCurves(item, item); item = sel->singleItem(); // get new item LivePathEffect::Effect::createAndApply(data->key.c_str(), doc, item); diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index 600754ce3..30524e483 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -71,7 +71,6 @@ private: void effect_list_reload(SPLPEItem *lpeitem); void set_sensitize_all(bool sensitive); - void rectsToCurves(SPItem *topitem, SPItem *item); void showParams(LivePathEffect::Effect& effect); void showText(Glib::ustring const &str); void selectInList(LivePathEffect::Effect* effect); |
