Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-mask.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_SP_MASK_H
3#define SEEN_SP_MASK_H
4
5/*
6 * SVG <mask> implementation
7 *
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Abhishek Sharma
11 *
12 * Copyright (C) 2003 authors
13 *
14 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 */
16
17#include <memory>
18#include <vector>
19#include <2geom/rect.h>
20
21#include "object-view.h"
22#include "sp-object-group.h"
23#include "uri-references.h"
24#include "xml/node.h"
25
26namespace Inkscape {
27class Drawing;
28class DrawingItem;
29class DrawingGroup;
30} // namespace Inkscape
31
32class SPMask final
33 : public SPObjectGroup
34{
35public:
36 SPMask();
37 ~SPMask() override;
38 int tag() const override { return tag_of<decltype(*this)>; }
39
40 bool mask_content_units() const { return maskContentUnits; }
41
42 // Fixme: Hack used by cairo-renderer.
43 Geom::OptRect get_last_bbox() const { return views.back().bbox; }
44
45 static char const *create(std::vector<Inkscape::XML::Node*> &reprs, SPDocument *document);
46
47 Inkscape::DrawingItem *show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox);
48 void hide(unsigned key);
49 void setBBox(unsigned key, Geom::OptRect const &bbox);
50
51 Geom::OptRect geometricBounds(Geom::Affine const &transform) const;
52 Geom::OptRect visualBounds(Geom::Affine const &transform) const;
53
54protected:
55 void build(SPDocument *doc, Inkscape::XML::Node *repr) override;
56 void release() override;
57 void set(SPAttr key, char const *value) override;
58 void update(SPCtx *ctx, unsigned flags) override;
59 void modified(unsigned flags) override;
61
63
64private:
65 bool maskUnits_set : 1;
66 bool maskUnits : 1;
67
70
72 std::vector<View> views;
73 void update_view(View &v);
74};
75
78{
79public:
82
84 {
85 return static_cast<SPMask*>(URIReference::getObject());
86 }
87
88 sigc::connection modified_connection;
89
90protected:
97 bool _acceptObject(SPObject *obj) const override;
98};
99
100#endif // SEEN_SP_MASK_H
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis-aligned rectangle that can be empty.
Definition rect.h:203
SVG drawing item for display.
A class encapsulating a reference to a particular URI; observers can be notified when the URI comes t...
URIReference(SPObject *owner)
Constructor.
Interface for refcounted XML nodes.
Definition node.h:80
Typed SVG document implementation.
Definition document.h:101
bool _acceptObject(SPObject *obj) const override
If the owner element of this reference (the element with <... mask="...">) is a child of the mask it ...
Definition sp-mask.cpp:265
sigc::connection modified_connection
Definition sp-mask.h:88
SPMaskReference(SPObject *obj)
Definition sp-mask.h:80
SPMask * getObject() const
Definition sp-mask.h:83
Geom::OptRect visualBounds(Geom::Affine const &transform) const
Definition sp-mask.cpp:116
void release() override
Definition sp-mask.cpp:51
bool maskUnits_set
Definition sp-mask.h:65
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
Definition sp-mask.cpp:129
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Definition sp-mask.cpp:40
void update(SPCtx *ctx, unsigned flags) override
Definition sp-mask.cpp:144
SPMask()
Definition sp-mask.cpp:29
~SPMask() override
Geom::OptRect get_last_bbox() const
Definition sp-mask.h:43
bool mask_content_units() const
Definition sp-mask.h:40
bool maskUnits
Definition sp-mask.h:66
bool maskContentUnits_set
Definition sp-mask.h:68
std::vector< View > views
Definition sp-mask.h:72
bool maskContentUnits
Definition sp-mask.h:69
int tag() const override
Definition sp-mask.h:38
void setBBox(unsigned key, Geom::OptRect const &bbox)
Definition sp-mask.cpp:253
void modified(unsigned flags) override
Definition sp-mask.cpp:169
Inkscape::DrawingItem * show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox)
Definition sp-mask.cpp:217
void hide(unsigned key)
Definition sp-mask.cpp:237
Geom::OptRect geometricBounds(Geom::Affine const &transform) const
Definition sp-mask.cpp:103
void update_view(View &v)
Definition sp-mask.cpp:160
Inkscape::XML::Node * write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned flags) override
Definition sp-mask.cpp:181
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPDocument * document
Definition sp-object.h:188
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
View helper class used by hatch, clippath, mask and pattern.
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
Axis-aligned rectangle.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
std::unique_ptr< Toolbar >(* create)()
Definition toolbars.cpp:56
Interface for XML nodes.