diff options
| author | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-12-05 12:48:06 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-12-05 12:48:06 +0000 |
| commit | c0a73d338290a417a79005a296d8975e12429fb2 (patch) | |
| tree | f9dd2c315a4e42fd615aa60e1562dc434c78af5b /src | |
| parent | Add fix to problem switching pen tool modes (diff) | |
| parent | Attemp to fix compile bug (diff) | |
| download | inkscape-c0a73d338290a417a79005a296d8975e12429fb2.tar.gz inkscape-c0a73d338290a417a79005a296d8975e12429fb2.zip | |
Merge branch 'master' into pen-tool-mode-fixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/parameter/parameter.cpp | 11 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.h | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.cpp | 6 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.h | 1 | ||||
| -rw-r--r-- | src/live_effects/parameter/random.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/parameter/random.h | 1 | ||||
| -rw-r--r-- | src/sp-ellipse.cpp | 59 | ||||
| -rw-r--r-- | src/sp-ellipse.h | 13 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.cpp | 24 | ||||
| -rw-r--r-- | src/ui/widget/registered-widget.h | 5 | ||||
| -rw-r--r-- | src/ui/widget/scalar.cpp | 6 | ||||
| -rw-r--r-- | src/ui/widget/scalar.h | 5 | ||||
| -rw-r--r-- | src/widgets/arc-toolbar.cpp | 57 |
13 files changed, 140 insertions, 57 deletions
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 319ab3fe8..497113e03 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -129,9 +129,6 @@ ScalarParam::param_update_default(const gchar * default_value) void ScalarParam::param_set_value(gdouble val) { - if (value != val) { - param_effect->upd_params = true; - } value = val; if (integer) value = round(value); @@ -180,7 +177,7 @@ ScalarParam::param_set_undo(bool set_undo) Gtk::Widget * ScalarParam::param_newWidget() { - if(widget_is_visible){ + if (widget_is_visible) { Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); @@ -192,6 +189,7 @@ ScalarParam::param_newWidget() if (add_slider) { rsu->addSlider(); } + rsu->signal_button_release_event().connect(sigc::mem_fun (*this, &ScalarParam::on_button_release)); if(_set_undo){ rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } @@ -201,6 +199,11 @@ ScalarParam::param_newWidget() } } +bool ScalarParam::on_button_release(GdkEventButton* button_event) { + param_effect->upd_params = true; + return false; +} + void ScalarParam::param_set_digits(unsigned digits) { diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 1586ef346..aa4212f15 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -141,6 +141,8 @@ protected: bool _set_undo; private: + bool on_button_release(GdkEventButton* button_event); + ScalarParam(const ScalarParam&); ScalarParam& operator=(const ScalarParam&); }; diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index da6edf812..ff5f59ce2 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -146,6 +146,7 @@ PointParam::param_newWidget() pointwdg->setValue( *this ); pointwdg->clearProgrammatically(); pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter")); + pointwdg->signal_button_release_event().connect(sigc::mem_fun (*this, &PointParam::on_button_release)); Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true); @@ -153,6 +154,11 @@ PointParam::param_newWidget() return dynamic_cast<Gtk::Widget *> (hbox); } +bool PointParam::on_button_release(GdkEventButton* button_event) { + param_effect->upd_params = true; + return false; +} + void PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 03256f6d0..6c5f8df65 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -57,6 +57,7 @@ public: private: PointParam(const PointParam&); PointParam& operator=(const PointParam&); + bool on_button_release(GdkEventButton* button_event); Geom::Point defvalue; bool liveupdate; KnotHolder *knoth; diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp index c2c1b5440..4afa43c6e 100644 --- a/src/live_effects/parameter/random.cpp +++ b/src/live_effects/parameter/random.cpp @@ -103,7 +103,6 @@ RandomParam::param_update_default(const gchar * default_value){ void RandomParam::param_set_value(gdouble val, long newseed) { - param_effect->upd_params = true; value = val; if (integer) value = round(value); @@ -154,12 +153,18 @@ RandomParam::param_newWidget() } regrandom->setRange(min, max); regrandom->setProgrammatically = false; + regrandom->signal_button_release_event().connect(sigc::mem_fun (*this, &RandomParam::on_button_release)); regrandom->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change random parameter")); return dynamic_cast<Gtk::Widget *> (regrandom); } +bool RandomParam::on_button_release(GdkEventButton* button_event) { + param_effect->upd_params = true; + return false; +} + RandomParam::operator gdouble() { return rand() * value; diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h index c10473e85..a2c3712a1 100644 --- a/src/live_effects/parameter/random.h +++ b/src/live_effects/parameter/random.h @@ -57,6 +57,7 @@ protected: gdouble defvalue; private: + bool on_button_release(GdkEventButton* button_event); long setup_seed(long); gdouble rand(); diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 166237c8e..c32e3012c 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -721,6 +721,65 @@ bool SPGenericEllipse::_isSlice() const return !(Geom::are_near(a.extent(), 0) || Geom::are_near(a.extent(), SP_2PI)); } +/** +Returns the ratio in which the vector from p0 to p1 is stretched by transform + */ +gdouble SPGenericEllipse::vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform) { + if (p0 == p1) { + return 0; + } + + return (Geom::distance(p0 * xform, p1 * xform) / Geom::distance(p0, p1)); +} + +void SPGenericEllipse::setVisibleRx(gdouble rx) { + if (rx == 0) { + this->rx.unset(); + } else { + this->rx = rx / SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed + 1, this->cy.computed), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); + } + + this->updateRepr(); +} + +void SPGenericEllipse::setVisibleRy(gdouble ry) { + if (ry == 0) { + this->ry.unset(); + } else { + this->ry = ry / SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed, this->cy.computed + 1), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); + } + + this->updateRepr(); +} + +gdouble SPGenericEllipse::getVisibleRx() const { + if (!this->rx._set) { + return 0; + } + + return this->rx.computed * SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed + 1, this->cy.computed), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); +} + +gdouble SPGenericEllipse::getVisibleRy() const { + if (!this->ry._set) { + return 0; + } + + return this->ry.computed * SPGenericEllipse::vectorStretch( + Geom::Point(this->cx.computed, this->cy.computed + 1), + Geom::Point(this->cx.computed, this->cy.computed), + this->i2doc_affine()); +} + /* Local Variables: mode:c++ diff --git a/src/sp-ellipse.h b/src/sp-ellipse.h index a879c596d..a31b571d8 100644 --- a/src/sp-ellipse.h +++ b/src/sp-ellipse.h @@ -20,8 +20,8 @@ #include "sp-shape.h" /* Common parent class */ -#define SP_GENERICELLIPSE(obj) (dynamic_cast<SPGenericEllipse*>(obj)) -#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((obj)) != NULL) +#define SP_GENERICELLIPSE(obj) (dynamic_cast<SPGenericEllipse*>((SPObject*)obj)) +#define SP_IS_GENERICELLIPSE(obj) (dynamic_cast<const SPGenericEllipse*>((SPObject*)obj) != NULL) enum GenericEllipseType { SP_GENERIC_ELLIPSE_UNDEFINED, // FIXME shouldn't exist @@ -83,11 +83,20 @@ public: bool set_elliptical_path_attribute(Inkscape::XML::Node *repr); void position_set(double x, double y, double rx, double ry); + double getVisibleRx() const; + void setVisibleRx(double rx); + + double getVisibleRy() const; + void setVisibleRy(double ry); + protected: /** * @brief Determines whether the shape is a part of an ellipse. */ bool _isSlice() const; + +private: + static double vectorStretch(Geom::Point p0, Geom::Point p1, Geom::Affine xform); }; #endif diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index a88413347..a3b87f89b 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -279,7 +279,6 @@ RegisteredScalar::RegisteredScalar ( const Glib::ustring& label, const Glib::ust init_parent(key, wr, repr_in, doc_in); setProgrammatically = false; - setRange (-1e6, 1e6); setDigits (2); setIncrements(0.1, 1.0); @@ -299,12 +298,14 @@ RegisteredScalar::on_value_changed() _wr->setUpdating (true); Inkscape::SVGOStringStream os; - os << getValue(); - - set_sensitive(false); + //Force exact 0 if decimals over to 6 + double val = getValue() < 1e-6 && getValue() > -1e-6?0.0:getValue(); + os << val; + //TODO: Test is ok remove this sensitives + //also removed in registed text and in registered random + //set_sensitive(false); write_to_xml(os.str().c_str()); - set_sensitive(true); - + //set_sensitive(true); _wr->setUpdating (false); } @@ -342,11 +343,9 @@ RegisteredText::on_activate() } _wr->setUpdating (true); Glib::ustring str(getText()); - set_sensitive(false); Inkscape::SVGOStringStream os; os << str; write_to_xml(os.str().c_str()); - set_sensitive(true); _wr->setUpdating (false); } @@ -757,7 +756,6 @@ RegisteredRandom::RegisteredRandom ( const Glib::ustring& label, const Glib::ust init_parent(key, wr, repr_in, doc_in); setProgrammatically = false; - setRange (-1e6, 1e6); setDigits (2); setIncrements(0.1, 1.0); @@ -786,12 +784,10 @@ RegisteredRandom::on_value_changed() _wr->setUpdating (true); Inkscape::SVGOStringStream os; - os << getValue() << ';' << getStartSeed(); - - set_sensitive(false); + //Force exact 0 if decimals over to 6 + double val = getValue() < 1e-6 && getValue() > -1e-6?0.0:getValue(); + os << val << ';' << getStartSeed(); write_to_xml(os.str().c_str()); - set_sensitive(true); - _wr->setUpdating (false); } diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index f66d5cbf2..78de055de 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -12,11 +12,11 @@ #ifndef INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_ #define INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_ -#include "ui/widget/scalar.h" #include <2geom/affine.h> #include "xml/node.h" #include "registry.h" +#include "ui/widget/scalar.h" #include "ui/widget/scalar-unit.h" #include "ui/widget/point.h" #include "ui/widget/text.h" @@ -244,9 +244,8 @@ public: Registry& wr, Inkscape::XML::Node* repr_in = NULL, SPDocument *doc_in = NULL ); - protected: - sigc::connection _value_changed_connection; + sigc::connection _value_changed_connection; void on_value_changed(); }; diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index f8543a371..937bea697 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -14,7 +14,6 @@ # include <config.h> #endif - #include "scalar.h" #include "spinbutton.h" #include <gtkmm/scale.h> @@ -149,6 +148,11 @@ Glib::SignalProxy0<void> Scalar::signal_value_changed() return static_cast<SpinButton*>(_widget)->signal_value_changed(); } +Glib::SignalProxy1<bool, GdkEventButton*> Scalar::signal_button_release_event() +{ + return static_cast<SpinButton*>(_widget)->signal_button_release_event(); +} + } // namespace Widget } // namespace UI diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index f186f46ac..b2c923953 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -153,6 +153,11 @@ public: Glib::SignalProxy0<void> signal_value_changed(); /** + * Signal raised when the spin button's pressed. + */ + Glib::SignalProxy1<bool, GdkEventButton*> signal_button_release_event(); + + /** * true if the value was set by setValue, not changed by the user; * if a callback checks it, it must reset it back to false. */ diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 3faea1750..907285a60 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -122,9 +122,9 @@ static void sp_arctb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const SPGenericEllipse *ge = SP_GENERICELLIPSE(item); if (!strcmp(value_name, "rx")) { - ge->rx = Quantity::convert(gtk_adjustment_get_value(adj), unit, "px") / scale[Geom::X]; + ge->setVisibleRx(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); } else { - ge->ry = Quantity::convert(gtk_adjustment_get_value(adj), unit, "px") / scale[Geom::Y]; + ge->setVisibleRy(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); } ge->normalize(); @@ -308,37 +308,25 @@ static void arc_tb_event_attr_changed(Inkscape::XML::Node *repr, gchar const * / // in turn, prevent callbacks from responding g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); - UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) ); - Unit const *unit = tracker->getActiveUnit(); - g_return_if_fail(unit != NULL); - - gdouble radius = 0; - gdouble rx = 0; - gdouble ry = 0; - sp_repr_get_double(repr, "r", &radius); - if (radius) { - rx = ry = radius; - } else { - sp_repr_get_double(repr, "rx", &rx); - sp_repr_get_double(repr, "ry", &ry); - } - if (!rx) { - sp_repr_get_double(repr, "sodipodi:rx", &rx); - sp_repr_get_double(repr, "sodipodi:ry", &ry); - } + gpointer item = g_object_get_data( tbl, "item" ); + if (item && SP_IS_GENERICELLIPSE(item)) { + SPGenericEllipse *ge = SP_GENERICELLIPSE(item); - SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" )); - SPDocument* document = desktop->getDocument(); - Geom::Scale scale = document->getDocumentScale(); + UnitTracker* tracker = reinterpret_cast<UnitTracker*>( g_object_get_data( tbl, "tracker" ) ); + Unit const *unit = tracker->getActiveUnit(); + g_return_if_fail(unit != NULL); - GtkAdjustment *adj; - adj = GTK_ADJUSTMENT( g_object_get_data(tbl, "rx") ); - gtk_adjustment_set_value(adj, Quantity::convert(rx, "px", unit) * scale[Geom::X]); - gtk_adjustment_value_changed(adj); + GtkAdjustment *adj; + adj = GTK_ADJUSTMENT( g_object_get_data(tbl, "rx") ); + gdouble rx = ge->getVisibleRx(); + gtk_adjustment_set_value(adj, Quantity::convert(rx, "px", unit)); + gtk_adjustment_value_changed(adj); - adj = GTK_ADJUSTMENT( g_object_get_data(tbl, "ry") ); - gtk_adjustment_set_value(adj, Quantity::convert(ry, "px", unit) * scale[Geom::Y]); - gtk_adjustment_value_changed(adj); + adj = GTK_ADJUSTMENT( g_object_get_data(tbl, "ry") ); + gdouble ry = ge->getVisibleRy(); + gtk_adjustment_set_value(adj, Quantity::convert(ry, "px", unit)); + gtk_adjustment_value_changed(adj); + } gdouble start = 0.; gdouble end = 0.; @@ -387,14 +375,18 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb { int n_selected = 0; Inkscape::XML::Node *repr = NULL; + SPItem *item = NULL; + if ( g_object_get_data( tbl, "repr" ) ) { + g_object_set_data( tbl, "item", NULL ); + } purge_repr_listener( tbl, tbl ); auto itemlist= selection->items(); for(auto i=itemlist.begin();i!=itemlist.end();++i){ - SPItem *item = *i; - if (SP_IS_GENERICELLIPSE(item)) { + if (SP_IS_GENERICELLIPSE(*i)) { n_selected++; + item = *i; repr = item->getRepr(); } } @@ -415,6 +407,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb if (repr) { g_object_set_data( tbl, "repr", repr ); + g_object_set_data( tbl, "item", item ); Inkscape::GC::anchor(repr); sp_repr_add_listener(repr, &arc_tb_repr_events, tbl); sp_repr_synthesize_events(repr, &arc_tb_repr_events, tbl); |
