summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-12-19 23:30:04 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-12-19 23:30:04 +0000
commit302667a7160ef1d144e2fb5a284f6d845c76790f (patch)
tree90a450cabb9a173b7a7b362d188590b25dec3224 /src
parentfix guide dragging (diff)
downloadinkscape-302667a7160ef1d144e2fb5a284f6d845c76790f.tar.gz
inkscape-302667a7160ef1d144e2fb5a284f6d845c76790f.zip
correctly handle orientation changes of guidelines
(bzr r4261)
Diffstat (limited to 'src')
-rw-r--r--src/display/guideline.cpp6
-rw-r--r--src/display/guideline.h1
-rw-r--r--src/sp-guide.cpp33
-rw-r--r--src/sp-guide.h1
4 files changed, 40 insertions, 1 deletions
diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp
index 32d0e0c1e..1f1d996ff 100644
--- a/src/display/guideline.cpp
+++ b/src/display/guideline.cpp
@@ -183,6 +183,12 @@ void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line)
NR::Matrix(NR::translate(point_on_line)));
}
+void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line)
+{
+ gl->normal_to_line = normal_to_line;
+ sp_canvas_item_request_update(SP_CANVAS_ITEM (gl));
+}
+
void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba)
{
gl->rgba = rgba;
diff --git a/src/display/guideline.h b/src/display/guideline.h
index b3d9bb56b..24353af0a 100644
--- a/src/display/guideline.h
+++ b/src/display/guideline.h
@@ -41,6 +41,7 @@ GType sp_guideline_get_type();
SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, Geom::Point normal);
void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line);
+void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line);
void sp_guideline_set_color(SPGuideLine *gl, unsigned int rgba);
void sp_guideline_set_sensitive(SPGuideLine *gl, int sensitive);
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index 94f937ff9..bd5823e16 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -199,6 +199,7 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
// default to vertical line for bad arguments
guide->normal_to_line = component_vectors[NR::X];
}
+ sp_guide_set_normal(*guide, guide->normal_to_line.to_2geom(), false);
}
break;
case SP_ATTR_POSITION:
@@ -301,7 +302,7 @@ void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool
sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line);
}
- /* Calling sp_repr_set_svg_double must precede calling sp_item_notify_moveto in the commit
+ /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit
case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
if (commit) {
sp_repr_set_svg_point(SP_OBJECT(&guide)->repr, "position", point_on_line);
@@ -319,6 +320,36 @@ void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool
}
/**
+ * \arg commit False indicates temporary moveto in response to motion event while dragging,
+ * true indicates a "committing" version: in response to button release event after
+ * dragging a guideline, or clicking OK in guide editing dialog.
+ */
+void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit)
+{
+ g_assert(SP_IS_GUIDE(&guide));
+
+ for (GSList *l = guide.views; l != NULL; l = l->next) {
+ sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line);
+ }
+
+ /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit
+ case, so that the guide's new position is available for sp_item_rm_unsatisfied_cns. */
+ if (commit) {
+ sp_repr_set_svg_point(SP_OBJECT(&guide)->repr, "orientation", normal_to_line);
+ }
+
+/* DISABLED CODE BECAUSE SPGuideAttachment IS NOT USE AT THE MOMENT (johan)
+ for (vector<SPGuideAttachment>::const_iterator i(guide.attached_items.begin()),
+ iEnd(guide.attached_items.end());
+ i != iEnd; ++i)
+ {
+ SPGuideAttachment const &att = *i;
+ sp_item_notify_moveto(*att.item, guide, att.snappoint_ix, position, commit);
+ }
+*/
+}
+
+/**
* Returns a human-readable description of the guideline for use in dialog boxes and status bar.
*
* The caller is responsible for freeing the string.
diff --git a/src/sp-guide.h b/src/sp-guide.h
index 48583bbe6..436428474 100644
--- a/src/sp-guide.h
+++ b/src/sp-guide.h
@@ -48,6 +48,7 @@ void sp_guide_sensitize(SPGuide *guide, SPCanvas *canvas, gboolean sensitive);
Geom::Point sp_guide_position_from_pt(SPGuide const *guide, NR::Point const &pt);
double sp_guide_distance_from_pt(SPGuide const *guide, Geom::Point const &pt);
void sp_guide_moveto(SPGuide const &guide, Geom::Point const point_on_line, bool const commit);
+void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, bool const commit);
void sp_guide_remove(SPGuide *guide);
char *sp_guide_description(SPGuide const *guide);