Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-paint-server.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_SP_PAINT_SERVER_H
3#define SEEN_SP_PAINT_SERVER_H
4
5/*
6 * Base class for gradients and patterns
7 *
8 * Author:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Jon A. Cruz <jon@joncruz.org>
11 *
12 * Copyright (C) 1999-2002 Lauris Kaplinski
13 * Copyright (C) 2000-2001 Ximian, Inc.
14 * Copyright (C) 2010 Authors
15 *
16 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
17 */
18
19#include <memory>
20#include <cairo.h>
21#include <2geom/rect.h>
22#include <sigc++/slot.h>
23#include "sp-object.h"
24
25namespace Inkscape {
26class Drawing;
27class DrawingPattern;
28class DrawingPaintServer;
29} // namespace Inkscape
30
32 : public SPObject
33{
34public:
36 ~SPPaintServer() override;
37 int tag() const override { return tag_of<decltype(*this)>; }
38
39 bool isSwatch() const;
40 virtual bool isValid() const;
41
42 /*
43 * There are two ways to implement a paint server:
44 *
45 * 1. Simple paint servers (solid colors and gradients) implement the create_drawing_paintserver() method.
46 * This returns a DrawingPaintServer instance holding a copy of the paint server's resources which is
47 * used to produce a pattern on-demand using create_pattern().
48 *
49 * 2. The other paint servers (patterns and hatches) implement set_visible(true), set_visible(false) and setBBox().
50 * The drawing item subtree returned by set_visible(true) is attached as a fill/stroke child of the
51 * drawing item the paint server is applied to, and used directly when rendering.
52 *
53 * Paint servers only need to implement one method. If both are implemented, then option 2 is used.
54 */
55
56 virtual std::unique_ptr<Inkscape::DrawingPaintServer> create_drawing_paintserver();
57
58 virtual Inkscape::DrawingPattern *show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox);
59 virtual void hide(unsigned key);
60 virtual void setBBox(unsigned key, Geom::OptRect const &bbox);
61
62protected:
63 bool swatch = false;
64};
65
66#endif // SEEN_SP_PAINT_SERVER_H
67/*
68 Local Variables:
69 mode:c++
70 c-file-style:"stroustrup"
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
72 indent-tabs-mode:nil
73 fill-column:99
74 End:
75*/
76// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Drawing tree node used for rendering paints.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
virtual bool isValid() const
virtual std::unique_ptr< Inkscape::DrawingPaintServer > create_drawing_paintserver()
virtual Inkscape::DrawingPattern * show(Inkscape::Drawing &drawing, unsigned key, Geom::OptRect const &bbox)
int tag() const override
~SPPaintServer() override
virtual void setBBox(unsigned key, Geom::OptRect const &bbox)
bool isSwatch() const
virtual void hide(unsigned key)
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Axis-aligned rectangle.