summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-07-29 23:44:17 +0000
committerjabiertxof <info@marker.es>2016-07-29 23:44:17 +0000
commitd60fb000cfc3717ef51b716d9ccb9b63ecb38aa8 (patch)
treeb64c872c22dc7a81f335b93dd06c7dd8aacf18ac /src/live_effects
parentAdd orientation and alow unsort combobox enum widget (diff)
downloadinkscape-d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8.tar.gz
inkscape-d60fb000cfc3717ef51b716d9ccb9b63ecb38aa8.zip
Remove font-Dialog and useGtk::FontSelector instead
(bzr r15017.1.13)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/CMakeLists.txt4
-rw-r--r--src/live_effects/lpe-measure-line.cpp27
-rw-r--r--src/live_effects/lpe-measure-line.h5
-rw-r--r--src/live_effects/parameter/Makefile_insert2
-rw-r--r--src/live_effects/parameter/font.cpp129
-rw-r--r--src/live_effects/parameter/fontbutton.cpp92
-rw-r--r--src/live_effects/parameter/fontbutton.h (renamed from src/live_effects/parameter/font.h)26
7 files changed, 117 insertions, 168 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index c3d740862..784317090 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -69,7 +69,7 @@ set(live_effects_SRC
parameter/powerstrokepointarray.cpp
parameter/random.cpp
parameter/text.cpp
- parameter/font.cpp
+ parameter/fontbutton.cpp
parameter/togglebutton.cpp
parameter/transformedpoint.cpp
parameter/unit.cpp
@@ -151,7 +151,7 @@ set(live_effects_SRC
parameter/powerstrokepointarray.h
parameter/random.h
parameter/text.h
- parameter/font.h
+ parameter/fontbutton.h
parameter/togglebutton.h
parameter/transformedpoint.h
parameter/unit.h
diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp
index 6145f7592..5df3d499e 100644
--- a/src/live_effects/lpe-measure-line.cpp
+++ b/src/live_effects/lpe-measure-line.cpp
@@ -7,6 +7,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-measure-line.h"
+#include <pangomm/fontdescription.h>
+#include <libnrtype/font-lister.h>
#include "inkscape.h"
#include "xml/node.h"
#include "uri.h"
@@ -47,13 +49,13 @@ static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationM
LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- fontselector(_("Font Selector*"), _("Font Selector"), "fontselector", &wr, this, " "),
+ fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this),
orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false),
origin(_("Optional Origin"), _("Optional origin"), "origin", &wr, this),
curve_linked(_("Curve on optional origin"), _("Curve on optional origin, set 0 to start/end"), "curve_linked", &wr, this, 1),
origin_offset(_("Optional origin offset*"), _("Optional origin offset"), "origin_offset", &wr, this, 5),
scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0),
- precision(_("Number precision*"), _("Number precision"), "precision", &wr, this, 2),
+ precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2),
offset_right_left(_("Offset right left*"), _("Offset right left"), "offset_right_left", &wr, this, 0),
offset_top_bottom(_("Offset top bottom*"), _("Offset top bottom"), "offset_top_bottom", &wr, this, 5),
gap_start(_("Gap to line from origin"), _("Gap to line from origin, without affecting measure"), "gap_start", &wr, this, 0),
@@ -64,7 +66,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
scale_insensitive(_("Scale insensitive*"), _("Scale insensitive to transforms in element, parents..."), "scale_insensitive", &wr, this, true),
local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true)
{
- registerParameter(&fontselector);
+ registerParameter(&fontbutton);
registerParameter(&orientation);
registerParameter(&origin);
registerParameter(&curve_linked);
@@ -81,7 +83,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
registerParameter(&scale_insensitive);
registerParameter(&local_locale);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- fontselector.param_update_default(prefs->getString("/live_effects/measure-line/fontselector"));
+ fontbutton.param_update_default(prefs->getString("/live_effects/measure-line/fontbutton"));
scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0));
precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2));
offset_right_left.param_update_default(prefs->getDouble("/live_effects/measure-line/offset_right_left", 0.0));
@@ -116,7 +118,6 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
gap_end.param_set_range(-999999.0, 999999.0);
gap_end.param_set_increments(1, 1);
gap_end.param_set_digits(2);
- fontlister = Inkscape::FontLister::get_instance();
}
bool LPEMeasureLine::alerts_off = false;
@@ -294,15 +295,14 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
rtspan->setAttribute("sodipodi:role", "line");
}
SPCSSAttr *css = sp_repr_css_attr_new();
- Glib::ustring fontspec = fontselector.param_readFontSpec(fontselector.param_getSVGValue());
- double fontsize = fontselector.param_readFontSize(fontselector.param_getSVGValue());
- fontlister->fill_css( css, fontspec );
+ Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue());
+ double fontsize = fontdesc.get_size()/Pango::SCALE;
+ Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance();
+ fontlister->fill_css( css, (Glib::ustring)fontbutton.param_getSVGValue() );
std::stringstream font_size;
font_size.imbue(std::locale::classic());
font_size << fontsize << "pt";
sp_repr_css_set_property (css, "font-size", font_size.str().c_str());
- sp_repr_css_set_property (css, "font-style", "normal");
- sp_repr_css_set_property (css, "font-weight", "normal");
sp_repr_css_set_property (css, "line-height", "125%");
sp_repr_css_set_property (css, "letter-spacing", "0");
sp_repr_css_set_property (css, "word-spacing", "0");
@@ -352,14 +352,15 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
}
length = Inkscape::Util::Quantity::convert(length, doc_unit.c_str(), unit.get_abbreviation());
std::stringstream length_str;
- length_str.setf(std::ios::fixed, std::ios::floatfield);
length_str.precision(precision);
+ length_str.setf(std::ios::fixed, std::ios::floatfield);
if (local_locale) {
length_str.imbue(std::locale(""));
} else {
length_str.imbue(std::locale::classic());
}
- length_str << length << unit.get_abbreviation();
+ length_str << std::fixed << length;
+ length_str << unit.get_abbreviation();
Inkscape::XML::Node *rstring = NULL;
if (!elemref) {
rstring = xml_doc->createTextNode(length_str.str().c_str());
@@ -509,7 +510,7 @@ void
LPEMeasureLine::saveDefault()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("/live_effects/measure-line/fontselector", (Glib::ustring)fontselector.param_getSVGValue());
+ prefs->setString("/live_effects/measure-line/fontbutton", (Glib::ustring)fontbutton.param_getSVGValue());
prefs->setDouble("/live_effects/measure-line/scale", scale);
prefs->setInt("/live_effects/measure-line/precision", precision);
prefs->setDouble("/live_effects/measure-line/offset_right_left", offset_right_left);
diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h
index 67d27408a..15831e231 100644
--- a/src/live_effects/lpe-measure-line.h
+++ b/src/live_effects/lpe-measure-line.h
@@ -12,7 +12,7 @@
#include "live_effects/effect.h"
#include "live_effects/parameter/enum.h"
-#include "live_effects/parameter/font.h"
+#include "live_effects/parameter/fontbutton.h"
#include "live_effects/parameter/text.h"
#include "live_effects/parameter/unit.h"
#include "live_effects/parameter/bool.h"
@@ -47,8 +47,7 @@ public:
void saveDefault();
virtual Gtk::Widget *newWidget();
private:
- FontParam fontselector;
- Inkscape::FontLister *fontlister;
+ FontButtonParam fontbutton;
EnumParam<OrientationMethod> orientation;
OriginalPathParam origin;
ScalarParam curve_linked;
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