diff options
author | Bad Diode <bd@badd10de.dev> | 2023-07-15 22:16:00 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-07-15 22:16:00 +0200 |
commit | 1e666da666081bece2c244c2297d08801add3103 (patch) | |
tree | 7cf2cbe834ba0a5e39bba33f09e447d54ad70f8c | |
parent | 4c6c09b1f6debdfaea80bf5ad56dee25089ef49b (diff) | |
download | stepper-1e666da666081bece2c244c2297d08801add3103.tar.gz stepper-1e666da666081bece2c244c2297d08801add3103.zip |
Add cursors and fully functioning chain workflow
-rw-r--r-- | src/drawing.c | 21 | ||||
-rw-r--r-- | src/globals.c | 1 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/sequencer.c | 62 |
4 files changed, 86 insertions, 2 deletions
diff --git a/src/drawing.c b/src/drawing.c index 8cd63db..b7d5421 100644 --- a/src/drawing.c +++ b/src/drawing.c | |||
@@ -1152,6 +1152,24 @@ clear_cursors(void) { | |||
1152 | } | 1152 | } |
1153 | 1153 | ||
1154 | void | 1154 | void |
1155 | draw_pattern_chain_cursor(void) { | ||
1156 | size_t offset_x = (PAT_TRIG_H + 7) * (param_selection_loc % 8); | ||
1157 | size_t offset_y = param_selection_loc < 8 ? 0 : 0 + PAT_TRIG_OFFSET_Y; | ||
1158 | size_t x0 = PAT_TRIG_START_X + offset_x; | ||
1159 | size_t x1 = PAT_TRIG_START_X + offset_x + PAT_TRIG_W; | ||
1160 | size_t y = PAT_TRIG_START_Y + offset_y + PAT_TRIG_H + 2; | ||
1161 | switch (settings.cursor) { | ||
1162 | case CURSOR_THICK_LINE: { | ||
1163 | draw_line(x0, y, x1, y, COL_ACC_0); | ||
1164 | draw_line(x0, y + 1, x1, y + 1, COL_ACC_0); | ||
1165 | } break; | ||
1166 | default: { | ||
1167 | draw_line(x0, y, x1, y, COL_ACC_0); | ||
1168 | } break; | ||
1169 | } | ||
1170 | } | ||
1171 | |||
1172 | void | ||
1155 | draw_cursors(void) { | 1173 | draw_cursors(void) { |
1156 | clear_cursors(); | 1174 | clear_cursors(); |
1157 | draw_current_step(step_counter, COL_ACC_1); | 1175 | draw_current_step(step_counter, COL_ACC_1); |
@@ -1184,6 +1202,9 @@ draw_cursors(void) { | |||
1184 | input_handler == handle_param_selection_ch4) { | 1202 | input_handler == handle_param_selection_ch4) { |
1185 | draw_params_cursor(param_selection_loc, COL_ACC_0); | 1203 | draw_params_cursor(param_selection_loc, COL_ACC_0); |
1186 | } | 1204 | } |
1205 | if (input_handler == handle_pattern_chain) { | ||
1206 | draw_pattern_chain_cursor(); | ||
1207 | } | ||
1187 | } | 1208 | } |
1188 | 1209 | ||
1189 | TriggerNote * get_current_trig(void); | 1210 | TriggerNote * get_current_trig(void); |
diff --git a/src/globals.c b/src/globals.c index 1efa90c..1e0d964 100644 --- a/src/globals.c +++ b/src/globals.c | |||
@@ -119,6 +119,7 @@ void handle_param_selection_ch1(void); | |||
119 | void handle_param_selection_ch2(void); | 119 | void handle_param_selection_ch2(void); |
120 | void handle_param_selection_ch3(void); | 120 | void handle_param_selection_ch3(void); |
121 | void handle_param_selection_ch4(void); | 121 | void handle_param_selection_ch4(void); |
122 | void handle_pattern_chain(void); | ||
122 | 123 | ||
123 | typedef enum Scene { | 124 | typedef enum Scene { |
124 | SCENE_SEQUENCER = 0, | 125 | SCENE_SEQUENCER = 0, |
@@ -94,8 +94,8 @@ render_sequencer(void) { | |||
94 | redraw_params = false; | 94 | redraw_params = false; |
95 | } | 95 | } |
96 | 96 | ||
97 | if (input_handler == handle_pattern_selection){ | 97 | if (input_handler == handle_pattern_selection || |
98 | // TODO: redraw_params in pattern_selection context? | 98 | input_handler == handle_pattern_chain){ |
99 | draw_pattern_chain(); | 99 | draw_pattern_chain(); |
100 | } | 100 | } |
101 | 101 | ||
diff --git a/src/sequencer.c b/src/sequencer.c index eeb7816..9de08f8 100644 --- a/src/sequencer.c +++ b/src/sequencer.c | |||
@@ -316,6 +316,7 @@ handle_channel_selection(void) { | |||
316 | redraw_params = true; | 316 | redraw_params = true; |
317 | } else if (key_tap(KEY_LEFT)) { | 317 | } else if (key_tap(KEY_LEFT)) { |
318 | input_handler = handle_pattern_selection; | 318 | input_handler = handle_pattern_selection; |
319 | param_selection_loc = 0; | ||
319 | redraw_params = true; | 320 | redraw_params = true; |
320 | } else if (key_tap(KEY_UP)) { | 321 | } else if (key_tap(KEY_UP)) { |
321 | if (channel_selection_loc == 0) { | 322 | if (channel_selection_loc == 0) { |
@@ -459,6 +460,7 @@ handle_right_col_selection(void) { | |||
459 | right_col_selection_loc = R_COL_STOP; | 460 | right_col_selection_loc = R_COL_STOP; |
460 | } else { | 461 | } else { |
461 | input_handler = handle_pattern_selection; | 462 | input_handler = handle_pattern_selection; |
463 | param_selection_loc = 0; | ||
462 | redraw_trigs = true; | 464 | redraw_trigs = true; |
463 | } | 465 | } |
464 | } else if (key_tap(KEY_UP)) { | 466 | } else if (key_tap(KEY_UP)) { |
@@ -529,6 +531,64 @@ handle_right_col_selection(void) { | |||
529 | } | 531 | } |
530 | 532 | ||
531 | void | 533 | void |
534 | handle_pattern_chain(void) { | ||
535 | if (key_tap(KEY_A)) { | ||
536 | input_handler = handle_pattern_selection; | ||
537 | } else if (key_tap(KEY_LEFT)) { | ||
538 | if (param_selection_loc == 8) { | ||
539 | param_selection_loc = 15; | ||
540 | } else if (param_selection_loc > 0) { | ||
541 | param_selection_loc--; | ||
542 | } else if (param_selection_loc == 0) { | ||
543 | param_selection_loc = 7; | ||
544 | } | ||
545 | } else if (key_tap(KEY_RIGHT)) { | ||
546 | if (param_selection_loc < 15 && param_selection_loc != 7) { | ||
547 | param_selection_loc++; | ||
548 | } else if (param_selection_loc == 7) { | ||
549 | param_selection_loc = 0; | ||
550 | } else if (param_selection_loc == 15) { | ||
551 | param_selection_loc = 8; | ||
552 | } | ||
553 | } else if (key_tap(KEY_UP)) { | ||
554 | if (param_selection_loc <= 7) { | ||
555 | param_selection_loc += 8; | ||
556 | } else { | ||
557 | param_selection_loc -= 8; | ||
558 | } | ||
559 | } else if (key_tap(KEY_DOWN)) { | ||
560 | if (param_selection_loc <= 7) { | ||
561 | param_selection_loc += 8; | ||
562 | } else { | ||
563 | param_selection_loc -= 8; | ||
564 | } | ||
565 | } else if (key_tap(KEY_B)) { | ||
566 | if (chain.active[param_selection_loc]) { | ||
567 | // Can't toggle current chain. | ||
568 | if (!play_status || param_selection_loc != chain.current) { | ||
569 | chain.active[param_selection_loc] = 0; | ||
570 | chain.len--; | ||
571 | } | ||
572 | } else { | ||
573 | chain.active[param_selection_loc] = 1; | ||
574 | chain.len++; | ||
575 | } | ||
576 | } else if (key_tap(KEY_L)) { | ||
577 | if (chain.active[param_selection_loc] | ||
578 | && chain.chain[param_selection_loc] > 0 | ||
579 | && (!play_status || param_selection_loc != chain.current)) { | ||
580 | chain.chain[param_selection_loc]--; | ||
581 | } | ||
582 | } else if (key_tap(KEY_R)) { | ||
583 | if (chain.active[param_selection_loc] | ||
584 | && chain.chain[param_selection_loc] < 7 | ||
585 | && (!play_status || param_selection_loc != chain.current)) { | ||
586 | chain.chain[param_selection_loc]++; | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | |||
591 | void | ||
532 | handle_pattern_selection(void) { | 592 | handle_pattern_selection(void) { |
533 | if (key_tap(KEY_B)) { | 593 | if (key_tap(KEY_B)) { |
534 | if (key_hold(KEY_SELECT)) { | 594 | if (key_hold(KEY_SELECT)) { |
@@ -541,6 +601,8 @@ handle_pattern_selection(void) { | |||
541 | if (key_tap(KEY_A)) { | 601 | if (key_tap(KEY_A)) { |
542 | if (key_hold(KEY_SELECT)) { | 602 | if (key_hold(KEY_SELECT)) { |
543 | clipboard_paste(); | 603 | clipboard_paste(); |
604 | } else { | ||
605 | input_handler = handle_pattern_chain; | ||
544 | } | 606 | } |
545 | } | 607 | } |
546 | if (key_tap(KEY_RIGHT)) { | 608 | if (key_tap(KEY_RIGHT)) { |