summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-03-18 01:53:59 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-03-18 01:53:59 +0000
commita5fc5840c370d58f395b7b256a11fd11ef3a9a54 (patch)
tree0136821ae5b542e224d85a124f597002d45470b4 /src/live_effects
parentWorking with widjets (diff)
downloadinkscape-a5fc5840c370d58f395b7b256a11fd11ef3a9a54.tar.gz
inkscape-a5fc5840c370d58f395b7b256a11fd11ef3a9a54.zip
working whith widgets
(bzr r11950.1.57)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-bspline.cpp94
-rw-r--r--src/live_effects/lpe-bspline.h47
2 files changed, 104 insertions, 37 deletions
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index b1e40655d..5d50eae87 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -31,7 +31,6 @@
#include "helper/geom-curves.h"
#include "ui/widget/scalar.h"
-
// For handling un-continuous paths:
#include "message-stack.h"
#include "inkscape.h"
@@ -42,15 +41,20 @@ using Inkscape::DocumentUndo;
namespace Inkscape {
namespace LivePathEffect {
+
LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) :
Effect(lpeobject)
{
- Glib::ustring title = Glib::ustring(_("Ignore cusp nodes"));
- Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes"));
- LPEBSpline::Gtk::Widget *noCusp = new LPEBSpline::newCheckButton(title,tip);
- title = Glib::ustring(_("Unify weights:"));
- tip = Glib::ustring(_("Percent of the with for all poinrs"));
- LPEBSpline::Gtk::Widget *scal = new LPEBSpline::newScalar(title,tip);
+ Glib::ustring title = Glib::ustring(_("Unify weights:"));
+ Glib::ustring tip = Glib::ustring(_("Percent of the with for all poinrs"));
+ registerScal(title,tip);
+ title = Glib::ustring(_("Ignore cusp nodes"));
+ registerNoCusp(title);
+ title = Glib::ustring(_("Reset"));
+ registerReset(title);
+ title = Glib::ustring(_("CTRL handle steps:"));
+ tip = Glib::ustring(_("CTRL handle steps"));
+ registerStepsHandles(title,tip);
}
LPEBSpline::~LPEBSpline()
@@ -243,39 +247,79 @@ LPEBSpline::doEffect(SPCurve * curve)
Gtk::Widget *
LPEBSpline::newWidget()
{
- Gtk::VBox * vbox = dynamic_cast<Gtk::VBox*>(Effect::newWidget());
+ Gtk::VBox * vbox = Gtk::manage( dynamic_cast<Gtk::VBox*>(LPEBSpline::newWidget()));
vbox->set_border_width(5);
- vbox->pack_start(&noCusp,true,true,(guint)2);
- vbox->pack_start(&scal, true, true,2);
+ vbox->pack_start(*noCusp,true,true,2);
+ vbox->pack_start(*scal, true, true,2);
+ vbox->pack_start(*reset, true, true,2);
+ vbox->pack_start(*stepsHandles, true, true,2);
return dynamic_cast<Gtk::VBox *> (vbox);
}
Gtk::Widget *
-LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip)
+LPEBSpline::newScal(Glib::ustring title, Glib::ustring tip)
+{
+ Inkscape::UI::Widget::Scalar *scalIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip));
+ scalIn->setRange(0, 100.);
+ scalIn->setDigits(2);
+ scalIn->setIncrements(1., 5.);
+ scalIn->setValue(33.33);
+ scalIn->setProgrammatically = false;
+ scalIn->addSlider();
+ scalIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles));
+ return dynamic_cast<Gtk::Widget *>(scalIn);
+}
+
+Gtk::Widget *
+LPEBSpline::newNoCusp(Glib::ustring title)
+{
+ Gtk::CheckButton * noCuspIn = Gtk::manage( new Gtk::CheckButton(title,true));
+ noCuspIn->set_alignment(0.0, 0.5);
+ return dynamic_cast<Gtk::Widget *>(noCuspIn);
+}
+
+Gtk::Widget *
+LPEBSpline::newReset(Glib::ustring title)
{
- scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip));
- scal->setValue(33.);
- scal->setDigits(2);
- scal->setIncrements(1., 5.);
- scal->setRange(0, 100.);
- scal->setProgrammatically = false;
- scal->addSlider();
- scal->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles));
- return dynamic_cast<Gtk::Widget *>(scal);
+ Gtk::Button * resetIn = Gtk::manage(new Gtk::Button(title));
+ resetIn->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::resetHandles));
+ resetIn->set_alignment(0.0, 0.5);
+ return dynamic_cast<Gtk::Widget *>(resetIn);
}
Gtk::Widget *
-LPEBSpline::newCheckButton(Glib::ustring title, Glib::ustring tip)
+LPEBSpline::newStepsHandles(Glib::ustring title, Glib::ustring tip)
{
- noCusp = Gtk::manage( new Gtk::CheckButton(title,tip));
- return dynamic_cast<Gtk::Widget *>(noCusp);
+ Inkscape::UI::Widget::Scalar *stepsIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip));
+ stepsIn->setRange(1, 10);
+ stepsIn->setDigits(0);
+ stepsIn->setIncrements(1.,1.);
+ stepsIn->setValue(2);
+ stepsIn->setProgrammatically = false;
+ stepsIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateSteps));
+ return dynamic_cast<Gtk::Widget *>(stepsIn);
+}
+
+void
+LPEBSpline::resetHandles(){
+ Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast<Inkscape::UI::Widget::Scalar *>(scal);
+ scalIn->setValue(33.33);
+ updateAllHandles();
+}
+
+void
+LPEBSpline::updateSteps(){
+ Inkscape::UI::Widget::Scalar * stepsIn = dynamic_cast<Inkscape::UI::Widget::Scalar *>(stepsHandles);
+ updateStepsValue(stepsIn->getValue());
}
void
LPEBSpline::updateAllHandles()
{
- double value = scal->setValue(33.);
- bool noCusp = false;
+ Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast<Inkscape::UI::Widget::Scalar *>(scal);
+ double value = scalIn->getValue()/100;
+ Gtk::CheckButton * noCuspIn = dynamic_cast<Gtk::CheckButton *>(noCusp);
+ bool noCusp = noCuspIn->get_active();
SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop?
Inkscape::Selection *selection = sp_desktop_selection(desktop);
for (GSList *items = (GSList *) selection->itemList();
diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h
index dbe0789f2..3915a476c 100644
--- a/src/live_effects/lpe-bspline.h
+++ b/src/live_effects/lpe-bspline.h
@@ -8,16 +8,12 @@
*/
#include "live_effects/effect.h"
-#include "live_effects/parameter/parameter.h"
-#include "ui/widget/scalar.h"
-#include <gtkmm/checkbutton.h>
namespace Inkscape {
namespace LivePathEffect {
-
-
class LPEBSpline : public Effect {
+
public:
LPEBSpline(LivePathEffectObject *lpeobject);
virtual ~LPEBSpline();
@@ -28,23 +24,50 @@ public:
virtual void doEffect(SPCurve * curve);
- virtual void updateAllHandles();
+ virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp);
- virtual void newScalar(Glib::ustring title, Glib::ustring tip);
+ virtual Gtk::Widget * newWidget();
- virtual void newCheckButton(Glib::ustring title, Glib::ustring tip);
+ int steps;
+protected:
- virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp);
+ Gtk::Widget* scal;
- virtual Gtk::Widget * newWidget();
+ Gtk::Widget* noCusp;
+
+ Gtk::Widget* reset;
+
+ Gtk::Widget* stepsHandles;
+
+ virtual void registerScal(Glib::ustring title, Glib::ustring tip){scal = LPEBSpline::newScal(title,tip);};
+
+ virtual void registerNoCusp(Glib::ustring title){noCusp = LPEBSpline::newNoCusp(title);};
+
+ virtual void registerReset(Glib::ustring title){reset = LPEBSpline::newReset(title);};
+
+ virtual void registerStepsHandles(Glib::ustring title, Glib::ustring tip){stepsHandles = LPEBSpline::newStepsHandles(title,tip);};
+
+ virtual Gtk::Widget* newScal(Glib::ustring title, Glib::ustring tip);
+
+ virtual Gtk::Widget* newNoCusp(Glib::ustring title);
+
+ virtual Gtk::Widget* newReset(Glib::ustring title);
+
+ virtual Gtk::Widget* newStepsHandles(Glib::ustring title, Glib::ustring tip);
+
+ virtual void updateAllHandles();
+
+ virtual void resetHandles();
+
+ virtual void updateSteps();
+ virtual void updateStepsValue(int stepsValue){steps=stepsValue;};
private:
- Gtk::Widget * scal;
- Gtk::Widget * noCusp;
LPEBSpline(const LPEBSpline&);
LPEBSpline& operator=(const LPEBSpline&);
+
};
}; //namespace LivePathEffect