1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
3 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
4 
5 /*
6  * Inkscape::LivePathEffectParameters
7  *
8  * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
9  *
10  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11  */
12 
13 #include <glib.h>
14 
15 #include <2geom/point.h>
16 
17 #include "display/control/canvas-item-enums.h"
18 #include "live_effects/parameter/parameter.h"
19 #include "ui/widget/registered-widget.h"
20 
21 class KnotHolder;
22 class KnotHolderEntity;
23 
24 namespace Inkscape {
25 
26 namespace LivePathEffect {
27 
28 class PointParamKnotHolderEntity;
29 
30 class PointParam : public Geom::Point, public Parameter {
31 public:
32     PointParam( const Glib::ustring& label,
33                 const Glib::ustring& tip,
34                 const Glib::ustring& key,
35                 Inkscape::UI::Widget::Registry* wr,
36                 Effect* effect,
37                 const gchar *handle_tip = nullptr,// tip for automatically associated on-canvas handle
38                 Geom::Point default_value = Geom::Point(0,0),
39                 bool live_update = true );
40     ~PointParam() override;
41 
42     Gtk::Widget * param_newWidget() override;
43 
44     bool param_readSVGValue(const gchar * strvalue) override;
45     Glib::ustring param_getSVGValue() const override;
46     Glib::ustring param_getDefaultSVGValue() const override;
handleTip()47     inline const gchar *handleTip() const { return handle_tip ? handle_tip : param_tooltip.c_str(); }
48     void param_setValue(Geom::Point newpoint, bool write = false);
49     void param_set_default() override;
50     void param_hide_knot(bool hide);
51     Geom::Point param_get_default() const;
52     void param_set_liveupdate(bool live_update);
53     void param_update_default(Geom::Point default_point);
54 
55     void param_update_default(const gchar * default_point) override;
56     void param_transform_multiply(Geom::Affine const & /*postmul*/, bool set) override;
57 
58     void set_oncanvas_looks(Inkscape::CanvasItemCtrlShape shape,
59                             Inkscape::CanvasItemCtrlMode mode,
60                             guint32 color);
61 
providesKnotHolderEntities()62     bool providesKnotHolderEntities() const override { return true; }
63     void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item) override;
64     friend class PointParamKnotHolderEntity;
65 private:
66     PointParam(const PointParam&) = delete;
67     PointParam& operator=(const PointParam&) = delete;
68     bool on_button_release(GdkEventButton* button_event);
69     Geom::Point defvalue;
70     bool liveupdate;
71     KnotHolderEntity * _knot_entity = nullptr;
72     Inkscape::CanvasItemCtrlShape knot_shape = Inkscape::CANVAS_ITEM_CTRL_SHAPE_DIAMOND;
73     Inkscape::CanvasItemCtrlMode knot_mode = Inkscape::CANVAS_ITEM_CTRL_MODE_XOR;
74     guint32 knot_color = 0xffffff00;
75     gchar *handle_tip;
76 };
77 
78 
79 } //namespace LivePathEffect
80 
81 } //namespace Inkscape
82 
83 #endif
84