Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
rubberband.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef SEEN_RUBBERBAND_H
3#define SEEN_RUBBERBAND_H
4/*
5 * Authors:
6 * Lauris Kaplinski <lauris@kaplinski.com>
7 * Carl Hetherington <inkscape@carlh.net>
8 *
9 * Copyright (C) 1999-2002 Lauris Kaplinski
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#include <cairomm/pattern.h>
15#include <2geom/point.h>
16#include <2geom/path.h>
17#include <2geom/rect.h>
18#include <vector>
21
22/* fixme: do multidocument safe */
23
24class SPDesktop;
25
26namespace Inkscape {
27
28class CanvasItemBpath;
29class CanvasItemRect;
30
35{
36public:
37 enum class Mode {
38 RECT,
41 };
42 enum class Operation {
43 ADD,
44 INVERT,
45 REMOVE
46 };
47
48 void start(SPDesktop *desktop, Geom::Point const &p, bool tolerance = false);
49 void move(Geom::Point const &p);
51 void stop();
52 bool isStarted() const { return _started; }
53 bool isMoved() const { return _moved; }
54
55 Rubberband::Mode getMode() const { return _mode; }
56 std::vector<Geom::Point> getPoints() const;
57 Geom::Path getPath() const;
58
59 static constexpr auto default_mode = Rubberband::Mode::RECT;
64
66 void setOperation(Rubberband::Operation operation) { _operation = operation; };
68
70
71private:
74
79
82 CanvasItemCtrlType _handle = default_handle; // Used for styling through css
86
88 // use default deselect mechanism unless it's a freehand path
91 } else {
93 }
94 }
95
100
101 void delete_canvas_items();
102
103 bool _started = false;
104 bool _moved = false;
107 double _tolerance = 0.0;
108};
109
110} // namespace Inkscape
111
112#endif // SEEN_RUBBERBAND_H
113
114/*
115 Local Variables:
116 mode:c++
117 c-file-style:"stroustrup"
118 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
119 indent-tabs-mode:nil
120 fill-column:99
121 End:
122*/
123// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Path - a sequence of contiguous curves.
Cartesian point / 2D vector and related operations.
Enums for CanvasItems.
std::unique_ptr< T, CanvasItemUnlinkDeleter > CanvasItemPtr
Smart pointer used to hold CanvasItems, like std::unique_ptr.
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Sequence of contiguous curves, aka spline.
Definition path.h:353
Two-dimensional point that doubles as a vector.
Definition point.h:66
Rubberbanding selector.
Definition rubberband.h:35
static constexpr auto default_operation
Definition rubberband.h:60
CanvasItemCtrlType _handle
Definition rubberband.h:82
CanvasItemCtrlType _invert_handle
Definition rubberband.h:83
void setHandle(CanvasItemCtrlType handle)
Definition rubberband.h:67
static constexpr auto default_mode
Definition rubberband.h:59
std::vector< Geom::Point > getPoints() const
Geom::Path getPath() const
static constexpr auto default_deselect_handle
Definition rubberband.h:62
bool isMoved() const
Definition rubberband.h:53
CanvasItemCtrlType _deselect_handle
Definition rubberband.h:84
Rubberband::Mode _mode
Definition rubberband.h:105
void setMode(Rubberband::Mode mode)
Definition rubberband.h:65
Geom::Path _touchpath_curve
Definition rubberband.h:85
static Rubberband * get(SPDesktop *desktop)
void move(Geom::Point const &p)
void setOperation(Rubberband::Operation operation)
Definition rubberband.h:66
SPDesktop * _desktop
Definition rubberband.h:75
static constexpr auto default_handle
Definition rubberband.h:61
Rubberband::Operation _operation
Definition rubberband.h:106
CanvasItemPtr< CanvasItemRect > _rect
Definition rubberband.h:80
Geom::OptRect getRectangle() const
static Rubberband * _instance
Definition rubberband.h:73
Rubberband::Mode getMode() const
Definition rubberband.h:55
Geom::Point _start
Definition rubberband.h:76
CanvasItemCtrlType _get_deselect_handle(CanvasItemCtrlType handle)
Definition rubberband.h:87
static constexpr auto default_invert_handle
Definition rubberband.h:63
CanvasItemCtrlType _get_invert_handle(CanvasItemCtrlType handle)
Definition rubberband.h:96
CanvasItemPtr< CanvasItemBpath > _touchpath
Definition rubberband.h:81
bool isStarted() const
Definition rubberband.h:52
To do: update description of desktop.
Definition desktop.h:149
Geom::Point start
Helper class to stream background task notifications as a series of messages.
@ RUBBERBAND_TOUCHPATH_SELECT
@ RUBBERBAND_TOUCHPATH_DESELECT
@ RUBBERBAND_TOUCHPATH_INVERT
int mode
Axis-aligned rectangle.
SPDesktop * desktop