diff options
| -rw-r--r-- | src/canvas.c | 6 | ||||
| -rw-r--r-- | src/canvas.h | 8 | ||||
| -rw-r--r-- | src/ui.c | 51 | 
3 files changed, 58 insertions, 7 deletions
diff --git a/src/canvas.c b/src/canvas.c index 9807c26..e24a404 100644 --- a/src/canvas.c +++ b/src/canvas.c @@ -18,6 +18,8 @@ uint8 is_drawing;  #define HNEXT(i)    (i == HISTLENGTH-1 ? 0 : i+1)  #define HPREV(i)    (i == 0 ? HISTLENGTH-1 : i-1) +typedef struct Layer Layer; +  static Layer   *layer_create(uint, uint, uint);  static void     layer_destroy(Layer *);  static uint     canvas_fill_bfs(Canvas *, int, int, uint, uint); @@ -56,10 +58,14 @@ canvas_init(uint w, uint h, void *ren)  	c->h = h;  	c->cur_col = 0;  	c->cur_layer = 0; +	c->cur_frame = 0;  	c->zoom = 1;  	c->proj_path = NULL;  	c->layer_arr_cnt = 1;  	c->layer_arr_sz = 1; +	/* TEMP: TODO */ +	c->frame_arr_cnt = 4; +	c->frame_arr_sz = 4;  	c->x = c->y = 0;  	c->hist_i = c->hist_s = c->hist_isend = 0;  	c->hist_e = HNEXT(c->hist_s); diff --git a/src/canvas.h b/src/canvas.h index 21b1d67..58f20b7 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -10,9 +10,14 @@ struct Layer {  	char name[LAYERNAMELEN+1];  }; +struct Frame { +	unsigned int state; +}; +  struct Canvas {  	unsigned int layer_arr_cnt, layer_arr_sz; -	unsigned int cur_col, cur_layer; +	unsigned int frame_arr_cnt, frame_arr_sz; +	unsigned int cur_col, cur_layer, cur_frame;  	unsigned int w, h, zoom;  	char *proj_path;  	struct Layer **layers; @@ -29,7 +34,6 @@ struct Canvas {  	unsigned int a;  }; -typedef struct Layer Layer;  typedef struct Canvas Canvas;  extern unsigned char is_drawing; @@ -142,7 +142,7 @@ ui_create(const char *path)  	/* ui_panel_divider_init(&main_ui->p_divs[0], 5, 10, 100, 1, &main_ui->p_canvas, &main_ui->p_timeline); */  	ui_panel_divider_init(&main_ui->p_divs[0], 5, 5, 120, 0, &main_ui->p_divs[1], &main_ui->p_divs[2]);  	ui_panel_divider_init(&main_ui->p_divs[1], 0, 8, 22+31*((tool_array_size()+2)/3), 3, &main_ui->p_palette, &main_ui->p_buttons); -	ui_panel_divider_init(&main_ui->p_divs[2], 0, 5, 120, 3, &main_ui->p_canvas, &main_ui->p_timeline); +	ui_panel_divider_init(&main_ui->p_divs[2], 0, 5, 168, 3, &main_ui->p_canvas, &main_ui->p_timeline);  	ui_resize();  } @@ -297,6 +297,10 @@ ui_mousel_down(int x, int y)  		x = x - fpan->geom.x - 8;  		y = y - fpan->geom.y - 8;  		y /= 22; +		if (y == 0) { +			break; +		} +		y -= 1;  		if (y < 0 || y >= cur_canvas->layer_arr_cnt) break;  		if (x <= 22) {  			cur_canvas->layers[cur_canvas->layer_arr_cnt-1-y]->visible ^= 1; @@ -344,6 +348,7 @@ ui_mouser_down(int x, int y)  		x = x - fpan->geom.x - 8;  		y = y - fpan->geom.y - 8;  		y /= 22; +		y--;  		if (y < 0 || y >= cur_canvas->layer_arr_cnt) break;  		if (x > 22 && x <= 162) {  			cur_canvas->a = cur_canvas->layer_arr_cnt-y-1; @@ -697,7 +702,8 @@ static uint8  ui_panel_timeline_redraw(UIPanelTimeline *p)  {  	SDL_Rect dest; -	int i; +	int i, j, k; +	char text[4];  	dest.x = 6;  	dest.y = 6;  	dest.w = p->head.geom.w - 12; @@ -706,14 +712,17 @@ ui_panel_timeline_redraw(UIPanelTimeline *p)  	SDL_SetRenderDrawColor(ren, INTTOCOLA(0xc7cfddff));  	SDL_RenderClear(ren);  	if (cur_canvas != NULL) { +		/* Draw selected */  		dest.x = 2;  		dest.h = 20;  		dest.w = 162; -		dest.y = (cur_canvas->layer_arr_cnt - 1 - cur_canvas->cur_layer) * 22 + 2; +		dest.y = (cur_canvas->layer_arr_cnt - 1 - cur_canvas->cur_layer) * 22 + 24;  		SDL_SetRenderDrawColor(ren, INTTOCOLA(0x657392ff));  		SDL_RenderFillRect(ren, &dest); + +		/* Draw Layer column */  		for (i = 0; i < cur_canvas->layer_arr_cnt; i++) { -			dest.y = 6 + (cur_canvas->layer_arr_cnt - 1 - i) * 22; +			dest.y = 28 + (cur_canvas->layer_arr_cnt - 1 - i) * 22;  			dest.x = 6;  			dest.h = 24;  			dest.w = 166; @@ -740,13 +749,45 @@ ui_panel_timeline_redraw(UIPanelTimeline *p)  				SDL_RenderCopy(ren, main_ui->theme, &ui_timeline_rect[0], &dest);  			else  				SDL_RenderCopy(ren, main_ui->theme, &ui_timeline_rect[1], &dest); -			dest.y = 6 + (cur_canvas->layer_arr_cnt - 1 - i) * 22; +			dest.y = 28 + (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);  		} + +		/* Draw Frame row */ +		for (i = 0; i < cur_canvas->frame_arr_cnt; i++) { +			dest.y = 6; +			dest.x = 170 + i * 22; +			dest.h = 24; +			dest.w = 24; +			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_SetRenderDrawColor(ren, INTTOCOLA(0x000000ff)); +			j = i; k = 2; +			text[3] = '\0'; +			while (j) { +				text[k--] = (j%10) + '0'; +				j /= 10; +			} + +			j = k+1; +			for (k = 0; j < 4; j++, k++) { +				text[k] = text[j]; +			} + +			SBDF_SDLPrint(ren, font, text, 9, 5); +		}  	}  	SDL_RenderSetViewport(ren, NULL);  	ui_panel_draw_frame(&p->head);  |