Dev:State stroke

From Synfig Studio :: Documentation
Jump to: navigation, search


state_stroke is an 'invisible' mode - that is, you can't select it from the Toolbox. You see it on the Draw Tool and the Sketch Tool between mouse-down and mouse up, it's what's actually drawing to the canvas and taking your data.

NOTE: state_stroke does NOT handle mouse-down! This is to allow your tool to figure out if it needs to do anything different based on where the mouse is clicking, *before* state_stroke is entered!



EventStroke is sent to the tool that calls state_stroke as soon as the state exits, along with the stroke data. Intercept this event to do something with the data.


Events Caught

  • EVENT_STOP: event_stop_handler
  • EVENT_REFRESH: event_refresh_handler
  • EVENT_WORKAREA_MOUSE_BUTTON_UP: event_mouse_up_handler
  • EVENT_WORKAREA_MOUSE_BUTTON_DRAG: event_mouse_draw_handler
  • EVENT_REFRESH_TOOL_OPTIONS event_refresh_tool_options


State constructor


State destructor

Restores the previous duck view, refreshes the toolbox, and raises EventStroke on the State Machine.


Intercepts the event, and nothing further.


exits the state (pop-exception)


Intercepts the event, and nothing further.


MouseUp Handler

If this is the LMB, set 'modifier' for the destructor event from the mouse event's data, then exit the state (pop-exception)

If this is for the RMB, intercept the signal and end.

If this is for any other mouse button, pass it along.


Mouse drag event handler

If this is the LMB, accept the event, add the event's position to stroke_data, and the event's pressure to width_data, and call queue_draw (?).

If it's the RMB, accept the event to keep the context menu from appearing.

Any other button, pass the event along.