diff options
author | Krow Savcik <krow@savcik.xyz> | 2023-09-26 22:32:35 +0300 |
---|---|---|
committer | Krow Savcik <krow@savcik.xyz> | 2023-09-26 22:32:35 +0300 |
commit | 9e660e594f6d3a43ea1427fb872801a2fcedad93 (patch) | |
tree | 459cd0c6fc5fef0366f7ef249ae19dd67c363772 /src/tools.c |
initial commit
Diffstat (limited to 'src/tools.c')
-rw-r--r-- | src/tools.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tools.c b/src/tools.c new file mode 100644 index 0000000..1ff979a --- /dev/null +++ b/src/tools.c @@ -0,0 +1,39 @@ +#include <assert.h> + +#include "tools.h" +#include "types.h" +#include "canvas.h" +#include "ui.h" + +uint8 tool_cur; +static uint8 prev_tool; + +/* TODO: Move to config.h */ +uint8 tool_array[] = { + TOOL_TYPE_PENCIL, + TOOL_TYPE_ERASER, + TOOL_TYPE_FILL, + TOOL_TYPE_CPICKER, + TOOL_TYPE_ZOOMOUT, + TOOL_TYPE_ZOOMIN, + TOOL_TYPE_EMPTY, + TOOL_TYPE_CLOWN, +}; + +void +tool_change(uint8 t) +{ + if (t != tool_cur) { + canvas_mousel_up(cur_canvas); + assert(t < tool_array_size()); + t = (t < tool_array_size()) ? t : tool_array_size() - 1; + tool_cur = t; + ui_redraw_panel(UI_PANELTYPE_BUTTONS); + } +} + +uint8 +tool_array_size() +{ + return (sizeof tool_array / sizeof *tool_array); +} |