From b486d1f47e0bbc1a0e3414df1f4f9193a3997300 Mon Sep 17 00:00:00 2001 From: Krow Savcik Date: Sat, 20 Jul 2024 00:22:00 +0300 Subject: feature: added frames --- src/user.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/user.c') diff --git a/src/user.c b/src/user.c index 9d1b437..7469708 100644 --- a/src/user.c +++ b/src/user.c @@ -168,7 +168,7 @@ void user_layer_add(const Arg *x) { if (cur_canvas == NULL) return; - canvas_add_layer(cur_canvas, cur_canvas->cur_layer+1); + if (canvas_add_layer(cur_canvas, cur_canvas->cur_layer+1)) return; cur_canvas->cur_layer++; ui_redraw_panel(UI_PANELTYPE_CANVAS); ui_redraw_panel(UI_PANELTYPE_TIMELINE); @@ -182,6 +182,29 @@ user_layer_chng(const Arg *x) ui_redraw_panel(UI_PANELTYPE_TIMELINE); } +void +user_frame_add(const Arg *x) +{ + int i; + if (cur_canvas == NULL) return; + if (canvas_add_frame(cur_canvas, cur_canvas->cur_frame+1)) return; + for (i = 0; i < cur_canvas->layer_arr_cnt; i++) + memcpy(cur_canvas->cells[(cur_canvas->cur_frame + 1) * cur_canvas->layer_arr_cnt+i], + cur_canvas->cells[cur_canvas->cur_frame * cur_canvas->layer_arr_cnt+i], + cur_canvas->w * cur_canvas->h * sizeof *cur_canvas->cells[0]); + canvas_change_frame(cur_canvas, cur_canvas->cur_frame+1); + ui_redraw_panel(UI_PANELTYPE_CANVAS); + ui_redraw_panel(UI_PANELTYPE_TIMELINE); +} + +void +user_frame_chng(const Arg *x) +{ + if (cur_canvas == NULL) return; + canvas_change_frame(cur_canvas, (cur_canvas->cur_frame + (unsigned int)cur_canvas->frame_arr_cnt + (x->i % (int)cur_canvas->frame_arr_cnt)) % cur_canvas->frame_arr_cnt); + ui_redraw_panel(UI_PANELTYPE_TIMELINE); +} + void user_debug_mem_show(const Arg *x) { -- cgit v1.2.3