summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects/parameter/text.cpp')
-rw-r--r--src/live_effects/parameter/text.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index 234a6174d..0650b7e66 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -31,12 +31,16 @@ 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), "");
- 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
@@ -46,9 +50,26 @@ TextParam::param_set_default()
}
void
+TextParam::param_update_default(Glib::ustring default_value)
+{
+ defvalue = default_value;
+}
+
+void
+TextParam::param_hide_canvas_text()
+{
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_text(canvas_text, " ");
+ _hide_canvas_text = true;
+ }
+}
+
+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 +84,10 @@ TextParam::setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &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 +95,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
@@ -94,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"));
@@ -107,8 +130,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 */