aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-23 18:48:32 +0200
committerBad Diode <bd@badd10de.dev>2023-04-23 18:48:32 +0200
commitec5c1ad9f16772434f0f49811c87ec58a3569e83 (patch)
tree854894d7e4e9abb15eceb71332dd9678adc21506 /src/main.c
parentef6af29d99f7df6acf088ee28dc026023258c10c (diff)
downloadstepper-ec5c1ad9f16772434f0f49811c87ec58a3569e83.tar.gz
stepper-ec5c1ad9f16772434f0f49811c87ec58a3569e83.zip
Add conditional redrawing
This covers most of the previous functionality, but separating the input handling and rendering functions. Only cursor drawing and a few corner cases missing.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c64
1 files changed, 45 insertions, 19 deletions
diff --git a/src/main.c b/src/main.c
index 8ee4945..b6be6b9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,27 +21,53 @@ WITH REGARD TO THIS SOFTWARE.
21 21
22void 22void
23render(void) { 23render(void) {
24 // TODO: Make sure we are drawing the proper cursor color.
25 // TODO: Decouple update from rendering. 24 // TODO: Decouple update from rendering.
26 PROF(screen_fill(0), clear_cycles); 25 // PROF(screen_fill(0), clear_cycles);
27 PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); 26 PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles);
28 PROF(draw_triggers(), draw_trigs_cycles); 27 if (redraw_trigs) {
29 PROF(draw_channels(), draw_btn_cycles); 28 PROF(draw_triggers(), draw_trigs_cycles);
30 PROF(draw_pattern_buttons(), draw_btn_cycles); 29 redraw_trigs = false;
31 PROF(draw_bank_buttons(), draw_btn_cycles); 30 }
32 PROF(draw_bpm(), draw_btn_cycles); 31 if (redraw_channels) {
33 PROF(draw_play(), draw_btn_cycles); 32 PROF(draw_channels(), draw_btn_cycles);
34 PROF(draw_stop(), draw_btn_cycles); 33 redraw_channels = false;
35 PROF(draw_piano(), draw_piano_cycles); 34 }
36 // TODO: Draw the notes currently playing with a fade off animation for the 35 if (redraw_pattern_buttons) {
37 // first 3 channels. 36 PROF(draw_pattern_buttons(), draw_btn_cycles);
38 TriggerNote *trig = get_current_trig(); 37 redraw_pattern_buttons = false;
39 PROF(draw_note(trig->note, COL_NOTE_PRESSED), draw_piano_cycles); 38 }
40 PROF(draw_parameters(), draw_param_cycles); 39 if (redraw_bank_buttons) {
41 PROF(draw_trig_cursor(trig_selection_loc, COL_CURSOR), draw_cursor_cycles); 40 PROF(draw_bank_buttons(), draw_btn_cycles);
42 PROF(draw_channel_cursor(channel_selection_loc, COL_GREY), draw_cursor_cycles); 41 redraw_bank_buttons = false;
43 PROF(draw_pattern_cursor(pattern_selection_loc, COL_GREY), draw_cursor_cycles); 42 }
44 PROF(draw_current_step(COL_RED), draw_cursor_cycles); 43 if (redraw_bpm) {
44 PROF(draw_bpm(), draw_btn_cycles);
45 redraw_bpm = false;
46 }
47 if (redraw_play_pause) {
48 PROF(draw_play(), draw_btn_cycles);
49 PROF(draw_stop(), draw_btn_cycles);
50 redraw_play_pause = false;
51 }
52 if (redraw_piano_note) {
53 PROF(draw_piano(), draw_piano_cycles);
54 // TODO: Draw the notes currently playing with a fade off animation for
55 // the first 3 channels.
56 TriggerNote *trig = get_current_trig();
57 PROF(draw_note(trig->note, COL_NOTE_PRESSED), draw_piano_cycles);
58 redraw_piano_note = false;
59 }
60 if (redraw_params) {
61 PROF(draw_parameters(), draw_param_cycles);
62 redraw_params = false;
63 }
64
65 // TODO: Make sure we are drawing the cursors properly.
66 // PROF(draw_trig_cursor(trig_selection_loc, COL_CURSOR), draw_cursor_cycles);
67 // PROF(draw_channel_cursor(channel_selection_loc, COL_GREY), draw_cursor_cycles);
68 // PROF(draw_pattern_cursor(pattern_selection_loc, COL_GREY), draw_cursor_cycles);
69
70 // PROF(draw_current_step(COL_RED), draw_cursor_cycles);
45} 71}
46 72
47int 73int