From ebc3de9a6a7213566564620ba99602df0ca8b64e Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 4 Mar 2010 00:52:16 -0800 Subject: [PATCH] Added method to query "solid paint" status of SPGradient. --- src/sp-gradient.cpp | 14 +++++++++++ src/sp-gradient.h | 59 ++++++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 84a0a9870..3fd120fb3 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -638,6 +638,20 @@ sp_gradient_modified(SPObject *object, guint flags) } } + +bool SPGradient::isSolid() const +{ + bool solid = false; + if ( SP_GRADIENT_HAS_STOPS(this) && (sp_number_of_stops(this) == 0) ) { + gchar const * attr = repr->attribute("osb:paint"); + if (attr && !strcmp(attr, "solid")) { + solid = true; + } + } + return solid; +} + + /** * Write gradient attributes to repr. */ diff --git a/src/sp-gradient.h b/src/sp-gradient.h index abd44538e..947cc49cc 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -27,15 +27,15 @@ struct SPGradientReference; typedef enum { - SP_GRADIENT_TYPE_UNKNOWN, - SP_GRADIENT_TYPE_LINEAR, - SP_GRADIENT_TYPE_RADIAL + SP_GRADIENT_TYPE_UNKNOWN, + SP_GRADIENT_TYPE_LINEAR, + SP_GRADIENT_TYPE_RADIAL } SPGradientType; typedef enum { - SP_GRADIENT_STATE_UNKNOWN, - SP_GRADIENT_STATE_VECTOR, - SP_GRADIENT_STATE_PRIVATE + SP_GRADIENT_STATE_UNKNOWN, + SP_GRADIENT_STATE_VECTOR, + SP_GRADIENT_STATE_PRIVATE } SPGradientState; typedef enum { @@ -49,7 +49,7 @@ typedef enum { POINT_RG_MID1, POINT_RG_MID2, // insert new point types here. - + POINT_G_INVALID } GrPointType; @@ -61,41 +61,44 @@ typedef enum { */ struct SPGradient : public SPPaintServer { - /** Reference (href) */ - SPGradientReference *ref; + /** Reference (href) */ + SPGradientReference *ref; + + /** State in Inkscape gradient system */ + guint state : 2; + + /** gradientUnits attribute */ + SPGradientUnits units; + guint units_set : 1; - /** State in Inkscape gradient system */ - guint state : 2; + /** gradientTransform attribute */ + Geom::Matrix gradientTransform; + guint gradientTransform_set : 1; - /** gradientUnits attribute */ - SPGradientUnits units; - guint units_set : 1; + /** spreadMethod attribute */ + SPGradientSpread spread; + guint spread_set : 1; - /** gradientTransform attribute */ - Geom::Matrix gradientTransform; - guint gradientTransform_set : 1; + /** Gradient stops */ + guint has_stops : 1; - /** spreadMethod attribute */ - SPGradientSpread spread; - guint spread_set : 1; + /** Composed vector */ + SPGradientVector vector; - /** Gradient stops */ - guint has_stops : 1; + /** Rendered color array (4 * 1024 bytes) */ + guchar *color; - /** Composed vector */ - SPGradientVector vector; + sigc::connection modified_connection; - /** Rendered color array (4 * 1024 bytes) */ - guchar *color; - sigc::connection modified_connection; + bool isSolid() const; }; /** * The SPGradient vtable. */ struct SPGradientClass { - SPPaintServerClass parent_class; + SPPaintServerClass parent_class; }; -- 2.30.2