summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2010-02-14 23:53:33 +0000
committerJohan <Johan@JohannesMobile>2010-02-14 23:53:33 +0000
commitbe7994523333ce17d828ef5923b8c183fdb750e7 (patch)
tree028ddd2e838a24351fd3a5c7517c288194cc577d /src/ui
parentGradient editor: don't show pre-snap indicator when hovering above the knot o... (diff)
parentfix bug: when creating an xy-grid, respect the default unit setting. (the pre... (diff)
downloadinkscape-be7994523333ce17d828ef5923b8c183fdb750e7.tar.gz
inkscape-be7994523333ce17d828ef5923b8c183fdb750e7.zip
- fix bug: xy grid default unit was not respected
- color original-d path as normal path in node tool - remove obsolete todo comment - add widget controls for vectorparam in lpe (bzr r9092)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp2
-rw-r--r--src/ui/tool/node-tool.cpp2
-rw-r--r--src/ui/widget/labelled.h2
-rw-r--r--src/ui/widget/point.cpp2
-rw-r--r--src/ui/widget/point.h2
-rw-r--r--src/ui/widget/registered-widget.cpp90
-rw-r--r--src/ui/widget/registered-widget.h25
7 files changed, 121 insertions, 4 deletions
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 821a7c095..82bca9da0 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1020,7 +1020,7 @@ void InkscapePreferences::initPageGrids()
_page_grids.add_line( false, "", _grids_notebook, "", "", false);
_grids_notebook.append_page(_grids_xy, CanvasGrid::getName( GRID_RECTANGULAR ));
_grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));
- _grids_xy_units.init("/options/grids/units");
+ _grids_xy_units.init("/options/grids/xy/units");
_grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false);
_grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
_grids_xy_origin_y.init("/options/grids/xy/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp
index 7ddd3316b..443e7f258 100644
--- a/src/ui/tool/node-tool.cpp
+++ b/src/ui/tool/node-tool.cpp
@@ -362,7 +362,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh
ShapeRecord r;
r.item = static_cast<SPItem*>(obj);
r.edit_transform = Geom::identity(); // TODO wrong?
- r.role = SHAPE_ROLE_LPE_PARAM;
+ r.role = role;
s.insert(r);
} else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) {
for (SPObject *c = obj->children; c; c = c->next) {
diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h
index 3685944a4..5670af0b6 100644
--- a/src/ui/widget/labelled.h
+++ b/src/ui/widget/labelled.h
@@ -39,6 +39,8 @@ public:
Gtk::Widget const *getWidget() const;
Gtk::Label const *getLabel() const;
+ void setLabelText(const Glib::ustring &str) { _label->set_text(str); };
+
protected:
Gtk::Widget *_widget;
Gtk::Label *_label;
diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp
index 508a8d961..f27cfe8c6 100644
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
@@ -194,7 +194,7 @@ Point::setRange(double min, double max)
/** Sets the value of the spin button */
void
-Point::setValue(Geom::Point & p)
+Point::setValue(Geom::Point const & p)
{
xwidget.setValue(p[0]);
ywidget.setValue(p[1]);
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index 57a46de76..94477d877 100644
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
@@ -64,7 +64,7 @@ public:
void setDigits(unsigned digits);
void setIncrements(double step, double page);
void setRange(double min, double max);
- void setValue(Geom::Point & p);
+ void setValue(Geom::Point const & p);
void update();
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index 95ddec286..db31d08d3 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -587,6 +587,96 @@ RegisteredTransformedPoint::on_value_changed()
}
/*#########################################
+ * Registered TRANSFORMEDPOINT
+ */
+
+RegisteredVector::~RegisteredVector()
+{
+ _value_x_changed_connection.disconnect();
+ _value_y_changed_connection.disconnect();
+}
+
+RegisteredVector::RegisteredVector ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+ : RegisteredWidget<Point> (label, tip),
+ _polar_coords(false)
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ setRange (-1e6, 1e6);
+ setDigits (2);
+ setIncrements(0.1, 1.0);
+ _value_x_changed_connection = signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
+ _value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
+}
+
+void
+RegisteredVector::setValue(Geom::Point const & p)
+{
+ if (!_polar_coords) {
+ Point::setValue(p);
+ } else {
+ Geom::Point polar;
+ polar[Geom::X] = atan2(p) *180/M_PI;
+ polar[Geom::Y] = p.length();
+ Point::setValue(polar);
+ }
+}
+
+void
+RegisteredVector::setValue(Geom::Point const & p, Geom::Point const & origin)
+{
+ RegisteredVector::setValue(p);
+ _origin = origin;
+}
+
+/**
+ * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector.
+ * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length.
+ * After changing the coords type (polar/non-polar), the value has to be reset (setValue).
+ */
+void
+RegisteredVector::setPolarCoords(bool polar_coords)
+{
+ _polar_coords = polar_coords;
+ if (polar_coords) {
+ xwidget.setLabelText("Angle:");
+ ywidget.setLabelText("Distance:");
+ } else {
+ xwidget.setLabelText("X:");
+ ywidget.setLabelText("Y:");
+ }
+}
+
+void
+RegisteredVector::on_value_changed()
+{
+ if (setProgrammatically()) {
+ clearProgrammatically();
+ return;
+ }
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Geom::Point origin = _origin;
+ Geom::Point vector = getValue();
+ if (_polar_coords) {
+ vector = Geom::Point::polar(vector[Geom::X]*M_PI/180, vector[Geom::Y]);
+ }
+
+ Inkscape::SVGOStringStream os;
+ os << origin << " , " << vector;
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
+/*#########################################
* Registered RANDOM
*/
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index a5c61f68a..7aefbb90e 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -334,6 +334,31 @@ protected:
};
+class RegisteredVector : public RegisteredWidget<Point> {
+public:
+ virtual ~RegisteredVector();
+ RegisteredVector (const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
+
+ // redefine setValue, because transform must be applied
+ void setValue(Geom::Point const & p);
+ void setValue(Geom::Point const & p, Geom::Point const & origin);
+ void setPolarCoords(bool polar_coords = true);
+
+protected:
+ sigc::connection _value_x_changed_connection;
+ sigc::connection _value_y_changed_connection;
+ void on_value_changed();
+
+ Geom::Point _origin;
+ bool _polar_coords;
+};
+
+
class RegisteredRandom : public RegisteredWidget<Random> {
public:
virtual ~RegisteredRandom();