From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/rubberband.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/rubberband.h (limited to 'src/rubberband.h') diff --git a/src/rubberband.h b/src/rubberband.h new file mode 100644 index 0000000..0d93d7c --- /dev/null +++ b/src/rubberband.h @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef SEEN_RUBBERBAND_H +#define SEEN_RUBBERBAND_H +/* + * Authors: + * Lauris Kaplinski + * Carl Hetherington + * + * Copyright (C) 1999-2002 Lauris Kaplinski + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include <2geom/point.h> +#include <2geom/rect.h> +#include +#include + +/* fixme: do multidocument safe */ + +class SPCurve; +class SPDesktop; + +enum { + RUBBERBAND_MODE_RECT, + RUBBERBAND_MODE_TOUCHPATH, + RUBBERBAND_MODE_TOUCHRECT +}; + +namespace Inkscape +{ + +class CanvasItemBpath; +class CanvasItemRect; + +/** + * Rubberbanding selector. + */ +class Rubberband +{ +public: + + void start(SPDesktop *desktop, Geom::Point const &p); + void move(Geom::Point const &p); + Geom::OptRect getRectangle() const; + void stop(); + bool is_started(); + + inline int getMode() {return _mode;} + inline std::vector getPoints() {return _points;} + + void setMode(int mode); + void defaultMode(); + + static Rubberband* get(SPDesktop *desktop); + +private: + + Rubberband(SPDesktop *desktop); + static Rubberband* _instance; + + SPDesktop *_desktop; + Geom::Point _start; + Geom::Point _end; + + std::vector _points; + + Inkscape::CanvasItemRect *_rect = nullptr; + Inkscape::CanvasItemBpath *_touchpath = nullptr; + SPCurve *_touchpath_curve = nullptr; + + void delete_canvas_items(); + + bool _started = false; + int _mode = RUBBERBAND_MODE_RECT; +}; + +} + +#endif // SEEN_RUBBERBAND_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3