From 3b4e451ace16cc3a4c62d2dfdc50587d4a8acf8c Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Mon, 26 May 2014 21:02:55 +0200 Subject: SPPattern c++-sification: replaced guint by bool and enum (bzr r13341.6.16) --- src/sp-pattern.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index eb34b6714..d836e7a42 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -33,6 +33,11 @@ class SPPatternReference; class SPPattern : public SPPaintServer, public SPViewBox { public: + enum PatternUnits { + UNITS_USERSPACEONUSE, + UNITS_OBJECTBOUNDINGBOX + }; + SPPattern(); virtual ~SPPattern(); @@ -41,13 +46,13 @@ public: SPPatternReference *ref; /* patternUnits and patternContentUnits attribute */ - guint patternUnits : 1; - guint patternUnits_set : 1; - guint patternContentUnits : 1; - guint patternContentUnits_set : 1; + PatternUnits patternUnits : 1; + bool patternUnits_set : 1; + PatternUnits patternContentUnits : 1; + bool patternContentUnits_set : 1; /* patternTransform attribute */ Geom::Affine patternTransform; - guint patternTransform_set : 1; + bool patternTransform_set : 1; /* Tile rectangle */ SVGLength x; SVGLength y; @@ -82,11 +87,6 @@ protected: } }; -enum { - SP_PATTERN_UNITS_USERSPACEONUSE, - SP_PATTERN_UNITS_OBJECTBOUNDINGBOX -}; - guint pattern_users (SPPattern *pattern); SPPattern *pattern_chain (SPPattern *pattern); SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property); @@ -96,8 +96,8 @@ const gchar *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *documen SPPattern *pattern_getroot (SPPattern *pat); -guint pattern_patternUnits (SPPattern const *pat); -guint pattern_patternContentUnits (SPPattern const *pat); +SPPattern::PatternUnits pattern_patternUnits (SPPattern const *pat); +SPPattern::PatternUnits pattern_patternContentUnits (SPPattern const *pat); Geom::Affine const &pattern_patternTransform(SPPattern const *pat); gdouble pattern_x (SPPattern const *pat); gdouble pattern_y (SPPattern const *pat); -- cgit v1.2.3 From 258b23eac6fadcd3c02053ac6e890b0be5819194 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Mon, 26 May 2014 22:52:46 +0200 Subject: SPPattern c++-sification: replaced gchar* by Glib::ustring (bzr r13341.6.17) --- src/sp-pattern.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index d836e7a42..422adb169 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -42,7 +42,7 @@ public: virtual ~SPPattern(); /* Reference (href) */ - gchar *href; + Glib::ustring href; SPPatternReference *ref; /* patternUnits and patternContentUnits attribute */ -- cgit v1.2.3 From 6508c429a4a678541bc51df10a8335bbb45f0128 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 27 May 2014 19:13:09 +0200 Subject: SPPattern c++-sification: replaced GSList by std::list (bzr r13341.6.18) --- src/sp-pattern.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 422adb169..3f7433d62 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -13,22 +13,29 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include +#include +#include #include "sp-item.h" +#include "svg/svg-length.h" +#include "sp-paint-server.h" +#include "uri-references.h" +#include "viewbox.h" #define SP_PATTERN(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_PATTERN(obj) (dynamic_cast((SPObject*)obj) != NULL) class SPPatternReference; -#include "svg/svg-length.h" -#include "sp-paint-server.h" -#include "uri-references.h" -#include "viewbox.h" +namespace Inkscape { +namespace XML { -#include -#include +class Node; + +} +} class SPPattern : public SPPaintServer, public SPViewBox { @@ -92,7 +99,7 @@ SPPattern *pattern_chain (SPPattern *pattern); SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property); void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); -const gchar *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const gchar *pattern_tile (const std::list &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); SPPattern *pattern_getroot (SPPattern *pat); -- cgit v1.2.3 From 22db6068f172d060429f17a489bdce59e5836c69 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 27 May 2014 21:57:33 +0200 Subject: SPPattern c++-sification: replacing pattern_ functions by methods pt1 (bzr r13341.6.19) --- src/sp-pattern.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 3f7433d62..f1dcc7963 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -70,6 +70,15 @@ public: bool isValid() const; + gdouble get_x() const; + gdouble get_y() const; + gdouble get_width() const; + gdouble get_height() const; + Geom::OptRect get_viewbox() const; + SPPattern::PatternUnits get_pattern_units() const; + SPPattern::PatternUnits get_pattern_content_units() const; + Geom::Affine const &get_transform() const; + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); protected: @@ -78,6 +87,9 @@ protected: virtual void set(unsigned int key, const gchar* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); + +private: + bool _has_item_children() const; }; @@ -103,14 +115,6 @@ const gchar *pattern_tile (const std::list &reprs, Geom::R SPPattern *pattern_getroot (SPPattern *pat); -SPPattern::PatternUnits pattern_patternUnits (SPPattern const *pat); -SPPattern::PatternUnits pattern_patternContentUnits (SPPattern const *pat); -Geom::Affine const &pattern_patternTransform(SPPattern const *pat); -gdouble pattern_x (SPPattern const *pat); -gdouble pattern_y (SPPattern const *pat); -gdouble pattern_width (SPPattern const *pat); -gdouble pattern_height (SPPattern const *pat); -Geom::OptRect pattern_viewBox (SPPattern const *pat); #endif // SEEN_SP_PATTERN_H -- cgit v1.2.3 From 9f92d7370e6e3f456259f5774d3443ae763160d3 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 27 May 2014 22:21:15 +0200 Subject: SPPattern c++-sification: removed unused declatations and includes (bzr r13341.6.20) --- src/sp-pattern.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index f1dcc7963..f2a1e1c6c 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -1,9 +1,6 @@ -#ifndef SEEN_SP_PATTERN_H -#define SEEN_SP_PATTERN_H - -/* +/** @file * SVG implementation - * + *//* * Author: * Lauris Kaplinski * Abhishek Sharma @@ -13,21 +10,21 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#ifndef SEEN_SP_PATTERN_H +#define SEEN_SP_PATTERN_H + #include -#include #include +#include #include -#include "sp-item.h" #include "svg/svg-length.h" #include "sp-paint-server.h" #include "uri-references.h" #include "viewbox.h" -#define SP_PATTERN(obj) (dynamic_cast((SPObject*)obj)) -#define SP_IS_PATTERN(obj) (dynamic_cast((SPObject*)obj) != NULL) - class SPPatternReference; +class SPItem; namespace Inkscape { namespace XML { @@ -37,6 +34,8 @@ class Node; } } +#define SP_PATTERN(obj) (dynamic_cast((SPObject*)obj)) +#define SP_IS_PATTERN(obj) (dynamic_cast((SPObject*)obj) != NULL) class SPPattern : public SPPaintServer, public SPViewBox { public: @@ -106,7 +105,6 @@ protected: } }; -guint pattern_users (SPPattern *pattern); SPPattern *pattern_chain (SPPattern *pattern); SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property); void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); -- cgit v1.2.3 From 4d75f1ecca2fcab4cbfec9fb84c5b1f3647dbc17 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Wed, 28 May 2014 23:28:17 +0200 Subject: SPPattern c++-sification: replaced function by methods (bzr r13341.6.21) --- src/sp-pattern.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index f2a1e1c6c..0c468d8f7 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -77,6 +77,10 @@ public: SPPattern::PatternUnits get_pattern_units() const; SPPattern::PatternUnits get_pattern_content_units() const; Geom::Affine const &get_transform() const; + SPPattern *get_root(); //TODO: const + + SPPattern *clone_if_necessary(SPItem *item, const gchar *property); + void transform_multiply(Geom::Affine postmul, bool set); virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); @@ -89,6 +93,12 @@ protected: private: bool _has_item_children() const; + SPPattern *_chain() const; + + /** + Count how many times pat is used by the styles of o and its descendants + */ + guint _count_hrefs(SPObject* o) const; }; @@ -105,14 +115,9 @@ protected: } }; -SPPattern *pattern_chain (SPPattern *pattern); -SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property); -void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); const gchar *pattern_tile (const std::list &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); -SPPattern *pattern_getroot (SPPattern *pat); - #endif // SEEN_SP_PATTERN_H -- cgit v1.2.3 From 85840ae655411c47248cd794a19dedd9ea3a591f Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Thu, 29 May 2014 12:04:56 +0200 Subject: SPPattern c++-sification: replaced function by methods pt3 (bzr r13341.6.22) --- src/sp-pattern.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 0c468d8f7..1eec0da7f 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -82,6 +82,14 @@ public: SPPattern *clone_if_necessary(SPItem *item, const gchar *property); void transform_multiply(Geom::Affine postmul, bool set); + /** + * @brief create a new pattern in XML tree + * @return created pattern id + */ + static const gchar *produce(const std::list &reprs, + Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); + + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); protected: @@ -96,9 +104,19 @@ private: SPPattern *_chain() const; /** - Count how many times pat is used by the styles of o and its descendants + Count how many times pattern is used by the styles of o and its descendants */ guint _count_hrefs(SPObject* o) const; + + /** + Gets called when the pattern is reattached to another + */ + void _on_ref_changed(SPObject *old_ref, SPObject *ref); + + /** + Gets called when the referenced is changed + */ + void _on_ref_modified(SPObject *ref, guint flags); }; @@ -115,10 +133,6 @@ protected: } }; - -const gchar *pattern_tile (const std::list &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); - - #endif // SEEN_SP_PATTERN_H /* -- cgit v1.2.3 From 35100d54d146fd0fcf702abca02311b0ef95152f Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Thu, 29 May 2014 12:35:19 +0200 Subject: SPPattern c++-sification: class fields are private (bzr r13341.6.23) --- src/sp-pattern.h | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/sp-pattern.h') diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 1eec0da7f..3fe0f53d8 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -51,24 +51,6 @@ public: Glib::ustring href; SPPatternReference *ref; - /* patternUnits and patternContentUnits attribute */ - PatternUnits patternUnits : 1; - bool patternUnits_set : 1; - PatternUnits patternContentUnits : 1; - bool patternContentUnits_set : 1; - /* patternTransform attribute */ - Geom::Affine patternTransform; - bool patternTransform_set : 1; - /* Tile rectangle */ - SVGLength x; - SVGLength y; - SVGLength width; - SVGLength height; - - sigc::connection modified_connection; - - bool isValid() const; - gdouble get_x() const; gdouble get_y() const; gdouble get_width() const; @@ -89,7 +71,7 @@ public: static const gchar *produce(const std::list &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); - + bool isValid() const; virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); protected: @@ -101,6 +83,7 @@ protected: private: bool _has_item_children() const; + void _get_children(std::list& l); SPPattern *_chain() const; /** @@ -117,6 +100,22 @@ private: Gets called when the referenced is changed */ void _on_ref_modified(SPObject *ref, guint flags); + + /* patternUnits and patternContentUnits attribute */ + PatternUnits patternUnits : 1; + bool patternUnits_set : 1; + PatternUnits patternContentUnits : 1; + bool patternContentUnits_set : 1; + /* patternTransform attribute */ + Geom::Affine patternTransform; + bool patternTransform_set : 1; + /* Tile rectangle */ + SVGLength x; + SVGLength y; + SVGLength width; + SVGLength height; + + sigc::connection modified_connection; }; -- cgit v1.2.3