aboutsummaryrefslogtreecommitdiffstats
path: root/src/drawing.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-05-29 16:44:50 +0200
committerBad Diode <bd@badd10de.dev>2023-05-29 16:44:50 +0200
commit3b5ee67114bf789c93db23b7a3611302dce7142e (patch)
tree32b5bbd2879b5ffeecd7df6e20c836f80f555c72 /src/drawing.c
parentac17920096b18caa4cadec3fea347f9fc804baea (diff)
downloadstepper-3b5ee67114bf789c93db23b7a3611302dce7142e.tar.gz
stepper-3b5ee67114bf789c93db23b7a3611302dce7142e.zip
Add initial theming support
Diffstat (limited to 'src/drawing.c')
-rw-r--r--src/drawing.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/src/drawing.c b/src/drawing.c
index 3264ad8..622b468 100644
--- a/src/drawing.c
+++ b/src/drawing.c
@@ -23,7 +23,7 @@ draw_channels(void) {
23 case 2: { active = patterns[pattern_selection_loc].ch3.active; } break; 23 case 2: { active = patterns[pattern_selection_loc].ch3.active; } break;
24 case 3: { active = patterns[pattern_selection_loc].ch4.active; } break; 24 case 3: { active = patterns[pattern_selection_loc].ch4.active; } break;
25 } 25 }
26 u8 clr = active ? colors[i] : COL_GREY; 26 u8 clr = active ? colors[i] : COL_OFF;
27 size_t y = CHAN_START_Y + i * CHAN_OFFSET_Y; 27 size_t y = CHAN_START_Y + i * CHAN_OFFSET_Y;
28 draw_channel_sprite(CHAN_START_X, y, clr, i); 28 draw_channel_sprite(CHAN_START_X, y, clr, i);
29 } 29 }
@@ -150,7 +150,7 @@ draw_bank_buttons() {
150 'A', 'B', 'C', 'D', 150 'A', 'B', 'C', 'D',
151 }; 151 };
152 for (int i = 0; i < 4; i++) { 152 for (int i = 0; i < 4; i++) {
153 int color = COL_GREY; 153 int color = COL_OFF;
154 if (i == current_bank) { 154 if (i == current_bank) {
155 color = COL_FG; 155 color = COL_FG;
156 } 156 }
@@ -175,12 +175,12 @@ draw_pattern_buttons() {
175 'E', 'F', 'G', 'H', 175 'E', 'F', 'G', 'H',
176 }; 176 };
177 for (int i = 0; i < 8; i++) { 177 for (int i = 0; i < 8; i++) {
178 int color = COL_GREY; 178 int color = COL_OFF;
179 if (i == current_pattern) { 179 if (i == current_pattern) {
180 color = COL_FG; 180 color = COL_FG;
181 } 181 }
182 if (i == next_pattern && current_pattern != next_pattern) { 182 if (i == next_pattern && current_pattern != next_pattern) {
183 color = COL_BLUE; 183 color = COL_ACC_0;
184 } 184 }
185 draw_rect(x, y, x + PAT_W, y + PAT_H, color); 185 draw_rect(x, y, x + PAT_W, y + PAT_H, color);
186 txt_drawc(pat_names[i], x + 4, y + 2, color); 186 txt_drawc(pat_names[i], x + 4, y + 2, color);
@@ -203,18 +203,18 @@ draw_play() {
203 size_t x = PLAY_START_X; 203 size_t x = PLAY_START_X;
204 size_t y = PLAY_START_Y; 204 size_t y = PLAY_START_Y;
205 draw_filled_rect(x, y, x + R_COL_W, y + PLAY_STOP_H, COL_BG); 205 draw_filled_rect(x, y, x + R_COL_W, y + PLAY_STOP_H, COL_BG);
206 draw_rect(x, y, x + R_COL_W, y + PLAY_STOP_H, COL_CYAN); 206 draw_rect(x, y, x + R_COL_W, y + PLAY_STOP_H, COL_ACC_2);
207 if (play_status == 1) { 207 if (play_status == 1) {
208 // Pause button 208 // Pause button
209 draw_filled_rect(x + 10, y + 3, x + 11, y + 7, COL_CYAN); 209 draw_filled_rect(x + 10, y + 3, x + 11, y + 7, COL_ACC_2);
210 draw_filled_rect(x + 13, y + 3, x + 14, y + 7, COL_CYAN); 210 draw_filled_rect(x + 13, y + 3, x + 14, y + 7, COL_ACC_2);
211 } else { 211 } else {
212 // Play button 212 // Play button
213 x += 1; 213 x += 1;
214 draw_line(x + 10, y + 2, x + 10, y + 8, COL_CYAN); 214 draw_line(x + 10, y + 2, x + 10, y + 8, COL_ACC_2);
215 draw_line(x + 11, y + 3, x + 11, y + 7, COL_CYAN); 215 draw_line(x + 11, y + 3, x + 11, y + 7, COL_ACC_2);
216 draw_line(x + 12, y + 4, x + 12, y + 6, COL_CYAN); 216 draw_line(x + 12, y + 4, x + 12, y + 6, COL_ACC_2);
217 draw_line(x + 13, y + 5, x + 13, y + 5, COL_CYAN); 217 draw_line(x + 13, y + 5, x + 13, y + 5, COL_ACC_2);
218 } 218 }
219} 219}
220 220
@@ -222,8 +222,8 @@ void
222draw_stop() { 222draw_stop() {
223 size_t x = STOP_START_X; 223 size_t x = STOP_START_X;
224 size_t y = STOP_START_Y; 224 size_t y = STOP_START_Y;
225 draw_rect(x, y, x + R_COL_W, y + PLAY_STOP_H, COL_RED); 225 draw_rect(x, y, x + R_COL_W, y + PLAY_STOP_H, COL_ACC_1);
226 draw_filled_rect(x + 10, y + 3, x + 14, y + 7, COL_RED); 226 draw_filled_rect(x + 10, y + 3, x + 14, y + 7, COL_ACC_1);
227} 227}
228 228
229void 229void
@@ -528,7 +528,7 @@ void
528draw_parameters_wave(ChannelWaveParams *params, bool global) { 528draw_parameters_wave(ChannelWaveParams *params, bool global) {
529 u8 col_fg = COL_FG; 529 u8 col_fg = COL_FG;
530 if (global && input_handler == handle_channel_selection) { 530 if (global && input_handler == handle_channel_selection) {
531 col_fg = COL_GREY; 531 col_fg = COL_OFF;
532 } 532 }
533 533
534 // Draw current wave data. 534 // Draw current wave data.
@@ -540,8 +540,8 @@ draw_parameters_wave(ChannelWaveParams *params, bool global) {
540 size_t y = PARAMS_START_Y + 13; 540 size_t y = PARAMS_START_Y + 13;
541 541
542 // Wave Patterns. 542 // Wave Patterns.
543 draw_wave_pattern(wave_a, x, y, COL_WAVE_A); 543 draw_wave_pattern(wave_a, x, y, COL_ACC_1);
544 draw_wave_pattern(wave_b, x + 70, y, COL_WAVE_B); 544 draw_wave_pattern(wave_b, x + 70, y, COL_ACC_2);
545 545
546 // Wave text. 546 // Wave text.
547 x -= 2; 547 x -= 2;
@@ -624,7 +624,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep, bool global) {
624 size_t x_offset = sweep ? 0 : 30; 624 size_t x_offset = sweep ? 0 : 30;
625 u8 col_fg = COL_FG; 625 u8 col_fg = COL_FG;
626 if (global && input_handler == handle_channel_selection) { 626 if (global && input_handler == handle_channel_selection) {
627 col_fg = COL_GREY; 627 col_fg = COL_OFF;
628 } 628 }
629 629
630 // Duty cycle. 630 // Duty cycle.
@@ -673,18 +673,18 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep, bool global) {
673 x5 += 20; 673 x5 += 20;
674 } break; 674 } break;
675 } 675 }
676 draw_line(x0, y0, x1, y0, COL_RED); 676 draw_line(x0, y0, x1, y0, COL_ACC_1);
677 draw_line(x1, y1, x1, y0, COL_RED); 677 draw_line(x1, y1, x1, y0, COL_ACC_1);
678 draw_line(x1, y1, x2, y1, COL_RED); 678 draw_line(x1, y1, x2, y1, COL_ACC_1);
679 draw_line(x2, y1, x2, y0, COL_RED); 679 draw_line(x2, y1, x2, y0, COL_ACC_1);
680 draw_line(x2, y0, x3, y0, COL_RED); 680 draw_line(x2, y0, x3, y0, COL_ACC_1);
681 draw_line(x3, y1, x3, y0, COL_RED); 681 draw_line(x3, y1, x3, y0, COL_ACC_1);
682 draw_line(x3, y1, x4, y1, COL_RED); 682 draw_line(x3, y1, x4, y1, COL_ACC_1);
683 draw_line(x4, y1, x4, y0, COL_RED); 683 draw_line(x4, y1, x4, y0, COL_ACC_1);
684 draw_line(x4, y0, x5, y0, COL_RED); 684 draw_line(x4, y0, x5, y0, COL_ACC_1);
685 685
686 // Bounding box. 686 // Bounding box.
687 draw_rect(x, y - 3, x + 24, y + 18, COL_RED); 687 draw_rect(x, y - 3, x + 24, y + 18, COL_ACC_1);
688 } 688 }
689 689
690 // Param box. 690 // Param box.
@@ -717,7 +717,7 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep, bool global) {
717 size_t y0 = PARAMS_START_Y + PARAMS_H - 47; 717 size_t y0 = PARAMS_START_Y + PARAMS_H - 47;
718 size_t x1 = x0 + 79; 718 size_t x1 = x0 + 79;
719 size_t y1 = y0 + 21; 719 size_t y1 = y0 + 21;
720 draw_rect(x0, y0, x1, y1, COL_CYAN); 720 draw_rect(x0, y0, x1, y1, COL_ACC_2);
721 } 721 }
722 722
723 size_t x = PARAMS_START_X + 42 + x_offset; 723 size_t x = PARAMS_START_X + 42 + x_offset;
@@ -731,10 +731,10 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep, bool global) {
731 731
732 // Env. 732 // Env.
733 if (params->env_time == 0) { 733 if (params->env_time == 0) {
734 draw_line(x1, y0, x2, y0, COL_CYAN); 734 draw_line(x1, y0, x2, y0, COL_ACC_2);
735 } else { 735 } else {
736 draw_line(x0, y0, x1, y1, COL_CYAN); 736 draw_line(x0, y0, x1, y1, COL_ACC_2);
737 draw_line(x1, y1, x2, y2, COL_CYAN); 737 draw_line(x1, y1, x2, y2, COL_ACC_2);
738 } 738 }
739 } 739 }
740 740
@@ -894,7 +894,7 @@ draw_parameters_noise(ChannelNoiseParams* params, bool global) {
894 size_t x_offset = 30; 894 size_t x_offset = 30;
895 u8 col_fg = COL_FG; 895 u8 col_fg = COL_FG;
896 if (global && input_handler == handle_channel_selection) { 896 if (global && input_handler == handle_channel_selection) {
897 col_fg = COL_GREY; 897 col_fg = COL_OFF;
898 } 898 }
899 899
900 // Bit mode. 900 // Bit mode.
@@ -927,7 +927,7 @@ draw_parameters_noise(ChannelNoiseParams* params, bool global) {
927 size_t y0 = PARAMS_START_Y + PARAMS_H - 47; 927 size_t y0 = PARAMS_START_Y + PARAMS_H - 47;
928 size_t x1 = x0 + 79; 928 size_t x1 = x0 + 79;
929 size_t y1 = y0 + 21; 929 size_t y1 = y0 + 21;
930 draw_rect(x0, y0, x1, y1, COL_CYAN); 930 draw_rect(x0, y0, x1, y1, COL_ACC_2);
931 } 931 }
932 932
933 size_t x = PARAMS_START_X + 42 + x_offset; 933 size_t x = PARAMS_START_X + 42 + x_offset;
@@ -941,10 +941,10 @@ draw_parameters_noise(ChannelNoiseParams* params, bool global) {
941 941
942 // Env. 942 // Env.
943 if (params->env_time == 0) { 943 if (params->env_time == 0) {
944 draw_line(x1, y0, x2, y0, COL_CYAN); 944 draw_line(x1, y0, x2, y0, COL_ACC_2);
945 } else { 945 } else {
946 draw_line(x0, y0, x1, y1, COL_CYAN); 946 draw_line(x0, y0, x1, y1, COL_ACC_2);
947 draw_line(x1, y1, x2, y2, COL_CYAN); 947 draw_line(x1, y1, x2, y2, COL_ACC_2);
948 } 948 }
949 } 949 }
950 950
@@ -1073,42 +1073,42 @@ clear_cursors(void) {
1073 draw_pattern_cursor(last_pattern_loc, COL_BG); 1073 draw_pattern_cursor(last_pattern_loc, COL_BG);
1074 draw_right_col_cursor(last_right_col_loc, COL_BG); 1074 draw_right_col_cursor(last_right_col_loc, COL_BG);
1075 for (size_t i = 0; i < 16; i++) { 1075 for (size_t i = 0; i < 16; i++) {
1076 draw_current_step(i, COL_GREY); 1076 draw_current_step(i, COL_OFF);
1077 } 1077 }
1078} 1078}
1079 1079
1080void 1080void
1081draw_cursors(void) { 1081draw_cursors(void) {
1082 clear_cursors(); 1082 clear_cursors();
1083 draw_current_step(step_counter, COL_RED); 1083 draw_current_step(step_counter, COL_ACC_1);
1084 if (input_handler == handle_trigger_selection) { 1084 if (input_handler == handle_trigger_selection) {
1085 draw_trig_cursor(trig_selection_loc, COL_CURSOR); 1085 draw_trig_cursor(trig_selection_loc, COL_ACC_0);
1086 } 1086 }
1087 if (input_handler == handle_channel_selection) { 1087 if (input_handler == handle_channel_selection) {
1088 draw_channel_cursor(channel_selection_loc, COL_CURSOR); 1088 draw_channel_cursor(channel_selection_loc, COL_ACC_0);
1089 } else { 1089 } else {
1090 draw_channel_cursor(channel_selection_loc, COL_GREY); 1090 draw_channel_cursor(channel_selection_loc, COL_OFF);
1091 } 1091 }
1092 if (input_handler == handle_pattern_selection) { 1092 if (input_handler == handle_pattern_selection) {
1093 draw_pattern_cursor(pattern_selection_loc, COL_CURSOR); 1093 draw_pattern_cursor(pattern_selection_loc, COL_ACC_0);
1094 } else { 1094 } else {
1095 draw_pattern_cursor(pattern_selection_loc, COL_GREY); 1095 draw_pattern_cursor(pattern_selection_loc, COL_OFF);
1096 } 1096 }
1097 if (input_handler == handle_right_col_selection) { 1097 if (input_handler == handle_right_col_selection) {
1098 draw_right_col_cursor(right_col_selection_loc, COL_CURSOR); 1098 draw_right_col_cursor(right_col_selection_loc, COL_ACC_0);
1099 } 1099 }
1100 if (input_handler == handle_param_selection_sq1 || 1100 if (input_handler == handle_param_selection_sq1 ||
1101 input_handler == handle_param_selection_sq2 || 1101 input_handler == handle_param_selection_sq2 ||
1102 input_handler == handle_param_selection_wave || 1102 input_handler == handle_param_selection_wave ||
1103 input_handler == handle_param_selection_noise) { 1103 input_handler == handle_param_selection_noise) {
1104 draw_params_cursor(param_selection_loc, COL_CURSOR); 1104 draw_params_cursor(param_selection_loc, COL_ACC_0);
1105 draw_trig_cursor(trig_selection_loc, COL_GREY); 1105 draw_trig_cursor(trig_selection_loc, COL_OFF);
1106 } 1106 }
1107 if (input_handler == handle_param_selection_ch1 || 1107 if (input_handler == handle_param_selection_ch1 ||
1108 input_handler == handle_param_selection_ch2 || 1108 input_handler == handle_param_selection_ch2 ||
1109 input_handler == handle_param_selection_ch3 || 1109 input_handler == handle_param_selection_ch3 ||
1110 input_handler == handle_param_selection_ch4) { 1110 input_handler == handle_param_selection_ch4) {
1111 draw_params_cursor(param_selection_loc, COL_CURSOR); 1111 draw_params_cursor(param_selection_loc, COL_ACC_0);
1112 } 1112 }
1113} 1113}
1114 1114
@@ -1124,17 +1124,17 @@ draw_piano_notes(void) {
1124 switch (channel_selection_loc) { 1124 switch (channel_selection_loc) {
1125 case 0: { 1125 case 0: {
1126 if (pat->ch1.active && pat->ch1.notes[step].active) { 1126 if (pat->ch1.active && pat->ch1.notes[step].active) {
1127 draw_note(pat->ch1.notes[step].note, COL_NOTE_PRESSED); 1127 draw_note(pat->ch1.notes[step].note, COL_OFF);
1128 } 1128 }
1129 } break; 1129 } break;
1130 case 1: { 1130 case 1: {
1131 if (pat->ch2.active && pat->ch2.notes[step].active) { 1131 if (pat->ch2.active && pat->ch2.notes[step].active) {
1132 draw_note(pat->ch2.notes[step].note, COL_NOTE_PRESSED); 1132 draw_note(pat->ch2.notes[step].note, COL_OFF);
1133 } 1133 }
1134 } break; 1134 } break;
1135 case 2: { 1135 case 2: {
1136 if (pat->ch3.active && pat->ch3.notes[step].active) { 1136 if (pat->ch3.active && pat->ch3.notes[step].active) {
1137 draw_note(pat->ch3.notes[step].note, COL_NOTE_PRESSED); 1137 draw_note(pat->ch3.notes[step].note, COL_OFF);
1138 } 1138 }
1139 } break; 1139 } break;
1140 } 1140 }
@@ -1146,20 +1146,20 @@ draw_piano_notes(void) {
1146 input_handler == handle_param_selection_noise) { 1146 input_handler == handle_param_selection_noise) {
1147 // Show currently selected trigger note. 1147 // Show currently selected trigger note.
1148 TriggerNote *trig = get_current_trig(); 1148 TriggerNote *trig = get_current_trig();
1149 draw_note(trig->note, COL_NOTE_PRESSED); 1149 draw_note(trig->note, COL_OFF);
1150 } else { 1150 } else {
1151 // Show last/current played notes in all channels. 1151 // Show last/current played notes in all channels.
1152 if (play_status == 1) { 1152 if (play_status == 1) {
1153 Pattern *pat = &patterns[current_pattern]; 1153 Pattern *pat = &patterns[current_pattern];
1154 u8 step = (step_counter - 1) % 16; 1154 u8 step = (step_counter - 1) % 16;
1155 if (pat->ch3.active && pat->ch3.notes[step].active) { 1155 if (pat->ch3.active && pat->ch3.notes[step].active) {
1156 draw_note(pat->ch3.notes[step].note, COL_NOTE_PRESSED); 1156 draw_note(pat->ch3.notes[step].note, COL_OFF);
1157 } 1157 }
1158 if (pat->ch2.active && pat->ch2.notes[step].active) { 1158 if (pat->ch2.active && pat->ch2.notes[step].active) {
1159 draw_note(pat->ch2.notes[step].note, COL_NOTE_PRESSED); 1159 draw_note(pat->ch2.notes[step].note, COL_OFF);
1160 } 1160 }
1161 if (pat->ch1.active && pat->ch1.notes[step].active) { 1161 if (pat->ch1.active && pat->ch1.notes[step].active) {
1162 draw_note(pat->ch1.notes[step].note, COL_NOTE_PRESSED); 1162 draw_note(pat->ch1.notes[step].note, COL_OFF);
1163 } 1163 }
1164 } 1164 }
1165 } 1165 }