Inkscape
Vector Graphics Editor
|
#include <gradient-tool.h>
Public Member Functions | |
GradientTool (SPDesktop *desktop) | |
~GradientTool () override | |
void | add_stops_between_selected_stops () |
![]() | |
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 () |
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 Member Functions | |
void | select_next () |
void | select_prev () |
void | selection_changed () |
void | simplify (double tolerance) |
Remove unnecessary stops in the adjacent currently selected stops. | |
void | add_stop_near_point (SPItem *item, Geom::Point const &mouse_p) |
void | drag (Geom::Point const &pt, uint32_t etime) |
SPItem * | is_over_curve (Geom::Point const &event_p) |
Private Attributes | |
Geom::Point | mousepoint_doc |
Geom::Point | origin |
bool | cursor_addnode = false |
sigc::scoped_connection | selcon |
sigc::scoped_connection | subselcon |
Additional Inherited Members | |
![]() | |
std::unique_ptr< MessageContext > | message_context |
SelCue * | _selcue = nullptr |
GrDrag * | _grdrag = nullptr |
ShapeEditor * | shape_editor = nullptr |
bool | _uses_snap = false |
![]() | |
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 26 of file gradient-tool.h.
Inkscape::UI::Tools::GradientTool::GradientTool | ( | SPDesktop * | desktop | ) |
Definition at line 41 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_grdrag, SPDesktop::connect_gradient_stop_selected(), Inkscape::Selection::connectChanged(), desktop, Inkscape::UI::Tools::ToolBase::enableGrDrag(), Inkscape::UI::Tools::ToolBase::enableSelectionCue(), Inkscape::Preferences::get(), SPDesktop::getSelection(), selcon, GrDrag::selectByStop(), selection_changed(), subselcon, and Inkscape::UI::Tools::ToolBase::tolerance.
|
override |
Definition at line 69 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::enableGrDrag().
|
private |
Definition at line 394 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, GrDrag::addStopNearPoint(), SPDesktop::current_zoom(), Inkscape::DocumentUndo::done(), Inkscape::UI::Tools::ToolBase::get_drag(), SPDesktop::getDocument(), item, GrDrag::local_change, GrDrag::selectByStop(), Inkscape::UI::Tools::ToolBase::tolerance, and GrDrag::updateDraggers().
void Inkscape::UI::Tools::GradientTool::add_stops_between_selected_stops | ( | ) |
Definition at line 257 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_grdrag, Inkscape::DocumentUndo::done(), Inkscape::UI::Tools::get_stop_intervals(), getGradient(), GrDrag::hasSelection(), GrDrag::local_change, GrDrag::numSelected(), SPStop::offset, offset, SPObject::parent, POINT_LG_END, POINT_RG_FOCUS, POINT_RG_R1, POINT_RG_R2, GrDrag::selectByStop(), GrDrag::selected, sp_get_stop_i(), sp_gradient_add_stop(), sp_gradient_get_forked_vector_if_necessary(), sp_vector_add_stop(), and GrDrag::updateDraggers().
|
private |
Definition at line 701 of file gradient-tool.cpp.
References css, Inkscape::FOR_FILL, Inkscape::FOR_STROKE, Inkscape::Preferences::get(), SPObject::getRepr(), item, items, Inkscape::NORMAL_MESSAGE, origin, POINT_LG_BEGIN, POINT_LG_END, POINT_RG_CENTER, POINT_RG_R1, SPObject::requestModified(), SP_GRADIENT_TYPE_LINEAR, SP_GRADIENT_TYPE_RADIAL, sp_gradient_vector_for_object(), sp_item_gradient_set_coords(), sp_item_repr_compare_position_bool(), sp_item_set_gradient(), sp_repr_css_attr_new(), sp_repr_css_attr_unref(), sp_repr_css_change_recursive(), sp_repr_css_set_property(), and Inkscape::WARNING_MESSAGE.
Referenced by simplify().
|
private |
Definition at line 155 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::UI::Tools::ToolBase::_grdrag, GrDrag::item_curves, mousepoint_doc, Inkscape::UI::Tools::ToolBase::tolerance, and SPDesktop::w2d().
|
overrideprotectedvirtual |
Reimplemented from Inkscape::UI::Tools::ToolBase.
Definition at line 406 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::DocumentUndo::done(), Inkscape::Preferences::get(), SPDesktop::getDocument(), SPDesktop::getSelection(), Inkscape::inspect_event(), and Inkscape::UI::Tools::ToolBase::tolerance.
|
private |
Definition at line 141 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::UI::Tools::ToolBase::_grdrag, SPDesktop::scroll_to_point(), and GrDrag::select_next().
|
private |
Definition at line 148 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::UI::Tools::ToolBase::_grdrag, SPDesktop::scroll_to_point(), and GrDrag::select_prev().
|
private |
Definition at line 92 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_desktop, Inkscape::UI::Tools::ToolBase::_grdrag, SPDesktop::getSelection(), Inkscape::UI::Tools::gr_handle_descr, GrDrag::isNonEmpty(), Inkscape::UI::Tools::ToolBase::message_context, Inkscape::NORMAL_MESSAGE, GrDrag::numDraggers(), GrDrag::numSelected(), GrDrag::singleSelectedDraggerNumDraggables(), and GrDrag::singleSelectedDraggerSingleDraggableType().
Referenced by GradientTool().
|
private |
Remove unnecessary stops in the adjacent currently selected stops.
For selected stops that are adjacent to each other, remove stops that don't change the gradient visually, within a range of tolerance.
tolerance | maximum difference between stop and expected color at that position |
Definition at line 345 of file gradient-tool.cpp.
References Inkscape::UI::Tools::ToolBase::_grdrag, Inkscape::Colors::Color::averaged(), Inkscape::DocumentUndo::done(), drag(), Inkscape::UI::Tools::get_stop_intervals(), SPStop::getColor(), SPStop::offset, parent, and Inkscape::UI::Tools::ToolBase::tolerance.
|
private |
Definition at line 40 of file gradient-tool.h.
|
private |
Definition at line 38 of file gradient-tool.h.
Referenced by is_over_curve().
|
private |
Definition at line 39 of file gradient-tool.h.
|
private |
Definition at line 42 of file gradient-tool.h.
Referenced by GradientTool().
|
private |
Definition at line 43 of file gradient-tool.h.
Referenced by GradientTool().