Inkscape
Vector Graphics Editor
|
#include <canvas-item-ctrl.h>
Public Member Functions | |
CanvasItemCtrl (CanvasItemGroup *group) | |
Create a null control node. | |
CanvasItemCtrl (CanvasItemGroup *group, CanvasItemCtrlType type) | |
Create a control with type. | |
CanvasItemCtrl (CanvasItemGroup *group, CanvasItemCtrlType type, Geom::Point const &p) | |
Create a control ctrl. | |
void | set_position (Geom::Point const &position) |
Set the position. | |
double | closest_distance_to (Geom::Point const &p) const |
Returns distance between point in canvas units and position of ctrl. | |
bool | contains (Geom::Point const &p, double tolerance=0) override |
If tolerance is zero, returns true if point p (in canvas units) is inside bounding box, else returns true if p (in canvas units) is within tolerance (canvas units) distance of ctrl. | |
void | set_size (HandleSize rel_size) |
void | set_fill (uint32_t rgba) override |
void | set_stroke (uint32_t rgba) override |
void | set_shape (CanvasItemCtrlShape shape) |
void | set_size_via_index (int size_index) |
void | set_size_default () |
void | set_anchor (SPAnchorType anchor) |
void | set_angle (double angle) |
void | set_type (CanvasItemCtrlType type) |
void | set_selected (bool selected=true) |
void | set_click (bool click=true) |
void | set_hover (bool hover=true) |
void | set_normal (bool selected=false) |
Reset the state to normal or normal selected. | |
void | _set_size (int size) |
![]() | |
CanvasItem (CanvasItemContext *context) | |
CanvasItem (CanvasItemGroup *parent) | |
CanvasItem (CanvasItem const &)=delete | |
CanvasItem & | operator= (CanvasItem const &)=delete |
void | unlink () |
UI::Widget::Canvas * | get_canvas () const |
CanvasItemGroup * | get_parent () const |
bool | is_descendant_of (CanvasItem const *ancestor) const |
void | set_z_position (int zpos) |
void | raise_to_top () |
void | lower_to_bottom () |
void | request_update () |
void | update (bool propagate) |
virtual void | visit_page_rects (std::function< void(Geom::Rect const &)> const &) const |
Geom::OptRect const & | get_bounds () const |
void | grab (EventMask event_mask, Glib::RefPtr< Gdk::Cursor > const &={}) |
void | ungrab () |
void | render (Inkscape::CanvasItemBuffer &buf) const |
bool | is_visible () const |
virtual void | set_visible (bool visible) |
void | request_redraw () |
void | set_fill (CanvasItemColor color) |
void | set_fill_pattern (Cairo::RefPtr< Cairo::Pattern > pattern) |
void | set_stroke (CanvasItemColor color) |
void | set_stroke_width (double width) |
Set the stroke width. | |
void | set_outline (uint32_t color) |
Set the outline color. | |
void | set_outline_width (double width) |
Set the outline width. | |
double | get_effective_outline () const |
Get the effective outline. | |
void | set_name (std::string &&name) |
std::string const & | get_name () const |
void | update_canvas_item_ctrl_sizes (int size_index) |
void | set_pickable (bool pickable) |
bool | is_pickable () const |
sigc::connection | connect_event (sigc::slot< bool(CanvasEvent const &)> const &slot) |
virtual bool | handle_event (CanvasEvent const &event) |
void | canvas_item_print_tree (int level=0, int zorder=0) const |
Protected Member Functions | |
~CanvasItemCtrl () override=default | |
void | _update (bool propagate) override |
Update and redraw control ctrl. | |
void | _render (CanvasItemBuffer &buf) const override |
Render ctrl to screen via Cairo. | |
void | _invalidate_ctrl_handles () override |
void | build_cache (int device_scale) const |
Build object-specific cache. | |
float | get_width () const |
float | get_total_width () const |
![]() | |
virtual | ~CanvasItem () |
Geom::Affine const & | affine () const |
virtual void | _mark_net_invisible () |
template<typename F > | |
void | defer (F &&f) |
Private Member Functions | |
float | get_stroke_width () const |
int | get_pixmap_width (int device_scale) const |
void | _dump () |
Private Attributes | |
Geom::Point | _position |
InitLock | _built |
std::shared_ptr< Cairo::ImageSurface const > | _cache |
Handles::TypeState | _handle |
CanvasItemCtrlShape | _shape = CANVAS_ITEM_CTRL_SHAPE_SQUARE |
uint32_t | _fill = 0x000000ff |
uint32_t | _stroke = 0xffffffff |
bool | _shape_set = false |
bool | _fill_set = false |
bool | _stroke_set = false |
bool | _size_set = false |
double | _angle = 0 |
SPAnchorType | _anchor = SP_ANCHOR_CENTER |
int | _width = 5 |
HandleSize | _rel_size = HandleSize::NORMAL |
Geom::Point | _pos |
Additional Inherited Members | |
![]() | |
boost::intrusive::list_member_hook | member_hook |
![]() | |
CanvasItemContext * | _context |
CanvasItemGroup * | _parent |
Geom::OptRect | _bounds |
bool | _need_update = false |
bool | _visible = true |
bool | _net_visible = true |
bool | _pickable = false |
uint32_t | _fill = CANVAS_ITEM_COLORS[CANVAS_ITEM_SECONDARY] |
Cairo::RefPtr< Cairo::Pattern > | _fill_pattern |
uint32_t | _stroke = CANVAS_ITEM_COLORS[CANVAS_ITEM_PRIMARY] |
double | _stroke_width = 1.0 |
uint32_t | _outline = 0x0 |
double | _outline_width = 0 |
std::string | _name |
sigc::signal< bool(CanvasEvent const &)> | _event_signal |
Definition at line 36 of file canvas-item-ctrl.h.
Inkscape::CanvasItemCtrl::CanvasItemCtrl | ( | CanvasItemGroup * | group | ) |
Create a null control node.
Definition at line 36 of file canvas-item-ctrl.cpp.
References Inkscape::CanvasItem::_name, and Inkscape::CanvasItem::_pickable.
Inkscape::CanvasItemCtrl::CanvasItemCtrl | ( | CanvasItemGroup * | group, |
CanvasItemCtrlType | type | ||
) |
Create a control with type.
Definition at line 46 of file canvas-item-ctrl.cpp.
References _dump(), _handle, Inkscape::CanvasItem::_name, Inkscape::CanvasItem::_pickable, set_size_default(), and Inkscape::Handles::TypeState::type.
Inkscape::CanvasItemCtrl::CanvasItemCtrl | ( | CanvasItemGroup * | group, |
CanvasItemCtrlType | type, | ||
Geom::Point const & | p | ||
) |
Create a control ctrl.
Point is in document coordinates.
Definition at line 136 of file canvas-item-ctrl.cpp.
References _position, and Inkscape::CanvasItem::request_update().
|
overrideprotecteddefault |
|
private |
Definition at line 58 of file canvas-item-ctrl.cpp.
References _position, _render(), _update(), buf, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_CALIGN, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_CENTER, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_HANDLE, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_MALIGN, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_ROTATE, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_SALIGN, Inkscape::CANVAS_ITEM_CTRL_TYPE_ADJ_SKEW, Inkscape::CANVAS_ITEM_CTRL_TYPE_CENTER, Inkscape::CANVAS_ITEM_CTRL_TYPE_GUIDE_HANDLE, Inkscape::CANVAS_ITEM_CTRL_TYPE_MARKER, Inkscape::CANVAS_ITEM_CTRL_TYPE_NODE_AUTO, Inkscape::CANVAS_ITEM_CTRL_TYPE_NODE_CUSP, Inkscape::CANVAS_ITEM_CTRL_TYPE_NODE_SMOOTH, Inkscape::CANVAS_ITEM_CTRL_TYPE_POINT, Inkscape::CANVAS_ITEM_CTRL_TYPE_POINTER, DUMP_HANDLES, Inkscape::CanvasItemBuffer::rect, scale, set_hover(), set_size_via_index(), set_type(), Inkscape::size, and surface.
Referenced by CanvasItemCtrl().
|
overrideprotectedvirtual |
Reimplemented from Inkscape::CanvasItem.
Definition at line 501 of file canvas-item-ctrl.cpp.
References _built, Inkscape::CanvasItem::_context, Inkscape::CanvasItem::request_update(), InitLock::reset(), and Inkscape::CanvasItemContext::snapshotted().
|
overrideprotectedvirtual |
Render ctrl to screen via Cairo.
Implements Inkscape::CanvasItem.
Definition at line 485 of file canvas-item-ctrl.cpp.
References _built, _cache, _pos, buf, build_cache(), and InitLock::init().
Referenced by _dump().
void Inkscape::CanvasItemCtrl::_set_size | ( | int | size | ) |
Definition at line 215 of file canvas-item-ctrl.cpp.
References _built, _width, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_update(), InitLock::reset(), and Inkscape::size.
Referenced by set_size_via_index().
|
overrideprotectedvirtual |
Update and redraw control ctrl.
Implements Inkscape::CanvasItem.
Definition at line 350 of file canvas-item-ctrl.cpp.
References _anchor, _angle, Inkscape::CanvasItem::_bounds, _built, Inkscape::CanvasItem::_context, _handle, _pos, _position, _shape, _shape_set, Inkscape::CanvasItem::affine(), Inkscape::angle_of(), Inkscape::CANVAS_ITEM_CTRL_SHAPE_CALIGN, Inkscape::CANVAS_ITEM_CTRL_SHAPE_CARROW, Inkscape::CANVAS_ITEM_CTRL_SHAPE_DARROW, Inkscape::CANVAS_ITEM_CTRL_SHAPE_MALIGN, Inkscape::CANVAS_ITEM_CTRL_SHAPE_PIVOT, Inkscape::CANVAS_ITEM_CTRL_SHAPE_SALIGN, Inkscape::CANVAS_ITEM_CTRL_SHAPE_SARROW, Geom::Affine::flips(), Geom::GenericRect< Coord >::from_xywh(), get_total_width(), Inkscape::CanvasItemContext::handlesCss(), Geom::Point::isFinite(), Inkscape::CanvasItem::request_redraw(), InitLock::reset(), SP_ANCHOR_CENTER, SP_ANCHOR_E, SP_ANCHOR_N, SP_ANCHOR_NE, SP_ANCHOR_NW, SP_ANCHOR_S, SP_ANCHOR_SE, SP_ANCHOR_SW, SP_ANCHOR_W, and width.
Referenced by _dump().
|
protected |
Build object-specific cache.
Definition at line 518 of file canvas-item-ctrl.cpp.
References _angle, _cache, Inkscape::CanvasItem::_context, _fill, _fill_set, _handle, _shape, _shape_set, _stroke, _stroke_set, Inkscape::Handles::draw(), fill, get_pixmap_width(), get_stroke_width(), get_width(), Inkscape::CanvasItemContext::handlesCss(), Inkscape::size, and width.
Referenced by _render().
double Inkscape::CanvasItemCtrl::closest_distance_to | ( | Geom::Point const & | p | ) | const |
Returns distance between point in canvas units and position of ctrl.
Definition at line 158 of file canvas-item-ctrl.cpp.
References _position, Inkscape::CanvasItem::affine(), and Geom::distance().
Referenced by contains().
|
overridevirtual |
If tolerance is zero, returns true if point p (in canvas units) is inside bounding box, else returns true if p (in canvas units) is within tolerance (canvas units) distance of ctrl.
The latter assumes ctrl center anchored.
Reimplemented from Inkscape::CanvasItem.
Definition at line 169 of file canvas-item-ctrl.cpp.
References Inkscape::CanvasItem::_bounds, and closest_distance_to().
|
private |
Definition at line 261 of file canvas-item-ctrl.cpp.
References get_total_width().
Referenced by build_cache().
|
private |
Definition at line 508 of file canvas-item-ctrl.cpp.
References Inkscape::CanvasItem::_context, _handle, _width, and Inkscape::CanvasItemContext::handlesCss().
Referenced by build_cache(), and get_total_width().
|
protected |
Definition at line 255 of file canvas-item-ctrl.cpp.
References Inkscape::CanvasItem::_context, _handle, get_stroke_width(), get_width(), Inkscape::CanvasItemContext::handlesCss(), and width.
Referenced by _update(), and get_pixmap_width().
|
protected |
Definition at line 249 of file canvas-item-ctrl.cpp.
References Inkscape::CanvasItem::_context, _handle, _width, Inkscape::CanvasItemContext::handlesCss(), and Inkscape::size.
Referenced by build_cache(), get_total_width(), and Inkscape::CanvasItemGuideHandle::radius().
void Inkscape::CanvasItemCtrl::set_anchor | ( | SPAnchorType | anchor | ) |
Definition at line 333 of file canvas-item-ctrl.cpp.
References _anchor, Inkscape::CanvasItem::defer(), and Inkscape::CanvasItem::request_update().
void Inkscape::CanvasItemCtrl::set_angle | ( | double | angle | ) |
Definition at line 323 of file canvas-item-ctrl.cpp.
References _angle, _built, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_update(), and InitLock::reset().
void Inkscape::CanvasItemCtrl::set_click | ( | bool | click = true | ) |
Definition at line 291 of file canvas-item-ctrl.cpp.
References _built, _handle, Inkscape::Handles::TypeState::click, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_update(), and InitLock::reset().
|
overridevirtual |
Reimplemented from Inkscape::CanvasItem.
Definition at line 182 of file canvas-item-ctrl.cpp.
References _built, _fill, _fill_set, Inkscape::CanvasItem::defer(), fill, Inkscape::CanvasItem::request_redraw(), and InitLock::reset().
void Inkscape::CanvasItemCtrl::set_hover | ( | bool | hover = true | ) |
Definition at line 300 of file canvas-item-ctrl.cpp.
References _built, _handle, Inkscape::CanvasItem::defer(), Inkscape::Handles::TypeState::hover, Inkscape::CanvasItem::request_update(), and InitLock::reset().
Referenced by _dump().
void Inkscape::CanvasItemCtrl::set_normal | ( | bool | selected = false | ) |
Reset the state to normal or normal selected.
Definition at line 312 of file canvas-item-ctrl.cpp.
References _built, _handle, Inkscape::Handles::TypeState::click, Inkscape::CanvasItem::defer(), Inkscape::Handles::TypeState::hover, Inkscape::CanvasItem::request_update(), InitLock::reset(), and Inkscape::Handles::TypeState::selected.
void Inkscape::CanvasItemCtrl::set_position | ( | Geom::Point const & | position | ) |
Set the position.
Point is in document coordinates.
Definition at line 146 of file canvas-item-ctrl.cpp.
References _position, Inkscape::CanvasItem::defer(), and Inkscape::CanvasItem::request_update().
void Inkscape::CanvasItemCtrl::set_selected | ( | bool | selected = true | ) |
Definition at line 282 of file canvas-item-ctrl.cpp.
References _built, _handle, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_update(), InitLock::reset(), and Inkscape::Handles::TypeState::selected.
Referenced by Inkscape::Display::SnapIndicator::set_new_snaptarget().
void Inkscape::CanvasItemCtrl::set_shape | ( | CanvasItemCtrlShape | shape | ) |
Definition at line 204 of file canvas-item-ctrl.cpp.
References _built, _shape, _shape_set, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_update(), and InitLock::reset().
Referenced by Inkscape::CanvasItemGuideHandle::CanvasItemGuideHandle().
void Inkscape::CanvasItemCtrl::set_size | ( | HandleSize | rel_size | ) |
Definition at line 232 of file canvas-item-ctrl.cpp.
References _rel_size, Inkscape::get_size_default(), and set_size_via_index().
void Inkscape::CanvasItemCtrl::set_size_default | ( | ) |
Definition at line 265 of file canvas-item-ctrl.cpp.
References Inkscape::get_size_default(), set_size_via_index(), and Inkscape::size.
Referenced by CanvasItemCtrl(), and set_type().
void Inkscape::CanvasItemCtrl::set_size_via_index | ( | int | size_index | ) |
Definition at line 237 of file canvas-item-ctrl.cpp.
References _rel_size, _set_size(), Inkscape::MAX_INDEX, Inkscape::MIN_INDEX, and Inkscape::size.
Referenced by _dump(), set_size(), and set_size_default().
|
overridevirtual |
Reimplemented from Inkscape::CanvasItem.
Definition at line 193 of file canvas-item-ctrl.cpp.
References _built, _stroke, _stroke_set, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_redraw(), InitLock::reset(), and stroke.
void Inkscape::CanvasItemCtrl::set_type | ( | CanvasItemCtrlType | type | ) |
Definition at line 271 of file canvas-item-ctrl.cpp.
References _built, _handle, Inkscape::CanvasItem::defer(), Inkscape::CanvasItem::request_update(), InitLock::reset(), set_size_default(), and Inkscape::Handles::TypeState::type.
Referenced by _dump().
|
private |
Definition at line 95 of file canvas-item-ctrl.h.
Referenced by _update(), and set_anchor().
|
private |
Definition at line 94 of file canvas-item-ctrl.h.
Referenced by _update(), build_cache(), and set_angle().
|
private |
Definition at line 83 of file canvas-item-ctrl.h.
Referenced by _invalidate_ctrl_handles(), _render(), _set_size(), _update(), set_angle(), set_click(), set_fill(), set_hover(), set_normal(), set_selected(), set_shape(), set_stroke(), and set_type().
|
mutableprivate |
Definition at line 84 of file canvas-item-ctrl.h.
Referenced by _render(), and build_cache().
|
private |
Definition at line 88 of file canvas-item-ctrl.h.
Referenced by build_cache(), and set_fill().
|
private |
Definition at line 91 of file canvas-item-ctrl.h.
Referenced by build_cache(), and set_fill().
|
private |
Definition at line 86 of file canvas-item-ctrl.h.
Referenced by _update(), build_cache(), CanvasItemCtrl(), get_stroke_width(), get_total_width(), get_width(), set_click(), set_hover(), set_normal(), set_selected(), and set_type().
|
private |
Definition at line 98 of file canvas-item-ctrl.h.
|
private |
Definition at line 81 of file canvas-item-ctrl.h.
Referenced by _dump(), _update(), CanvasItemCtrl(), closest_distance_to(), and set_position().
|
private |
Definition at line 97 of file canvas-item-ctrl.h.
Referenced by set_size(), and set_size_via_index().
|
private |
Definition at line 87 of file canvas-item-ctrl.h.
Referenced by _update(), build_cache(), and set_shape().
|
private |
Definition at line 90 of file canvas-item-ctrl.h.
Referenced by _update(), build_cache(), and set_shape().
|
private |
Definition at line 93 of file canvas-item-ctrl.h.
|
private |
Definition at line 89 of file canvas-item-ctrl.h.
Referenced by build_cache(), and set_stroke().
|
private |
Definition at line 92 of file canvas-item-ctrl.h.
Referenced by build_cache(), and set_stroke().
|
private |
Definition at line 96 of file canvas-item-ctrl.h.
Referenced by _set_size(), get_stroke_width(), and get_width().