diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-03-02 23:12:03 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-03-02 23:12:03 +0000 |
| commit | db0fad4a62a657057339dfb7755cee69ef9138a3 (patch) | |
| tree | 433f0dbfa541c33c55aa2a33af6d472e03d828d8 /src | |
| parent | added more fillet/chamfer properties (diff) | |
| parent | Extensions. Fix for Bug #1426684 (INX optiongroup does not trigger a refresh). (diff) | |
| download | inkscape-db0fad4a62a657057339dfb7755cee69ef9138a3.tar.gz inkscape-db0fad4a62a657057339dfb7755cee69ef9138a3.zip | |
update to trunk
(bzr r13645.1.29)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/param/radiobutton.cpp | 41 | ||||
| -rw-r--r-- | src/live_effects/lpe-bspline.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/lpe-copy_rotate.cpp | 3 | ||||
| -rw-r--r-- | src/live_effects/lpe-lattice.cpp | 15 | ||||
| -rw-r--r-- | src/live_effects/lpe-lattice2.cpp | 60 | ||||
| -rw-r--r-- | src/live_effects/lpe-lattice2.h | 52 | ||||
| -rw-r--r-- | src/live_effects/lpe-offset.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/lpe-parallel.cpp | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective-envelope.cpp | 10 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective-envelope.h | 10 | ||||
| -rw-r--r-- | src/live_effects/lpe-test-doEffect-stack.cpp | 1 | ||||
| -rw-r--r-- | src/live_effects/parameter/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.cpp | 46 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.h | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/pointreseteable.cpp | 210 | ||||
| -rw-r--r-- | src/live_effects/parameter/pointreseteable.h | 74 |
16 files changed, 167 insertions, 382 deletions
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index f9515197c..740acf1d1 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -249,28 +249,35 @@ void ParamRadioButtonWdg::changed(void) class ComboWdg : public Gtk::ComboBoxText { +private: + ParamRadioButton* _base; + SPDocument* _doc; + Inkscape::XML::Node* _node; + sigc::signal<void> * _changeSignal; + public: - ComboWdg(ParamRadioButton* base, SPDocument * doc, Inkscape::XML::Node * node) : - Gtk::ComboBoxText(), - base(base), - doc(doc), - node(node) + ComboWdg(ParamRadioButton* base, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : + _base(base), + _doc(doc), + _node(node), + _changeSignal(changeSignal) { + this->signal_changed().connect(sigc::mem_fun(this, &ComboWdg::changed)); } virtual ~ComboWdg() {} + void changed (void); +}; -protected: - ParamRadioButton* base; - SPDocument* doc; - Inkscape::XML::Node* node; - - virtual void on_changed() { - if ( base ) { - Glib::ustring value = base->value_from_label(get_active_text()); - base->set(value.c_str(), doc, node); - } +void ComboWdg::changed(void) +{ + if ( _base ) { + Glib::ustring value = _base->value_from_label(get_active_text()); + _base->set(value.c_str(), _doc, _node); } -}; + if (_changeSignal != NULL) { + _changeSignal->emit(); + } +} /** * Returns the value for the options label parameter @@ -317,7 +324,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node Gtk::ComboBoxText* cbt = 0; bool comboSet = false; if (_mode == MINIMAL) { - cbt = Gtk::manage(new ComboWdg(this, doc, node)); + cbt = Gtk::manage(new ComboWdg(this, doc, node, changeSignal)); cbt->show(); vbox->pack_start(*cbt, false, false); } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 2bed90139..045974147 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -356,11 +356,13 @@ void LPEBSpline::toWeight() void LPEBSpline::changeWeight(double weightValue) { - SPPath *path = SP_PATH(sp_lpe_item); - SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve, weightValue); - gchar *str = sp_svg_write_path(curve->get_pathvector()); - path->getRepr()->setAttribute("inkscape:original-d", str); + SPPath *path = dynamic_cast<SPPath *>(sp_lpe_item); + if(path){ + SPCurve *curve = path->get_curve_for_edit(); + LPEBSpline::doBSplineFromWidget(curve, weightValue); + gchar *str = sp_svg_write_path(curve->get_pathvector()); + path->getRepr()->setAttribute("inkscape:original-d", str); + } } void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 0fa2ebedc..fd9b853d5 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -69,7 +69,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : registerParameter(&rotation_angle); registerParameter(&num_copies); registerParameter(&origin); - + num_copies.param_make_integer(true); num_copies.param_set_range(0, 1000); } @@ -88,6 +88,7 @@ LPECopyRotate::doOnApply(SPLPEItem const* lpeitem) A = Point(boundingbox_X.min(), boundingbox_Y.middle()); B = Point(boundingbox_X.middle(), boundingbox_Y.middle()); origin.param_setValue(A); + origin.param_update_default(A); dist_angle_handle = L2(B - A); dir = unit_vector(B - A); } diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index a241a8a2e..ce0e4941b 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -236,6 +236,21 @@ LPELattice::resetDefaults(SPItem const* item) grid_point15[Geom::X] = 2.0/3*boundingbox_X.max()+1.0/3*boundingbox_X.min(); grid_point15[Geom::Y] = 2.0/3*boundingbox_Y.max()+1.0/3*boundingbox_Y.min(); + grid_point1.param_set_and_write_new_value(grid_point1); + grid_point2.param_set_and_write_new_value(grid_point2); + grid_point3.param_set_and_write_new_value(grid_point3); + grid_point4.param_set_and_write_new_value(grid_point4); + grid_point5.param_set_and_write_new_value(grid_point5); + grid_point6.param_set_and_write_new_value(grid_point6); + grid_point7.param_set_and_write_new_value(grid_point7); + grid_point8.param_set_and_write_new_value(grid_point8); + grid_point9.param_set_and_write_new_value(grid_point9); + grid_point10.param_set_and_write_new_value(grid_point10); + grid_point11.param_set_and_write_new_value(grid_point11); + grid_point12.param_set_and_write_new_value(grid_point12); + grid_point13.param_set_and_write_new_value(grid_point13); + grid_point14.param_set_and_write_new_value(grid_point14); + grid_point15.param_set_and_write_new_value(grid_point15); } /** diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index e1cd91340..1bcbe286f 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -44,31 +44,31 @@ namespace LivePathEffect { LPELattice2::LPELattice2(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - grid_point0(_("Control handle 0:"), _("Control handle 0 - Ctrl+Alt+Click to reset"), "gridpoint0", &wr, this), - grid_point1(_("Control handle 1:"), _("Control handle 1 - Ctrl+Alt+Click to reset"), "gridpoint1", &wr, this), - grid_point2(_("Control handle 2:"), _("Control handle 2 - Ctrl+Alt+Click to reset"), "gridpoint2", &wr, this), - grid_point3(_("Control handle 3:"), _("Control handle 3 - Ctrl+Alt+Click to reset"), "gridpoint3", &wr, this), - grid_point4(_("Control handle 4:"), _("Control handle 4 - Ctrl+Alt+Click to reset"), "gridpoint4", &wr, this), - grid_point5(_("Control handle 5:"), _("Control handle 5 - Ctrl+Alt+Click to reset"), "gridpoint5", &wr, this), - grid_point6(_("Control handle 6:"), _("Control handle 6 - Ctrl+Alt+Click to reset"), "gridpoint6", &wr, this), - grid_point7(_("Control handle 7:"), _("Control handle 7 - Ctrl+Alt+Click to reset"), "gridpoint7", &wr, this), - grid_point8x9(_("Control handle 8x9:"), _("Control handle 8x9 - Ctrl+Alt+Click to reset"), "gridpoint8x9", &wr, this), - grid_point10x11(_("Control handle 10x11:"), _("Control handle 10x11 - Ctrl+Alt+Click to reset"), "gridpoint10x11", &wr, this), - grid_point12(_("Control handle 12:"), _("Control handle 12 - Ctrl+Alt+Click to reset"), "gridpoint12", &wr, this), - grid_point13(_("Control handle 13:"), _("Control handle 13 - Ctrl+Alt+Click to reset"), "gridpoint13", &wr, this), - grid_point14(_("Control handle 14:"), _("Control handle 14 - Ctrl+Alt+Click to reset"), "gridpoint14", &wr, this), - grid_point15(_("Control handle 15:"), _("Control handle 15 - Ctrl+Alt+Click to reset"), "gridpoint15", &wr, this), - grid_point16(_("Control handle 16:"), _("Control handle 16 - Ctrl+Alt+Click to reset"), "gridpoint16", &wr, this), - grid_point17(_("Control handle 17:"), _("Control handle 17 - Ctrl+Alt+Click to reset"), "gridpoint17", &wr, this), - grid_point18(_("Control handle 18:"), _("Control handle 18 - Ctrl+Alt+Click to reset"), "gridpoint18", &wr, this), - grid_point19(_("Control handle 19:"), _("Control handle 19 - Ctrl+Alt+Click to reset"), "gridpoint19", &wr, this), - grid_point20x21(_("Control handle 20x21:"), _("Control handle 20x21 - Ctrl+Alt+Click to reset"), "gridpoint20x21", &wr, this), - grid_point22x23(_("Control handle 22x23:"), _("Control handle 22x23 - Ctrl+Alt+Click to reset"), "gridpoint22x23", &wr, this), - grid_point24x26(_("Control handle 24x26:"), _("Control handle 24x26 - Ctrl+Alt+Click to reset"), "gridpoint24x26", &wr, this), - grid_point25x27(_("Control handle 25x27:"), _("Control handle 25x27 - Ctrl+Alt+Click to reset"), "gridpoint25x27", &wr, this), - grid_point28x30(_("Control handle 28x30:"), _("Control handle 28x30 - Ctrl+Alt+Click to reset"), "gridpoint28x30", &wr, this), - grid_point29x31(_("Control handle 29x31:"), _("Control handle 29x31 - Ctrl+Alt+Click to reset"), "gridpoint29x31", &wr, this), - grid_point32x33x34x35(_("Control handle 32x33x34x35:"), _("Control handle 32x33x34x35 - Ctrl+Alt+Click to reset"), "gridpoint32x33x34x35", &wr, this) + grid_point0(_("Control handle 0:"), _("Control handle 0 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint0", &wr, this), + grid_point1(_("Control handle 1:"), _("Control handle 1 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint1", &wr, this), + grid_point2(_("Control handle 2:"), _("Control handle 2 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint2", &wr, this), + grid_point3(_("Control handle 3:"), _("Control handle 3 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint3", &wr, this), + grid_point4(_("Control handle 4:"), _("Control handle 4 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint4", &wr, this), + grid_point5(_("Control handle 5:"), _("Control handle 5 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint5", &wr, this), + grid_point6(_("Control handle 6:"), _("Control handle 6 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint6", &wr, this), + grid_point7(_("Control handle 7:"), _("Control handle 7 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint7", &wr, this), + grid_point8x9(_("Control handle 8x9:"), _("Control handle 8x9 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint8x9", &wr, this), + grid_point10x11(_("Control handle 10x11:"), _("Control handle 10x11 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint10x11", &wr, this), + grid_point12(_("Control handle 12:"), _("Control handle 12 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint12", &wr, this), + grid_point13(_("Control handle 13:"), _("Control handle 13 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint13", &wr, this), + grid_point14(_("Control handle 14:"), _("Control handle 14 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint14", &wr, this), + grid_point15(_("Control handle 15:"), _("Control handle 15 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint15", &wr, this), + grid_point16(_("Control handle 16:"), _("Control handle 16 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint16", &wr, this), + grid_point17(_("Control handle 17:"), _("Control handle 17 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint17", &wr, this), + grid_point18(_("Control handle 18:"), _("Control handle 18 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint18", &wr, this), + grid_point19(_("Control handle 19:"), _("Control handle 19 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint19", &wr, this), + grid_point20x21(_("Control handle 20x21:"), _("Control handle 20x21 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint20x21", &wr, this), + grid_point22x23(_("Control handle 22x23:"), _("Control handle 22x23 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint22x23", &wr, this), + grid_point24x26(_("Control handle 24x26:"), _("Control handle 24x26 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint24x26", &wr, this), + grid_point25x27(_("Control handle 25x27:"), _("Control handle 25x27 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint25x27", &wr, this), + grid_point28x30(_("Control handle 28x30:"), _("Control handle 28x30 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint28x30", &wr, this), + grid_point29x31(_("Control handle 29x31:"), _("Control handle 29x31 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint29x31", &wr, this), + grid_point32x33x34x35(_("Control handle 32x33x34x35:"), _("Control handle 32x33x34x35 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint32x33x34x35", &wr, this) { @@ -218,12 +218,14 @@ LPELattice2::newWidget() 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* resetButton = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset grid")))); - resetButton->set_alignment(0.0, 0.5); resetButton->signal_clicked().connect(sigc::mem_fun (*this,&LPELattice2::resetGrid)); - Gtk::Widget* resetButtonWidget = dynamic_cast<Gtk::Widget *>(resetButton); - resetButtonWidget->set_tooltip_text("Reset grid"); - vbox->pack_start(*resetButtonWidget, true, true,2); + resetButton->set_size_request(140,30); + vbox->pack_start(*hbox, true,true,2); + hbox->pack_start(*resetButton, false, false,2); std::vector<Parameter *>::iterator it = param_vector.begin(); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { diff --git a/src/live_effects/lpe-lattice2.h b/src/live_effects/lpe-lattice2.h index 461f835c6..5084ceead 100644 --- a/src/live_effects/lpe-lattice2.h +++ b/src/live_effects/lpe-lattice2.h @@ -21,7 +21,7 @@ #include "live_effects/parameter/enum.h" #include "live_effects/effect.h" -#include "live_effects/parameter/pointreseteable.h" +#include "live_effects/parameter/point.h" #include "live_effects/lpegroupbbox.h" namespace Inkscape { @@ -56,31 +56,31 @@ protected: void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec); private: - PointReseteableParam grid_point0; - PointReseteableParam grid_point1; - PointReseteableParam grid_point2; - PointReseteableParam grid_point3; - PointReseteableParam grid_point4; - PointReseteableParam grid_point5; - PointReseteableParam grid_point6; - PointReseteableParam grid_point7; - PointReseteableParam grid_point8x9; - PointReseteableParam grid_point10x11; - PointReseteableParam grid_point12; - PointReseteableParam grid_point13; - PointReseteableParam grid_point14; - PointReseteableParam grid_point15; - PointReseteableParam grid_point16; - PointReseteableParam grid_point17; - PointReseteableParam grid_point18; - PointReseteableParam grid_point19; - PointReseteableParam grid_point20x21; - PointReseteableParam grid_point22x23; - PointReseteableParam grid_point24x26; - PointReseteableParam grid_point25x27; - PointReseteableParam grid_point28x30; - PointReseteableParam grid_point29x31; - PointReseteableParam grid_point32x33x34x35; + PointParam grid_point0; + PointParam grid_point1; + PointParam grid_point2; + PointParam grid_point3; + PointParam grid_point4; + PointParam grid_point5; + PointParam grid_point6; + PointParam grid_point7; + PointParam grid_point8x9; + PointParam grid_point10x11; + PointParam grid_point12; + PointParam grid_point13; + PointParam grid_point14; + PointParam grid_point15; + PointParam grid_point16; + PointParam grid_point17; + PointParam grid_point18; + PointParam grid_point19; + PointParam grid_point20x21; + PointParam grid_point22x23; + PointParam grid_point24x26; + PointParam grid_point25x27; + PointParam grid_point28x30; + PointParam grid_point29x31; + PointParam grid_point32x33x34x35; LPELattice2(const LPELattice2&); LPELattice2& operator=(const LPELattice2&); diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index dc91775b7..232f1c9db 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -42,7 +42,9 @@ LPEOffset::~LPEOffset() void LPEOffset::doOnApply(SPLPEItem const* lpeitem) { - offset_pt.param_set_and_write_new_value(*(SP_SHAPE(lpeitem)->_curve->first_point())); + Geom::Point offset = *(SP_SHAPE(lpeitem)->_curve->first_point()); + offset_pt.param_update_default(offset); + offset_pt.param_set_and_write_new_value(offset); } static void append_half_circle(Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2, diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index bb37fd42c..a1e713fe2 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -72,8 +72,9 @@ LPEParallel::doOnApply (SPLPEItem const* lpeitem) A = *(curve->first_point()); B = *(curve->last_point()); dir = unit_vector(B - A); - - offset_pt.param_set_and_write_new_value((A + B)/2 + dir.ccw() * 100); + Geom::Point offset = (A + B)/2 + dir.ccw() * 100; + offset_pt.param_update_default(offset); + offset_pt.param_set_and_write_new_value(offset); } Geom::Piecewise<Geom::D2<Geom::SBasis> > diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index b5ef26e2f..d38427d0a 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -44,10 +44,10 @@ LPEPerspectiveEnvelope::LPEPerspectiveEnvelope(LivePathEffectObject *lpeobject) Effect(lpeobject), // initialise your parameters here: deform_type(_("Type"), _("Select the type of deformation"), "deform_type", DeformationTypeConverter, &wr, this, DEFORMATION_PERSPECTIVE), - Up_Left_Point(_("Top Left"), _("Top Left - Ctrl+Alt+Click to reset"), "Up_Left_Point", &wr, this), - Up_Right_Point(_("Top Right"), _("Top Right - Ctrl+Alt+Click to reset"), "Up_Right_Point", &wr, this), - Down_Left_Point(_("Down Left"), _("Down Left - Ctrl+Alt+Click to reset"), "Down_Left_Point", &wr, this), - Down_Right_Point(_("Down Right"), _("Down Right - Ctrl+Alt+Click to reset"), "Down_Right_Point", &wr, this) + Up_Left_Point(_("Top Left"), _("Top Left - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Up_Left_Point", &wr, this), + Up_Right_Point(_("Top Right"), _("Top Right - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Up_Right_Point", &wr, this), + Down_Left_Point(_("Down Left"), _("Down Left - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Down_Left_Point", &wr, this), + Down_Right_Point(_("Down Right"), _("Down Right - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Down_Right_Point", &wr, this) { // register all your parameters here, so Inkscape knows which parameters this effect has: registerParameter( dynamic_cast<Parameter *>(&deform_type)); @@ -298,7 +298,7 @@ LPEPerspectiveEnvelope::newWidget() Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); Gtk::Button* resetButton = Gtk::manage(new Gtk::Button(Gtk::Stock::CLEAR)); resetButton->signal_clicked().connect(sigc::mem_fun (*this,&LPEPerspectiveEnvelope::resetGrid)); - resetButton->set_size_request(140,45); + resetButton->set_size_request(140,30); vbox->pack_start(*hbox, true,true,2); hbox->pack_start(*resetButton, false, false,2); return dynamic_cast<Gtk::Widget *>(vbox); diff --git a/src/live_effects/lpe-perspective-envelope.h b/src/live_effects/lpe-perspective-envelope.h index 2f253882e..d3ff76445 100644 --- a/src/live_effects/lpe-perspective-envelope.h +++ b/src/live_effects/lpe-perspective-envelope.h @@ -19,7 +19,7 @@ #include "live_effects/parameter/enum.h" #include "live_effects/effect.h" -#include "live_effects/parameter/pointreseteable.h" +#include "live_effects/parameter/point.h" #include "live_effects/lpegroupbbox.h" namespace Inkscape { @@ -55,10 +55,10 @@ protected: private: EnumParam<unsigned> deform_type; - PointReseteableParam Up_Left_Point; - PointReseteableParam Up_Right_Point; - PointReseteableParam Down_Left_Point; - PointReseteableParam Down_Right_Point; + PointParam Up_Left_Point; + PointParam Up_Right_Point; + PointParam Down_Left_Point; + PointParam Down_Right_Point; LPEPerspectiveEnvelope(const LPEPerspectiveEnvelope&); LPEPerspectiveEnvelope& operator=(const LPEPerspectiveEnvelope&); diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index 03e3e7997..36ab6b547 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -28,6 +28,7 @@ LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) : registerParameter( dynamic_cast<Parameter *>(&path) ); point.set_oncanvas_looks(SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR, 0x00ff0000); + point.param_set_and_write_new_value(point); } LPEdoEffectStackTest::~LPEdoEffectStackTest() diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert index c9f40f7d1..74b499fa2 100644 --- a/src/live_effects/parameter/Makefile_insert +++ b/src/live_effects/parameter/Makefile_insert @@ -11,8 +11,6 @@ ink_common_sources += \ live_effects/parameter/random.h \ live_effects/parameter/point.cpp \ live_effects/parameter/point.h \ - live_effects/parameter/pointreseteable.cpp \ - live_effects/parameter/pointreseteable.h \ live_effects/parameter/enum.h \ live_effects/parameter/path-reference.cpp \ live_effects/parameter/path-reference.h \ diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 302818e55..1d48bda8d 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -15,6 +15,8 @@ #include "verbs.h" #include "knotholder.h" #include <glibmm/i18n.h> +#include "ui/tools-switch.h" +#include "ui/tools/node-tool.h" // needed for on-canvas editting: #include "desktop.h" @@ -46,6 +48,18 @@ PointParam::param_set_default() param_setValue(defvalue); } +void +PointParam::param_set_and_write_default() +{ + param_set_and_write_new_value(defvalue); +} + +void +PointParam::param_update_default(Geom::Point newpoint) +{ + this->defvalue = newpoint; +} + bool PointParam::param_readSVGValue(const gchar * strvalue) { @@ -99,6 +113,13 @@ void PointParam::param_setValue(Geom::Point newpoint) { *dynamic_cast<Geom::Point *>( this ) = newpoint; + if(SP_ACTIVE_DESKTOP){ + SPDesktop* desktop = SP_ACTIVE_DESKTOP; + if (tools_isactive( desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>( desktop->event_context); + nt->update_helperpath(); + } + } } void @@ -140,9 +161,20 @@ private: }; void -PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) { - Geom::Point const s = snap_knot_position(p, state); + Geom::Point s = snap_knot_position(p, state); + if (state & GDK_CONTROL_MASK) { + Geom::Point A(origin[Geom::X],p[Geom::Y]); + Geom::Point B(p[Geom::X],origin[Geom::Y]); + double distanceA = Geom::distance(A,p); + double distanceB = Geom::distance(B,p); + if(distanceA > distanceB){ + s = B; + } else { + s = A; + } + } pparam->param_setValue(s); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } @@ -154,9 +186,14 @@ PointParamKnotHolderEntity::knot_get() const } void -PointParamKnotHolderEntity::knot_click(guint /*state*/) +PointParamKnotHolderEntity::knot_click(guint state) { - g_print ("This is the handle associated to parameter '%s'\n", pparam->param_key.c_str()); + if (state & GDK_CONTROL_MASK) { + if (state & GDK_MOD1_MASK) { + this->pparam->param_set_default(); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + } + } } void @@ -166,7 +203,6 @@ PointParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SP // TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself??? e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color); knotholder->add(e); - } } /* namespace LivePathEffect */ diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 319835bb3..95854ea52 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -20,6 +20,7 @@ namespace Inkscape { namespace LivePathEffect { +class PointParamKnotHolderEntity; class PointParam : public Geom::Point, public Parameter { public: @@ -40,6 +41,8 @@ public: void param_setValue(Geom::Point newpoint); void param_set_default(); + void param_set_and_write_default(); + void param_update_default(Geom::Point newpoint); void param_set_and_write_new_value(Geom::Point newpoint); @@ -50,6 +53,7 @@ public: virtual bool providesKnotHolderEntities() const { return true; } virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + friend class PointParamKnotHolderEntity; private: PointParam(const PointParam&); PointParam& operator=(const PointParam&); diff --git a/src/live_effects/parameter/pointreseteable.cpp b/src/live_effects/parameter/pointreseteable.cpp deleted file mode 100644 index c0f8858b8..000000000 --- a/src/live_effects/parameter/pointreseteable.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "ui/widget/registered-widget.h" -#include "live_effects/parameter/pointreseteable.h" -#include "live_effects/effect.h" -#include "svg/svg.h" -#include "svg/stringstream.h" -#include "ui/widget/point.h" -#include "widgets/icon.h" -#include "inkscape.h" -#include "verbs.h" -#include "knotholder.h" -#include <glibmm/i18n.h> -#include "ui/tools-switch.h" -#include "ui/tools/node-tool.h" - -// needed for on-canvas editting: -#include "desktop.h" - -namespace Inkscape { - -namespace LivePathEffect { - -PointReseteableParam::PointReseteableParam( const Glib::ustring& label, const Glib::ustring& tip, - const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const gchar *htip, Geom::Point default_value) - : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value) -{ - knot_shape = SP_KNOT_SHAPE_DIAMOND; - knot_mode = SP_KNOT_MODE_XOR; - knot_color = 0xffffff00; - handle_tip = g_strdup(htip); -} - -PointReseteableParam::~PointReseteableParam() -{ - if (handle_tip) - g_free(handle_tip); -} - -void -PointReseteableParam::param_set_default() -{ - param_setValue(defvalue); -} - -void -PointReseteableParam::param_set_and_write_default() -{ - param_set_and_write_new_value(defvalue); -} - -void -PointReseteableParam::param_update_default(Geom::Point newpoint) -{ - this->defvalue = newpoint; -} - -bool -PointReseteableParam::param_readSVGValue(const gchar * strvalue) -{ - gchar ** strarray = g_strsplit(strvalue, ",", 2); - double newx, newy; - unsigned int success = sp_svg_number_read_d(strarray[0], &newx); - success += sp_svg_number_read_d(strarray[1], &newy); - g_strfreev (strarray); - if (success == 2) { - param_setValue( Geom::Point(newx, newy) ); - return true; - } - return false; -} - -gchar * -PointReseteableParam::param_getSVGValue() const -{ - Inkscape::SVGOStringStream os; - os << *dynamic_cast<Geom::Point const *>( this ); - gchar * str = g_strdup(os.str().c_str()); - return str; -} - -Gtk::Widget * -PointReseteableParam::param_newWidget() -{ - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() ) ); - // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP) - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - Geom::Affine transf = desktop->doc2dt(); - pointwdg->setTransform(transf); - pointwdg->setValue( *this ); - pointwdg->clearProgrammatically(); - pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter")); - - Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); - static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true); - static_cast<Gtk::HBox*>(hbox)->show_all_children(); - - return dynamic_cast<Gtk::Widget *> (hbox); -} - -void -PointReseteableParam::param_setValue(Geom::Point newpoint) -{ - *dynamic_cast<Geom::Point *>( this ) = newpoint; - if(SP_ACTIVE_DESKTOP){ - SPDesktop* desktop = SP_ACTIVE_DESKTOP; - if (tools_isactive( desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>( desktop->event_context); - nt->update_helperpath(); - } - } -} - -void -PointReseteableParam::param_set_and_write_new_value (Geom::Point newpoint) -{ - Inkscape::SVGOStringStream os; - os << newpoint; - gchar * str = g_strdup(os.str().c_str()); - param_write_to_repr(str); - g_free(str); -} - -void -PointReseteableParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) -{ - param_set_and_write_new_value( (*this) * postmul ); -} - - -void -PointReseteableParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) -{ - knot_shape = shape; - knot_mode = mode; - knot_color = color; -} - -class PointReseteableParamKnotHolderEntity : public KnotHolderEntity { -public: - PointReseteableParamKnotHolderEntity(PointReseteableParam *p) { this->pparam = p; } - virtual ~PointReseteableParamKnotHolderEntity() {} - - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); - virtual Geom::Point knot_get() const; - virtual void knot_click(guint state); - -private: - PointReseteableParam *pparam; -}; - -void -PointReseteableParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) -{ - Geom::Point const s = snap_knot_position(p, state); - pparam->param_setValue(s); - sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); -} - -Geom::Point -PointReseteableParamKnotHolderEntity::knot_get() const -{ - return *pparam; -} - -void -PointReseteableParamKnotHolderEntity::knot_click(guint state) -{ - if (state & GDK_CONTROL_MASK) { - if (state & GDK_MOD1_MASK) { - this->pparam->param_set_default(); - sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); - } - } -} - -void -PointReseteableParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) -{ - PointReseteableParamKnotHolderEntity *e = new PointReseteableParamKnotHolderEntity(this); - // TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself??? - e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color); - knotholder->add(e); -} - -} /* namespace LivePathEffect */ - -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/parameter/pointreseteable.h b/src/live_effects/parameter/pointreseteable.h deleted file mode 100644 index 5ae1fdf02..000000000 --- a/src/live_effects/parameter/pointreseteable.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_RESETEABLE_H -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_RESETEABLE_H - -/* - * Inkscape::LivePathEffectParameters - * -* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <glib.h> -#include <2geom/point.h> - -#include "live_effects/parameter/parameter.h" - -#include "knot-holder-entity.h" - -namespace Inkscape { - -namespace LivePathEffect { - -class PointReseteableParamKnotHolderEntity; - -class PointReseteableParam : public Geom::Point, public Parameter { -public: - PointReseteableParam( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, - Inkscape::UI::Widget::Registry* wr, - Effect* effect, - const gchar *handle_tip = NULL, - Geom::Point default_value = Geom::Point(0,0) ); // tip for automatically associated on-canvas handle - virtual ~PointReseteableParam(); - - virtual Gtk::Widget * param_newWidget(); - - bool param_readSVGValue(const gchar * strvalue); - gchar * param_getSVGValue() const; - inline const gchar *handleTip() const { return handle_tip ? handle_tip : param_tooltip.c_str(); } - - void param_setValue(Geom::Point newpoint); - void param_set_default(); - void param_set_and_write_default(); - void param_update_default(Geom::Point newpoint); - - void param_set_and_write_new_value(Geom::Point newpoint); - - virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); - - void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); - - virtual bool providesKnotHolderEntities() const { return true; } - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - - friend class PointReseteableParamKnotHolderEntity; -private: - PointReseteableParam(const PointReseteableParam&); - PointReseteableParam& operator=(const PointReseteableParam&); - - Geom::Point defvalue; - - SPKnotShapeType knot_shape; - SPKnotModeType knot_mode; - guint32 knot_color; - gchar *handle_tip; -}; - - -} //namespace LivePathEffect - -} //namespace Inkscape - -#endif |
