From d9e84828804bef871c833e6b749a826f29c0e153 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 2 Feb 2015 22:59:36 +0100 Subject: Fix some problems pointed by su_v (bzr r13879.1.7) --- src/live_effects/lpe-transform_2pts.cpp | 35 +++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'src/live_effects/lpe-transform_2pts.cpp') diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index bb126b2bb..049212302 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -23,7 +23,7 @@ #include <2geom/path.h> #include "sp-path.h" #include "ui/tools-switch.h" - +#include "ui/icon-names.h" #include "inkscape.h" namespace Inkscape { @@ -31,7 +31,7 @@ namespace LivePathEffect { LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : Effect(lpeobject), - fromOriginalWidth(_("Use bounding box"), _("Use bounding box"), "fromOriginalWidth", &wr, this, false), + fromOriginalWidth(_("From original width"), _("From original width"), "fromOriginalWidth", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), start(_("Start"), _("Start point"), "start", &wr, this, "Start point"), end(_("End"), _("End point"), "end", &wr, this, "End point"), firstKnot(_("First Knot"), _("First Knot"), "firstKnot", &wr, this, 1), @@ -68,7 +68,7 @@ LPETransform2Pts::doOnApply(SPLPEItem const* lpeitem) A = *(c->first_point()); B = *(c->last_point()); int nnodes = (int)c->nodes_in_path(); - lastKnot.param_set_value((int)c->nodes_in_path()); + lastKnot.param_set_value(nnodes); } } start.param_setValue(A); @@ -79,6 +79,10 @@ void LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; + if(fromOriginalWidthToogler != fromOriginalWidth){ + fromOriginalWidthToogler = fromOriginalWidth; + reset(); + } original_bbox(lpeitem); SPLPEItem* item = const_cast(lpeitem); SPPath *path = dynamic_cast(item); @@ -100,17 +104,20 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem) int nnodes = (int)c->nodes_in_path(); firstKnot.param_set_range(1, lastKnot-1); lastKnot.param_set_range(firstKnot+1, nnodes); + fromOriginalWidth.param_setValue(false); } else { firstKnot.param_set_value(1); lastKnot.param_set_value(2); firstKnot.param_set_range(1,1); lastKnot.param_set_range(2,2); + fromOriginalWidth.param_setValue(true); } } else { firstKnot.param_set_value(1); lastKnot.param_set_value(2); firstKnot.param_set_range(1,1); lastKnot.param_set_range(2,2); + fromOriginalWidth.param_setValue(true); } item->apply_to_clippath(item); item->apply_to_mask(item); @@ -123,7 +130,6 @@ LPETransform2Pts::updateIndex() if(path && !fromOriginalWidth){ SPCurve * c = NULL; c = path->get_original_curve(); - int nnodes = (int)c->nodes_in_path(); if(!c->is_closed() && c->first_path() == c->last_path()){ c->reset(); c = path->getCurve(); @@ -161,6 +167,8 @@ LPETransform2Pts::reset() SPCurve * c = NULL; c = path->get_original_curve(); int nnodes = (int)c->nodes_in_path(); + firstKnot.param_set_range(1, lastKnot-1); + lastKnot.param_set_range(firstKnot+1, nnodes); firstKnot.param_set_value(1); lastKnot.param_set_value(nnodes); A = *(c->first_point()); @@ -189,7 +197,7 @@ Gtk::Widget *LPETransform2Pts::newWidget() vbox->set_spacing(6); std::vector::iterator it = param_vector.begin(); - + Gtk::HBox * button = Gtk::manage(new Gtk::HBox(true,0)); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter *param = *it; @@ -206,6 +214,19 @@ Gtk::Widget *LPETransform2Pts::newWidget() entryWidg->set_width_chars(3); } } + if (param->param_key == "fromOriginalWidth") + { + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + button->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } if (widg) { vbox->pack_start(*widg, true, true, 2); if (tip) { @@ -219,11 +240,9 @@ Gtk::Widget *LPETransform2Pts::newWidget() ++it; } - Gtk::HBox * button = Gtk::manage(new Gtk::HBox(true,0)); Gtk::Button *reset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); reset->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::reset)); - reset->set_size_request(140,45); - button->pack_start(*reset, false, false, 2); + button->pack_start(*reset, true, true, 2); vbox->pack_start(*button, true, true, 2); return dynamic_cast(vbox); } -- cgit v1.2.3