diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/drawing-item.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerclip.cpp | 148 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerclip.h | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitesarray.h | 1 | ||||
| -rw-r--r-- | src/sp-clippath.cpp | 1 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 2 |
6 files changed, 99 insertions, 59 deletions
diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 1df60d783..21f6ffacc 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -120,9 +120,7 @@ public: void setBlendMode(unsigned blend_mode); void setTransform(Geom::Affine const &trans); void setClip(DrawingItem *item); - DrawingItem * getClip(){ return _clip;} void setMask(DrawingItem *item); - DrawingItem * getMask(){ return _mask;} void setFillPattern(DrawingPattern *pattern); void setStrokePattern(DrawingPattern *pattern); void setZOrder(unsigned z); diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 7ab662bbc..bbbe733fe 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -30,7 +30,6 @@ namespace LivePathEffect { LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) : Effect(lpeobject), - hide_clip(_("Temporary hide"), _("Hide clip, not storeable, reset on doc load"), "hide_clip", &wr, this, false), inverse(_("Inverse clip"), _("Inverse clip"), "inverse", &wr, this, false), flatten(_("Flatten clip"), _("Flatten clip"), "flatten", &wr, this, false), fillrule(_("Set/unset evenodd fill rule"), _("Set/unset evenodd fill rule (this is overwriting your current value)."), "fillrule", &wr, this, false), @@ -43,47 +42,18 @@ LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject) registerParameter(&fillrule); registerParameter(&convert_shapes); registerParameter(&is_inverse); - registerParameter(&hide_clip); is_clip = false; previous_fillrule = fillrule; - previous_hide_clip = false; + hide_clip = false; } LPEPowerClip::~LPEPowerClip() {} void LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){ - if (is_load) { - hide_clip.param_setValue(false); - } + original_bbox(lpeitem); const Glib::ustring uri = (Glib::ustring)sp_lpe_item->getRepr()->attribute("clip-path"); SPClipPath *clip_path = SP_ITEM(lpeitem)->clip_ref->getObject(); - SPItem * item = SP_ITEM(lpeitem); - if (!is_load) { - if(clip_path && hide_clip && previous_hide_clip != hide_clip) { - SPItemView *v; - for (v = item->display; v != NULL; v = v->next) { - clip_path->hide(v->arenaitem->key()); - } - } else if (clip_path && !hide_clip && previous_hide_clip != hide_clip) { - Geom::OptRect bbox = item->geometricBounds(); - for (SPItemView *v = item->display; v != NULL; v = v->next) { - if (!v->arenaitem->key()) { - v->arenaitem->setKey(SPItem::display_key_new(3)); - } - Inkscape::DrawingItem *ai = clip_path->show( - v->arenaitem->drawing(), - v->arenaitem->key()); - v->arenaitem->setClip(ai); - clip_path->setBBox(v->arenaitem->key(), bbox); - } - } - } - if(!is_load && previous_hide_clip != hide_clip) { - clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); - } - previous_hide_clip = hide_clip; - original_bbox(lpeitem); Geom::Point topleft = Geom::Point(boundingbox_X.min() - 5,boundingbox_Y.max() + 5); Geom::Point topright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.max() + 5); Geom::Point bottomright = Geom::Point(boundingbox_X.max() + 5,boundingbox_Y.min() - 5); @@ -152,17 +122,17 @@ LPEPowerClip::addInverse (SPItem * clip_data){ SP_SHAPE(clip_data)->setCurve(c, TRUE); c->unref(); is_inverse.param_setValue((Glib::ustring)"true", true); -// SPDesktop *desktop = SP_ACTIVE_DESKTOP; -// if (desktop) { -// if (tools_isactive(desktop, TOOLS_NODES)) { -// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); -// SPItem * item = sel->singleItem(); -// if (item != NULL) { -// sel->remove(item); -// sel->add(item); -// } -// } -// } + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } + } + } } } } @@ -187,22 +157,92 @@ LPEPowerClip::removeInverse (SPItem * clip_data){ SP_SHAPE(clip_data)->setCurve(c, TRUE); c->unref(); is_inverse.param_setValue((Glib::ustring)"false", true); -// SPDesktop *desktop = SP_ACTIVE_DESKTOP; -// if (desktop) { -// if (tools_isactive(desktop, TOOLS_NODES)) { -// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); -// SPItem * item = sel->singleItem(); -// if (item != NULL) { -// sel->remove(item); -// sel->add(item); -// } -// } -// } + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection(); + SPItem * item = sel->singleItem(); + if (item != NULL) { + sel->remove(item); + sel->add(item); + } + } + } + } + } + } +} + +void +LPEPowerClip::toggleClip() { + SPItem * item = SP_ITEM(sp_lpe_item); + if (item) { + SPClipPath *clip_path = item->clip_ref->getObject(); + if (clip_path) { + hide_clip = !hide_clip; + if(hide_clip) { + SPItemView *v; + for (v = item->display; v != NULL; v = v->next) { + clip_path->hide(v->arenaitem->key()); + } + } else { + Geom::OptRect bbox = item->geometricBounds(); + for (SPItemView *v = item->display; v != NULL; v = v->next) { + if (!v->arenaitem->key()) { + v->arenaitem->setKey(SPItem::display_key_new(3)); + } + Inkscape::DrawingItem *ai = clip_path->show( + v->arenaitem->drawing(), + v->arenaitem->key()); + v->arenaitem->setClip(ai); + clip_path->setBBox(v->arenaitem->key(), bbox); + } } + clip_path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } } +Gtk::Widget * +LPEPowerClip::newWidget() +{ + // use manage here, because after deletion of Effect object, others might still be pointing to this widget. + Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); + + vbox->set_border_width(5); + vbox->set_homogeneous(false); + vbox->set_spacing(6); + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); + Gtk::Button * toggle_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Toggle clip visibiliy")))); + toggle_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::toggleClip)); + toggle_button->set_size_request(140,30); + vbox->pack_start(*hbox, true,true,2); + hbox->pack_start(*toggle_button, false, false,2); + std::vector<Parameter *>::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget()); + if(param->param_key == "grid") { + widg = NULL; + } + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } + + ++it; + } + return dynamic_cast<Gtk::Widget *>(vbox); +} + void LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/) { diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index bf3eeac0d..63594cfd8 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -23,6 +23,8 @@ public: virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); //virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); + virtual Gtk::Widget * newWidget(); + void toggleClip(); void addInverse (SPItem * clip_data); void removeInverse (SPItem * clip_data); void flattenClip(SPItem * clip_data, Geom::PathVector &path_in); @@ -31,7 +33,6 @@ protected: //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: - BoolParam hide_clip; BoolParam inverse; BoolParam flatten; BoolParam fillrule; @@ -39,6 +40,7 @@ private: HiddenParam is_inverse; Geom::Path clip_box; bool is_clip; + bool hide_clip; bool previous_fillrule; bool previous_hide_clip; }; diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 300a7a9dd..5ae372ac2 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -57,7 +57,6 @@ public: void setEffectType(EffectType et); void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write = true); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); - bool widget_is_visible; friend class FilletChamferKnotHolderEntity; friend class LPEFilletChamfer; diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 619f7c65e..b26a2cbf2 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -35,6 +35,7 @@ struct SPClipPathView { Inkscape::DrawingItem *arenaitem; Geom::OptRect bbox; }; + static SPClipPathView* sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem); static SPClipPathView* sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view); diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 5daedcd02..eb4538057 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -386,7 +386,7 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape ShapeRecord r; r.item = item; // TODO add support for objectBoundingBox - r.edit_transform = base || role == SHAPE_ROLE_CLIPPING_PATH ? base->i2doc_affine() : Geom::identity(); + r.edit_transform = base ? base->i2doc_affine() : Geom::identity(); r.role = role; if (s.insert(r).second) { |
