From: johanengelen Date: Wed, 16 Jan 2008 19:21:46 +0000 (+0000) Subject: RegisteredScalar subclassed from RegisteredWidget instead of old RegisteredWdg X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c2057a738f9ea8cb7acdeb1feb69cef5b0d4bc56;p=inkscape.git RegisteredScalar subclassed from RegisteredWidget instead of old RegisteredWdg --- diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 65caa41cb..51aa43783 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -382,21 +382,22 @@ Gtk::Widget * CanvasAxonomGrid::newSpecificWidget() { Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) ); + table->set_spacings(2); + +_wr.setUpdating (true); Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = new Inkscape::UI::Widget::RegisteredUnitMenu(); Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = new Inkscape::UI::Widget::RegisteredScalarUnit(); Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = new Inkscape::UI::Widget::RegisteredScalarUnit(); Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = new Inkscape::UI::Widget::RegisteredScalarUnit(); - Inkscape::UI::Widget::RegisteredScalar *_rsu_ax = new Inkscape::UI::Widget::RegisteredScalar(); - Inkscape::UI::Widget::RegisteredScalar *_rsu_az = new Inkscape::UI::Widget::RegisteredScalar(); + Inkscape::UI::Widget::RegisteredScalar *_rsu_ax = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( + _("Angle X:"), _("Angle of x-axis"), "gridanglex", _wr, repr, doc ) ); + Inkscape::UI::Widget::RegisteredScalar *_rsu_az = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( + _("Angle Z:"), _("Angle of z-axis"), "gridanglez", _wr, repr, doc ) ); Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gcol = new Inkscape::UI::Widget::RegisteredColorPicker(); Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gmcol = new Inkscape::UI::Widget::RegisteredColorPicker(); Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = new Inkscape::UI::Widget::RegisteredSuffixedInteger(); - // initialize widgets: - table->set_spacings(2); - -_wr.setUpdating (true); Inkscape::UI::Widget::ScalarUnit * sutemp = NULL; _rumg->init (_("Grid _units:"), "units", _wr, repr, doc); _rsu_ox->init (_("_Origin X:"), _("X coordinate of grid origin"), @@ -414,10 +415,6 @@ _wr.setUpdating (true); sutemp = _rsu_sy->getSU(); sutemp->setDigits(4); sutemp->setIncrements(0.1, 1.0); - _rsu_ax->init (_("Angle X:"), _("Angle of x-axis"), - "gridanglex", _wr, repr, doc); - _rsu_az->init (_("Angle Z:"), _("Angle of z-axis"), - "gridanglez", _wr, repr, doc); _rcp_gcol->init (_("Grid line _color:"), _("Grid line color"), _("Color of grid lines"), "color", "opacity", _wr, repr, doc); _rcp_gmcol->init (_("Ma_jor grid line color:"), _("Major grid line color"), @@ -431,8 +428,8 @@ _wr.setUpdating (false); 0, _rsu_ox->getSU(), 0, _rsu_oy->getSU(), 0, _rsu_sy->getSU(), - 0, _rsu_ax->getS(), - 0, _rsu_az->getS(), + 0, _rsu_ax, + 0, _rsu_az, _rcp_gcol->_label, _rcp_gcol->_cp, 0, 0, _rcp_gmcol->_label, _rcp_gmcol->_cp, diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index ca08b2b3d..67111ef9e 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -57,7 +57,6 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, min = -NR_HUGE; max = NR_HUGE; integer = false; - rsu = NULL; inc_step = 0.1; inc_page = 1; digits = 2; @@ -65,8 +64,6 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, ScalarParam::~ScalarParam() { - if (rsu) - delete rsu; } bool @@ -106,9 +103,6 @@ ScalarParam::param_set_value(gdouble val) value = max; if (value < min) value = min; - - if (rsu && !rsu->is_updating()) - rsu->setValue(value); } void @@ -116,8 +110,6 @@ ScalarParam::param_set_range(gdouble min, gdouble max) { this->min = min; this->max = max; - if (rsu) - rsu->getS()->setRange(this->min, this->max); param_set_value(value); // reset value to see whether it is in ranges } @@ -129,37 +121,28 @@ ScalarParam::param_make_integer(bool yes) digits = 0; inc_step = 1; inc_page = 10; - if (rsu) { - rsu->getS()->setDigits(digits); - rsu->getS()->setIncrements(inc_step, inc_page); - } } Gtk::Widget * ScalarParam::param_newWidget(Gtk::Tooltips * tooltips) { - // WIDGET TODO: This implementation is incorrect, it should create a *new* widget for the caller, not just return an already created widget - g_warning("ScalarParam::param_newWidget still needs recoding to work with multiple document views"); - if (!rsu) { - rsu = new Inkscape::UI::Widget::RegisteredScalar(); - rsu->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()); - rsu->setValue(value); - rsu->getS()->setDigits(digits); - rsu->getS()->setIncrements(inc_step, inc_page); - rsu->getS()->setRange(min, max); - - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); - } - return dynamic_cast (rsu->getS()); + 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() ) ); + + rsu->setValue(value); + rsu->setDigits(digits); + rsu->setIncrements(inc_step, inc_page); + rsu->setRange(min, max); + + rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + + return dynamic_cast (rsu); } void ScalarParam::param_set_digits(unsigned digits) { this->digits = digits; - if (rsu) { - rsu->getS()->setDigits(digits); - } } void @@ -167,9 +150,6 @@ ScalarParam::param_set_increments(double step, double page) { inc_step = step; inc_page = page; - if (rsu) { - rsu->getS()->setIncrements(inc_step, inc_page); - } } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 67384a6e6..256ab343f 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -108,7 +108,6 @@ protected: gdouble max; bool integer; gdouble defvalue; - Inkscape::UI::Widget::RegisteredScalar * rsu; unsigned digits; double inc_step; double inc_page; diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 6848dbe05..dfa42107e 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -270,51 +270,33 @@ RegisteredScalarUnit::on_value_changed() } -RegisteredScalar::RegisteredScalar() -{ - _widget = NULL; -} +/*######################################### + * Registered SCALAR + */ RegisteredScalar::~RegisteredScalar() { - if (_widget) - delete _widget; - _value_changed_connection.disconnect(); } -void -RegisteredScalar::init ( const Glib::ustring& label, const Glib::ustring& tip, +RegisteredScalar::RegisteredScalar ( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument * doc_in ) + : RegisteredWidget(label, tip) { init_parent(key, wr, repr_in, doc_in); - _widget = new Scalar (label, tip); - _widget->setRange (-1e6, 1e6); - _widget->setDigits (2); - _widget->setIncrements(0.1, 1.0); - _value_changed_connection = _widget->signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalar::on_value_changed)); -} - -Scalar* -RegisteredScalar::getS() -{ - return _widget; -} - -void -RegisteredScalar::setValue (double val) -{ - if (_widget) - _widget->setValue (val); + setRange (-1e6, 1e6); + setDigits (2); + setIncrements(0.1, 1.0); + _value_changed_connection = signal_value_changed().connect (sigc::mem_fun (*this, &RegisteredScalar::on_value_changed)); } void RegisteredScalar::on_value_changed() { - if (_widget->setProgrammatically) { - _widget->setProgrammatically = false; + if (setProgrammatically) { + setProgrammatically = false; return; } @@ -324,16 +306,20 @@ RegisteredScalar::on_value_changed() _wr->setUpdating (true); Inkscape::SVGOStringStream os; - os << _widget->getValue(); + os << getValue(); - _widget->set_sensitive(false); + set_sensitive(false); write_to_xml(os.str().c_str()); - _widget->set_sensitive(true); + set_sensitive(true); _wr->setUpdating (false); } +/*######################################### + * Registered COLORPICKER + */ + RegisteredColorPicker::RegisteredColorPicker() : _label(0), _cp(0) { diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 185d1e3b4..9a0ba46fc 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -218,27 +218,17 @@ protected: void on_value_changed(); }; -class RegisteredScalar : public RegisteredWdg { +class RegisteredScalar : public RegisteredWidget { public: - RegisteredScalar(); - ~RegisteredScalar(); - void init (const Glib::ustring& label, + virtual ~RegisteredScalar(); + RegisteredScalar (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, - Inkscape::XML::Node* repr_in, - SPDocument *doc_in); - inline void init ( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, - Registry& wr) - { init(label, tip, key, wr, NULL, NULL); }; - - Scalar* getS(); - void setValue (double); + Inkscape::XML::Node* repr_in = NULL, + SPDocument *doc_in = NULL ); protected: - Scalar *_widget; sigc::connection _value_changed_connection; void on_value_changed(); };