Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors:
6 * Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
7 * Hugo Rodrigues <haa.rodrigues@gmail.com>
8 *
9 * Copyright (C) 2006 Hugo Rodrigues
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SP_FEIMAGE_H_SEEN
15#define SP_FEIMAGE_H_SEEN
16
17#include <memory>
18#include "sp-filter-primitive.h"
19#include "enums.h"
20
21class SPItem;
22
23namespace Inkscape {
24class URIReference;
25class DrawingItem;
26class Drawing;
27class Pixbuf;
28} // namespace Inksacpe
29
30class SPFeImage final
31 : public SPFilterPrimitive
32{
33public:
34 SPFeImage();
35 int tag() const override { return tag_of<decltype(*this)>; }
36
37private:
38 std::string href;
39
40 // preserveAspectRatio
42 unsigned char aspect_clip = SP_ASPECT_MEET;
43
44 enum Type
45 {
46 ELEM, // If href points to an element that is an SPItem.
47 IMAGE, // If href points to non-element that is an image filename.
48 NONE // Neither of the above.
49 };
51 std::unique_ptr<Inkscape::URIReference> elemref; // Tracks href if it is a valid URI.
52 SPItem *elem; // If type == ELEM, the referenced element.
53 std::shared_ptr<Inkscape::Pixbuf const> pixbuf; // If type == IMAGE, the loaded image.
54
55 sigc::connection _href_changed_connection; // Tracks the reference being reattached.
56 sigc::connection _href_modified_connection; // If type == ELEM, tracks the referenced object being modified.
57
58 void try_load_image();
59 void reread_href();
60
62 void on_href_modified();
63
64 struct View
65 {
66 Inkscape::DrawingItem *parent; // The item to which the filter is applied.
67 Inkscape::DrawingItem *child; // The element or image shown by the filter.
68 unsigned inner_key; // The display key at which child is shown at.
69 };
70 std::vector<View> views;
71 void create_view(View &v);
72 void destroy_view(View &v);
73
74 bool valid_for(SPObject const *obj) const override;
75
76protected:
77 void build(SPDocument *doc, Inkscape::XML::Node *repr) override;
78 void release() override;
79 void set(SPAttr key, char const *value) override;
80
81 void show(Inkscape::DrawingItem *item) override;
82 void hide(Inkscape::DrawingItem *item) override;
83
84 std::unique_ptr<Inkscape::Filters::FilterPrimitive> build_renderer(Inkscape::DrawingItem *item) const override;
85};
86
87#endif // SP_FEIMAGE_H_SEEN
88
89/*
90 Local Variables:
91 mode:c++
92 c-file-style:"stroustrup"
93 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
94 indent-tabs-mode:nil
95 fill-column:99
96 End:
97*/
98// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
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
SVG drawing item for display.
Interface for refcounted XML nodes.
Definition node.h:80
SVGLength x
Typed SVG document implementation.
Definition document.h:101
std::vector< View > views
Definition image.h:70
void release() override
Definition image.cpp:271
void try_load_image()
Definition image.cpp:137
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Definition image.cpp:50
void destroy_view(View &v)
Definition image.cpp:284
void create_view(View &v)
Definition image.cpp:296
std::string href
Definition image.h:38
int tag() const override
Definition image.h:35
void on_href_modified()
Definition image.cpp:266
void on_href_changed(SPObject *new_elem)
Definition image.cpp:225
unsigned char aspect_align
Definition image.h:41
bool valid_for(SPObject const *obj) const override
Definition image.cpp:343
SPFeImage()
Definition image.cpp:47
void hide(Inkscape::DrawingItem *item) override
Definition image.cpp:326
void reread_href()
Definition image.cpp:177
sigc::connection _href_changed_connection
Definition image.h:55
unsigned char aspect_clip
Definition image.h:42
Type type
Definition image.h:50
void show(Inkscape::DrawingItem *item) override
Definition image.cpp:315
@ NONE
Definition image.h:48
@ ELEM
Definition image.h:46
@ IMAGE
Definition image.h:47
std::shared_ptr< Inkscape::Pixbuf const > pixbuf
Definition image.h:53
std::unique_ptr< Inkscape::Filters::FilterPrimitive > build_renderer(Inkscape::DrawingItem *item) const override
Definition image.cpp:349
SPItem * elem
Definition image.h:52
std::unique_ptr< Inkscape::URIReference > elemref
Definition image.h:51
sigc::connection _href_modified_connection
Definition image.h:56
Base class for visual SVG elements.
Definition sp-item.h:109
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
@ SP_ASPECT_XMID_YMID
Definition enums.h:47
@ SP_ASPECT_MEET
Definition enums.h:55
SPItem * item
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Document level base class for all SVG filter primitives.
Inkscape::DrawingItem * parent
Definition image.h:66
Inkscape::DrawingItem * child
Definition image.h:67
unsigned inner_key
Definition image.h:68