From ae4f6cc7e9b567bcecc7fb812aa4ab5058aca379 Mon Sep 17 00:00:00 2001 From: Krow Savcik Date: Fri, 16 Feb 2024 18:32:54 +0200 Subject: improved: layer interface New layer is added above the selected one rather than being added on top. --- src/canvas.c | 8 ++++++++ src/canvas.h | 1 + src/cdraw.c | 4 ---- src/cdraw.h | 2 +- src/ui.c | 4 ++-- src/user.c | 13 ++++--------- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/canvas.c b/src/canvas.c index 2cc2e58..cfee1a3 100644 --- a/src/canvas.c +++ b/src/canvas.c @@ -462,6 +462,14 @@ canvas_refresh(Canvas *c) SDL_SetRenderTarget(ren, NULL); } +void +canvas_change_layer(Canvas *c, unsigned int l) +{ + if (l < c->layer_arr_cnt) + c->cur_layer = l; +} + + static void canvas_set_proj_path(Canvas *c, const char *path) { diff --git a/src/canvas.h b/src/canvas.h index 5735aba..ae45dfa 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -46,6 +46,7 @@ void canvas_add_layer(Canvas *, unsigned int); void canvas_move_x(Canvas *, long int); void canvas_move_y(Canvas *, long int); void canvas_refresh(Canvas *); +void canvas_change_layer(Canvas *, unsigned int); unsigned char canvas_save(Canvas *, const char *, short int); unsigned char canvas_export_png(Canvas *, const char *, void *); void action_undo(Canvas *); diff --git a/src/cdraw.c b/src/cdraw.c index 6088df9..fab4fa7 100644 --- a/src/cdraw.c +++ b/src/cdraw.c @@ -199,8 +199,4 @@ main(int argc, char *argv[]) if (ltick < fdif) SDL_Delay(fdif-ltick); } - -#ifdef F_MEMORY_DEBUG - f_debug_mem_show(); -#endif } diff --git a/src/cdraw.h b/src/cdraw.h index e3bc4fd..2a6710a 100644 --- a/src/cdraw.h +++ b/src/cdraw.h @@ -33,7 +33,7 @@ void user_canvas_pal_col_chng(const Arg *); void user_canvas_undo(const Arg *); void user_canvas_redo(const Arg *); void user_tool_change(const Arg *); +void user_layer_add(const Arg *); void user_layer_chng(const Arg *); -void user_testing_layer_add(const Arg *); void user_testing_reload_tex(const Arg *); void user_debug_mem_show(const Arg *); diff --git a/src/ui.c b/src/ui.c index dd9c9fe..9a49fc4 100644 --- a/src/ui.c +++ b/src/ui.c @@ -305,8 +305,8 @@ ui_mousel_down(int x, int y) ui_redraw_panel(UI_PANELTYPE_CANVAS); } else if (x <= 162) { y = cur_canvas->layer_arr_cnt-y-1; - y -= (int)(cur_canvas->cur_layer); - user_layer_chng(&y); + canvas_change_layer(cur_canvas, y); + ui_redraw_panel(UI_PANELTYPE_TIMELINE); } break; } diff --git a/src/user.c b/src/user.c index 54ae60d..9d1b437 100644 --- a/src/user.c +++ b/src/user.c @@ -165,12 +165,11 @@ user_tool_change(const Arg *x) } void -user_testing_layer_add(const Arg *x) +user_layer_add(const Arg *x) { -/* TODO: temp function */ if (cur_canvas == NULL) return; - canvas_add_layer(cur_canvas, -1); - cur_canvas->cur_layer = cur_canvas->layer_arr_cnt-1; + canvas_add_layer(cur_canvas, cur_canvas->cur_layer+1); + cur_canvas->cur_layer++; ui_redraw_panel(UI_PANELTYPE_CANVAS); ui_redraw_panel(UI_PANELTYPE_TIMELINE); } @@ -179,11 +178,7 @@ void user_layer_chng(const Arg *x) { if (cur_canvas == NULL) return; - cur_canvas->cur_layer += (unsigned int)cur_canvas->layer_arr_cnt; - cur_canvas->cur_layer += (x->i % (int)cur_canvas->layer_arr_cnt); - cur_canvas->cur_layer %= cur_canvas->layer_arr_cnt; - - ui_redraw_panel(UI_PANELTYPE_CANVAS); + canvas_change_layer(cur_canvas, (cur_canvas->cur_layer + (unsigned int)cur_canvas->layer_arr_cnt + (x->i % (int)cur_canvas->layer_arr_cnt)) % cur_canvas->layer_arr_cnt); ui_redraw_panel(UI_PANELTYPE_TIMELINE); } -- cgit v1.2.3