From e7afb49bd67284227bf5df1df22f9993b1bfa581 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 21 Jul 2016 21:05:55 +0200 Subject: =?UTF-8?q?This=20for=20you=20CR=20=C2=B7=20Measure=20line,=20show?= =?UTF-8?q?=20the=20distance=20on=20rect=20lines=20CAD=20like=20with=20aut?= =?UTF-8?q?o=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r15017.1.1) --- src/live_effects/parameter/texttopath.cpp | 125 ++++++++++++++++++++++++++++++ src/live_effects/parameter/texttopath.h | 87 +++++++++++++++++++++ 2 files changed, 212 insertions(+) create mode 100644 src/live_effects/parameter/texttopath.cpp create mode 100644 src/live_effects/parameter/texttopath.h (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/texttopath.cpp b/src/live_effects/parameter/texttopath.cpp new file mode 100644 index 000000000..8625e4d71 --- /dev/null +++ b/src/live_effects/parameter/texttopath.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) Maximilian Albert 2008 + * + * Authors: + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "ui/widget/registered-widget.h" +#include + +#include "live_effects/parameter/texttopath.h" +#include "live_effects/effect.h" +#include "svg/svg.h" +#include "svg/stringstream.h" +#include "widgets/icon.h" +#include "inkscape.h" +#include "verbs.h" +#include "display/canvas-text.h" + +#include <2geom/sbasis-geometric.h> + +namespace Inkscape { + +namespace LivePathEffect { + +TextToPathParam::TextToPathParam( const Glib::ustring& label, const Glib::ustring& tip, + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, + Effect* effect, const Glib::ustring default_value ) + : Parameter(label, tip, key, wr, effect), + value(default_value), + defvalue(default_value) +{ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this! + canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); + sp_canvastext_set_text (canvas_text, default_value.c_str()); + sp_canvastext_set_coords (canvas_text, 0, 0); +} + +void +TextToPathParam::param_set_default() +{ + param_setValue(defvalue); +} + +void +TextToPathParam::setPos(Geom::Point pos) +{ + sp_canvastext_set_coords (canvas_text, pos); +} + +void +TextToPathParam::setPosAndAnchor(const Geom::Piecewise > &pwd2, + const double t, const double length, bool /*use_curvature*/) +{ + using namespace Geom; + + Piecewise > pwd2_reparam = arc_length_parametrization(pwd2, 2 , 0.1); + double t_reparam = pwd2_reparam.cuts.back() * t; + Point pos = pwd2_reparam.valueAt(t_reparam); + Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam)); + Point n = -rot90(dir); + double angle = Geom::angle_between(dir, Point(1,0)); + + sp_canvastext_set_coords(canvas_text, pos + n * length); + sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle)); +} + +void +TextToPathParam::setAnchor(double x_value, double y_value) +{ + anchor_x = x_value; + anchor_y = y_value; + sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y); +} + +bool +TextToPathParam::param_readSVGValue(const gchar * strvalue) +{ + param_setValue(strvalue); + return true; +} + +gchar * +TextToPathParam::param_getSVGValue() const +{ + return g_strdup(value.c_str()); +} + +Gtk::Widget * +TextToPathParam::param_newWidget() +{ + Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( + param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); + + rsu->setText(value.c_str()); + rsu->setProgrammatically = false; + + rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter")); + + return dynamic_cast (rsu); +} + +void +TextToPathParam::param_setValue(const Glib::ustring newvalue) +{ + value = newvalue; + + sp_canvastext_set_text (canvas_text, newvalue.c_str()); +} + +} /* 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/texttopath.h b/src/live_effects/parameter/texttopath.h new file mode 100644 index 000000000..9a0ee38e2 --- /dev/null +++ b/src/live_effects/parameter/texttopath.h @@ -0,0 +1,87 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_TEXT_TO_PATH_H +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TEXT_TO_PATH_H + +/* + * Inkscape::LivePathEffectParameters + * + * Authors: + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include + +#include "display/canvas-bpath.h" +#include "live_effects/parameter/parameter.h" + +struct SPCanvasText; + +namespace Inkscape { + +namespace LivePathEffect { + +class TextToPathParam : public Parameter { +public: + TextToPathParam( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Inkscape::UI::Widget::Registry* wr, + Effect* effect, + const Glib::ustring default_value = ""); + virtual ~TextToPathParam() {} + + virtual Gtk::Widget * param_newWidget(); + + virtual bool param_readSVGValue(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + + void param_setValue(const Glib::ustring newvalue); + virtual void param_set_default(); + void setPos(Geom::Point pos); + void setPosAndAnchor(const Geom::Piecewise > &pwd2, + const double t, const double length, bool use_curvature = false); + void setAnchor(double x_value, double y_value); + + const Glib::ustring get_value() const { return defvalue; }; + +private: + TextToPathParam(const TextToPathParam&); + TextToPathParam& operator=(const TextToPathParam&); + double anchor_x; + double anchor_y; + + Glib::ustring value; + Glib::ustring defvalue; + + SPCanvasText *canvas_text; +}; + +/* + * This parameter does not display a widget in the LPE dialog; LPEs can use it to display on-canvas + * text that should not be settable by the user. Note that since no widget is provided, the + * parameter must be initialized differently than usual (only with a pointer to the parent effect; + * no label, no tooltip, etc.). + */ +class TextToPathParamInternal : public TextToPathParam { +public: + TextToPathParamInternal(Effect* effect) : + TextToPathParam("", "", "", NULL, effect) {} + + virtual Gtk::Widget * param_newWidget() { return NULL; } +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif + +/* + 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 : -- cgit v1.2.3 From a5d6c9a27683820be3d84eea73c2d6f161ce0e8e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 24 Jul 2016 18:49:11 +0200 Subject: Add Text tag and update widgets code (bzr r15017.1.2) --- src/live_effects/parameter/font.cpp | 126 ++++++++++++++++++++++++++++ src/live_effects/parameter/font.h | 77 +++++++++++++++++ src/live_effects/parameter/point.cpp | 2 +- src/live_effects/parameter/point.h | 1 - src/live_effects/parameter/texttopath.cpp | 125 --------------------------- src/live_effects/parameter/texttopath.h | 87 ------------------- src/live_effects/parameter/togglebutton.cpp | 8 ++ 7 files changed, 212 insertions(+), 214 deletions(-) create mode 100644 src/live_effects/parameter/font.cpp create mode 100644 src/live_effects/parameter/font.h delete mode 100644 src/live_effects/parameter/texttopath.cpp delete mode 100644 src/live_effects/parameter/texttopath.h (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/font.cpp b/src/live_effects/parameter/font.cpp new file mode 100644 index 000000000..174b66152 --- /dev/null +++ b/src/live_effects/parameter/font.cpp @@ -0,0 +1,126 @@ +/* + * Authors: + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + +#include "ui/widget/registered-widget.h" +#include "live_effects/parameter/font.h" +#include "live_effects/effect.h" +#include "ui/widget/font-selector.h" +#include "svg/svg.h" +#include "svg/stringstream.h" +#include "verbs.h" + +#include + +namespace Inkscape { + +namespace LivePathEffect { + +FontParam::FontParam( const Glib::ustring& label, const Glib::ustring& tip, + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, + Effect* effect, const Glib::ustring default_value ) + : Parameter(label, tip, key, wr, effect), + value(default_value), + defvalue(default_value) +{ +} + +void +FontParam::param_set_default() +{ + param_setValue(defvalue); +} + + +Glib::ustring +FontParam::param_readFontSpec(const gchar * strvalue) +{ + Glib::ustring result; + gchar ** strarray = g_strsplit(strvalue, " @ ", 2); + double fontsize; + if (strarray[1]) { + unsigned int success = sp_svg_number_read_d(strarray[1], &fontsize); + if (success == 1) { + result = (Glib::ustring)strarray[0]; + g_strfreev (strarray); + return result; + } + } + g_strfreev (strarray); + return result; +} + +double +FontParam::param_readFontSize(const gchar * strvalue) +{ + gchar ** strarray = g_strsplit(strvalue, " @ ", 2); + double fontsize = 0; + if (strarray[1]) { + unsigned int success = sp_svg_number_read_d(strarray[1], &fontsize); + if (success == 1) { + g_strfreev (strarray); + return fontsize; + } + } + g_strfreev (strarray); + return fontsize; +} + +bool +FontParam::param_readSVGValue(const gchar * strvalue) +{ + double fontsize = param_readFontSize(strvalue); + Glib::ustring fontspec = param_readFontSpec(strvalue); + Inkscape::SVGOStringStream os; + os << fontspec << " @ " << fontsize; + param_setValue((Glib::ustring)os.str()); + return true; +} + +gchar * +FontParam::param_getSVGValue() const +{ + return g_strdup(value.c_str()); +} + +Gtk::Widget * +FontParam::param_newWidget() +{ + Inkscape::UI::Widget::RegisteredFontSelector * fontselectorwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredFontSelector( param_label, + param_tooltip, + param_key, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc() ) ); + double fontsize = param_readFontSize(param_getSVGValue()); + Glib::ustring fontspec = param_readFontSpec(param_getSVGValue()); + fontselectorwdg->setValue( fontspec, fontsize ); + fontselectorwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font selector parameter")); + + return dynamic_cast (fontselectorwdg); +} + +void +FontParam::param_setValue(const Glib::ustring newvalue) +{ + value = newvalue; +} + +} /* 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/font.h b/src/live_effects/parameter/font.h new file mode 100644 index 000000000..e7bcc59d2 --- /dev/null +++ b/src/live_effects/parameter/font.h @@ -0,0 +1,77 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H + +/* + * Inkscape::LivePathEffectParameters + * + * Authors: + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#include +#include +#include "live_effects/parameter/parameter.h" + +namespace Inkscape { + +namespace LivePathEffect { + +class FontParam : public Parameter { +public: + FontParam( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Inkscape::UI::Widget::Registry* wr, + Effect* effect, + const Glib::ustring default_value = ""); + virtual ~FontParam() {} + + virtual Gtk::Widget * param_newWidget(); + virtual bool param_readSVGValue(const gchar * strvalue); + double param_readFontSize(const gchar * strvalue); + Glib::ustring param_readFontSpec(const gchar * strvalue); + virtual gchar * param_getSVGValue() const; + + void param_setValue(const Glib::ustring newvalue); + + virtual void param_set_default(); + + const Glib::ustring get_value() const { return defvalue; }; + +private: + FontParam(const FontParam&); + FontParam& operator=(const FontParam&); + Glib::ustring value; + Glib::ustring defvalue; + +}; + +/* + * This parameter does not display a widget in the LPE dialog; LPEs can use it to display on-canvas + * text that should not be settable by the user. Note that since no widget is provided, the + * parameter must be initialized differently than usual (only with a pointer to the parent effect; + * no label, no tooltip, etc.). + */ +class FontParamInternal : public FontParam { +public: + FontParamInternal(Effect* effect) : + FontParam("", "", "", NULL, effect) {} + + virtual Gtk::Widget * param_newWidget() { return NULL; } +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif + +/* + 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/point.cpp b/src/live_effects/parameter/point.cpp index ca3471b29..b4f2c7758 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -134,7 +134,7 @@ PointParam::param_newWidget() Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); static_cast(hbox)->pack_start(*pointwdg, true, true); static_cast(hbox)->show_all_children(); - + param_effect->upd_params = false; return dynamic_cast (hbox); } diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 4329e0bcd..06773c80e 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -11,7 +11,6 @@ #include #include <2geom/point.h> - #include "live_effects/parameter/parameter.h" #include "knot-holder-entity.h" diff --git a/src/live_effects/parameter/texttopath.cpp b/src/live_effects/parameter/texttopath.cpp deleted file mode 100644 index 8625e4d71..000000000 --- a/src/live_effects/parameter/texttopath.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) Maximilian Albert 2008 - * - * Authors: - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "ui/widget/registered-widget.h" -#include - -#include "live_effects/parameter/texttopath.h" -#include "live_effects/effect.h" -#include "svg/svg.h" -#include "svg/stringstream.h" -#include "widgets/icon.h" -#include "inkscape.h" -#include "verbs.h" -#include "display/canvas-text.h" - -#include <2geom/sbasis-geometric.h> - -namespace Inkscape { - -namespace LivePathEffect { - -TextToPathParam::TextToPathParam( const Glib::ustring& label, const Glib::ustring& tip, - const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const Glib::ustring default_value ) - : Parameter(label, tip, key, wr, effect), - value(default_value), - defvalue(default_value) -{ - SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this! - canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); - sp_canvastext_set_text (canvas_text, default_value.c_str()); - sp_canvastext_set_coords (canvas_text, 0, 0); -} - -void -TextToPathParam::param_set_default() -{ - param_setValue(defvalue); -} - -void -TextToPathParam::setPos(Geom::Point pos) -{ - sp_canvastext_set_coords (canvas_text, pos); -} - -void -TextToPathParam::setPosAndAnchor(const Geom::Piecewise > &pwd2, - const double t, const double length, bool /*use_curvature*/) -{ - using namespace Geom; - - Piecewise > pwd2_reparam = arc_length_parametrization(pwd2, 2 , 0.1); - double t_reparam = pwd2_reparam.cuts.back() * t; - Point pos = pwd2_reparam.valueAt(t_reparam); - Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam)); - Point n = -rot90(dir); - double angle = Geom::angle_between(dir, Point(1,0)); - - sp_canvastext_set_coords(canvas_text, pos + n * length); - sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle)); -} - -void -TextToPathParam::setAnchor(double x_value, double y_value) -{ - anchor_x = x_value; - anchor_y = y_value; - sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y); -} - -bool -TextToPathParam::param_readSVGValue(const gchar * strvalue) -{ - param_setValue(strvalue); - return true; -} - -gchar * -TextToPathParam::param_getSVGValue() const -{ - return g_strdup(value.c_str()); -} - -Gtk::Widget * -TextToPathParam::param_newWidget() -{ - Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( - param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); - - rsu->setText(value.c_str()); - rsu->setProgrammatically = false; - - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter")); - - return dynamic_cast (rsu); -} - -void -TextToPathParam::param_setValue(const Glib::ustring newvalue) -{ - value = newvalue; - - sp_canvastext_set_text (canvas_text, newvalue.c_str()); -} - -} /* 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/texttopath.h b/src/live_effects/parameter/texttopath.h deleted file mode 100644 index 9a0ee38e2..000000000 --- a/src/live_effects/parameter/texttopath.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_TEXT_TO_PATH_H -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TEXT_TO_PATH_H - -/* - * Inkscape::LivePathEffectParameters - * - * Authors: - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include - -#include "display/canvas-bpath.h" -#include "live_effects/parameter/parameter.h" - -struct SPCanvasText; - -namespace Inkscape { - -namespace LivePathEffect { - -class TextToPathParam : public Parameter { -public: - TextToPathParam( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, - Inkscape::UI::Widget::Registry* wr, - Effect* effect, - const Glib::ustring default_value = ""); - virtual ~TextToPathParam() {} - - virtual Gtk::Widget * param_newWidget(); - - virtual bool param_readSVGValue(const gchar * strvalue); - virtual gchar * param_getSVGValue() const; - - void param_setValue(const Glib::ustring newvalue); - virtual void param_set_default(); - void setPos(Geom::Point pos); - void setPosAndAnchor(const Geom::Piecewise > &pwd2, - const double t, const double length, bool use_curvature = false); - void setAnchor(double x_value, double y_value); - - const Glib::ustring get_value() const { return defvalue; }; - -private: - TextToPathParam(const TextToPathParam&); - TextToPathParam& operator=(const TextToPathParam&); - double anchor_x; - double anchor_y; - - Glib::ustring value; - Glib::ustring defvalue; - - SPCanvasText *canvas_text; -}; - -/* - * This parameter does not display a widget in the LPE dialog; LPEs can use it to display on-canvas - * text that should not be settable by the user. Note that since no widget is provided, the - * parameter must be initialized differently than usual (only with a pointer to the parent effect; - * no label, no tooltip, etc.). - */ -class TextToPathParamInternal : public TextToPathParam { -public: - TextToPathParamInternal(Effect* effect) : - TextToPathParam("", "", "", NULL, effect) {} - - virtual Gtk::Widget * param_newWidget() { return NULL; } -}; - -} //namespace LivePathEffect - -} //namespace Inkscape - -#endif - -/* - 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/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index 47a8b5615..5977a5114 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -12,6 +12,7 @@ #include "live_effects/effect.h" #include "svg/svg.h" #include "svg/stringstream.h" +#include "selection.h" #include "widgets/icon.h" #include "inkscape.h" #include "verbs.h" @@ -106,6 +107,7 @@ ToggleButtonParam::param_newWidget() }else{ gtk_box_pack_start (GTK_BOX(boxButton), labelButton, false, false, 1); } + param_effect->upd_params = false; checkwdg->add(*Gtk::manage(Glib::wrap(boxButton))); checkwdg->setActive(value); checkwdg->setProgrammatically = false; @@ -157,6 +159,12 @@ ToggleButtonParam::param_setValue(bool newvalue) void ToggleButtonParam::toggled() { + //Force redraw for update widgets + param_effect->upd_params = true; + if (SP_ACTIVE_DESKTOP) { + Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection(); + selection ->emitModified(); + } _signal_toggled.emit(); } -- cgit v1.2.3 From 066d5189a44b52d9bb4f75633e6748b73bfc2a8a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 24 Jul 2016 19:00:29 +0200 Subject: Fix a var name bug (bzr r15017.1.4) --- src/live_effects/parameter/togglebutton.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index b30a5a3d2..dd1717b40 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -110,7 +110,7 @@ ToggleButtonParam::param_newWidget() gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1); } - checkwdg->add(*Gtk::manage(Glib::wrap(boxButton))); + checkwdg->add(*Gtk::manage(Glib::wrap(box_button))); checkwdg->setActive(value); checkwdg->setProgrammatically = false; checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter")); -- cgit v1.2.3 From 10790202dbd81463005cc3ae7cdb6f2068003adb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 25 Jul 2016 01:43:33 +0200 Subject: Add strore parameters (bzr r15017.1.5) --- src/live_effects/parameter/bool.cpp | 6 ++++++ src/live_effects/parameter/bool.h | 2 +- src/live_effects/parameter/font.cpp | 7 +++++-- src/live_effects/parameter/font.h | 1 + src/live_effects/parameter/parameter.cpp | 7 +++++++ src/live_effects/parameter/parameter.h | 1 + src/live_effects/parameter/point.cpp | 4 ++-- src/live_effects/parameter/point.h | 2 +- src/live_effects/parameter/unit.cpp | 6 ++++++ src/live_effects/parameter/unit.h | 1 + 10 files changed, 31 insertions(+), 6 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index 9ecadbdeb..af99ef362 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -36,6 +36,12 @@ BoolParam::param_set_default() param_setValue(defvalue); } +void +BoolParam::param_update_default(bool const default_value) +{ + defvalue = default_value; +} + bool BoolParam::param_readSVGValue(const gchar * strvalue) { diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h index 403dd0b87..7ad8a9368 100644 --- a/src/live_effects/parameter/bool.h +++ b/src/live_effects/parameter/bool.h @@ -36,7 +36,7 @@ public: void param_setValue(bool newvalue); virtual void param_set_default(); - + void param_update_default(bool const default_value); bool get_value() const { return value; }; inline operator bool() const { return value; }; diff --git a/src/live_effects/parameter/font.cpp b/src/live_effects/parameter/font.cpp index 174b66152..8f89ee5c4 100644 --- a/src/live_effects/parameter/font.cpp +++ b/src/live_effects/parameter/font.cpp @@ -33,7 +33,10 @@ FontParam::param_set_default() { param_setValue(defvalue); } - +void +FontParam::param_update_default(const Glib::ustring default_value){ + defvalue = default_value; +} Glib::ustring FontParam::param_readFontSpec(const gchar * strvalue) @@ -100,7 +103,7 @@ FontParam::param_newWidget() Glib::ustring fontspec = param_readFontSpec(param_getSVGValue()); fontselectorwdg->setValue( fontspec, fontsize ); fontselectorwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font selector parameter")); - + param_effect->upd_params = false; return dynamic_cast (fontselectorwdg); } diff --git a/src/live_effects/parameter/font.h b/src/live_effects/parameter/font.h index e7bcc59d2..3909ea424 100644 --- a/src/live_effects/parameter/font.h +++ b/src/live_effects/parameter/font.h @@ -28,6 +28,7 @@ public: virtual Gtk::Widget * param_newWidget(); virtual bool param_readSVGValue(const gchar * strvalue); double param_readFontSize(const gchar * strvalue); + void param_update_default(const Glib::ustring defvalue); Glib::ustring param_readFontSpec(const gchar * strvalue); virtual gchar * param_getSVGValue() const; diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index d4e213948..ae55c84e9 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -101,6 +101,12 @@ ScalarParam::param_set_default() param_set_value(defvalue); } +void +ScalarParam::param_update_default(gdouble default_value) +{ + defvalue = default_value; +} + void ScalarParam::param_set_value(gdouble val) { @@ -169,6 +175,7 @@ ScalarParam::param_newWidget() if(!overwrite_widget){ rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } + param_effect->upd_params = false; return dynamic_cast (rsu); } else { return NULL; diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 0ef28650a..8556b0d9a 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -110,6 +110,7 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); + void param_update_default(gdouble default_value); void param_set_value(gdouble val); void param_make_integer(bool yes = true); void param_set_range(gdouble min, gdouble max); diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index b4f2c7758..90a5b252b 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -62,9 +62,9 @@ PointParam::param_get_default() const{ } void -PointParam::param_update_default(Geom::Point newpoint) +PointParam::param_update_default(const Geom::Point default_point) { - defvalue = newpoint; + defvalue = default_point; } void diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index 06773c80e..d41e8a710 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -42,7 +42,7 @@ public: void param_set_default(); Geom::Point param_get_default() const; void param_set_liveupdate(bool live_update); - void param_update_default(Geom::Point newpoint); + void param_update_default(const Geom::Point default_point); virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/); void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color); diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp index 0ee553e2c..b6ea99bfe 100644 --- a/src/live_effects/parameter/unit.cpp +++ b/src/live_effects/parameter/unit.cpp @@ -54,6 +54,12 @@ UnitParam::param_set_default() param_set_value(*defunit); } +void +UnitParam::param_update_default(const Glib::ustring default_unit) +{ + defunit = unit_table.getUnit(default_unit); +} + void UnitParam::param_set_value(Inkscape::Util::Unit const &val) { diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h index 59a483018..ae58cf956 100644 --- a/src/live_effects/parameter/unit.h +++ b/src/live_effects/parameter/unit.h @@ -33,6 +33,7 @@ public: virtual gchar * param_getSVGValue() const; virtual void param_set_default(); void param_set_value(Inkscape::Util::Unit const &val); + void param_update_default(const Glib::ustring default_unit); const gchar *get_abbreviation() const; virtual Gtk::Widget * param_newWidget(); -- cgit v1.2.3 From 881b103a91e5668c1f7333ac989e4a968aa92aed Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 29 Jul 2016 12:06:16 +0200 Subject: Improvements to widget redraw (bzr r15017.1.11) --- src/live_effects/parameter/parameter.cpp | 38 +++++++++++++++++++++----------- src/live_effects/parameter/parameter.h | 2 ++ src/live_effects/parameter/point.cpp | 31 ++++++++++++++------------ src/live_effects/parameter/point.h | 2 ++ 4 files changed, 46 insertions(+), 27 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index ae55c84e9..3f8fced4b 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -4,8 +4,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/registered-widget.h" -#include #include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" @@ -16,6 +14,8 @@ #include "verbs.h" +#include + #define noLPEREALPARAM_DEBUG namespace Inkscape { @@ -66,7 +66,8 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, inc_page(1), add_slider(false), overwrite_widget(false), - hide_widget(no_widget) + hide_widget(no_widget), + _rsu(NULL) { } @@ -117,6 +118,9 @@ ScalarParam::param_set_value(gdouble val) value = max; if (value < min) value = min; + if (_rsu) { + _rsu->setValue(val); + } } void @@ -138,7 +142,9 @@ ScalarParam::param_set_range(gdouble min, gdouble max) } else { this->max = SCALARPARAM_G_MAXDOUBLE; } - + if (_rsu) { + _rsu->setRange(this->min, this->max); + } param_set_value(value); // reset value to see whether it is in ranges } @@ -161,22 +167,22 @@ Gtk::Widget * ScalarParam::param_newWidget() { if(!hide_widget){ - Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new 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->setProgrammatically = false; + _rsu->setValue(value); + _rsu->setDigits(digits); + _rsu->setIncrements(inc_step, inc_page); + _rsu->setRange(min, max); + _rsu->setProgrammatically = false; if (add_slider) { - rsu->addSlider(); + _rsu->addSlider(); } if(!overwrite_widget){ - rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + _rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } param_effect->upd_params = false; - return dynamic_cast (rsu); + return dynamic_cast (_rsu); } else { return NULL; } @@ -186,6 +192,9 @@ void ScalarParam::param_set_digits(unsigned digits) { this->digits = digits; + if (_rsu) { + _rsu->setDigits(this->digits); + } } void @@ -193,6 +202,9 @@ ScalarParam::param_set_increments(double step, double page) { inc_step = step; inc_page = page; + if (_rsu) { + _rsu->setIncrements(inc_step, inc_page); + } } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 8556b0d9a..63c55203e 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -12,6 +12,7 @@ #include #include <2geom/forward.h> #include <2geom/pathvector.h> +#include "ui/widget/registered-widget.h" // In gtk2, this wasn't an issue; we could toss around // G_MAXDOUBLE and not worry about size allocations. But @@ -140,6 +141,7 @@ protected: private: ScalarParam(const ScalarParam&); ScalarParam& operator=(const ScalarParam&); + Inkscape::UI::Widget::RegisteredScalar *_rsu; }; } //namespace LivePathEffect diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 90a5b252b..3442fd851 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -4,7 +4,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/registered-widget.h" #include "live_effects/parameter/point.h" #include "live_effects/effect.h" #include "svg/svg.h" @@ -30,7 +29,8 @@ PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip, : Parameter(label, tip, key, wr, effect), defvalue(default_value), liveupdate(live_update), - knoth(NULL) + knoth(NULL), + _pointwdg(NULL) { knot_shape = SP_KNOT_SHAPE_DIAMOND; knot_mode = SP_KNOT_MODE_XOR; @@ -81,6 +81,9 @@ PointParam::param_setValue(Geom::Point newpoint, bool write) if(knoth && liveupdate){ knoth->update_knots(); } + if (_pointwdg) { + _pointwdg->setValue( newpoint ); + } } bool @@ -116,7 +119,7 @@ PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) Gtk::Widget * PointParam::param_newWidget() { - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( + _pointwdg = Gtk::manage( new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, param_tooltip, param_key, @@ -126,13 +129,13 @@ PointParam::param_newWidget() // 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")); + _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(hbox)->pack_start(*pointwdg, true, true); + static_cast(hbox)->pack_start(*_pointwdg, true, true); static_cast(hbox)->show_all_children(); param_effect->upd_params = false; return dynamic_cast (hbox); @@ -191,13 +194,13 @@ void PointParamKnotHolderEntity::knot_click(guint state) { if (state & GDK_CONTROL_MASK) { - if (state & GDK_MOD1_MASK) { - this->pparam->param_set_default(); - SPLPEItem * splpeitem = dynamic_cast(item); - if(splpeitem){ - sp_lpe_item_update_patheffect(splpeitem, false, false); - } + if (state & GDK_MOD1_MASK) { + this->pparam->param_set_default(); + SPLPEItem * splpeitem = dynamic_cast(item); + if(splpeitem){ + sp_lpe_item_update_patheffect(splpeitem, false, false); } + } } } diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h index d41e8a710..62c6fb83d 100644 --- a/src/live_effects/parameter/point.h +++ b/src/live_effects/parameter/point.h @@ -11,6 +11,7 @@ #include #include <2geom/point.h> +#include "ui/widget/registered-widget.h" #include "live_effects/parameter/parameter.h" #include "knot-holder-entity.h" @@ -61,6 +62,7 @@ private: SPKnotModeType knot_mode; guint32 knot_color; gchar *handle_tip; + Inkscape::UI::Widget::RegisteredTransformedPoint * _pointwdg; }; -- cgit v1.2.3 From 53500549df51879d6a7aaec5a0c8c37ca7087817 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 29 Jul 2016 20:28:00 +0200 Subject: Add orientation and alow unsort combobox enum widget (bzr r15017.1.12) --- src/live_effects/parameter/enum.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h index 2340663c3..dbfc68623 100644 --- a/src/live_effects/parameter/enum.h +++ b/src/live_effects/parameter/enum.h @@ -27,12 +27,14 @@ public: const Util::EnumDataConverter& c, Inkscape::UI::Widget::Registry* wr, Effect* effect, - E default_value) + E default_value, + bool sort = true) : Parameter(label, tip, key, wr, effect) { enumdataconv = &c; defvalue = default_value; value = defvalue; + sorted = sort; }; virtual ~EnumParam() { }; @@ -40,12 +42,11 @@ public: virtual Gtk::Widget * param_newWidget() { Inkscape::UI::Widget::RegisteredEnum *regenum = Gtk::manage ( new Inkscape::UI::Widget::RegisteredEnum( param_label, param_tooltip, - param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) ); regenum->set_active_by_id(value); regenum->combobox()->setProgrammatically = false; regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter")); - return dynamic_cast (regenum); }; @@ -86,6 +87,7 @@ private: E value; E defvalue; + bool sorted; const Util::EnumDataConverter * enumdataconv; }; -- cgit v1.2.3 From d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 30 Jul 2016 01:44:17 +0200 Subject: Remove font-Dialog and useGtk::FontSelector instead (bzr r15017.1.13) --- src/live_effects/parameter/Makefile_insert | 2 + src/live_effects/parameter/font.cpp | 129 ----------------------------- src/live_effects/parameter/font.h | 78 ----------------- src/live_effects/parameter/fontbutton.cpp | 92 ++++++++++++++++++++ src/live_effects/parameter/fontbutton.h | 62 ++++++++++++++ 5 files changed, 156 insertions(+), 207 deletions(-) delete mode 100644 src/live_effects/parameter/font.cpp delete mode 100644 src/live_effects/parameter/font.h create mode 100644 src/live_effects/parameter/fontbutton.cpp create mode 100644 src/live_effects/parameter/fontbutton.h (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert index bd1c5b600..d9cd5b3c1 100644 --- a/src/live_effects/parameter/Makefile_insert +++ b/src/live_effects/parameter/Makefile_insert @@ -11,6 +11,8 @@ ink_common_sources += \ live_effects/parameter/random.h \ live_effects/parameter/point.cpp \ live_effects/parameter/point.h \ + live_effects/parameter/fontbutton.cpp \ + live_effects/parameter/fontbutton.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/font.cpp b/src/live_effects/parameter/font.cpp deleted file mode 100644 index 8f89ee5c4..000000000 --- a/src/live_effects/parameter/font.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Authors: - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - - -#include "ui/widget/registered-widget.h" -#include "live_effects/parameter/font.h" -#include "live_effects/effect.h" -#include "ui/widget/font-selector.h" -#include "svg/svg.h" -#include "svg/stringstream.h" -#include "verbs.h" - -#include - -namespace Inkscape { - -namespace LivePathEffect { - -FontParam::FontParam( const Glib::ustring& label, const Glib::ustring& tip, - const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, - Effect* effect, const Glib::ustring default_value ) - : Parameter(label, tip, key, wr, effect), - value(default_value), - defvalue(default_value) -{ -} - -void -FontParam::param_set_default() -{ - param_setValue(defvalue); -} -void -FontParam::param_update_default(const Glib::ustring default_value){ - defvalue = default_value; -} - -Glib::ustring -FontParam::param_readFontSpec(const gchar * strvalue) -{ - Glib::ustring result; - gchar ** strarray = g_strsplit(strvalue, " @ ", 2); - double fontsize; - if (strarray[1]) { - unsigned int success = sp_svg_number_read_d(strarray[1], &fontsize); - if (success == 1) { - result = (Glib::ustring)strarray[0]; - g_strfreev (strarray); - return result; - } - } - g_strfreev (strarray); - return result; -} - -double -FontParam::param_readFontSize(const gchar * strvalue) -{ - gchar ** strarray = g_strsplit(strvalue, " @ ", 2); - double fontsize = 0; - if (strarray[1]) { - unsigned int success = sp_svg_number_read_d(strarray[1], &fontsize); - if (success == 1) { - g_strfreev (strarray); - return fontsize; - } - } - g_strfreev (strarray); - return fontsize; -} - -bool -FontParam::param_readSVGValue(const gchar * strvalue) -{ - double fontsize = param_readFontSize(strvalue); - Glib::ustring fontspec = param_readFontSpec(strvalue); - Inkscape::SVGOStringStream os; - os << fontspec << " @ " << fontsize; - param_setValue((Glib::ustring)os.str()); - return true; -} - -gchar * -FontParam::param_getSVGValue() const -{ - return g_strdup(value.c_str()); -} - -Gtk::Widget * -FontParam::param_newWidget() -{ - Inkscape::UI::Widget::RegisteredFontSelector * fontselectorwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredFontSelector( param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() ) ); - double fontsize = param_readFontSize(param_getSVGValue()); - Glib::ustring fontspec = param_readFontSpec(param_getSVGValue()); - fontselectorwdg->setValue( fontspec, fontsize ); - fontselectorwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font selector parameter")); - param_effect->upd_params = false; - return dynamic_cast (fontselectorwdg); -} - -void -FontParam::param_setValue(const Glib::ustring newvalue) -{ - value = newvalue; -} - -} /* 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/font.h b/src/live_effects/parameter/font.h deleted file mode 100644 index 3909ea424..000000000 --- a/src/live_effects/parameter/font.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H -#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H - -/* - * Inkscape::LivePathEffectParameters - * - * Authors: - * Released under GNU GPL, read the file 'COPYING' for more information - */ -#include -#include -#include "live_effects/parameter/parameter.h" - -namespace Inkscape { - -namespace LivePathEffect { - -class FontParam : public Parameter { -public: - FontParam( const Glib::ustring& label, - const Glib::ustring& tip, - const Glib::ustring& key, - Inkscape::UI::Widget::Registry* wr, - Effect* effect, - const Glib::ustring default_value = ""); - virtual ~FontParam() {} - - virtual Gtk::Widget * param_newWidget(); - virtual bool param_readSVGValue(const gchar * strvalue); - double param_readFontSize(const gchar * strvalue); - void param_update_default(const Glib::ustring defvalue); - Glib::ustring param_readFontSpec(const gchar * strvalue); - virtual gchar * param_getSVGValue() const; - - void param_setValue(const Glib::ustring newvalue); - - virtual void param_set_default(); - - const Glib::ustring get_value() const { return defvalue; }; - -private: - FontParam(const FontParam&); - FontParam& operator=(const FontParam&); - Glib::ustring value; - Glib::ustring defvalue; - -}; - -/* - * This parameter does not display a widget in the LPE dialog; LPEs can use it to display on-canvas - * text that should not be settable by the user. Note that since no widget is provided, the - * parameter must be initialized differently than usual (only with a pointer to the parent effect; - * no label, no tooltip, etc.). - */ -class FontParamInternal : public FontParam { -public: - FontParamInternal(Effect* effect) : - FontParam("", "", "", NULL, effect) {} - - virtual Gtk::Widget * param_newWidget() { return NULL; } -}; - -} //namespace LivePathEffect - -} //namespace Inkscape - -#endif - -/* - 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/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp new file mode 100644 index 000000000..ff8ab76a0 --- /dev/null +++ b/src/live_effects/parameter/fontbutton.cpp @@ -0,0 +1,92 @@ +/* + * Authors: + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + + +#include "ui/widget/registered-widget.h" +#include "live_effects/parameter/fontbutton.h" +#include "live_effects/effect.h" +#include "ui/widget/font-button.h" +#include "svg/svg.h" +#include "svg/stringstream.h" +#include "verbs.h" + +#include + +namespace Inkscape { + +namespace LivePathEffect { + +FontButtonParam::FontButtonParam( const Glib::ustring& label, const Glib::ustring& tip, + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, + Effect* effect, const Glib::ustring default_value ) + : Parameter(label, tip, key, wr, effect), + value(default_value), + defvalue(default_value) +{ +} + +void +FontButtonParam::param_set_default() +{ + param_setValue(defvalue); +} +void +FontButtonParam::param_update_default(const Glib::ustring default_value){ + defvalue = default_value; +} + +bool +FontButtonParam::param_readSVGValue(const gchar * strvalue) +{ + Inkscape::SVGOStringStream os; + os << strvalue; + param_setValue((Glib::ustring)os.str()); + return true; +} + +gchar * +FontButtonParam::param_getSVGValue() const +{ + return g_strdup(value.c_str()); +} + +Gtk::Widget * +FontButtonParam::param_newWidget() +{ + Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredFontButton( param_label, + param_tooltip, + param_key, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc() ) ); + Glib::ustring fontspec = param_getSVGValue(); + fontbuttonwdg->setValue( fontspec); + fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter")); + param_effect->upd_params = false; + return dynamic_cast (fontbuttonwdg); +} + +void +FontButtonParam::param_setValue(const Glib::ustring newvalue) +{ + value = newvalue; +} + +} /* 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/fontbutton.h b/src/live_effects/parameter/fontbutton.h new file mode 100644 index 000000000..387ad130b --- /dev/null +++ b/src/live_effects/parameter/fontbutton.h @@ -0,0 +1,62 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H + +/* + * Inkscape::LivePathEffectParameters + * + * Authors: + * Released under GNU GPL, read the file 'COPYING' for more information + */ +#include +#include +#include "live_effects/parameter/parameter.h" + +namespace Inkscape { + +namespace LivePathEffect { + +class FontButtonParam : public Parameter { +public: + FontButtonParam( const Glib::ustring& label, + const Glib::ustring& tip, + const Glib::ustring& key, + Inkscape::UI::Widget::Registry* wr, + Effect* effect, + const Glib::ustring default_value = ""); + virtual ~FontButtonParam() {} + + virtual Gtk::Widget * param_newWidget(); + virtual bool param_readSVGValue(const gchar * strvalue); + void param_update_default(const Glib::ustring defvalue); + virtual gchar * param_getSVGValue() const; + + void param_setValue(const Glib::ustring newvalue); + + virtual void param_set_default(); + + const Glib::ustring get_value() const { return defvalue; }; + +private: + FontButtonParam(const FontButtonParam&); + FontButtonParam& operator=(const FontButtonParam&); + Glib::ustring value; + Glib::ustring defvalue; + +}; + +} //namespace LivePathEffect + +} //namespace Inkscape + +#endif + +/* + 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 : -- cgit v1.2.3 From 7f16afbb515eceed9c63afacec73cd528a662327 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 30 Jul 2016 19:04:34 +0200 Subject: Full rewrite on working mode now no linked paths necesary (bzr r15017.1.15) --- src/live_effects/parameter/parameter.cpp | 43 +++++++++++++------------------- src/live_effects/parameter/parameter.h | 2 -- 2 files changed, 17 insertions(+), 28 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 3f8fced4b..befac4df1 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -5,8 +5,8 @@ */ -#include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" +#include "live_effects/parameter/parameter.h" #include "svg/svg.h" #include "xml/repr.h" @@ -66,8 +66,7 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip, inc_page(1), add_slider(false), overwrite_widget(false), - hide_widget(no_widget), - _rsu(NULL) + hide_widget(no_widget) { } @@ -111,6 +110,7 @@ ScalarParam::param_update_default(gdouble default_value) void ScalarParam::param_set_value(gdouble val) { + param_effect->upd_params = true; value = val; if (integer) value = round(value); @@ -118,9 +118,6 @@ ScalarParam::param_set_value(gdouble val) value = max; if (value < min) value = min; - if (_rsu) { - _rsu->setValue(val); - } } void @@ -131,7 +128,7 @@ ScalarParam::param_set_range(gdouble min, gdouble max) // Once again, in gtk2, this is not a problem. But in gtk3, // widgets get allocated the amount of size they ask for, // leading to excessively long widgets. - + param_effect->upd_params = true; if (min >= -SCALARPARAM_G_MAXDOUBLE) { this->min = min; } else { @@ -140,10 +137,7 @@ ScalarParam::param_set_range(gdouble min, gdouble max) if (max <= SCALARPARAM_G_MAXDOUBLE) { this->max = max; } else { - this->max = SCALARPARAM_G_MAXDOUBLE; - } - if (_rsu) { - _rsu->setRange(this->min, this->max); + this->max = SCALARPARAM_G_MAXDOUBLE; } param_set_value(value); // reset value to see whether it is in ranges } @@ -151,6 +145,7 @@ ScalarParam::param_set_range(gdouble min, gdouble max) void ScalarParam::param_make_integer(bool yes) { + param_effect->upd_params = true; integer = yes; digits = 0; inc_step = 1; @@ -167,22 +162,22 @@ Gtk::Widget * ScalarParam::param_newWidget() { if(!hide_widget){ - _rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( + 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->setProgrammatically = false; + rsu->setValue(value); + rsu->setDigits(digits); + rsu->setIncrements(inc_step, inc_page); + rsu->setRange(min, max); + rsu->setProgrammatically = false; if (add_slider) { - _rsu->addSlider(); + rsu->addSlider(); } if(!overwrite_widget){ - _rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); + rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter")); } param_effect->upd_params = false; - return dynamic_cast (_rsu); + return dynamic_cast (rsu); } else { return NULL; } @@ -191,20 +186,16 @@ ScalarParam::param_newWidget() void ScalarParam::param_set_digits(unsigned digits) { + param_effect->upd_params = true; this->digits = digits; - if (_rsu) { - _rsu->setDigits(this->digits); - } } void ScalarParam::param_set_increments(double step, double page) { + param_effect->upd_params = true; inc_step = step; inc_page = page; - if (_rsu) { - _rsu->setIncrements(inc_step, inc_page); - } } diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h index 63c55203e..3658bded8 100644 --- a/src/live_effects/parameter/parameter.h +++ b/src/live_effects/parameter/parameter.h @@ -117,7 +117,6 @@ public: void param_set_range(gdouble min, gdouble max); void param_set_digits(unsigned digits); void param_set_increments(double step, double page); - void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; }; void param_overwrite_widget(bool overwrite_widget); @@ -141,7 +140,6 @@ protected: private: ScalarParam(const ScalarParam&); ScalarParam& operator=(const ScalarParam&); - Inkscape::UI::Widget::RegisteredScalar *_rsu; }; } //namespace LivePathEffect -- cgit v1.2.3 From 6ac79a669ea08356806bd130d1426871473b0b71 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 31 Jul 2016 16:02:08 +0200 Subject: Add options to fit on DIN (bzr r15017.1.16) --- src/live_effects/parameter/text.cpp | 36 ++++++++++++++++++++++++++++-------- src/live_effects/parameter/text.h | 4 +++- 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 234a6174d..e51cf93ab 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -31,7 +31,8 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, Effect* effect, const Glib::ustring default_value ) : Parameter(label, tip, key, wr, effect), value(default_value), - defvalue(default_value) + defvalue(default_value), + _hide_canvas_text(false) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this! canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); @@ -45,10 +46,25 @@ TextParam::param_set_default() param_setValue(defvalue); } +void +TextParam::param_update_default(Glib::ustring default_value) +{ + defvalue = default_value; +} + +void +TextParam::param_hide_canvas_text() +{ + _hide_canvas_text = true; + sp_canvastext_set_text (canvas_text,""); +} + void TextParam::setPos(Geom::Point pos) { - sp_canvastext_set_coords (canvas_text, pos); + if (!_hide_canvas_text) { + sp_canvastext_set_coords (canvas_text, pos); + } } void @@ -63,9 +79,10 @@ TextParam::setPosAndAnchor(const Geom::Piecewise > &pwd2, Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam)); Point n = -rot90(dir); double angle = Geom::angle_between(dir, Point(1,0)); - - sp_canvastext_set_coords(canvas_text, pos + n * length); - sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle)); + if (!_hide_canvas_text) { + sp_canvastext_set_coords(canvas_text, pos + n * length); + sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle)); + } } void @@ -73,7 +90,9 @@ TextParam::setAnchor(double x_value, double y_value) { anchor_x = x_value; anchor_y = y_value; - sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y); + if (!_hide_canvas_text) { + sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y); + } } bool @@ -107,8 +126,9 @@ void TextParam::param_setValue(const Glib::ustring newvalue) { value = newvalue; - - sp_canvastext_set_text (canvas_text, newvalue.c_str()); + if (!_hide_canvas_text) { + sp_canvastext_set_text (canvas_text, newvalue.c_str()); + } } } /* namespace LivePathEffect */ diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h index 62de70eec..553c84c0a 100644 --- a/src/live_effects/parameter/text.h +++ b/src/live_effects/parameter/text.h @@ -40,7 +40,9 @@ public: virtual gchar * param_getSVGValue() const; void param_setValue(const Glib::ustring newvalue); + void param_hide_canvas_text(); virtual void param_set_default(); + void param_update_default(Glib::ustring default_value); void setPos(Geom::Point pos); void setPosAndAnchor(const Geom::Piecewise > &pwd2, const double t, const double length, bool use_curvature = false); @@ -53,7 +55,7 @@ private: TextParam& operator=(const TextParam&); double anchor_x; double anchor_y; - + bool _hide_canvas_text; Glib::ustring value; Glib::ustring defvalue; -- cgit v1.2.3 From 28d25258de5d2274382dbb592f62e21ca8f91729 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 1 Aug 2016 00:47:38 +0200 Subject: Fix text param and alow run from commandline (bzr r15017.1.21) --- src/live_effects/parameter/text.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/live_effects/parameter') diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index e51cf93ab..0650b7e66 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -34,10 +34,13 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, defvalue(default_value), _hide_canvas_text(false) { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this! - canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); - sp_canvastext_set_text (canvas_text, default_value.c_str()); - sp_canvastext_set_coords (canvas_text, 0, 0); + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { // FIXME: we shouldn't use this! + canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); + sp_canvastext_set_text (canvas_text, default_value.c_str()); + sp_canvastext_set_coords (canvas_text, 0, 0); + } else { + _hide_canvas_text = true; + } } void @@ -55,8 +58,10 @@ TextParam::param_update_default(Glib::ustring default_value) void TextParam::param_hide_canvas_text() { - _hide_canvas_text = true; - sp_canvastext_set_text (canvas_text,""); + if (!_hide_canvas_text) { + sp_canvastext_set_text(canvas_text, " "); + _hide_canvas_text = true; + } } void @@ -113,8 +118,7 @@ TextParam::param_newWidget() { Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc())); - - rsu->setText(value.c_str()); + rsu->setText(value); rsu->setProgrammatically = false; rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter")); -- cgit v1.2.3