From dc9a97424933e43b69996c0cbab8ecc01cfe72d0 Mon Sep 17 00:00:00 2001 From: Krow Savcik Date: Fri, 16 Feb 2024 18:09:29 +0200 Subject: improved: layers now have names --- src/ui.c | 59 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'src/ui.c') diff --git a/src/ui.c b/src/ui.c index 130c464..dd9c9fe 100644 --- a/src/ui.c +++ b/src/ui.c @@ -3,7 +3,9 @@ #include #include +#define SBDF_USESDL #include "ui.h" +#include "sbdf.h" #include "cdraw.h" #include "types.h" #include "action.h" @@ -295,12 +297,17 @@ ui_mousel_down(int x, int y) x = x - fpan->geom.x - 8; y = y - fpan->geom.y - 8; y /= 22; - if (x > 22) break; if (y < 0 || y >= cur_canvas->layer_arr_cnt) break; - cur_canvas->layers[cur_canvas->layer_arr_cnt-1-y]->visible ^= 1; - canvas_refresh(cur_canvas); - ui_redraw_panel(UI_PANELTYPE_TIMELINE); - ui_redraw_panel(UI_PANELTYPE_CANVAS); + if (x <= 22) { + cur_canvas->layers[cur_canvas->layer_arr_cnt-1-y]->visible ^= 1; + canvas_refresh(cur_canvas); + ui_redraw_panel(UI_PANELTYPE_TIMELINE); + 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); + } break; } } @@ -674,25 +681,45 @@ ui_panel_timeline_redraw(UIPanelTimeline *p) SDL_RenderClear(ren); if (cur_canvas != NULL) { dest.x = 2; - dest.w = dest.h = 20; + dest.h = 20; + dest.w = 162; dest.y = (cur_canvas->layer_arr_cnt - 1 - cur_canvas->cur_layer) * 22 + 2; SDL_SetRenderDrawColor(ren, INTTOCOLA(0x657392ff)); SDL_RenderFillRect(ren, &dest); - SDL_SetRenderDrawColor(ren, 19, 19, 19, 255); for (i = 0; i < cur_canvas->layer_arr_cnt; i++) { - dest.y = (cur_canvas->layer_arr_cnt - 1 - i) * 22 + 2; + dest.y = 6 + (cur_canvas->layer_arr_cnt - 1 - i) * 22; + dest.x = 6; + dest.h = 24; + dest.w = 166; + SDL_RenderSetViewport(ren, &dest); + SDL_SetRenderDrawColor(ren, INTTOCOLA(0x131313ff)); + SDL_RenderDrawLine(ren, 2, 0, 21, 0); + SDL_RenderDrawLine(ren, 2, 1, 21, 1); + SDL_RenderDrawLine(ren, 0, 2, 0, 21); + SDL_RenderDrawLine(ren, 1, 2, 1, 21); + SDL_RenderDrawLine(ren, 2, 22, 21, 22); + SDL_RenderDrawLine(ren, 2, 23, 21, 23); + SDL_RenderDrawLine(ren, 22, 2, 22, 21); + SDL_RenderDrawLine(ren, 23, 2, 23, 21); + SDL_RenderDrawLine(ren, 24, 0, 163, 0); + SDL_RenderDrawLine(ren, 24, 1, 163, 1); + SDL_RenderDrawLine(ren, 24, 22, 163, 22); + SDL_RenderDrawLine(ren, 24, 23, 163, 23); + SDL_RenderDrawLine(ren, 164, 2, 164, 21); + SDL_RenderDrawLine(ren, 165, 2, 165, 21); + SDL_SetRenderDrawColor(ren, INTTOCOLA(0x000000ff)); + dest.y = dest.x = 2; + dest.w = dest.h = 20; if (cur_canvas->layers[i]->visible) SDL_RenderCopy(ren, main_ui->theme, &ui_timeline_rect[0], &dest); else SDL_RenderCopy(ren, main_ui->theme, &ui_timeline_rect[1], &dest); - SDL_RenderDrawLine(ren, 2, i*22, 21, i*22); - SDL_RenderDrawLine(ren, 2, i*22+1, 21, i*22+1); - SDL_RenderDrawLine(ren, 0, i*22+2, 0, i*22+21); - SDL_RenderDrawLine(ren, 1, i*22+2, 1, i*22+21); - SDL_RenderDrawLine(ren, 2, i*22+22, 21, i*22+22); - SDL_RenderDrawLine(ren, 2, i*22+23, 21, i*22+23); - SDL_RenderDrawLine(ren, 22, i*22+2, 22, i*22+21); - SDL_RenderDrawLine(ren, 23, i*22+2, 23, i*22+21); + dest.y = 6 + (cur_canvas->layer_arr_cnt - 1 - i) * 22; + dest.x = 30; + dest.w = 140; + dest.h = 24; + SDL_RenderSetViewport(ren, &dest); + SBDF_SDLPrint(ren, font, cur_canvas->layers[i]->name, 2, 5); } } SDL_RenderSetViewport(ren, NULL); -- cgit v1.2.3