diff options
Diffstat (limited to 'src/gradient-drag.cpp')
| -rw-r--r-- | src/gradient-drag.cpp | 228 |
1 files changed, 120 insertions, 108 deletions
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index fd5ad159f..65b26937b 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -34,6 +34,7 @@ #include "display/sp-ctrlcurve.h" #include "display/sp-canvas-util.h" #include "xml/repr.h" +#include "xml/sp-css-attr.h" #include "svg/css-ostringstream.h" #include "svg/svg.h" #include "preferences.h" @@ -132,7 +133,7 @@ static void gr_drag_sel_modified(Inkscape::Selection */*selection*/, guint /*fla * skip), and fill the \a style with the averaged color of all draggables of the selected dragger, if * any. */ -int gr_drag_style_query(SPStyle *style, int property, gpointer data) +static int gr_drag_style_query(SPStyle *style, int property, gpointer data) { GrDrag *drag = (GrDrag *) data; @@ -1759,7 +1760,7 @@ void GrDrag::selectByCoords(std::vector<Geom::Point> coords) /** * Select draggers by stop */ -void GrDrag::selectByStop(SPStop *stop ) +void GrDrag::selectByStop(SPStop *stop, bool add_to_selection, bool override ) { for (GList *i = this->draggers; i != NULL; i = i->next) { @@ -1768,11 +1769,11 @@ void GrDrag::selectByStop(SPStop *stop ) GrDraggable *d = (GrDraggable *) j->data; SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); - SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(gradient, false); + SPGradient *vector = gradient->getVector(false); SPStop *stop_i = sp_get_stop_i(vector, d->point_i); if (stop_i == stop) { - setSelected(dragger, true, true); + setSelected(dragger, add_to_selection, override); } } } @@ -2080,28 +2081,33 @@ void GrDrag::updateDraggers() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = style->getFillPaintServer(); - if ( server && server->isSolid() ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL ); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_FILL ); - } else if ( SP_IS_MESHGRADIENT(server) ) { - addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_FILL ); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_FILL ); + } else if ( SP_IS_MESHGRADIENT(server) ) { + addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL ); + } } - } if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = style->getStrokePaintServer(); - if ( server && server->isSolid() ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE ); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_STROKE ); - } else if ( SP_IS_MESHGRADIENT(server) ) { - addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addDraggersLinear( SP_LINEARGRADIENT(server), item, Inkscape::FOR_STROKE ); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + addDraggersRadial( SP_RADIALGRADIENT(server), item, Inkscape::FOR_STROKE ); + } else if ( SP_IS_MESHGRADIENT(server) ) { + addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE ); + } } } } @@ -2145,58 +2151,61 @@ void GrDrag::updateLines() if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( server && server->isSolid() ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_FILL); - addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); - addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); - } else if ( SP_IS_MESHGRADIENT(server) ) { - - SPMeshGradient *mg = SP_MESHGRADIENT(server); - - guint rows = mg->array.patch_rows(); - guint columns = mg->array.patch_columns(); - for ( guint i = 0; i < rows; ++i ) { - for ( guint j = 0; j < columns; ++j ) { - - std::vector<Geom::Point> h; - - SPMeshPatchI patch( &(mg->array.nodes), i, j ); - - // Top line - h = patch.getPointsForSide( 0 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); - - // Right line - if( j == columns - 1 ) { - h = patch.getPointsForSide( 1 ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_FILL), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_FILL); + addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); + addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_FILL), Inkscape::FOR_FILL); + } else if ( SP_IS_MESHGRADIENT(server) ) { + + SPMeshGradient *mg = SP_MESHGRADIENT(server); + + guint rows = mg->array.patch_rows(); + guint columns = mg->array.patch_columns(); + for ( guint i = 0; i < rows; ++i ) { + for ( guint j = 0; j < columns; ++j ) { + + std::vector<Geom::Point> h; + + SPMeshPatchI patch( &(mg->array.nodes), i, j ); + + // Top line + h = patch.getPointsForSide( 0 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); - } - // Bottom line - if( i == rows - 1 ) { - h = patch.getPointsForSide( 2 ); + // Right line + if( j == columns - 1 ) { + h = patch.getPointsForSide( 1 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); + } + + // Bottom line + if( i == rows - 1 ) { + h = patch.getPointsForSide( 2 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); + } + + // Left line + h = patch.getPointsForSide( 3 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); } - - // Left line - h = patch.getPointsForSide( 3 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_FILL ); } } } @@ -2204,61 +2213,64 @@ void GrDrag::updateLines() if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( server && server->isSolid() ) { - // Suppress "gradientness" of solid paint - } else if ( SP_IS_LINEARGRADIENT(server) ) { - addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); - } else if ( SP_IS_RADIALGRADIENT(server) ) { - Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_STROKE); - addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); - addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); - } else if ( SP_IS_MESHGRADIENT(server) ) { - - // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE. - SPMeshGradient *mg = SP_MESHGRADIENT(server); - - guint rows = mg->array.patch_rows(); - guint columns = mg->array.patch_columns(); - for ( guint i = 0; i < rows; ++i ) { - for ( guint j = 0; j < columns; ++j ) { - - std::vector<Geom::Point> h; - - SPMeshPatchI patch( &(mg->array.nodes), i, j ); - - // Top line - h = patch.getPointsForSide( 0 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); - - // Right line - if( j == columns - 1 ) { - h = patch.getPointsForSide( 1 ); + if ( server && SP_IS_GRADIENT( server ) ) { + if ( server->isSolid() + || (SP_GRADIENT(server)->getVector() && SP_GRADIENT(server)->getVector()->isSolid())) { + // Suppress "gradientness" of solid paint + } else if ( SP_IS_LINEARGRADIENT(server) ) { + addLine(item, getGradientCoords(item, POINT_LG_BEGIN, 0, Inkscape::FOR_STROKE), getGradientCoords(item, POINT_LG_END, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); + } else if ( SP_IS_RADIALGRADIENT(server) ) { + Geom::Point center = getGradientCoords(item, POINT_RG_CENTER, 0, Inkscape::FOR_STROKE); + addLine(item, center, getGradientCoords(item, POINT_RG_R1, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); + addLine(item, center, getGradientCoords(item, POINT_RG_R2, 0, Inkscape::FOR_STROKE), Inkscape::FOR_STROKE); + } else if ( SP_IS_MESHGRADIENT(server) ) { + + // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE. + SPMeshGradient *mg = SP_MESHGRADIENT(server); + + guint rows = mg->array.patch_rows(); + guint columns = mg->array.patch_columns(); + for ( guint i = 0; i < rows; ++i ) { + for ( guint j = 0; j < columns; ++j ) { + + std::vector<Geom::Point> h; + + SPMeshPatchI patch( &(mg->array.nodes), i, j ); + + // Top line + h = patch.getPointsForSide( 0 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); - } - // Bottom line - if( i == rows - 1 ) { - h = patch.getPointsForSide( 2 ); + // Right line + if( j == columns - 1 ) { + h = patch.getPointsForSide( 1 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); + } + + // Bottom line + if( i == rows - 1 ) { + h = patch.getPointsForSide( 2 ); + for( guint p = 0; p < 4; ++p ) { + h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); + } + addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); + } + + // Left line + h = patch.getPointsForSide( 3 ); for( guint p = 0; p < 4; ++p ) { h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); } addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); } - - // Left line - h = patch.getPointsForSide( 3 ); - for( guint p = 0; p < 4; ++p ) { - h[p] *= Geom::Affine(mg->gradientTransform) * (Geom::Affine)item->i2dt_affine(); - } - addCurve (item, h[0], h[1], h[2], h[3], Inkscape::FOR_STROKE ); - } - } + } + } } } } |
