X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-gradient.h;h=b05cb5fb82f4dbb2fffa00f6014bbd91f1434935;hb=e5a27fd62c20932a7c888d6c58087032763f2dc5;hp=0451092345c54cf75ebed78cb4293ea3870f0537;hpb=ea4c3217d91f40557abd8519207aea1ad5ff1e68;p=inkscape.git diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 045109234..b05cb5fb8 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -1,5 +1,5 @@ -#ifndef __SP_GRADIENT_H__ -#define __SP_GRADIENT_H__ +#ifndef SEEN_SP_GRADIENT_H +#define SEEN_SP_GRADIENT_H /** \file * SVG and implementation @@ -7,7 +7,9 @@ * Authors: * Lauris Kaplinski * Johan Engelen + * Jon A. Cruz * + * Copyrigt (C) 2010 Jon A. Cruz * Copyright (C) 2007 Johan Engelen * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. @@ -26,6 +28,13 @@ struct SPGradientReference; + +#define SP_TYPE_GRADIENT (SPGradient::getType()) +#define SP_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT, SPGradient)) +#define SP_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GRADIENT, SPGradientClass)) +#define SP_IS_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GRADIENT)) +#define SP_IS_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT)) + typedef enum { SP_GRADIENT_TYPE_UNKNOWN, SP_GRADIENT_TYPE_LINEAR, @@ -67,20 +76,24 @@ struct SPGradient : public SPPaintServer { /** State in Inkscape gradient system */ guint state : 2; +private: /** gradientUnits attribute */ SPGradientUnits units; guint units_set : 1; +public: /** gradientTransform attribute */ Geom::Matrix gradientTransform; guint gradientTransform_set : 1; +private: /** spreadMethod attribute */ SPGradientSpread spread; guint spread_set : 1; /** Gradient stops */ guint has_stops : 1; +public: /** Composed vector */ SPGradientVector vector; @@ -90,9 +103,54 @@ struct SPGradient : public SPPaintServer { sigc::connection modified_connection; + bool hasStops() const; SPStop* getFirstStop(); int getStopCount() const; + + + bool isUnitsSet() const; + SPGradientUnits getUnits() const; + void setUnits(SPGradientUnits units); + + + bool isSpreadSet() const; + SPGradientSpread getSpread() const; + +/** + * Returns private vector of given gradient (the gradient at the end of the href chain which has + * stops), optionally normalizing it. + * + * \pre SP_IS_GRADIENT(gradient). + * \pre There exists a gradient in the chain that has stops. + */ + SPGradient *getVector(bool force_private = false); + + static GType getType(); + + /** Forces vector to be built, if not present (i.e. changed) */ + void ensureVector(); + + /** Ensures that color array is populated */ + void ensureColors(); + + /** + * Set spread property of gradient and emit modified. + */ + void setSpread(SPGradientSpread spread); + + SPGradientSpread fetchSpread(); + SPGradientUnits fetchUnits(); + + void setSwatch(bool swatch = true); + +private: + bool invalidateVector(); + void rebuildVector(); + + friend class SPGradientImpl; + friend class SPLGPainter; + friend class SPRGPainter; }; /** @@ -105,7 +163,7 @@ struct SPGradientClass { #include "sp-gradient-fns.h" -#endif /* !__SP_GRADIENT_H__ */ +#endif // SEEN_SP_GRADIENT_H /* Local Variables: