diff options
| author | Jabiertxof <jtx@jtx> | 2017-05-28 05:40:43 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2017-05-28 05:40:43 +0000 |
| commit | 5f75967b19b3cc95f249194fa13a2e04ef582c36 (patch) | |
| tree | dc99c11e6bf21288957f45663a6e4ed7103e65db /src | |
| parent | Allow LPE clip or mask hasent effect applied (diff) | |
| download | inkscape-5f75967b19b3cc95f249194fa13a2e04ef582c36.tar.gz inkscape-5f75967b19b3cc95f249194fa13a2e04ef582c36.zip | |
Force not original-d if the clip-path or mask has not a LPE allowed to change it
(bzr r15707)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 104 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 6 | ||||
| -rw-r--r-- | src/sp-lpe-item.cpp | 92 | ||||
| -rw-r--r-- | src/sp-lpe-item.h | 2 |
4 files changed, 140 insertions, 64 deletions
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 6e90c9279..54f5d93e8 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -69,7 +69,10 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, defvalue = g_strdup(default_value); param_readSVGValue(defvalue); oncanvas_editable = true; - + _edit_button = true; + _copy_button = true; + _paste_button = true; + _link_button = true; ref_changed_connection = ref.changedSignal().connect(sigc::mem_fun(*this, &PathParam::ref_changed)); } @@ -167,6 +170,15 @@ PathParam::param_getSVGValue() const } } +void +PathParam::set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button) +{ + _edit_button = edit_button; + _copy_button = copy_button; + _paste_button = paste_button; + _link_button = link_button; +} + Gtk::Widget * PathParam::param_newWidget() { @@ -175,47 +187,55 @@ PathParam::param_newWidget() Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label)); static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true); pLabel->set_tooltip_text(param_tooltip); - - Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) ); - Gtk::Button * pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click)); - static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Edit on-canvas")); - - pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) ); - pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_copy_button_click)); - static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Copy path")); - - pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); - pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click)); - static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Paste path")); - - pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); - pButton = Gtk::manage(new Gtk::Button()); - pButton->set_relief(Gtk::RELIEF_NONE); - pIcon->show(); - pButton->add(*pIcon); - pButton->show(); - pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_link_button_click)); - static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); - pButton->set_tooltip_text(_("Link to path on clipboard")); - + Gtk::Widget * pIcon = NULL; + Gtk::Button * pButton = NULL; + if (_edit_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click)); + static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Edit on-canvas")); + } + + if (_copy_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_copy_button_click)); + static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Copy path")); + } + + if (_paste_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click)); + static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Paste path")); + } + if (_link_button) { + pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) ); + pButton = Gtk::manage(new Gtk::Button()); + pButton->set_relief(Gtk::RELIEF_NONE); + pIcon->show(); + pButton->add(*pIcon); + pButton->show(); + pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_link_button_click)); + static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); + pButton->set_tooltip_text(_("Link to path on clipboard")); + } + static_cast<Gtk::HBox*>(_widget)->show_all_children(); return dynamic_cast<Gtk::Widget *> (_widget); diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index 5381a6b36..ff5e4f1b8 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -44,7 +44,7 @@ public: void param_set_and_write_default(); void set_new_value (Geom::PathVector const &newpath, bool write_to_svg); void set_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const &newpath, bool write_to_svg); - + void set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button); virtual void param_editOncanvas(SPItem * item, SPDesktop * dt); virtual void param_setup_nodepath(Inkscape::NodePath::Path *np); virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec); @@ -91,6 +91,10 @@ protected: gchar * defvalue; private: + bool _edit_button; + bool _copy_button; + bool _paste_button; + bool _link_button; PathParam(const PathParam&); PathParam& operator=(const PathParam&); }; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 68f9843d5..d1f1697a8 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -215,12 +215,53 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape /** * returns true when LPE was successful. */ +bool SPLPEItem::hasPathEffectOnClipOrMask() const +{ + bool has_clipormask_lpe = false; + if (this->hasPathEffect() && this->pathEffectsEnabled()) { + for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) + { + LivePathEffectObject *lpeobj = (*it)->lpeobject; + if (!lpeobj) { + return false; + } + Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); + if (!lpe) { + return false; + } + if (lpe->isVisible()) { + if (lpe->acceptsNumClicks() > 0 && !lpe->isReady()) { + return false; + } + if (lpe->apply_to_clippath_and_mask) { + has_clipormask_lpe = true; + } + } + } + } + std::cout << has_clipormask_lpe << "has_clipormask_lpe\n"; + return has_clipormask_lpe; +} + +bool SPLPEItem::hasPathEffectOnClipOrMaskRecursive() const +{ + if (parent && SP_IS_LPE_ITEM(parent)) { + return hasPathEffectOnClipOrMask() || SP_LPE_ITEM(parent)->hasPathEffectOnClipOrMaskRecursive(); + } + else { + return hasPathEffectOnClipOrMask(); + } +} + +/** + * returns true when LPE was successful. + */ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip_or_mask) { if (!curve) { return false; } - bool has_lpe_clipmask = false; + bool has_clipormask_lpe = false; if (this->hasPathEffect() && this->pathEffectsEnabled()) { for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { @@ -247,7 +288,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip return false; } if (lpe->apply_to_clippath_and_mask) { - has_lpe_clipmask = true; + has_clipormask_lpe = true; } if (!is_clip_or_mask || (is_clip_or_mask && lpe->apply_to_clippath_and_mask)) { // Groups have their doBeforeEffect called elsewhere @@ -276,7 +317,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip } } } - if(!SP_IS_GROUP(this) && !is_clip_or_mask && has_lpe_clipmask){ + if(!SP_IS_GROUP(this) && !is_clip_or_mask && has_clipormask_lpe){ this->apply_to_clippath(this); this->apply_to_mask(this); } @@ -370,9 +411,8 @@ static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { g_return_if_fail(lpeitem != NULL); - if (SP_IS_GROUP(lpeitem)) { - if (!lpeitem->hasPathEffectRecursive()) { + if (!lpeitem->hasPathEffectOnClipOrMaskRecursive()) { SPMask * mask = lpeitem->mask_ref->getObject(); if(mask) { @@ -391,24 +431,24 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); } } - } - else if (SP_IS_PATH(lpeitem)) { + } else if (SP_IS_PATH(lpeitem)) { Inkscape::XML::Node *repr = lpeitem->getRepr(); - if (!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) { - SPMask * mask = lpeitem->mask_ref->getObject(); - if(mask) - { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); - } - SPClipPath * clip_path = lpeitem->clip_ref->getObject(); - if(clip_path) - { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); - } + SPMask * mask = lpeitem->mask_ref->getObject(); + if(mask) { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + } + mask = dynamic_cast<SPMask *>(lpeitem->parent); + clip_path = dynamic_cast<SPClipPath *>(lpeitem->parent); + if ((!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) || + ((mask || clip_path) && !lpeitem->hasPathEffectOnClipOrMask() && repr->attribute("inkscape:original-d"))) + { repr->setAttribute("d", repr->attribute("inkscape:original-d")); repr->setAttribute("inkscape:original-d", NULL); - } - else { + } else { sp_lpe_item_update_patheffect(lpeitem, true, true); } } @@ -462,7 +502,16 @@ void SPLPEItem::addPathEffect(std::string value, bool reset) // Apply the path effect sp_lpe_item_update_patheffect(this, true, true); - + SPMask * mask = mask_ref->getObject(); + if(mask && !hasPathEffectOnClipOrMask()) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); + } + SPClipPath * clip_path = clip_ref->getObject(); + if(clip_path && !hasPathEffectOnClipOrMask()) + { + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); + } //fix bug 1219324 if (SP_ACTIVE_DESKTOP ) { Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; @@ -649,6 +698,7 @@ bool SPLPEItem::hasPathEffectRecursive() const return hasPathEffect(); } } + void SPLPEItem::apply_to_clippath(SPItem *item) { diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 0f198c49c..d5d4e118b 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -70,6 +70,8 @@ public: virtual void update_patheffect(bool write); + bool hasPathEffectOnClipOrMask() const; + bool hasPathEffectOnClipOrMaskRecursive() const; bool performPathEffect(SPCurve *curve, SPShape *current = NULL, bool is_clip_or_mask = false); bool pathEffectsEnabled() const; |
