19#include <gdk/gdkkeysyms.h>
20#include <glibmm/i18n.h>
38 EventType::BUTTON_PRESS |
39 EventType::BUTTON_RELEASE |
41 EventType::KEY_PRESS |
42 EventType::KEY_RELEASE;
44static auto const nograbenv = getenv(
"INKSCAPE_NO_GRAB");
67 ctrl->set_name(
"CanvasItemCtrl:Knot:" +
name);
115 bool key_press_event_unconsumed =
false;
120 tolerance = prefs->getIntLimited(
"/options/dragtolerance/value", 0, 0, 100);
122 bool consumed =
false;
126 if (event.button != 1) {
129 if (event.num_press == 2) {
130 doubleclicked_signal.emit(this, event.modifiers);
135 auto const p = desktop->w2d(event.pos);
136 startDragging(p, event.pos.floor(), event.time);
137 mousedown_signal.emit(this, event.modifiers);
143 if (event.button == 1 &&
217 if (event.extinput.pressure) {
218 pressure = std::clamp(*event.extinput.pressure, 0.0, 1.0);
290 key_press_event_unconsumed =
true;
300 if (key_press_event_unconsumed) {
309 auto const motion_w =
event.pos;
310 auto const motion_dt =
desktop->
w2d(motion_w);
317 if (event.
modifiers & GDK_BUTTON1_MASK) {
347 ctrl->set_position(p);
358 ctrl->set_position(p);
366 this->
flags &= ~flag;
383 g_assert_not_reached();
426void SPKnot::setImage(guchar* normal, guchar* mouseover, guchar* dragging, guchar* selected) {
440 _tip = std::move(tip);
Two-dimensional point with integer coordinates.
Two-dimensional point that doubles as a vector.
void set(MessageType type, char const *message)
pushes a message on the stack, replacing our old message
void clear()
removes our current message from the stack
MessageId flash(MessageType type, char const *message)
Temporarily pushes a message onto the stack.
static Preferences * get()
Access the singleton Preferences object.
To do: update description of desktop.
Inkscape::UI::Widget::Canvas * getCanvas() const
Inkscape::CanvasItemGroup * getCanvasControls() const
SPDocument * getDocument() const
Inkscape::MessageStack * messageStack() const
Inkscape::UI::Tools::ToolBase * getTool() const
void set_coordinate_status(Geom::Point const &p)
Sets the coordinate status to a given point.
Geom::Affine const & w2d() const
Transformation from window to desktop coordinates (zoom/rotate).
Desktop-bound visual control object.
static void ref(SPKnot *knot)
Geom::Point drag_origin
Origin of drag.
sigc::signal< void(SPKnot *, unsigned int)> ungrabbed_signal
void _setCtrlState()
Set knot control state (dragging/mouseover/normal).
unsigned char * image[SP_KNOT_VISIBLE_STATES]
sigc::signal< void(SPKnot *, Geom::Point const &, unsigned int)> moved_signal
sigc::signal< void(SPKnot *, unsigned int)> click_signal
void setPosition(Geom::Point const &p, unsigned int state)
Move knot to new position and emits "moved" signal.
void handler_request_position(Inkscape::MotionEvent const &event)
Geom::Point pos
Our desktop coordinates.
void setImage(unsigned char *normal, unsigned char *mouseover, unsigned char *dragging, unsigned char *selected)
void setSize(Inkscape::HandleSize size)
sigc::signal< void(SPKnot *, unsigned int)> grabbed_signal
Geom::IntPoint xyp
Where drag started.
sigc::signal< bool(SPKnot *, Geom::Point *, unsigned int)> request_signal
SPKnot(SPDesktop *desktop, char const *tip, Inkscape::CanvasItemCtrlType type, Glib::ustring const &name="unknown")
CanvasItemPtr< Inkscape::CanvasItemCtrl > ctrl
Our CanvasItemCtrl.
sigc::signal< bool(SPKnot *, Inkscape::CanvasEvent const &)> event_signal
static void unref(SPKnot *knot)
void hide()
Hide knot on its canvas.
Inkscape::HandleSize _size
Always square.
void setAnchor(unsigned int i)
sigc::scoped_connection _event_connection
double angle
Angle of mesh handle.
void show()
Show knot on its canvas.
void setTip(Glib::ustring &&tip)
void requestPosition(Geom::Point const &pos, unsigned int state)
Request or set new position for knot.
bool size_set
Use default size unless explicitly set.
SPAnchorType anchor
Anchor.
double pressure
The tablet pen pressure when the knot is being dragged.
void setFlag(unsigned int flag, bool set)
Set flag in knot, with side effects.
Glib::RefPtr< Gdk::Cursor > _cursors[SP_KNOT_VISIBLE_STATES]
Geom::Point grabbed_rel_pos
Grabbed relative position.
void updateCtrl()
Update knot's control state.
SPDesktop * desktop
Desktop we are on.
void moveto(Geom::Point const &p)
Move knot to new position, without emitting a MOVED signal.
void selectKnot(bool select)
Select knot.
bool eventHandler(Inkscape::CanvasEvent const &event)
Event handler (from CanvasItems).
void setCursor(SPKnotStateType type, Glib::RefPtr< Gdk::Cursor > cursor)
void startDragging(Geom::Point const &p, Geom::IntPoint const &xy, uint32_t etime)
Update knot for dragging and tell canvas an item was grabbed.
Editable view implementation.
TODO: insert short description here.
@ SP_KNOT_STATE_MOUSEOVER
void knot_created_callback(void *knot)
void knot_deleted_callback(void *knot)
TODO: insert short description here.
static auto const nograbenv
static constexpr auto KNOT_EVENT_MASK
Declarations for SPKnot: Desktop-bound visual control object.
Interface for locally managing a current status message.
Raw stack of active status messages.
Coord LInfty(Point const &p)
EventType
The type of a CanvasEvent.
Abstract base class for events.
unsigned modifiers
The modifiers mask immediately before the event.
The pointer has entered a widget or item.
The pointer has exited a widget or item.
Movement of the mouse pointer.