summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7722f0a)
raw | patch | inline | side by side (parent: 7722f0a)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 12 Apr 2006 17:16:28 +0000 (17:16 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Wed, 12 Apr 2006 17:16:28 +0000 (17:16 +0000) |
src/node-context.cpp | patch | blob | history | |
src/nodepath.cpp | patch | blob | history | |
src/nodepath.h | patch | blob | history |
diff --git a/src/node-context.cpp b/src/node-context.cpp
index ccdb6c79eec6331054034b16ba94c9774e16dd26..1e01b1af9ac59e00602c3087623db0455cd4e89e 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
bool is_interactive, gpointer data)
{
SPItem *item = NULL;
- char const *newd = NULL, *newtypestr = NULL;
gboolean changed = FALSE;
g_assert(data);
if (np) {
item = SP_ITEM(np->path);
- if (!strcmp(name, "d")) {
- newd = new_value;
- changed = nodepath_repr_d_changed(np, new_value);
- } else if (!strcmp(name, "sodipodi:nodetypes")) {
- newtypestr = new_value;
- changed = nodepath_repr_typestr_changed(np, new_value);
- } else {
- return;
- // With paths, we only need to act if one of the path-affecting attributes has changed.
+ if (!strcmp(name, "d") || !strcmp(name, "sodipodi:nodetypes")) { // With paths, we only need to act if one of the path-affecting attributes has changed.
+ changed = (np->local_change == 0);
+ if (np->local_change > 0)
+ np->local_change--;
}
+
} else if (kh) {
item = SP_ITEM(kh->item);
changed = !(kh->local_change);
kh->local_change = FALSE;
}
+
if (np && changed) {
GList *saved = NULL;
SPDesktop *desktop = np->desktop;
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 97be9355cb2863be8d05a993b9324e54c182184e..b50ee90c7b6a0acae5ae6540a89024627b0eca5d 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
np->selected = NULL;
np->nodeContext = NULL; //Let the context that makes this set it
np->livarot_path = NULL;
+ np->local_change = 0;
// we need to update item's transform from the repr here,
// because they may be out of sync when we respond
g_list_free(badSubPaths);
}
-
-
-/**
- * \brief Returns true if the argument nodepath and the d attribute in
- * its repr do not match.
- *
- * This may happen if repr was changed in, e.g., XML editor or by undo.
- *
- * \todo
- * UGLY HACK, think how we can eliminate it. IDEA: try instead a local_change flag in node context?
- */
-gboolean nodepath_repr_d_changed(Inkscape::NodePath::Path *np, char const *newd)
-{
- g_assert(np);
-
- SPCurve *curve = create_curve(np);
-
- gchar *svgpath = sp_svg_write_path(curve->bpath);
-
- char const *attr_d = ( newd
- ? newd
- : SP_OBJECT(np->path)->repr->attribute("d") );
-
- gboolean ret;
- if (attr_d && svgpath)
- ret = strcmp(attr_d, svgpath);
- else
- ret = TRUE;
-
- g_free(svgpath);
- sp_curve_unref(curve);
-
- return ret;
-}
-
-/**
- * \brief Returns true if the argument nodepath and the sodipodi:nodetypes
- * attribute in its repr do not match.
- *
- * This may happen if repr was changed in, e.g., the XML editor or by undo.
- * IDEA: try instead a local_change flag in node context?
- */
-gboolean nodepath_repr_typestr_changed(Inkscape::NodePath::Path *np, char const *newtypestr)
-{
- g_assert(np);
- gchar *typestr = create_typestr(np);
- char const *attr_typestr = ( newtypestr
- ? newtypestr
- : SP_OBJECT(np->path)->repr->attribute("sodipodi:nodetypes") );
- gboolean const ret = (attr_typestr && strcmp(attr_typestr, typestr));
-
- g_free(typestr);
-
- return ret;
-}
-
/**
* Create new nodepath from b, make it subpath of np.
* \param t The node type.
gchar *typestr = create_typestr(np);
gchar *svgpath = sp_svg_write_path(curve->bpath);
- repr->setAttribute("d", svgpath);
- repr->setAttribute("sodipodi:nodetypes", typestr);
+ if (repr->attribute("d") == NULL || strcmp(svgpath, repr->attribute("d"))) { // d changed
+ np->local_change++;
+ repr->setAttribute("d", svgpath);
+ }
+
+ if (repr->attribute("sodipodi:nodetypes") == NULL || strcmp(typestr, repr->attribute("sodipodi:nodetypes"))) { // nodetypes changed
+ np->local_change++;
+ repr->setAttribute("sodipodi:nodetypes", typestr);
+ }
g_free(svgpath);
g_free(typestr);
diff --git a/src/nodepath.h b/src/nodepath.h
index aaa488cf3ff6f58c9d78a3c36599a1cc49d4bf66..656d64ebbe87662af748699d824fbb341a989ebb 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
/// livarot library is used for "point on path" and "nearest position on path", so we need to maintain its path representation as well
::Path *livarot_path;
+
+ /// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop
+ uint local_change;
};