summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 073bb00)
raw | patch | inline | side by side (parent: 073bb00)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 11 May 2007 19:22:30 +0000 (19:22 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 11 May 2007 19:22:30 +0000 (19:22 +0000) |
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 6c558149c172c598e8e2883e66da16376a31b7a1..4131c8ccaaeca8e439804d672c92a12c2b738f8a 100644 (file)
--- 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);
* 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
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);
}
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;
}
/**
* 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;
/**
* 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;
}
/**
* 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) {
/**
* 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) {
/**
* 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;
* 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) {
* 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) {
* 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 967650818764710eb0d6089b5b616a0c18206db4..7e4066769b9f0c4c90a638c290a3bd28cd9d38bd 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
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 1a0f319da0b362ea1bc027051e70d63e6bcf27a8..f865d6a4db648dd2d4a8006a855a9f15604f0119 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
}
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 () {
}
}
+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) {
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 85837d10558cdf2cf3d489a60cc9735364fad04d..8eca230a4c9468b8c8fdffe512a29b67c379a413 100644 (file)
--- a/src/shape-editor.h
+++ b/src/shape-editor.h
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();
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);
index dad4f11f6a3a61dfea4dd6df13e219374ce81c4c..9698d7c0c1d6bb8621286b5e72432816b47eb142 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
#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>
#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"
//# 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);
}
//################################