From b6c32a5f5d9afc26c217fcc42d08d0beaec9d3c7 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Sat, 3 Feb 2007 22:45:47 +0000 Subject: [PATCH] Fork gradientvector upon deletion of stops. --- src/gradient-chemistry.cpp | 18 ++++++++++++++---- src/gradient-chemistry.h | 2 ++ src/gradient-drag.cpp | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index bacdfb6aa..78ea13507 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -624,13 +624,11 @@ sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, if (!vector) // orphan! return; - - /* - vector = sp_gradient_fork_vector_if_necessary (vector); // TESTJOHAN + + vector = sp_gradient_fork_vector_if_necessary (vector); if ( gradient != vector && gradient->ref->getObject() != vector ) { sp_gradient_repr_set_link(SP_OBJECT_REPR(gradient), vector); } - */ switch (point_type) { case POINT_LG_BEGIN: @@ -1226,6 +1224,18 @@ sp_gradient_vector_for_object(SPDocument *const doc, SPDesktop *const desktop, return sp_document_default_gradient_vector(doc, rgba); } + +SPGradient * +sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector) +{ + SPGradient *vector = sp_gradient_get_vector (gradient, force_vector); + vector = sp_gradient_fork_vector_if_necessary (vector); + if ( gradient != vector && gradient->ref->getObject() != vector ) { + sp_gradient_repr_set_link(SP_OBJECT_REPR(gradient), vector); + } + return vector; +} + /* Local Variables: mode:c++ diff --git a/src/gradient-chemistry.h b/src/gradient-chemistry.h index 4ddae86ce..e4fbb79d9 100644 --- a/src/gradient-chemistry.h +++ b/src/gradient-chemistry.h @@ -51,6 +51,8 @@ SPGradient *sp_gradient_convert_to_userspace (SPGradient *gr, SPItem *item, cons SPGradient *sp_gradient_reset_to_userspace (SPGradient *gr, SPItem *item); SPGradient *sp_gradient_fork_vector_if_necessary (SPGradient *gr); +SPGradient *sp_gradient_get_forked_vector_if_necessary(SPGradient *gradient, bool force_vector); + SPStop* sp_first_stop(SPGradient *gradient); SPStop* sp_last_stop(SPGradient *gradient); diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 74fc2fe67..c02190df8 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1550,7 +1550,8 @@ GrDrag::deleteSelected (bool just_one) for (GSList * drgble = dragger->draggables; drgble != NULL; drgble = drgble->next) { GrDraggable *draggable = (GrDraggable*) drgble->data; SPGradient *gradient = sp_item_gradient (draggable->item, draggable->fill_or_stroke); - SPGradient *vector = sp_gradient_get_vector (gradient, false); + SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false); + switch (draggable->point_type) { case POINT_LG_MID: case POINT_RG_MID1: -- 2.30.2