summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomasz Boczkowski <penginsbacon@gmail.com>2014-05-29 10:04:56 +0000
committerTomasz Boczkowski <penginsbacon@gmail.com>2014-05-29 10:04:56 +0000
commit85840ae655411c47248cd794a19dedd9ea3a591f (patch)
tree926f3d95c00dd03f491a855995d1fa42bf390214 /src
parentSPPattern c++-sification: replaced function by methods (diff)
downloadinkscape-85840ae655411c47248cd794a19dedd9ea3a591f.tar.gz
inkscape-85840ae655411c47248cd794a19dedd9ea3a591f.zip
SPPattern c++-sification: replaced function by methods pt3
(bzr r13341.6.22)
Diffstat (limited to 'src')
-rw-r--r--src/selection-chemistry.cpp2
-rw-r--r--src/sp-pattern.cpp39
-rw-r--r--src/sp-pattern.h24
3 files changed, 30 insertions, 35 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 069aa57bb..fa4589129 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -3265,7 +3265,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
- gchar const *pat_id = pattern_tile(repr_copies, bbox, doc,
+ gchar const *pat_id = SPPattern::produce(repr_copies, bbox, doc,
( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X],
r->max()[Geom::Y]))))
* parent_transform.inverse() ),
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index bd24ab1bb..82e3cdacf 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -19,7 +19,8 @@
#include <cstring>
#include <string>
#include <2geom/transforms.h>
-#include "macros.h"
+#include <sigc++/functors/mem_fun.h>
+
#include "svg/svg.h"
#include "display/cairo-utils.h"
#include "display/drawing-context.h"
@@ -32,16 +33,6 @@
#include "style.h"
#include "sp-pattern.h"
#include "xml/repr.h"
-#include "display/grayscale.h"
-
-#include <sigc++/functors/ptr_fun.h>
-#include <sigc++/adaptors/bind.h>
-
-/*
- * Pattern
- */
-static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat);
-static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern);
#include "sp-factory.h"
@@ -55,7 +46,7 @@ namespace {
SPPattern::SPPattern() : SPPaintServer(), SPViewBox() {
this->ref = new SPPatternReference(this);
- this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(pattern_ref_changed), this));
+ this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_on_ref_changed));
this->patternUnits = UNITS_OBJECTBOUNDINGBOX;
this->patternUnits_set = false;
@@ -284,31 +275,21 @@ void SPPattern::modified(unsigned int flags) {
}
}
-/**
-Gets called when the pattern is reattached to another <pattern>
-*/
-static void
-pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat)
-{
+void SPPattern::_on_ref_changed(SPObject *old_ref, SPObject *ref) {
if (old_ref) {
- pat->modified_connection.disconnect();
+ modified_connection.disconnect();
}
if (SP_IS_PATTERN (ref)) {
- pat->modified_connection = ref->connectModified(sigc::bind<2>(sigc::ptr_fun(&pattern_ref_modified), pat));
+ modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_on_ref_modified));
}
- pattern_ref_modified (ref, 0, pat);
+ _on_ref_modified(ref, 0);
}
-/**
-Gets called when the referenced <pattern> is changed
-*/
-static void pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern *pattern)
+void SPPattern::_on_ref_modified(SPObject */*ref*/, guint /*flags*/)
{
- if ( SP_IS_OBJECT(pattern) ) {
- pattern->requestModified(SP_OBJECT_MODIFIED_FLAG);
- }
+ requestModified(SP_OBJECT_MODIFIED_FLAG);
// Conditional to avoid causing infinite loop if there's a cycle in the href chain.
}
@@ -390,7 +371,7 @@ void SPPattern::transform_multiply(Geom::Affine postmul, bool set) {
getRepr()->setAttribute("patternTransform", c);
}
-const gchar *pattern_tile(const std::list<Inkscape::XML::Node*> &reprs, Geom::Rect bounds,
+const gchar *SPPattern::produce(const std::list<Inkscape::XML::Node*> &reprs, Geom::Rect bounds,
SPDocument *document, Geom::Affine transform, Geom::Affine move)
{
typedef std::list<Inkscape::XML::Node*>::const_iterator NodePtrIterator;
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<Inkscape::XML::Node*> &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 <pattern>
+ */
+ void _on_ref_changed(SPObject *old_ref, SPObject *ref);
+
+ /**
+ Gets called when the referenced <pattern> is changed
+ */
+ void _on_ref_modified(SPObject *ref, guint flags);
};
@@ -115,10 +133,6 @@ protected:
}
};
-
-const gchar *pattern_tile (const std::list<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);
-
-
#endif // SEEN_SP_PATTERN_H
/*