diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | config.def.h | 1 | ||||
-rw-r--r-- | src/canvas.c | 8 | ||||
-rw-r--r-- | src/canvas.h | 1 | ||||
-rw-r--r-- | src/cdraw.c | 4 | ||||
-rw-r--r-- | src/cdraw.h | 2 | ||||
-rw-r--r-- | src/ui.c | 4 | ||||
-rw-r--r-- | src/user.c | 13 |
8 files changed, 18 insertions, 16 deletions
@@ -34,6 +34,7 @@ All the keybindings can be changed in *config.h*. - **SHIFT+I** export image (using system picker - terminal input by default) - **SHIFT+E** import image (using system picker - terminal input by default) - **U/R** undo/redo an action +- **J** add new layer above the exiting one - **B** select pencil - **E** select eraser - **F** select fill tool diff --git a/config.def.h b/config.def.h index bce7925..9ec9173 100644 --- a/config.def.h +++ b/config.def.h @@ -29,6 +29,7 @@ static Key keys[] = { {KMOD_RSHIFT, SDLK_o, user_canvas_open, {.s = NULL}}, {KMOD_RSHIFT, SDLK_e, user_canvas_export_png, {.v = NULL}}, {KMOD_RSHIFT, SDLK_i, user_canvas_import_png, {.s = NULL}}, + {0, SDLK_j, user_layer_add, {.v = NULL}}, {0, SDLK_b, user_tool_change, {.i = 0}}, {0, SDLK_e, user_tool_change, {.i = 1}}, {0, SDLK_f, user_tool_change, {.i = 2}}, 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 *); @@ -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; } @@ -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); } |