diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-22 12:28:10 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-22 12:28:10 +0200 |
commit | e5d61a87ec41443a2e32cd8be1ecc62b8c590251 (patch) | |
tree | 26b832481fcb0e93d843e9fe5d4f875e2e5d2232 /src/drawing.c | |
parent | 8fc5cc7f53ea3874bae5389f489814869d2abd04 (diff) | |
download | stepper-e5d61a87ec41443a2e32cd8be1ecc62b8c590251.tar.gz stepper-e5d61a87ec41443a2e32cd8be1ecc62b8c590251.zip |
Add pattern clearing with SEL+L+R on pattern view
Diffstat (limited to 'src/drawing.c')
-rw-r--r-- | src/drawing.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/drawing.c b/src/drawing.c index d24307b..253a961 100644 --- a/src/drawing.c +++ b/src/drawing.c | |||
@@ -3,7 +3,7 @@ | |||
3 | // | 3 | // |
4 | 4 | ||
5 | void | 5 | void |
6 | draw_param_stub(size_t idx, u8 color) { | 6 | draw_param_stub(size_t idx, u8 clr) { |
7 | if (idx >= 10) { | 7 | if (idx >= 10) { |
8 | return; | 8 | return; |
9 | } | 9 | } |
@@ -15,12 +15,12 @@ draw_param_stub(size_t idx, u8 color) { | |||
15 | } | 15 | } |
16 | u8 y1 = y0 + PARAMS_BOX_H; | 16 | u8 y1 = y0 + PARAMS_BOX_H; |
17 | for (size_t i = 0; i < PARAMS_BOX_W; i += 2) { | 17 | for (size_t i = 0; i < PARAMS_BOX_W; i += 2) { |
18 | draw_pixel(x0 + i + 1, y0, color); | 18 | draw_pixel(x0 + i + 1, y0, clr); |
19 | draw_pixel(x0 + i + 1, y1, color); | 19 | draw_pixel(x0 + i + 1, y1, clr); |
20 | } | 20 | } |
21 | for (size_t i = 0; i < PARAMS_BOX_H; i += 2) { | 21 | for (size_t i = 0; i < PARAMS_BOX_H; i += 2) { |
22 | draw_pixel(x0, y0 + i + 1, color); | 22 | draw_pixel(x0, y0 + i + 1, clr); |
23 | draw_pixel(x1, y0 + i + 1, color); | 23 | draw_pixel(x1, y0 + i + 1, clr); |
24 | } | 24 | } |
25 | } | 25 | } |
26 | 26 | ||
@@ -79,6 +79,9 @@ draw_channels(void) { | |||
79 | case 2: { active = patterns[pattern_selection_loc].ch3.active; } break; | 79 | case 2: { active = patterns[pattern_selection_loc].ch3.active; } break; |
80 | case 3: { active = patterns[pattern_selection_loc].ch4.active; } break; | 80 | case 3: { active = patterns[pattern_selection_loc].ch4.active; } break; |
81 | } | 81 | } |
82 | if (patterns[pattern_selection_loc].empty) { | ||
83 | active = true; | ||
84 | } | ||
82 | u8 clr = active ? colors[i] : COL_OFF; | 85 | u8 clr = active ? colors[i] : COL_OFF; |
83 | size_t y = CHAN_START_Y + i * CHAN_OFFSET_Y; | 86 | size_t y = CHAN_START_Y + i * CHAN_OFFSET_Y; |
84 | draw_channel_sprite(CHAN_START_X, y, clr, i); | 87 | draw_channel_sprite(CHAN_START_X, y, clr, i); |
@@ -274,13 +277,25 @@ draw_bank_buttons() { | |||
274 | } | 277 | } |
275 | 278 | ||
276 | void | 279 | void |
280 | draw_dotted_rect(size_t x0, size_t y0, size_t x1, size_t y1, u8 clr) { | ||
281 | size_t w = x1 - x0; | ||
282 | size_t h = y1 - y0; | ||
283 | for (size_t i = 0; i <= w; i += 2) { | ||
284 | draw_pixel(x0 + i, y0, clr); | ||
285 | draw_pixel(x0 + i, y1, clr); | ||
286 | } | ||
287 | for (size_t i = 0; i <= h; i += 2) { | ||
288 | draw_pixel(x0, y0 + i, clr); | ||
289 | draw_pixel(x1, y0 + i, clr); | ||
290 | } | ||
291 | } | ||
292 | |||
293 | void | ||
277 | draw_pattern_buttons() { | 294 | draw_pattern_buttons() { |
278 | // Clear patterns. | 295 | // Clear patterns. |
279 | size_t x = PAT_START_X; | 296 | size_t x = PAT_START_X; |
280 | size_t y = PAT_START_Y; | 297 | size_t y = PAT_START_Y; |
281 | 298 | ||
282 | draw_filled_rect(x, y, x + PAT_W, y + PAT_H * 8, COL_BG); | ||
283 | |||
284 | txt_drawf_small("PAT", x, y - 10, COL_FG); | 299 | txt_drawf_small("PAT", x, y - 10, COL_FG); |
285 | char pat_names[] = { | 300 | char pat_names[] = { |
286 | 'A', 'B', 'C', 'D', | 301 | 'A', 'B', 'C', 'D', |
@@ -294,7 +309,12 @@ draw_pattern_buttons() { | |||
294 | if (i == next_pattern && current_pattern != next_pattern) { | 309 | if (i == next_pattern && current_pattern != next_pattern) { |
295 | color = COL_ACC_0; | 310 | color = COL_ACC_0; |
296 | } | 311 | } |
297 | draw_rect(x, y, x + PAT_W, y + PAT_H, color); | 312 | draw_filled_rect(x, y, x + PAT_W, y + PAT_H, COL_BG); |
313 | if (patterns[i].empty) { | ||
314 | draw_dotted_rect(x, y, x + PAT_W, y + PAT_H, color); | ||
315 | } else { | ||
316 | draw_rect(x, y, x + PAT_W, y + PAT_H, color); | ||
317 | } | ||
298 | txt_drawc(pat_names[i], x + 4, y + 1, color); | 318 | txt_drawc(pat_names[i], x + 4, y + 1, color); |
299 | y += PAT_OFFSET_Y; | 319 | y += PAT_OFFSET_Y; |
300 | } | 320 | } |
@@ -404,7 +424,9 @@ draw_triggers(void) { | |||
404 | size_t y1 = TRIG_START_Y + offset_y + TRIG_H; | 424 | size_t y1 = TRIG_START_Y + offset_y + TRIG_H; |
405 | draw_rect(x0, y0, x1, y1, COL_FG); | 425 | draw_rect(x0, y0, x1, y1, COL_FG); |
406 | clear_trigger(i); | 426 | clear_trigger(i); |
407 | draw_trigger(channel_selection_loc, i); | 427 | if (!patterns[pattern_selection_loc].empty) { |
428 | draw_trigger(channel_selection_loc, i); | ||
429 | } | ||
408 | } | 430 | } |
409 | } | 431 | } |
410 | 432 | ||