diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
commit | cca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch) | |
tree | 146f39ded1c938019e1ed42d30923c2ac9e86789 /src/display/control/canvas-item-ctrl.h | |
parent | Initial commit. (diff) | |
download | inkscape-upstream/1.2.2.tar.xz inkscape-upstream/1.2.2.zip |
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/display/control/canvas-item-ctrl.h | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/display/control/canvas-item-ctrl.h b/src/display/control/canvas-item-ctrl.h new file mode 100644 index 0000000..4cccc88 --- /dev/null +++ b/src/display/control/canvas-item-ctrl.h @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef SEEN_CANVAS_ITEM_CTRL_H +#define SEEN_CANVAS_ITEM_CTRL_H + +/** + * A class to represent a control node. + */ + +/* + * Author: + * Tavmjong Bah + * + * Copyright (C) 2020 Tavmjong Bah + * + * Rewrite of SPCtrl + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include <memory> +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <2geom/point.h> + +#include "canvas-item.h" +#include "canvas-item-enums.h" + +#include "enums.h" // SP_ANCHOR_X + +namespace Inkscape { + +class CanvasItemGroup; // A canvas control that contains other canvas controls. + +class CanvasItemCtrl : public CanvasItem { + +public: + ~CanvasItemCtrl() override; + CanvasItemCtrl(CanvasItemGroup *group); + CanvasItemCtrl(CanvasItemGroup *group, CanvasItemCtrlType type); + CanvasItemCtrl(CanvasItemGroup *group, CanvasItemCtrlType type, Geom::Point const &p); + CanvasItemCtrl(CanvasItemGroup *group, CanvasItemCtrlShape shape); + CanvasItemCtrl(CanvasItemGroup *group, CanvasItemCtrlShape shape, Geom::Point const &p); + + // Geometry + void set_position(Geom::Point const &position); + + void update(Geom::Affine const &affine) override; + double closest_distance_to(Geom::Point const &p); + + // Selection + bool contains(Geom::Point const &p, double tolerance = 0) override; + + // Display + void render(Inkscape::CanvasItemBuffer *buf) override; + + // Properties + void set_fill(guint32 rgba) override; + void set_stroke(guint32 rgba) override; + void set_shape(int shape); + void set_shape_default(); // Use type to determine shape. + void set_mode(int mode); + void set_mode_default(); + void set_size(int size); + virtual void set_size_via_index(int size_index); + void set_size_default(); // Use preference and type to set size. + void set_size_extra(int extra); // Used to temporary increase size of ctrl. + void set_anchor(SPAnchorType anchor); + void set_angle(double angle); + void set_type(CanvasItemCtrlType type); + void set_pixbuf(GdkPixbuf *pixbuf); + +protected: + void build_cache(int device_scale); + + // Geometry + Geom::Point _position; + + // Display + guint32 *_cache = nullptr; + bool _built = false; + + // Properties + CanvasItemCtrlType _type = CANVAS_ITEM_CTRL_TYPE_DEFAULT; + CanvasItemCtrlShape _shape = CANVAS_ITEM_CTRL_SHAPE_SQUARE; + CanvasItemCtrlMode _mode = CANVAS_ITEM_CTRL_MODE_XOR; + unsigned int _width = 5; // Nominally width == height == size... unless we use a pixmap. + unsigned int _height = 5; + unsigned int _extra = 0; // Used to temporarily increase size. + double _angle = 0.0; // Used for triangles, could be used for arrows. + SPAnchorType _anchor = SP_ANCHOR_CENTER; + GdkPixbuf *_pixbuf = nullptr; +}; + + +} // namespace Inkscape + +#endif // SEEN_CANVAS_ITEM_CTRL_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 : |