From bb4af22481a27d9324f5377b7024e3592d4227ff Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 8 Aug 2023 18:50:46 +0200 Subject: Update main UI with new 1.7 design --- src/drawing.c | 77 +++++++++++++++++++++++++++++++++++++---------------------- src/globals.c | 55 +++++++++++++++++++++++------------------- src/main.c | 38 ++++++++++++++++------------- 3 files changed, 101 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/drawing.c b/src/drawing.c index a203f1c..c07b46d 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -126,6 +126,8 @@ draw_trig_cursor(size_t i, u8 clr) { void draw_right_col_cursor(int i, u8 clr) { + // TODO:... + return; size_t x0 = 0; size_t x1 = 0; size_t y = 0; @@ -192,21 +194,29 @@ draw_current_step(u8 step, u8 clr) { void draw_bank_buttons() { - size_t x = BANK_START_X; + size_t x = BANK_START_X + 1; size_t y = BANK_START_Y; - txt_drawf_small("BANK", x - 2, y - 10, COL_FG); + txt_drawf_small("BANK", x - 3, y - 10, COL_FG); char bank_names[] = { - 'A', 'B', 'C', 'D', + 'A', 'B', 'C', 'D', 'E', 'F' + }; + s16 x_offset[] = { + -8, 8, -8, 8, -8, 8, + }; + size_t y_offset[] = { + 0, 0, 18, 18, 36, 36, }; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 6; i++) { int color = COL_OFF; if (i == current_bank) { color = COL_FG; } - draw_filled_rect(x, y, x + PAT_W, y + PAT_H, COL_BG); - draw_rect(x, y, x + PAT_W, y + PAT_H, color); - txt_drawc(bank_names[i], x + 4, y + 1, color); - y += PAT_OFFSET_Y; + u8 x0 = x + x_offset[i]; + u8 x1 = x + x_offset[i] + BANK_W; + u8 y0 = y + y_offset[i]; + u8 y1 = y + y_offset[i] + BANK_H; + draw_rect(x0, y0, x1, y1, color); + txt_drawc(bank_names[i], x0 + 3, y0 + 1, color); } } @@ -264,15 +274,14 @@ draw_play() { size_t x_btn = x + PLAY_STOP_W / 2 - 1; if (play_status == 1) { // Pause button - draw_filled_rect(x_btn - 1, y + 3, x_btn, y + 7, COL_ACC_2); - draw_filled_rect(x_btn + 2, y + 3, x_btn + 3, y + 7, COL_ACC_2); + draw_filled_rect(x_btn - 1, y + 2, x_btn, y + 6, COL_ACC_2); + draw_filled_rect(x_btn + 2, y + 2, x_btn + 3, y + 6, COL_ACC_2); } else { // Play button x += 1; - draw_line(x_btn + 0, y + 2, x_btn + 0, y + 8, COL_ACC_2); - draw_line(x_btn + 1, y + 3, x_btn + 1, y + 7, COL_ACC_2); - draw_line(x_btn + 2, y + 4, x_btn + 2, y + 6, COL_ACC_2); - draw_line(x_btn + 3, y + 5, x_btn + 3, y + 5, COL_ACC_2); + draw_line(x_btn + 0, y + 2, x_btn + 0, y + 6, COL_ACC_2); + draw_line(x_btn + 1, y + 3, x_btn + 1, y + 5, COL_ACC_2); + draw_line(x_btn + 2, y + 4, x_btn + 2, y + 4, COL_ACC_2); } } @@ -280,12 +289,12 @@ void draw_settings() { size_t x = SETTINGS_START_X; size_t y = SETTINGS_START_Y; - draw_rect(x + 2, y, x + R_COL_W - 2, y + PLAY_STOP_H, COL_OFF); - draw_line(x + 6, y + 4, x + 9, y + 4, COL_OFF); - draw_line(x + 6, y + 6, x + 9, y + 6, COL_OFF); - draw_line(x + 15, y + 4, x + 18, y + 4, COL_OFF); - draw_line(x + 15, y + 6, x + 18, y + 6, COL_OFF); - draw_line(x + 9, y + 5, x + 15, y + 5, COL_OFF); + draw_rect(x + 2, y, x + R_COL_W, y + PLAY_STOP_H, COL_OFF); + draw_line(x + 10, y + 3, x + 13, y + 3, COL_OFF); + draw_line(x + 10, y + 5, x + 13, y + 5, COL_OFF); + draw_line(x + 19, y + 3, x + 22, y + 3, COL_OFF); + draw_line(x + 19, y + 5, x + 22, y + 5, COL_OFF); + draw_line(x + 13, y + 4, x + 19, y + 4, COL_OFF); } void @@ -294,8 +303,7 @@ draw_stop() { size_t y = STOP_START_Y; size_t x_btn = x + PLAY_STOP_W / 2 - 2; draw_rect(x, y, x + PLAY_STOP_W, y + PLAY_STOP_H, COL_ACC_1); - draw_filled_rect(x_btn, y + 3, x_btn + 4, y + 7, COL_ACC_1); - draw_settings(); + draw_filled_rect(x_btn, y + 2, x_btn + 4, y + 6, COL_ACC_1); } void @@ -304,20 +312,33 @@ draw_bpm() { size_t y = BPM_START_Y + 2; // Draw bounding box. - draw_filled_rect(x, y, x + R_COL_W, y + BPM_H - 4, COL_BG); - draw_rect(x, y, x + R_COL_W, y + BPM_H - 4, COL_FG); - draw_line(x + 5, y, x + 19, y, COL_BG); - txt_drawf_small("BPM", x + 5, y - 4, COL_FG); + draw_filled_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_BG); + draw_rect(x, y, x + R_COL_W - 2, y + BPM_H - 3, COL_FG); + txt_drawf_small("BPM", x + 7, y - 10, COL_FG); // Make sure its horizontally centered if only 2 digits int bpm = patterns[pattern_selection_loc].bpm; if (bpm >= 100) { - txt_drawf("%d", x + 3, y + 5, COL_FG, bpm); + txt_drawf("%d", x + 5, y + 2, COL_FG, bpm); } else { - txt_drawf("%d", x + 6, y + 5, COL_FG, bpm); + txt_drawf("%d", x + 8, y + 2, COL_FG, bpm); } } +void +draw_scale() { + size_t x = SCALE_START_X; + size_t y = SCALE_START_Y; + + // Draw bounding box. + draw_filled_rect(x, y, x + R_COL_W - 2, y + SCALE_H - 3, COL_BG); + draw_rect(x, y, x + R_COL_W - 2, y + SCALE_H - 3, COL_FG); + txt_drawf_small("SCALE", x + 3, y - 10, COL_FG); + + // TODO: Switch for different scales here + txt_drawf("CHRM", x + 2, y + 2, COL_FG); +} + void draw_triggers(void) { for (size_t i = 0; i < 16; i++) { diff --git a/src/globals.c b/src/globals.c index 57c77bb..842b39f 100644 --- a/src/globals.c +++ b/src/globals.c @@ -32,63 +32,68 @@ bool clear_screen = true; #define CHAN_W 19 #define CHAN_H 8 -#define CHAN_START_X 30 -#define CHAN_START_Y 98 +#define CHAN_START_X 28 +#define CHAN_START_Y 100 #define CHAN_OFFSET_Y 15 #define TRIG_W 15 #define TRIG_H 22 -#define TRIG_START_X 59 -#define TRIG_START_Y 98 +#define TRIG_START_X 55 +#define TRIG_START_Y 100 #define TRIG_OFFSET_X (TRIG_W + 3) #define TRIG_OFFSET_Y (TRIG_H + 8) #define PIANO_W 170 #define PIANO_H 12 #define PIANO_BLACK_H 10 -#define PIANO_START_X 30 +#define PIANO_START_X 27 #define PIANO_START_Y 80 #define PIANO_NOTE_W 2 #define NOTIF_W 170 #define NOTIF_H 10 -#define NOTIF_START_X 30 -#define NOTIF_START_Y 13 +#define NOTIF_START_X 27 +#define NOTIF_START_Y 12 #define PARAMS_W 166 #define PARAMS_H 52 -#define PARAMS_START_X 32 -#define PARAMS_START_Y 22 +#define PARAMS_START_X 29 +#define PARAMS_START_Y 20 #define PARAMS_BOX_W 30 #define PARAMS_BOX_H 24 #define PARAMS_BOX_OFFSET_X (PARAMS_BOX_W + 4) #define PARAMS_BOX_OFFSET_Y (PARAMS_BOX_H + 4) -#define R_SIDEBAR_X ((TRIG_START_X) + (TRIG_OFFSET_X) * 8 + 4) -#define L_SIDEBAR_X ((CHAN_START_X) - 26) +#define R_SIDEBAR_X ((TRIG_START_X) + (TRIG_OFFSET_X) * 8 + 8) -#define PAT_START_X (L_SIDEBAR_X + 4) -#define PAT_START_Y 21 +#define PAT_START_X 5 +#define PAT_START_Y 16 #define PAT_W 14 #define PAT_H 10 -#define PAT_OFFSET_Y 17 +#define PAT_OFFSET_Y 18 -#define R_COL_W 24 -#define BPM_START_X (R_SIDEBAR_X) -#define BPM_START_Y (TRIG_START_Y + TRIG_H + 8) -#define BPM_H 22 +#define R_COL_W 30 +#define BPM_START_X (R_SIDEBAR_X - 2) +#define BPM_START_Y (TRIG_START_Y + 8) +#define BPM_H 15 -#define SETTINGS_START_X (R_SIDEBAR_X) -#define SETTINGS_START_Y (TRIG_START_Y - 7) -#define PLAY_START_X (R_SIDEBAR_X) -#define PLAY_START_Y (TRIG_START_Y + 12) +#define SCALE_START_X (R_SIDEBAR_X - 2) +#define SCALE_START_Y (PIANO_START_Y) +#define SCALE_H 15 + +#define SETTINGS_START_X (R_SIDEBAR_X - 4) +#define SETTINGS_START_Y (TRIG_START_Y + 30) +#define PLAY_START_X (R_SIDEBAR_X - 2) +#define PLAY_START_Y (TRIG_START_Y + 44) #define STOP_START_X (R_SIDEBAR_X + 14) -#define STOP_START_Y (TRIG_START_Y + 12) -#define PLAY_STOP_W (10) -#define PLAY_STOP_H (10) +#define STOP_START_Y (TRIG_START_Y + 44) +#define PLAY_STOP_W (12) +#define PLAY_STOP_H (8) #define BANK_START_X (R_SIDEBAR_X + 5) #define BANK_START_Y (PAT_START_Y) +#define BANK_W 12 +#define BANK_H 10 #define PAT_TRIG_W 14 #define PAT_TRIG_H 14 diff --git a/src/main.c b/src/main.c index eb16687..76a54b6 100644 --- a/src/main.c +++ b/src/main.c @@ -14,11 +14,6 @@ WITH REGARD TO THIS SOFTWARE. // UI tweaks. // - Add custom user themes // - Animations for cursor movement/current step highlight. (A fade out maybe?) -// - Improve "grey" cursor with dithering instead. -// - Remove thin cursor option and make the fat one default, it's just better. -// - Settings page overhaul. -// - Make sure there is an ALL notification when modifying channel params so -// that it's clear it's affecting all triggers. // // Quality of life improvements. // - When not on play mode, adjusting a note or a parameter triggers the sound. @@ -27,7 +22,6 @@ WITH REGARD TO THIS SOFTWARE. // - Undo/Redo. // // Advanced -// - Scale mode for entering notes. // - Add tap tempo for BPM. // - Allow "marking" several trigs to be able to copy/paste them and/or adjust // their parameters. @@ -37,19 +31,30 @@ WITH REGARD TO THIS SOFTWARE. // - Per trig LFO? How would we go about this? There is at least one empty slot // in all channels. LFO amount? LFO speed? Would need a dedicated page for // configuring LFOs -// - Multiple pattern chains per bank that we can toggle between, gotta study -// if they fit in the SRAM. -// - Make sure bank switching is queued like patterns. -// - Add settings for "performance mode" in which banks are not saved by -// default while changing patterns. -// - Make sure sync works with the same cable for in/out. // - Per-channel N steps to create polymeters? -// - Higher resolution clock to allow for microtiming and more accurate tempo. // - Study how to better embed data into the cart that doesn't involve the // build system to generate .c files. Just use the linker to put binary data // into the ROM. +// +// WIP (1.7) +// - Scale mode for entering notes. // - Improve SRAM saving to make room for longer patterns and/or more banks. // - Add CLEAR ALL to the settings menu. +// - Higher resolution clock to allow for microtiming and more accurate tempo. +// - Multiple pattern chains per bank that we can toggle between, gotta study +// if they fit in the SRAM. +// - Make sure bank switching is queued like patterns. +// - Add settings for "performance mode" in which banks are not saved by +// default while changing patterns. +// - Make sure sync works with the same cable for in/out. +// - Improve "grey" cursor with dithering instead. +// - Remove thin cursor option and make the fat one default, it's just better. +// - Settings page overhaul. +// - Make sure there is an ALL notification when modifying channel params so +// that it's clear it's affecting all triggers. +// - Blank patterns could show up as empty on the pattern view for better +// separation and section organization. +// - Study more improvements for a "performance mode". // #include "gba/gba.h" @@ -65,7 +70,6 @@ WITH REGARD TO THIS SOFTWARE. void render_sequencer(void) { - PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); if (redraw_trigs) { PROF(draw_triggers(), draw_trigs_cycles); redraw_trigs = false; @@ -89,6 +93,9 @@ render_sequencer(void) { if (redraw_play_pause) { PROF(draw_play(), draw_btn_cycles); PROF(draw_stop(), draw_btn_cycles); + // TODO: Move to separate if condition + PROF(draw_settings(), draw_btn_cycles); + PROF(draw_scale(), draw_btn_cycles); redraw_play_pause = false; } if (redraw_piano_note) { @@ -112,7 +119,6 @@ render_sequencer(void) { void render_settings(void) { - PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); txt_drawf_small("settings", 11, 5, COL_FG) txt_printf("\n\n\n"); txt_printf(" SYNC: %s\n\n", sync_setting_str[settings.sync]); @@ -139,7 +145,7 @@ render(void) { } break; } // DEBUG: Ensuring the saved data don't exceed SRAM size (32k). - // txt_drawf("SIZE: %lu", 0, 0, COL_ACC_1, sizeof(Metadata) + sizeof(patterns) * 4 + sizeof(chain) * 4); + txt_drawf("SIZE: %lu", 0, 0, COL_ACC_1, sizeof(Metadata) + sizeof(patterns) * 6 + sizeof(chain) * 6); } void -- cgit v1.2.1