summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-05-11 19:22:30 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-05-11 19:22:30 +0000
commit02fa22f04f7a81655183192baf55e74aebf53df7 (patch)
tree8ad2d4d2fb0118631abac40d3e8232a1b50dfe6c /src
parentFixing compile warnings (diff)
downloadinkscape-02fa22f04f7a81655183192baf55e74aebf53df7.tar.gz
inkscape-02fa22f04f7a81655183192baf55e74aebf53df7.zip
fixed fixme's in shapeeditor and changed verbs for node editting. helps with multiple nodepath implementation in shape-editor.
(bzr r3000)
Diffstat (limited to 'src')
-rw-r--r--src/nodepath.cpp36
-rw-r--r--src/nodepath.h26
-rw-r--r--src/shape-editor.cpp32
-rw-r--r--src/shape-editor.h4
-rw-r--r--src/widgets/toolbox.cpp58
5 files changed, 97 insertions, 59 deletions
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 6c558149c..4131c8cca 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -1228,9 +1228,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
* handle possible snapping, and commit the change with possible undo.
*/
void
-sp_node_selected_move(gdouble dx, gdouble dy)
+sp_node_selected_move(Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return;
sp_nodepath_selected_nodes_move(nodepath, dx, dy, false);
@@ -1248,7 +1247,7 @@ sp_node_selected_move(gdouble dx, gdouble dy)
* Move node selection off screen and commit the change.
*/
void
-sp_node_selected_move_screen(gdouble dx, gdouble dy)
+sp_node_selected_move_screen(Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy)
{
// borrowed from sp_selection_move_screen in selection-chemistry.c
// we find out the current zoom factor and divide deltas by it
@@ -1258,7 +1257,6 @@ sp_node_selected_move_screen(gdouble dx, gdouble dy)
gdouble zdx = dx / zoom;
gdouble zdy = dy / zoom;
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return;
sp_nodepath_selected_nodes_move(nodepath, zdx, zdy, false);
@@ -1407,9 +1405,8 @@ static void sp_nodepath_update_handles(Inkscape::NodePath::Path *nodepath)
}
void
-sp_nodepath_show_handles(bool show)
+sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (nodepath == NULL) return;
nodepath->show_handles = show;
@@ -1517,9 +1514,8 @@ void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim
* Call sp_nodepath_line_add_node() for all selected segments.
*/
void
-sp_node_selected_add_node(void)
+sp_node_selected_add_node(Inkscape::NodePath::Path *nodepath)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) {
return;
}
@@ -1682,9 +1678,8 @@ sp_nodepath_curve_drag(int node, double t, NR::Point delta)
/**
* Call sp_nodepath_break() for all selected segments.
*/
-void sp_node_selected_break()
+void sp_node_selected_break(Inkscape::NodePath::Path *nodepath)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return;
GList *temp = NULL;
@@ -1710,9 +1705,8 @@ void sp_node_selected_break()
/**
* Duplicate the selected node(s).
*/
-void sp_node_selected_duplicate()
+void sp_node_selected_duplicate(Inkscape::NodePath::Path *nodepath)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) {
return;
}
@@ -1740,9 +1734,8 @@ void sp_node_selected_duplicate()
/**
* Join two nodes by merging them into one.
*/
-void sp_node_selected_join()
+void sp_node_selected_join(Inkscape::NodePath::Path *nodepath)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return; // there's no nodepath when editing rects, stars, spirals or ellipses
if (g_list_length(nodepath->selected) != 2) {
@@ -1842,9 +1835,8 @@ void sp_node_selected_join()
/**
* Join two nodes by adding a segment between them.
*/
-void sp_node_selected_join_segment()
+void sp_node_selected_join_segment(Inkscape::NodePath::Path *nodepath)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return; // there's no nodepath when editing rects, stars, spirals or ellipses
if (g_list_length(nodepath->selected) != 2) {
@@ -2079,9 +2071,8 @@ void sp_node_delete_preserve(GList *nodes_to_delete)
/**
* Delete one or more selected nodes.
*/
-void sp_node_selected_delete()
+void sp_node_selected_delete(Inkscape::NodePath::Path *nodepath)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return;
if (!nodepath->selected) return;
@@ -2117,12 +2108,11 @@ void sp_node_selected_delete()
* This is the code for 'split'.
*/
void
-sp_node_selected_delete_segment(void)
+sp_node_selected_delete_segment(Inkscape::NodePath::Path *nodepath)
{
Inkscape::NodePath::Node *start, *end; //Start , end nodes. not inclusive
Inkscape::NodePath::Node *curr, *next; //Iterators
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (!nodepath) return; // there's no nodepath when editing rects, stars, spirals or ellipses
if (g_list_length(nodepath->selected) != 2) {
@@ -2278,9 +2268,8 @@ sp_node_selected_delete_segment(void)
* Call sp_nodepath_set_line() for all selected segments.
*/
void
-sp_node_selected_set_line_type(NRPathcode code)
+sp_node_selected_set_line_type(Inkscape::NodePath::Path *nodepath, NRPathcode code)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (nodepath == NULL) return;
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
@@ -2298,9 +2287,8 @@ sp_node_selected_set_line_type(NRPathcode code)
* Call sp_nodepath_convert_node_type() for all selected nodes.
*/
void
-sp_node_selected_set_type(Inkscape::NodePath::NodeType type)
+sp_node_selected_set_type(Inkscape::NodePath::Path *nodepath, Inkscape::NodePath::NodeType type)
{
- Inkscape::NodePath::Path *nodepath = sp_nodepath_current();
if (nodepath == NULL) return;
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
diff --git a/src/nodepath.h b/src/nodepath.h
index 967650818..7e4066769 100644
--- a/src/nodepath.h
+++ b/src/nodepath.h
@@ -270,20 +270,20 @@ void sp_nodepath_curve_drag(int node, double t, NR::Point delta);
Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(int index);
/* possibly private functions */
-void sp_node_selected_add_node (void);
-void sp_node_selected_break (void);
-void sp_node_selected_duplicate (void);
-void sp_node_selected_join (void);
-void sp_node_selected_join_segment (void);
+void sp_node_selected_add_node (Inkscape::NodePath::Path *nodepath);
+void sp_node_selected_break (Inkscape::NodePath::Path *nodepath);
+void sp_node_selected_duplicate (Inkscape::NodePath::Path *nodepath);
+void sp_node_selected_join (Inkscape::NodePath::Path *nodepath);
+void sp_node_selected_join_segment (Inkscape::NodePath::Path *nodepath);
void sp_node_delete_preserve (GList *nodes_to_delete);
-void sp_node_selected_delete (void);
-void sp_node_selected_delete_segment (void);
-void sp_node_selected_set_type (Inkscape::NodePath::NodeType type);
-void sp_node_selected_set_line_type (NRPathcode code);
-void sp_node_selected_move (gdouble dx, gdouble dy);
-void sp_node_selected_move_screen (gdouble dx, gdouble dy);
-
-void sp_nodepath_show_handles(bool show);
+void sp_node_selected_delete (Inkscape::NodePath::Path *nodepath);
+void sp_node_selected_delete_segment (Inkscape::NodePath::Path *nodepath);
+void sp_node_selected_set_type (Inkscape::NodePath::Path *nodepath, Inkscape::NodePath::NodeType type);
+void sp_node_selected_set_line_type (Inkscape::NodePath::Path *nodepath, NRPathcode code);
+void sp_node_selected_move (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy);
+void sp_node_selected_move_screen (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy);
+
+void sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show);
void sp_nodepath_selected_nodes_rotate (Inkscape::NodePath::Path * nodepath, gdouble angle, int which, bool screen);
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 1a0f319da..f865d6a4d 100644
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
@@ -343,11 +343,11 @@ void ShapeEditor::deselect() {
}
void ShapeEditor::add_node () {
- sp_node_selected_add_node(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_add_node(this->nodepath);
}
void ShapeEditor::delete_nodes () {
- sp_node_selected_delete(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_delete(this->nodepath);
}
void ShapeEditor::delete_nodes_preserving_shape () {
@@ -356,31 +356,39 @@ void ShapeEditor::delete_nodes_preserving_shape () {
}
}
+void ShapeEditor::delete_segment () {
+ sp_node_selected_delete_segment(this->nodepath);
+}
+
void ShapeEditor::set_node_type(int type) {
- sp_node_selected_set_type((Inkscape::NodePath::NodeType) type); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_set_type(this->nodepath, (Inkscape::NodePath::NodeType) type);
}
void ShapeEditor::break_at_nodes() {
- sp_node_selected_break(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_break(this->nodepath);
}
void ShapeEditor::join_nodes() {
- sp_node_selected_join(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_join(this->nodepath);
+}
+
+void ShapeEditor::join_segments() {
+ sp_node_selected_join_segment(this->nodepath);
}
void ShapeEditor::duplicate_nodes() {
- sp_node_selected_duplicate(); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_duplicate(this->nodepath);
}
void ShapeEditor::set_type_of_segments(NRPathcode code) {
- sp_node_selected_set_line_type(code); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_set_line_type(this->nodepath, code);
}
void ShapeEditor::move_nodes_screen(gdouble dx, gdouble dy) {
- sp_node_selected_move_screen(dx, dy); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_move_screen(this->nodepath, dx, dy);
}
void ShapeEditor::move_nodes(gdouble dx, gdouble dy) {
- sp_node_selected_move(dx, dy); // FIXME fix that function by removing nodepath_current lookup, and pass it this->nodepath instead (needs fixing verbs/buttons first)
+ sp_node_selected_move(this->nodepath, dx, dy);
}
void ShapeEditor::rotate_nodes(gdouble angle, int which, bool screen) {
@@ -412,6 +420,12 @@ void ShapeEditor::select_prev () {
sp_nodepath_select_prev (this->nodepath);
}
+void ShapeEditor::show_handles (bool show) {
+ if (this->nodepath)
+ sp_nodepath_show_handles (this->nodepath, show);
+}
+
+
void ShapeEditor::flip (NR::Dim2 axis, NR::Maybe<NR::Point> center) {
if (this->nodepath)
sp_nodepath_flip (this->nodepath, axis, center);
diff --git a/src/shape-editor.h b/src/shape-editor.h
index 85837d105..8eca230a4 100644
--- a/src/shape-editor.h
+++ b/src/shape-editor.h
@@ -79,11 +79,13 @@ public:
void delete_nodes();
void delete_nodes_preserving_shape();
+ void delete_segment();
void set_node_type(int type);
void break_at_nodes();
void join_nodes();
+ void join_segments();
void duplicate_nodes();
@@ -102,6 +104,8 @@ public:
void select_next ();
void select_prev ();
+ void show_handles (bool show);
+
void flip (NR::Dim2 axis, NR::Maybe<NR::Point> center = NR::Nothing());
void distribute (NR::Dim2 axis);
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index dad4f11f6..9698d7c0c 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -47,7 +47,6 @@
#include "sp-namedview.h"
#include "desktop.h"
#include "desktop-handles.h"
-#include "nodepath.h"
#include "xml/repr.h"
#include "xml/node-event-vector.h"
#include <glibmm/i18n.h>
@@ -62,6 +61,8 @@
#include "gradient-toolbar.h"
#include "connector-context.h"
+#include "node-context.h"
+#include "shape-editor.h"
#include "sp-rect.h"
#include "sp-star.h"
#include "sp-spiral.h"
@@ -644,76 +645,107 @@ sp_commands_toolbox_new()
//# node editing callbacks
//####################################
+/**
+ * FIXME: Returns current shape_editor in context. // later eliminate this function at all!
+ */
+static ShapeEditor *get_current_shape_editor()
+{
+ if (!SP_ACTIVE_DESKTOP) {
+ return NULL;
+ }
+
+ SPEventContext *event_context = (SP_ACTIVE_DESKTOP)->event_context;
+
+ if (!SP_IS_NODE_CONTEXT(event_context)) {
+ return NULL;
+ }
+
+ return SP_NODE_CONTEXT(event_context)->shape_editor;
+}
+
+
void
sp_node_path_edit_add(void)
{
- sp_node_selected_add_node();
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->add_node();
}
void
sp_node_path_edit_delete(void)
{
- sp_node_selected_delete();
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->delete_nodes();
}
void
sp_node_path_edit_delete_segment(void)
{
- sp_node_selected_delete_segment();
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->delete_segment();
}
void
sp_node_path_edit_break(void)
{
- sp_node_selected_break();
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->break_at_nodes();
}
void
sp_node_path_edit_join(void)
{
- sp_node_selected_join();
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->join_nodes();
}
void
sp_node_path_edit_join_segment(void)
{
- sp_node_selected_join_segment();
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->join_segments();
}
void
sp_node_path_edit_toline(void)
{
- sp_node_selected_set_line_type(NR_LINETO);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->set_type_of_segments(NR_LINETO);
}
void
sp_node_path_edit_tocurve(void)
{
- sp_node_selected_set_line_type(NR_CURVETO);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->set_type_of_segments(NR_CURVETO);
}
void
sp_node_path_edit_cusp(void)
{
- sp_node_selected_set_type(Inkscape::NodePath::NODE_CUSP);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_CUSP);
}
void
sp_node_path_edit_smooth(void)
{
- sp_node_selected_set_type(Inkscape::NodePath::NODE_SMOOTH);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_SMOOTH);
}
void
sp_node_path_edit_symmetrical(void)
{
- sp_node_selected_set_type(Inkscape::NodePath::NODE_SYMM);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->set_node_type(Inkscape::NodePath::NODE_SYMM);
}
static void toggle_show_handles (GtkToggleAction *act, gpointer data) {
bool show = gtk_toggle_action_get_active( act );
prefs_set_int_attribute ("tools.nodes", "show_handles", show ? 1 : 0);
- sp_nodepath_show_handles(show);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->show_handles(show);
}
//################################