Inkscape
Vector Graphics Editor
|
#include <rect-tool.h>
Public Member Functions | |
RectTool (SPDesktop *desktop) | |
~RectTool () override | |
void | set (Preferences::Entry const &val) override |
Called by our pref_observer if a preference has been changed. | |
bool | root_handler (CanvasEvent const &event) override |
bool | item_handler (SPItem *item, CanvasEvent const &event) override |
Handles item specific events. | |
![]() | |
ToolBase (SPDesktop *desktop, std::string &&prefs_path, std::string &&cursor_filename, bool uses_snap=true) | |
virtual | ~ToolBase () |
virtual void | menu_popup (CanvasEvent const &event, SPObject *obj=nullptr) |
Create popup menu and tell Gtk to show it. | |
virtual bool | can_undo (bool redo=false) |
virtual bool | is_ready () const |
virtual void | switching_away (std::string const &new_tool) |
std::string const & | getPrefsPath () const |
void | enableSelectionCue (bool enable=true) |
Enables/disables the ToolBase's SelCue. | |
MessageContext * | defaultMessageContext () const |
SPDesktop * | getDesktop () const |
SPGroup * | currentLayer () const |
void | set_last_active_tool (Glib::ustring last_tool) |
const Glib::ustring & | get_last_active_tool () const |
bool | start_root_handler (CanvasEvent const &event) |
Handles snapping events for all tools and then passes to tool_root_handler. | |
bool | tool_root_handler (CanvasEvent const &event) |
Calls the right tool's event handler, depending on the selected tool and state. | |
bool | start_item_handler (SPItem *item, CanvasEvent const &event) |
Starts handling item snapping and pass to virtual_item_handler afterwards. | |
bool | virtual_item_handler (SPItem *item, CanvasEvent const &event) |
bool | is_panning () const |
True if we're panning with any method (space bar, middle-mouse, right-mouse+Ctrl) | |
bool | is_space_panning () const |
True if we're panning with the space bar. | |
void | snap_delay_handler (gpointer item, gpointer item2, MotionEvent const &event, DelayedSnapEvent::Origin origin) |
Analyses the current event, calculates the mouse speed, turns snapping off (temporarily) if the mouse speed is above a threshold, and stores the current event such that it can be re-triggered when needed (re-triggering is controlled by a timeout). | |
void | process_delayed_snap_event () |
When the delayed snap event timer expires, this method will be called and will re-inject the last motion event in an appropriate place, with snapping being turned on again. | |
void | discard_delayed_snap_event () |
If a delayed snap event has been scheduled, this function will cancel it. | |
void | set_cursor (std::string filename) |
Sets the current cursor to the given filename. | |
void | use_cursor (Glib::RefPtr< Gdk::Cursor > cursor) |
Set the cursor to this specific one, don't remember it. | |
Glib::RefPtr< Gdk::Cursor > | get_cursor (Gtk::Widget &widget, std::string const &filename) const |
Returns the Gdk Cursor for the given filename. | |
void | use_tool_cursor () |
Uses the saved cursor, based on the saved filename. | |
void | enableGrDrag (bool enable=true) |
bool | deleteSelectedDrag (bool just_one) |
Delete a selected GrDrag point. | |
bool | hasGradientDrag () const |
Return true if there is a gradient drag. | |
GrDrag * | get_drag () |
Private Member Functions | |
void | drag (Geom::Point const pt, unsigned state) |
void | finishItem () |
void | cancel () |
void | selection_changed (Selection *selection) |
Callback that processes the "changed" signal on the selection; destroys old and creates new knotholder. | |
Private Attributes | |
SPWeakPtr< SPRect > | rect |
Geom::Point | center |
double | rx |
double | ry |
sigc::connection | sel_changed_connection |
Additional Inherited Members | |
![]() | |
std::unique_ptr< MessageContext > | message_context |
SelCue * | _selcue = nullptr |
GrDrag * | _grdrag = nullptr |
ShapeEditor * | shape_editor = nullptr |
bool | _uses_snap = false |
![]() | |
void | setup_for_drag_start (ButtonPressEvent const &ev) |
void | saveDragOrigin (Geom::Point const &pos) |
bool | checkDragMoved (Geom::Point const &pos) |
Analyse the current position and return true once it has moved farther than tolerance from the drag origin (indicating they intend to move the object, not click). | |
void | grabCanvasEvents (EventMask mask=EventType::KEY_PRESS|EventType::BUTTON_RELEASE|EventType::MOTION|EventType::BUTTON_PRESS) |
Grab events from the Canvas Catchall. | |
void | ungrabCanvasEvents () |
Ungrab events from the Canvas Catchall. | |
bool | sp_event_context_knot_mouseover () const |
Returns true if we're hovering above a knot (needed because we don't want to pre-snap in that case). | |
void | set_high_motion_precision (bool high_precision=true) |
Enable (or disable) high precision for motion events. | |
![]() | |
Glib::RefPtr< Gdk::Cursor > | _cursor |
std::string | _cursor_filename = "select.svg" |
std::string | _cursor_default = "select.svg" |
Geom::IntPoint | xyp |
where drag started | |
bool | dragging = false |
are we dragging? | |
int | tolerance = 0 |
bool | within_tolerance = false |
are we still within tolerance of origin | |
bool | _button1on = false |
bool | _button2on = false |
bool | _button3on = false |
SPItem * | item_to_select = nullptr |
the item where mouse_press occurred, to be selected if this is a click not drag | |
SPDesktop * | _desktop = nullptr |
Util::ActionAccel | _acc_undo |
Util::ActionAccel | _acc_redo |
Util::ActionAccel | _acc_quick_preview |
Util::ActionAccel | _acc_quick_zoom |
Util::ActionAccel | _acc_quick_pan |
Definition at line 31 of file rect-tool.h.
Inkscape::UI::Tools::RectTool::RectTool | ( | SPDesktop * | desktop | ) |
Definition at line 47 of file rect-tool.cpp.
References Inkscape::Selection::connectChanged(), desktop, Inkscape::UI::Tools::ToolBase::enableGrDrag(), Inkscape::UI::Tools::ToolBase::enableSelectionCue(), Inkscape::Preferences::get(), Inkscape::Preferences::getBool(), SPDesktop::getSelection(), item, sel_changed_connection, selection_changed(), Inkscape::UI::ShapeEditor::set_item(), Inkscape::UI::Tools::ToolBase::shape_editor, Inkscape::ObjectSet::singleItem(), and Inkscape::UI::Tools::sp_event_context_read().
|
override |
Definition at line 77 of file rect-tool.cpp.
References Inkscape::UI::Tools::ToolBase::enableGrDrag(), finishItem(), rect, sel_changed_connection, Inkscape::UI::Tools::ToolBase::shape_editor, and Inkscape::UI::Tools::ToolBase::ungrabCanvasEvents().
|
private |
Definition at line 409 of file rect-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::DocumentUndo::cancel(), Inkscape::ObjectSet::clear(), SPObject::deleteObject(), SPDesktop::getDocument(), SPDesktop::getSelection(), Inkscape::UI::Tools::ToolBase::item_to_select, rect, Inkscape::UI::Tools::ToolBase::ungrabCanvasEvents(), Inkscape::UI::Tools::ToolBase::within_tolerance, and Inkscape::UI::Tools::ToolBase::xyp.
Referenced by finishItem(), and root_handler().
|
private |
Definition at line 301 of file rect-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::XML::Document::createElement(), Inkscape::UI::Tools::ToolBase::currentLayer(), Inkscape::UI::Tools::ToolBase::defaultMessageContext(), Geom::GenericRect< C >::dimensions(), SPNamedView::display_units, SPDesktop::doc(), Inkscape::SPWeakPtr< T >::get(), SPDesktop::getNamedView(), SPDocument::getReprDoc(), goldenratio, Inkscape::have_viable_layer(), SPItem::i2doc_affine(), Inkscape::IMMEDIATE_MESSAGE, Geom::Affine::inverse(), Inkscape::UI::Tools::ToolBase::message_context, Geom::GenericRect< C >::min(), MIN, rect, Inkscape::GC::release(), rx, ry, SPRect::setPosition(), SPRect::setRx(), SPRect::setRy(), Inkscape::snap_rectangular_box(), sp_desktop_apply_style_tool(), Inkscape::Util::Quantity::string(), SPItem::transform, SPObject::updateRepr(), Geom::X, and Geom::Y.
Referenced by root_handler().
|
private |
Definition at line 388 of file rect-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, cancel(), SVGLength::computed, Inkscape::DocumentUndo::done(), SPItem::doWriteTransform(), Inkscape::SPWeakPtr< T >::get(), SPDesktop::getDocument(), SPDesktop::getSelection(), Inkscape::UI::Tools::ToolBase::message_context, rect, Inkscape::Selection::set(), sp_lpe_item_update_patheffect(), SPItem::transform, SPObject::updateRepr(), and SPRect::width.
Referenced by root_handler(), and ~RectTool().
|
overridevirtual |
Handles item specific events.
Gets called from Gdk.
Only reacts to right mouse button at the moment.
Reimplemented from Inkscape::UI::Tools::ToolBase.
Definition at line 115 of file rect-tool.cpp.
References Inkscape::inspect_event(), item, and Inkscape::UI::Tools::ToolBase::item_handler().
|
overridevirtual |
Reimplemented from Inkscape::UI::Tools::ToolBase.
Definition at line 129 of file rect-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, cancel(), Inkscape::UI::Tools::ToolBase::checkDragMoved(), Inkscape::MessageContext::clear(), Inkscape::UI::Tools::ToolBase::defaultMessageContext(), Inkscape::UI::Tools::ToolBase::deleteSelectedDrag(), Inkscape::UI::Tools::ToolBase::discard_delayed_snap_event(), drag(), Inkscape::UI::Tools::ToolBase::dragging, finishItem(), Inkscape::Preferences::get(), Inkscape::UI::Tools::get_latin_keyval(), SPDesktop::getNamedView(), SPDesktop::getSelection(), Inkscape::UI::Tools::gobble_motion_events(), Inkscape::inspect_event(), Inkscape::UI::Tools::ToolBase::item_to_select, Inkscape::mod_alt_only(), Inkscape::mod_ctrl_only(), Inkscape::mod_shift_only(), Inkscape::CanvasEvent::modifiers, rect, Inkscape::UI::Tools::ToolBase::root_handler(), SPDesktop::setToolboxFocusTo(), SnapManager::setup(), SPNamedView::snap_manager, Inkscape::SNAPSOURCE_NODE_HANDLE, Inkscape::UI::Tools::ToolBase::sp_event_context_knot_mouseover(), Inkscape::UI::Tools::sp_event_show_modifier_tip(), Inkscape::ObjectSet::toGuides(), Inkscape::UI::Tools::ToolBase::tolerance, Inkscape::UI::Tools::ToolBase::ungrabCanvasEvents(), SPDesktop::w2d(), Inkscape::UI::Tools::ToolBase::within_tolerance, and Inkscape::UI::Tools::ToolBase::xyp.
|
private |
Callback that processes the "changed" signal on the selection; destroys old and creates new knotholder.
Definition at line 98 of file rect-tool.cpp.
References Inkscape::UI::ShapeEditor::set_item(), Inkscape::UI::Tools::ToolBase::shape_editor, Inkscape::ObjectSet::singleItem(), and Inkscape::UI::ShapeEditor::unset_item().
Referenced by RectTool().
|
overridevirtual |
Called by our pref_observer if a preference has been changed.
Reimplemented from Inkscape::UI::Tools::ToolBase.
Definition at line 103 of file rect-tool.cpp.
References Inkscape::Preferences::Entry::getDoubleLimited(), Inkscape::Preferences::Entry::getEntryName(), name, rx, and ry.
|
private |
Definition at line 43 of file rect-tool.h.
Definition at line 42 of file rect-tool.h.
Referenced by cancel(), drag(), finishItem(), root_handler(), and ~RectTool().
|
private |
Definition at line 45 of file rect-tool.h.
|
private |
Definition at line 46 of file rect-tool.h.
|
private |
Definition at line 48 of file rect-tool.h.
Referenced by RectTool(), and ~RectTool().