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 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/live_effects/parameter/text.cpp') 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 */ -- cgit v1.2.3