summaryrefslogtreecommitdiffstats
path: root/src
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
parentWorking with widjets (diff)
downloadinkscape-a5fc5840c370d58f395b7b256a11fd11ef3a9a54.tar.gz
inkscape-a5fc5840c370d58f395b7b256a11fd11ef3a9a54.zip
working whith widgets
(bzr r11950.1.57)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bspline.cpp94
-rw-r--r--src/live_effects/lpe-bspline.h47
-rw-r--r--src/ui/tool/node.cpp5
-rw-r--r--src/ui/tool/node.h3
-rw-r--r--src/ui/tool/path-manipulator.cpp16
-rw-r--r--src/ui/tool/path-manipulator.h3
6 files changed, 127 insertions, 41 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
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index bee2cc477..b628d3500 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -113,6 +113,9 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node
_degenerate(true)
{
setVisible(false);
+ //BSpline
+ setControlBsplineSteps( _pm().getControlBsplineSteps());
+ //BSpline End;
}
Handle::~Handle()
@@ -391,7 +394,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
double pos = 0;
h = this;
setPosition(new_pos);
- pos = ceilf(_pm().BSplineHandlePosition(h)*10)/10;
+ pos = ceilf(_pm().BSplineHandlePosition(h)*controlBsplineSteps)/controlBsplineSteps;
new_pos=_pm().BSplineHandleReposition(h,pos);
}
//BSpline End
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index e74698b1a..953ac0061 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -109,12 +109,15 @@ protected:
virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event);
//Bspline
virtual void handle_2button_press();
+ virtual void setControlBsplineSteps(int controlBsplineStepsValue){controlBsplineSteps = controlBsplineStepsValue;};
+ int controlBsplineSteps;
//BSpline End
virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event);
virtual bool grabbed(GdkEventMotion *event);
virtual void ungrabbed(GdkEventButton *event);
virtual bool clicked(GdkEventButton *event);
+
virtual Glib::ustring _getTip(unsigned state) const;
virtual Glib::ustring _getDragTip(GdkEventMotion *event) const;
virtual bool _hasDragTips() const { return true; }
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 0a100ecfb..b46e85622 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -36,6 +36,7 @@
#include "live_effects/lpeobject-reference.h"
#include "live_effects/parameter/path.h"
#include "sp-path.h"
+#include "sp-lpe-item.h"
#include "helper/geom.h"
#include "preferences.h"
#include "style.h"
@@ -1174,9 +1175,8 @@ void PathManipulator::_createControlPointsFromGeometry()
bool PathManipulator::isBSpline(){
LivePathEffect::LPEBSpline *lpe_bsp = NULL;
- if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) {
- PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path));
- lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>( effect_list.front()->lpeobject->get_lpe());
+ if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){
+ lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe());
}else{
lpe_bsp = NULL;
}
@@ -1186,6 +1186,16 @@ bool PathManipulator::isBSpline(){
return false;
}
+int PathManipulator::getControlBsplineSteps(){
+ LivePathEffect::LPEBSpline *lpe_bsp = NULL;
+ if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){
+ lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe());
+ if(lpe_bsp){
+ return lpe_bsp->steps;
+ }
+ }
+ return 2;
+}
double PathManipulator::BSplineHandlePosition(Handle *h){
using Geom::X;
using Geom::Y;
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index a235a3b05..04148592b 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -89,6 +89,9 @@ public:
void updateHandles();
void setControlsTransform(Geom::Affine const &);
void hideDragPoint();
+ //BSpline
+ int getControlBsplineSteps();
+ //BSpline End
MultiPathManipulator &mpm() { return _multi_path_manipulator; }
NodeList::iterator subdivideSegment(NodeList::iterator after, double t);