diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-07-29 23:44:17 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-07-29 23:44:17 +0000 |
| commit | d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8 (patch) | |
| tree | b64c872c22dc7a81f335b93dd06c7dd8aacf18ac /src/live_effects/parameter | |
| parent | Add orientation and alow unsort combobox enum widget (diff) | |
| download | inkscape-d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8.tar.gz inkscape-d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8.zip | |
Remove font-Dialog and useGtk::FontSelector instead
(bzr r15017.1.13)
Diffstat (limited to 'src/live_effects/parameter')
| -rw-r--r-- | src/live_effects/parameter/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/font.cpp | 129 | ||||
| -rw-r--r-- | src/live_effects/parameter/fontbutton.cpp | 92 | ||||
| -rw-r--r-- | src/live_effects/parameter/fontbutton.h (renamed from src/live_effects/parameter/font.h) | 26 |
4 files changed, 99 insertions, 150 deletions
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 <glibmm/i18n.h> - -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<Gtk::Widget *> (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/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 <glibmm/i18n.h> + +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<Gtk::Widget *> (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/font.h b/src/live_effects/parameter/fontbutton.h index 3909ea424..387ad130b 100644 --- a/src/live_effects/parameter/font.h +++ b/src/live_effects/parameter/fontbutton.h @@ -15,21 +15,19 @@ namespace Inkscape { namespace LivePathEffect { -class FontParam : public Parameter { +class FontButtonParam : public Parameter { public: - FontParam( const Glib::ustring& label, + 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 ~FontParam() {} + virtual ~FontButtonParam() {} 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); @@ -39,27 +37,13 @@ public: const Glib::ustring get_value() const { return defvalue; }; private: - FontParam(const FontParam&); - FontParam& operator=(const FontParam&); + FontButtonParam(const FontButtonParam&); + FontButtonParam& operator=(const FontButtonParam&); 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 |
