// paintui handles turning sdl input things // into drawing instructions // it might have some kind of state machine // for doing smooth lines between discrete mouse positions // all mouse pos stuff in this module is in world coordinates // someone else is responsible for doing the transform from // screen to world coords. use drawing; use drawing::{pos}; export type state = struct { // last known mouse position, in world coordinates last_mouse_pos: pos, // last known mouse pressed-ness last_mouse_pressed: bool }; export fn tick( pstate: *state, mouse_pos: pos, mouse_pressed: bool ) (void | drawing::op) = { defer { pstate.last_mouse_pos = mouse_pos; pstate.last_mouse_pressed = mouse_pressed; }; // if mouse down and (position moved OR newly pressed) return if (mouse_pressed && (mouse_pos.0 != pstate.last_mouse_pos.0 || mouse_pos.1 != pstate.last_mouse_pos.1 || (!pstate.last_mouse_pressed))) mouse_pos: drawing::op_circle else void; };