Inkscape
Vector Graphics Editor
|
#include <dropper-tool.h>
Public Member Functions | |
DropperTool (SPDesktop *desktop) | |
~DropperTool () override | |
std::optional< Colors::Color > | get_color (bool invert=false, bool non_dropping=false) const |
Returns the current dropper context color. | |
![]() | |
ToolBase (SPDesktop *desktop, std::string &&prefs_path, std::string &&cursor_filename, bool uses_snap=true) | |
virtual | ~ToolBase () |
virtual void | set (Preferences::Entry const &val) |
Called by our pref_observer if a preference has been changed. | |
virtual bool | item_handler (SPItem *item, CanvasEvent const &event) |
Handles item specific events. | |
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 () |
Public Attributes | |
sigc::signal< void(Colors::Color const &)> | onetimepick_signal |
![]() | |
std::unique_ptr< MessageContext > | message_context |
SelCue * | _selcue = nullptr |
GrDrag * | _grdrag = nullptr |
ShapeEditor * | shape_editor = nullptr |
bool | _uses_snap = false |
Protected Member Functions | |
bool | root_handler (CanvasEvent const &event) override |
![]() | |
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. | |
Private Attributes | |
std::optional< Colors::Color > | stored_color |
std::optional< Colors::Color > | non_dropping_color |
bool | invert = false |
Set color to inverse rgb value. | |
bool | stroke = false |
Set to stroke color. In dropping mode, set from stroke color. | |
bool | dropping = false |
When true, get color from selected objects instead of canvas. | |
double | radius = 0.0 |
Size of region under dragging mode. | |
CanvasItemPtr< CanvasItemBpath > | area |
Circle depicting region's borders in dragging mode. | |
Geom::Point | centre |
Center of region in dragging mode. | |
Additional Inherited Members | |
![]() | |
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 22 of file dropper-tool.h.
Inkscape::UI::Tools::DropperTool::DropperTool | ( | SPDesktop * | desktop | ) |
Definition at line 46 of file dropper-tool.cpp.
References area, desktop, Inkscape::UI::Tools::ToolBase::enableGrDrag(), Inkscape::UI::Tools::ToolBase::enableSelectionCue(), Inkscape::Preferences::get(), SPDesktop::getCanvasControls(), and SP_WIND_RULE_EVENODD.
|
override |
Definition at line 65 of file dropper-tool.cpp.
References Inkscape::UI::Tools::ToolBase::enableGrDrag(), and Inkscape::UI::Tools::ToolBase::ungrabCanvasEvents().
std::optional< Colors::Color > Inkscape::UI::Tools::DropperTool::get_color | ( | bool | invert = false , |
bool | non_dropping = false |
||
) | const |
Returns the current dropper context color.
invert | If true, invert the rgb value |
non_dropping | If true, use color from canvas, even in dropping mode. |
Definition at line 83 of file dropper-tool.cpp.
References Inkscape::Preferences::get(), invert, non_dropping_color, Inkscape::UI::Tools::PICK_ACTUAL, Inkscape::UI::Tools::PICK_VISIBLE, and stored_color.
Referenced by root_handler().
|
overrideprotectedvirtual |
Reimplemented from Inkscape::UI::Tools::ToolBase.
Definition at line 103 of file dropper-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_cursor_filename, Inkscape::UI::Tools::ToolBase::_desktop, area, Inkscape::Drawing::averageColor(), Inkscape::BUTTON_PRESS, Inkscape::BUTTON_RELEASE, centre, Inkscape::ObjectSet::clear(), Inkscape::Colors::Color::composed(), Inkscape::UI::Tools::ToolBase::defaultMessageContext(), Inkscape::DocumentUndo::done(), Inkscape::UI::Tools::ToolBase::dragging, dropping, Geom::GenericRect< C >::from_xywh(), Inkscape::Preferences::get(), get_color(), Inkscape::CanvasItemDrawing::get_drawing(), Inkscape::UI::Tools::get_latin_keyval(), SPDesktop::getCanvas(), SPDesktop::getCanvasDrawing(), Inkscape::PageManager::getDefaultBackgroundColor(), SPDesktop::getDocument(), SPDocument::getPageManager(), SPDesktop::getSelection(), Inkscape::UI::Tools::ToolBase::grabCanvasEvents(), Inkscape::inspect_event(), invert, Inkscape::ObjectSet::isEmpty(), Inkscape::UI::Tools::ToolBase::item_to_select, Inkscape::KEY_PRESS, Inkscape::KEY_RELEASE, Inkscape::mod_ctrl_only(), Inkscape::CanvasEvent::modifiers, Inkscape::MOTION, non_dropping_color, Inkscape::NORMAL_MESSAGE, onetimepick_signal, Inkscape::UI::Tools::PICK_VISIBLE, radius, Inkscape::UI::Tools::ToolBase::root_handler(), scale, Inkscape::set_svg_cursor(), Inkscape::MessageContext::setF(), sp_desktop_set_color(), Inkscape::UI::Tools::sp_event_context_find_item(), Inkscape::UI::Tools::sp_toggle_dropper(), stored_color, stroke, Inkscape::UI::Tools::ToolBase::ungrabCanvasEvents(), and SPDesktop::w2d().
|
private |
Circle depicting region's borders in dragging mode.
Definition at line 48 of file dropper-tool.h.
Referenced by DropperTool(), and root_handler().
|
private |
Center of region in dragging mode.
Definition at line 49 of file dropper-tool.h.
Referenced by root_handler().
|
private |
When true, get color from selected objects instead of canvas.
Definition at line 44 of file dropper-tool.h.
Referenced by root_handler().
|
private |
Set color to inverse rgb value.
Definition at line 42 of file dropper-tool.h.
Referenced by get_color(), and root_handler().
|
private |
Definition at line 40 of file dropper-tool.h.
Referenced by get_color(), and root_handler().
sigc::signal<void (Colors::Color const &)> Inkscape::UI::Tools::DropperTool::onetimepick_signal |
Definition at line 29 of file dropper-tool.h.
Referenced by root_handler().
|
private |
Size of region under dragging mode.
Definition at line 47 of file dropper-tool.h.
Referenced by root_handler().
|
private |
Definition at line 36 of file dropper-tool.h.
Referenced by get_color(), and root_handler().
|
private |
Set to stroke color. In dropping mode, set from stroke color.
Definition at line 43 of file dropper-tool.h.
Referenced by root_handler().