summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0eb8994)
raw | patch | inline | side by side (parent: 0eb8994)
author | Jon A. Cruz <jon@joncruz.org> | |
Mon, 8 Mar 2010 01:31:49 +0000 (17:31 -0800) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Mon, 8 Mar 2010 01:31:49 +0000 (17:31 -0800) |
17 files changed:
src/CMakeLists.txt | patch | blob | history | |
src/Makefile_insert | patch | blob | history | |
src/extension/internal/odf.cpp | patch | blob | history | |
src/gradient-chemistry.cpp | patch | blob | history | |
src/gradient-chemistry.h | patch | blob | history | |
src/gradient-context.cpp | patch | blob | history | |
src/gradient-drag.cpp | patch | blob | history | |
src/sp-gradient.cpp | patch | blob | history | |
src/sp-object-repr.cpp | patch | blob | history | |
src/sp-object.cpp | patch | blob | history | |
src/sp-object.h | patch | blob | history | |
src/sp-stop-fns.h | [deleted file] | patch | blob | history |
src/sp-stop.cpp | [new file with mode: 0644] | patch | blob |
src/sp-stop.h | patch | blob | history | |
src/spray-context.cpp | patch | blob | history | |
src/tweak-context.cpp | patch | blob | history | |
src/widgets/gradient-vector.cpp | patch | blob | history |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 46c2586d120753936a988cd310213e1e8cb48746..a956f6ad82d847629bbea539f911d48983b18676 100644 (file)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
sp-skeleton.cpp\r
sp-spiral.cpp\r
sp-star.cpp\r
+sp-stop.cpp\r
sp-string.cpp\r
sp-style-elem.cpp\r
sp-switch.cpp\r
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 574dfe084956f31329e86e0b534a9db7f51f3468..1e5b1fea0e3e62092c5aa402146e9ae182d8e259 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
sp-shape.cpp sp-shape.h \
sp-spiral.cpp sp-spiral.h \
sp-star.cpp sp-star.h \
- sp-stop-fns.h \
- sp-stop.h \
+ sp-stop.cpp sp-stop.h \
sp-string.cpp sp-string.h \
sp-style-elem.cpp sp-style-elem.h \
sp-switch.cpp sp-switch.h \
index 3537be4504646f29236e8d0f7578112a798a0273..76b901023640bb504ca3dd551611db2aff07726c 100644 (file)
SPGradient *grvec = sp_gradient_get_vector(gradient, FALSE);
for (SPStop *stop = grvec->getFirstStop() ;
- stop ; stop = sp_next_stop(stop))
+ stop ; stop = stop->getNextStop())
{
unsigned long rgba = sp_stop_get_rgba32(stop);
unsigned long rgb = (rgba >> 8) & 0xffffff;
index 04eaeb08de582814f09e125eb61830e6de867117..7382aa49bcdeb56641a37e2b9f7bcdfa92396b78 100644 (file)
return gradient;
}
-SPStop*
-sp_prev_stop(SPStop *stop, SPGradient *gradient)
-{
- if (sp_object_first_child(SP_OBJECT(gradient)) == SP_OBJECT(stop)) {
- return NULL;
- }
- SPObject *found = NULL;
- for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
- if (SP_IS_STOP (ochild)) {
- found = ochild;
- }
- if (SP_OBJECT_NEXT(ochild) == SP_OBJECT(stop) || SP_OBJECT(ochild) == SP_OBJECT(stop)) {
- break;
- }
- }
- return SP_STOP(found);
-}
-
-SPStop*
-sp_next_stop(SPStop *stop)
+SPStop* sp_last_stop(SPGradient *gradient)
{
- for (SPObject *ochild = SP_OBJECT_NEXT(stop); ochild != NULL; ochild = SP_OBJECT_NEXT(ochild)) {
- if (SP_IS_STOP (ochild))
- return SP_STOP(ochild);
- }
- return NULL;
-}
-
-SPStop*
-sp_last_stop(SPGradient *gradient)
-{
- for (SPStop *stop = gradient->getFirstStop(); stop != NULL; stop = sp_next_stop (stop)) {
- if (sp_next_stop (stop) == NULL)
+ for (SPStop *stop = gradient->getFirstStop(); stop != NULL; stop = stop->getNextStop()) {
+ if (stop->getNextStop() == NULL)
return stop;
}
return NULL;
if (stop->offset != 0)
stop_i --;
- for (guint i=0; i < stop_i; i++) {
- if (!stop) return NULL;
- stop = sp_next_stop (stop);
+ for (guint i = 0; i < stop_i; i++) {
+ if (!stop) {
+ return NULL;
+ }
+ stop = stop->getNextStop();
}
return stop;
index c6089a658b0e9bf9c2f04e99379c4a11d3218752..3f72fa394d0ab0ec8c34777c7baeeb9a095f426d 100644 (file)
--- a/src/gradient-chemistry.h
+++ b/src/gradient-chemistry.h
SPStop* sp_last_stop(SPGradient *gradient);
-SPStop* sp_prev_stop(SPStop *stop, SPGradient *gradient);
-SPStop* sp_next_stop(SPStop *stop);
SPStop* sp_get_stop_i(SPGradient *gradient, guint i);
guint sp_number_of_stops(SPGradient const *gradient);
guint sp_number_of_stops_before_stop(SPGradient const *gradient, SPStop *target);
index e78fa44a4d0cb11bc0b351d8657d3596d4d41b3b..ed20f9b619e79b5cc090b074d41f61cff0015839 100644 (file)
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -291,7 +291,7 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi
// from draggables to stops
SPStop *this_stop = sp_get_stop_i (vector, d->point_i);
- SPStop *next_stop = sp_next_stop (this_stop);
+ SPStop *next_stop = this_stop->getNextStop();
SPStop *last_stop = sp_last_stop (vector);
gint fs = d->fill_or_stroke;
SPGradient *gradient = sp_item_gradient (d->item, d->fill_or_stroke);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false);
SPStop *this_stop = sp_get_stop_i (vector, d->point_i);
- SPStop *next_stop = sp_next_stop (this_stop);
+ SPStop *next_stop = this_stop->getNextStop();
if (this_stop && next_stop) {
these_stops = g_slist_prepend (these_stops, this_stop);
next_stops = g_slist_prepend (next_stops, next_stop);
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index f96775360f0ea80ae9edfa31594c63a2e3e30798..13b422119f0efc6b61c57a20c3ac00e94ee44d5e 100644 (file)
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -334,11 +334,11 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance)
if (addknot) {
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false);
SPStop* prev_stop = vector->getFirstStop();
- SPStop* next_stop = sp_next_stop(prev_stop);
+ SPStop* next_stop = prev_stop->getNextStop();
guint i = 1;
while ( (next_stop) && (next_stop->offset < offset) ) {
prev_stop = next_stop;
- next_stop = sp_next_stop(next_stop);
+ next_stop = next_stop->getNextStop();
i++;
}
if (!next_stop) {
case POINT_RG_CENTER:
stop = gradient->getFirstStop();
{
- SPStop *next = sp_next_stop (stop);
+ SPStop *next = stop->getNextStop();
if (next) {
next->offset = 0;
sp_repr_set_css_double (SP_OBJECT_REPR (next), "offset", 0);
case POINT_RG_R2:
stop = sp_last_stop(gradient);
{
- SPStop *prev = sp_prev_stop (stop, gradient);
+ SPStop *prev = stop->getPrevStop();
if (prev) {
prev->offset = 1;
sp_repr_set_css_double (SP_OBJECT_REPR (prev), "offset", 1);
// iterate through midstops to set new offset values such that they won't move on canvas.
SPStop *laststop = sp_last_stop(stopinfo->vector);
- stop = sp_next_stop(stop);
+ stop = stop->getNextStop();
while ( stop != laststop ) {
stop->offset = (stop->offset - offset)/(1 - offset);
sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset);
- stop = sp_next_stop(stop);
+ stop = stop->getNextStop();
}
}
break;
// iterate through midstops to set new offset values such that they won't move on canvas.
SPStop *stop = stopinfo->vector->getFirstStop();
- stop = sp_next_stop(stop);
+ stop = stop->getNextStop();
while ( stop != laststop ) {
stop->offset = stop->offset / offset;
sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset);
- stop = sp_next_stop(stop);
+ stop = stop->getNextStop();
}
}
break;
case POINT_RG_CENTER:
{
- SPStop *newfirst = sp_next_stop (stopinfo->spstop);
+ SPStop *newfirst = stopinfo->spstop->getNextStop();
if (newfirst) {
newfirst->offset = 0;
sp_repr_set_css_double (SP_OBJECT_REPR (newfirst), "offset", 0);
// iterate through midstops to set new offset values such that they won't move on canvas.
SPStop *stop = stopinfo->vector->getFirstStop();
- stop = sp_next_stop(stop);
+ stop = stop->getNextStop();
while ( stop != laststop ) {
stop->offset = stop->offset / offset;
sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset);
- stop = sp_next_stop(stop);
+ stop = stop->getNextStop();
}
break;
}
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index fb16e9e5a495f44e3c5625b6ffa9cb34a58d4612..4e8e8e3738c59dfebcc0db49c60a86889169df74 100644 (file)
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
{
int count = 0;
- for (SPStop *stop = const_cast<SPGradient*>(this)->getFirstStop(); stop && sp_next_stop(stop); stop = sp_next_stop(stop)) {
+ for (SPStop *stop = const_cast<SPGradient*>(this)->getFirstStop(); stop && stop->getNextStop(); stop = stop->getNextStop()) {
count++;
}
diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp
index 4c3d5196ee2c4de5bb3753ca8ce46d17f94e4e79..62143e3ab047d458d07f611047ff00cf4935a75b 100644 (file)
--- a/src/sp-object-repr.cpp
+++ b/src/sp-object-repr.cpp
#include "persp3d.h"
#include "sp-ellipse.h"
#include "sp-star.h"
-#include "sp-stop-fns.h"
+#include "sp-stop.h"
#include "sp-spiral.h"
#include "sp-offset.h"
#include "sp-line.h"
diff --git a/src/sp-object.cpp b/src/sp-object.cpp
index f77f228cbfcaff724872ebc7435a1366d7243389..5e0f7275837f0b6a4d1a2e62ff18739d8ba35360 100644 (file)
--- a/src/sp-object.cpp
+++ b/src/sp-object.cpp
this->repr = NULL;
}
+
+SPObject *SPObject::getNext()
+{
+ return next;
+}
+
+SPObject *SPObject::getPrev()
+{
+ return sp_object_prev(this);
+}
+
/**
* Callback for child_added node event.
*/
diff --git a/src/sp-object.h b/src/sp-object.h
index 22a15a0a4b272a60ac4ce1b6ad2bd31ebd832156..f7ca0f3a343ddfaa518f8718992c08bff67503ee 100644 (file)
--- a/src/sp-object.h
+++ b/src/sp-object.h
/* A non-const version can be similarly constructed if you want one.
* (Don't just cast away the constness, which would be ill-formed.) */
+ SPObject *getNext();
+ SPObject *getPrev();
+
bool hasChildren() const { return ( children != NULL ); }
SPObject *firstChild() { return children; }
diff --git a/src/sp-stop-fns.h b/src/sp-stop-fns.h
--- a/src/sp-stop-fns.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef SEEN_SP_STOP_FNS_H
-#define SEEN_SP_STOP_FNS_H
-
-#include <glib-object.h>
-struct SPStop;
-struct SPStopClass;
-
-#define SP_TYPE_STOP (sp_stop_get_type())
-#define SP_STOP(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_STOP, SPStop))
-#define SP_STOP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_STOP, SPStopClass))
-#define SP_IS_STOP(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_STOP))
-#define SP_IS_STOP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_STOP))
-
-GType sp_stop_get_type();
-
-
-#endif /* !SEEN_SP_STOP_FNS_H */
diff --git a/src/sp-stop.cpp b/src/sp-stop.cpp
--- /dev/null
+++ b/src/sp-stop.cpp
@@ -0,0 +1,66 @@
+/** @file
+ * @gradient stop class.
+ */
+/* Authors:
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ * bulia byak
+ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
+ * Jon A. Cruz <jon@joncruz.org>
+ *
+ * Copyright (C) 1999,2005 authors
+ * Copyright (C) 2010 Jon A. Cruz
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+
+#include "sp-stop.h"
+
+
+// A stop might have some non-stop siblings
+SPStop* SPStop::getNextStop()
+{
+ SPStop *result = 0;
+
+ for (SPObject* obj = getNext(); obj && !result; obj = obj->getNext()) {
+ if (SP_IS_STOP(obj)) {
+ result = SP_STOP(obj);
+ }
+ }
+
+ return result;
+}
+
+SPStop* SPStop::getPrevStop()
+{
+ SPStop *result = 0;
+
+ for (SPObject* obj = getPrev(); obj; obj = obj->getPrev()) {
+ // The closest previous SPObject that is an SPStop *should* be ourself.
+ if (SP_IS_STOP(obj)) {
+ SPStop* stop = SP_STOP(obj);
+ // Sanity check to ensure we have a proper sibling structure.
+ if (stop->getNextStop() == this) {
+ result = stop;
+ } else {
+ g_warning("SPStop previous/next relationship broken");
+ }
+ break;
+ }
+ }
+
+ return result;
+}
+
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/sp-stop.h b/src/sp-stop.h
index 3203d8f7432edeb15eb9d72e9979eca719478dc7..bf6893db1262920a1dc84d8f373d30e68ef21108 100644 (file)
--- a/src/sp-stop.h
+++ b/src/sp-stop.h
*/
#include <glib/gtypes.h>
-//#include <glib-object.h>
#include "sp-object.h"
#include "color.h"
-#include "sp-stop-fns.h"
class SPObjectClass;
class SPColor;
+struct SPStop;
+struct SPStopClass;
+
+#define SP_TYPE_STOP (sp_stop_get_type())
+#define SP_STOP(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_STOP, SPStop))
+#define SP_STOP_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_STOP, SPStopClass))
+#define SP_IS_STOP(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_STOP))
+#define SP_IS_STOP_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_STOP))
+
+GType sp_stop_get_type();
+
/** Gradient stop. */
struct SPStop : public SPObject {
/// \todo fixme: Should be SPSVGPercentage
/// \todo fixme: Implement SPSVGNumber or something similar.
gfloat opacity;
+
+
+ SPStop* getNextStop();
+ SPStop* getPrevStop();
};
/// The SPStop vtable.
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index dc5618eef5f674f6b849a3ed09f83bcde5c55b19..051518e1fdd8aa2aa2e2bcb0ecb9b4846af9c621 100644 (file)
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
#include "path-chemistry.h"
#include "sp-gradient.h"
#include "sp-stop.h"
-#include "sp-stop-fns.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 3f55d040bc426a0f806c2d0f37617da34c167395..13299b5a4004fef123cb90f05cc659879cd7ca24 100644 (file)
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
#include "path-chemistry.h"
#include "sp-gradient.h"
#include "sp-stop.h"
-#include "sp-stop-fns.h"
#include "sp-gradient-reference.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
index 0b3c13820788c92cd9fe86cb8710a86031914e21..751898f4f0dd2091e364d4d184c5b613d99b1ce2 100644 (file)
@@ -583,8 +583,6 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_
// user selected existing stop from list
static void sp_grad_edit_select(GtkOptionMenu *mnu, GtkWidget *tbl)
{
- SPGradient *gradient = (SPGradient *)g_object_get_data(G_OBJECT(tbl), "gradient");
-
GObject *item = G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu))));
SPStop *stop = SP_STOP(g_object_get_data(item, "stop"));
if (!stop) {
bool isEndStop = false;
SPStop *prev = NULL;
- prev = sp_prev_stop(stop, gradient);
+ prev = stop->getPrevStop();
if (prev != NULL ) {
adj->lower = prev->offset;
} else {
}
SPStop *next = NULL;
- next = sp_next_stop(stop);
+ next = stop->getNextStop();
if (next != NULL ) {
adj->upper = next->offset;
} else {
Inkscape::XML::Node *new_stop_repr = NULL;
- SPStop *next = sp_next_stop(stop);
+ SPStop *next = stop->getNextStop();
if (next == NULL) {
- SPStop *prev = sp_prev_stop(stop, gradient);
+ SPStop *prev = stop->getPrevStop();
if (prev != NULL) {
next = stop;
stop = prev;
SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop));
} else {
next = stop;
- new_stop_repr = SP_OBJECT_REPR(sp_prev_stop(stop, gradient))->duplicate(SP_OBJECT_REPR(gradient)->document());
- SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(sp_prev_stop(stop, gradient)));
+ new_stop_repr = SP_OBJECT_REPR(stop->getPrevStop())->duplicate(SP_OBJECT_REPR(gradient)->document());
+ SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop->getPrevStop()));
}
SPStop *newstop = (SPStop *) SP_OBJECT_DOCUMENT(gradient)->getObjectByRepr(new_stop_repr);
// if we delete first or last stop, move the next/previous to the edge
if (stop->offset == 0) {
- SPStop *next = sp_next_stop(stop);
+ SPStop *next = stop->getNextStop();
if (next) {
next->offset = 0;
sp_repr_set_css_double(SP_OBJECT_REPR(next), "offset", 0);
}
} else if (stop->offset == 1) {
- SPStop *prev = sp_prev_stop(stop, gradient);
+ SPStop *prev = stop->getPrevStop();
if (prev) {
prev->offset = 1;
sp_repr_set_css_double(SP_OBJECT_REPR(prev), "offset", 1);