Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
knot-holder-entity.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_KNOT_HOLDER_ENTITY_H
3#define SEEN_KNOT_HOLDER_ENTITY_H
4/*
5 * Authors:
6 * Mitsuru Oka <oka326@parkcity.ne.jp>
7 * Maximilian Albert <maximilian.albert@gmail.com>
8 *
9 * Copyright (C) 1999-2001 Lauris Kaplinski
10 * Copyright (C) 2000-2001 Ximian, Inc.
11 * Copyright (C) 2001 Mitsuru Oka
12 * Copyright (C) 2004 Monash University
13 * Copyright (C) 2008 Maximilian Albert
14 *
15 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16 */
17
18#include <cstdint>
19#include <2geom/forward.h>
20
21#include "knot.h"
22#include "snapper.h"
23
28#include <sigc++/scoped_connection.h>
29
30class SPHatch;
31class SPItem;
32class SPKnot;
33class SPDesktop;
34class SPPattern;
35class SPGaussianBlur;
36class KnotHolder;
37
38namespace Inkscape::LivePathEffect { class Effect; }
39
44{
45public:
46 virtual ~KnotHolderEntity();
47
50 Glib::ustring const &name = "unknown",
51 char const *tip = "",
52 uint32_t color = 0xffffff00);
53
54 /* the get/set/click handlers are virtual functions; each handler class for a knot
55 should be derived from KnotHolderEntity and override these functions */
56 virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) = 0;
57 virtual void knot_grabbed(Geom::Point const &/*grab_position*/, unsigned /*state*/) {}
58 virtual void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) = 0;
59 virtual bool knot_missing() const { return false; }
60 virtual Geom::Point knot_get() const = 0;
61 virtual void knot_click(unsigned /*state*/) {}
62 virtual bool set_item_clickpos(Geom::Point loc) { return false; }
63
64 virtual void on_created() {}
65 virtual void update_knot();
66
67 // private:
68 Geom::Point snap_knot_position(Geom::Point const &p, unsigned state);
70
71 SPKnot *knot = nullptr;
72 SPItem *item = nullptr;
73 SPDesktop *desktop = nullptr;
75
76private:
77 sigc::scoped_connection _mousedown_connection;
78 sigc::scoped_connection _moved_connection;
79 sigc::scoped_connection _click_connection;
80 sigc::scoped_connection _ungrabbed_connection;
81};
82
83// LPEs
84
86{
87public:
89 void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
90
91protected:
93};
94
95// Pattern manipulation
96
98{
99public:
101 void on_created() override;
102 bool knot_missing() const override;
103 void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override {};
104 bool set_item_clickpos(Geom::Point loc) override;
105 void update_knot() override;
106
107protected:
108 SPPattern *_pattern() const;
109 Geom::Point _get_pos(double x, double y, bool transform = true) const;
111
113 bool _fill;
115};
116
118{
119public:
121 void on_created() override;
122 void update_knot() override;
123 Geom::Point knot_get() const override;
124 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
125
126private:
129};
130
132{
133public:
135 Geom::Point knot_get() const override;
136 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
137};
138
140{
141public:
143 Geom::Point knot_get() const override;
144 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
145 void knot_grabbed(Geom::Point const &grab_pos, unsigned state) override;
146
147private:
149 static constexpr double MAX_REPETITIONS = 1e6;
153};
154
155// Hatch manipulation
156
158{
159public:
161 bool knot_missing() const override;
162 void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override {};
163
164protected:
165 SPHatch *_hatch() const;
166
168 bool _fill;
169};
170
172{
173public:
175 Geom::Point knot_get() const override;
176 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
177};
178
180{
181public:
183 Geom::Point knot_get() const override;
184 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
185};
186
188{
189public:
191 Geom::Point knot_get() const override;
192 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
193};
194
195
196// Filter manipulation
197
199{
200public:
201 FilterKnotHolderEntity(bool topleft) : _topleft(topleft) {}
202 Geom::Point knot_get() const override;
203 void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override {};
204 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
205
206private:
207 bool _topleft;
208};
209
210// Blur manipulation
211
213{
214public:
215 BlurKnotHolderEntity(int direction) : _dir(direction) {}
216 void on_created() override;
217 void update_knot() override;
218 Geom::Point knot_get() const override;
219 void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override {};
220 void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override;
221
222private:
223 SPGaussianBlur *_blur() const;
224 Geom::Point _pos() const;
225
226 int _dir;
228 sigc::scoped_connection _watch_filter;
229 sigc::scoped_connection _watch_blur;
230};
231
232#endif // SEEN_KNOT_HOLDER_ENTITY_H
233
234/*
235 Local Variables:
236 mode:c++
237 c-file-style:"stroustrup"
238 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
239 indent-tabs-mode:nil
240 fill-column:99
241 End:
242*/
243// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Point origin
Definition aa.cpp:227
Enums for CanvasItems.
std::unique_ptr< T, CanvasItemUnlinkDeleter > CanvasItemPtr
Smart pointer used to hold CanvasItems, like std::unique_ptr.
BlurKnotHolderEntity(int direction)
CanvasItemPtr< Inkscape::CanvasItemCurve > _line
sigc::scoped_connection _watch_blur
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
SPGaussianBlur * _blur() const
Geom::Point _pos() const
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
sigc::scoped_connection _watch_filter
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
FilterKnotHolderEntity(bool topleft)
Geom::Point knot_get() const override
bool _topleft
true for top left point, false for bottom right
3x3 matrix representing an affine transformation.
Definition affine.h:70
Two-dimensional point with integer coordinates.
Definition int-point.h:57
Two-dimensional point that doubles as a vector.
Definition point.h:66
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
bool knot_missing() const override
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
bool _fill
true if the entity tracks fill, false for stroke
KnotHolderEntity definition.
virtual void on_created()
sigc::scoped_connection _ungrabbed_connection
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state)=0
Geom::Point snap_knot_position(Geom::Point const &p, unsigned state)
sigc::scoped_connection _click_connection
sigc::scoped_connection _moved_connection
KnotHolder * parent_holder
Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint, unsigned state)
virtual bool knot_missing() const
virtual void knot_grabbed(Geom::Point const &, unsigned)
virtual void update_knot()
virtual Geom::Point knot_get() const =0
virtual void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state)=0
virtual void knot_click(unsigned)
sigc::scoped_connection _mousedown_connection
virtual bool set_item_clickpos(Geom::Point loc)
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
LPEKnotHolderEntity(Inkscape::LivePathEffect::Effect *effect)
Inkscape::LivePathEffect::Effect * _effect
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
Geom::Point knot_get() const override
void knot_grabbed(Geom::Point const &grab_pos, unsigned state) override
Store pattern geometry info when the scale knot is first grabbed.
static constexpr double MAX_REPETITIONS
Maximum number of pattern repetitons allowed in an item.
CanvasItemPtr< Inkscape::CanvasItemQuad > _quad
Extra visual element to show the pattern editing area.
Geom::Point knot_get() const override
void knot_set(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
bool _fill
true if the entity tracks fill, false for stroke
Geom::Point _get_pos(double x, double y, bool transform=true) const
Returns the position based on the pattern's origin, shifted by the percent x/y of its size.
bool knot_missing() const override
Geom::IntPoint offset_to_cell(Geom::Point loc) const
void knot_ungrabbed(Geom::Point const &p, Geom::Point const &origin, unsigned state) override
bool set_item_clickpos(Geom::Point loc) override
To do: update description of desktop.
Definition desktop.h:149
Base class for visual SVG elements.
Definition sp-item.h:109
Desktop-bound visual control object.
Definition knot.h:51
Colors::Color fill
static char const *const parent
Definition dir-util.cpp:70
Contains forward declarations of 2geom types.
Declarations for SPKnot: Desktop-bound visual control object.
Live Path Effects code.
@ CANVAS_ITEM_CTRL_TYPE_DEFAULT
Snapper class.
std::unique_ptr< Toolbar >(* create)()
Definition toolbars.cpp:56
Glib::ustring name
Definition toolbars.cpp:55