Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
draw-anchor.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/*
7 * Authors:
8 * Copyright (C) 2000 Lauris Kaplinski
9 * Copyright (C) 2000-2001 Ximian, Inc.
10 * Copyright (C) 2002 Lauris Kaplinski
11 * Copyright (C) 2004 Monash University
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16
17#include "ui/draw-anchor.h"
18#include "ui/tools/tool-base.h"
19#include "ui/tools/lpe-tool.h"
20
22#include "display/curve.h"
23
28 : dc(dc), curve(std::move(curve)), start(start), active(FALSE), dp(delta),
29 ctrl(
30 make_canvasitem<Inkscape::CanvasItemCtrl>(
31 dc->getDesktop()->getCanvasControls(),
32 Inkscape::CANVAS_ITEM_CTRL_TYPE_ANCHOR
33 )
34 )
35{
36 ctrl->set_name("CanvasItemCtrl:DrawAnchor");
37 ctrl->set_position(delta);
38 ctrl->set_pickable(false); // We do our own checking. (TODO: Should be fixed!)
39}
40
42
48{
49 if (activate && ctrl->contains(w)) {
50 if (!active) {
51 ctrl->set_hover();
53 active = TRUE;
54 }
55 return this;
56 }
57
58 if (active) {
59 ctrl->set_normal();
61 active = FALSE;
62 }
63
64 return nullptr;
65}
66
67/*
68 Local Variables:
69 mode:c++
70 c-file-style:"stroustrup"
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
72 indent-tabs-mode:nil
73 fill-column:99
74 End:
75*/
76// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
auto make_canvasitem(Args &&... args)
Convienence function to create a CanvasItemPtr, like std::make_unique.
Two-dimensional point that doubles as a vector.
Definition point.h:66
The drawing anchor.
Definition draw-anchor.h:40
SPDrawAnchor(Inkscape::UI::Tools::FreehandBase *dc, std::shared_ptr< Geom::PathVector > curve, bool start, Geom::Point delta)
Creates an anchor object and initializes it.
CanvasItemPtr< Inkscape::CanvasItemCtrl > ctrl
Definition draw-anchor.h:47
SPDrawAnchor * anchorTest(Geom::Point w, bool activate)
Test if point is near anchor, if so fill anchor on canvas and return pointer to it or NULL.
const double w
Definition conic-4.cpp:19
The nodes at the ends of the path in the pen/pencil tools.
LPETool: a generic tool composed of subtools that are given by LPEs.
Geom::Point start
Helper class to stream background task notifications as a series of messages.
STL namespace.
Definition curve.h:24
int delta
static void activate(GApplication *app, gpointer)