diff options
author | Bad Diode <bd@badd10de.dev> | 2023-07-21 19:40:20 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-07-21 19:40:20 +0200 |
commit | 8d28d55285d70353001a105cf86797cb76617183 (patch) | |
tree | a4197453c513e1a4e616f3cef44cb41623fd0acf | |
parent | 385c70e9e802d0b84a7435f992669660aa2ae255 (diff) | |
download | stepper-8d28d55285d70353001a105cf86797cb76617183.tar.gz stepper-8d28d55285d70353001a105cf86797cb76617183.zip |
Add cursor drawing to wave and noise params in new UI
-rw-r--r-- | src/drawing.c | 185 |
1 files changed, 100 insertions, 85 deletions
diff --git a/src/drawing.c b/src/drawing.c index fcbdb95..e9852e5 100644 --- a/src/drawing.c +++ b/src/drawing.c | |||
@@ -464,93 +464,108 @@ draw_piano(void) { | |||
464 | 464 | ||
465 | void | 465 | void |
466 | draw_params_cursor_wave(size_t i, u8 clr) { | 466 | draw_params_cursor_wave(size_t i, u8 clr) { |
467 | // u8 x_positions[] = { | 467 | size_t x = PARAMS_START_X + (i % 5) * PARAMS_BOX_OFFSET_X; |
468 | // // 32 half bytes (Wave A). | 468 | size_t y = PARAMS_START_Y + PARAMS_BOX_H; |
469 | // 0, 4, 8, 12, 16, 20, 24, 28, | 469 | if (i >= 5) { |
470 | // 34, 38, 42, 46, 50, 54, 58, 62, | 470 | y += PARAMS_BOX_OFFSET_Y; |
471 | // 0, 4, 8, 12, 16, 20, 24, 28, | 471 | } |
472 | // 34, 38, 42, 46, 50, 54, 58, 62, | 472 | u8 x0 = x; |
473 | // // 32 half bytes (Wave B). | 473 | u8 x1 = x + PARAMS_BOX_W; |
474 | // 70, 74, 78, 82, 86, 90, 94, 98, | 474 | u8 y0 = y - 6; |
475 | // 104, 108, 112, 116, 120, 124, 128, 132, | 475 | u8 y1 = y; |
476 | // 70, 74, 78, 82, 86, 90, 94, 98, | 476 | draw_filled_rect(x0 + 1, y0, x1 - 1, y1, clr); |
477 | // 104, 108, 112, 116, 120, 124, 128, 132, | 477 | draw_line(x0, y0 + 1, x0, y1 - 1, clr); |
478 | // // Default wave A. | 478 | draw_line(x1, y0 + 1, x1, y1 - 1, clr); |
479 | // 1, 18, 35, 52, | 479 | { |
480 | // // Default wave B. | 480 | size_t x = PARAMS_START_X; |
481 | // 71, 88, 105, 122, | 481 | size_t y = PARAMS_START_Y; |
482 | // // Mode selection. | 482 | switch (i) { |
483 | // 141, | 483 | case 0: { |
484 | // // Volume selection. | 484 | x += 4 + PARAMS_BOX_OFFSET_X * 0; |
485 | // 141, | 485 | y += PARAMS_BOX_H - 7; |
486 | // }; | 486 | txt_drawf_small("shape", x, y, COL_BG); |
487 | // u8 y_positions[] = { | 487 | } break; |
488 | // // 32 half bytes (Wave A) | 488 | case 1: { |
489 | // 0, 0, 0, 0, 0, 0, 0, 0, | 489 | x += 4 + PARAMS_BOX_OFFSET_X * 1; |
490 | // 0, 0, 0, 0, 0, 0, 0, 0, | 490 | y += PARAMS_BOX_H - 7; |
491 | // 9, 9, 9, 9, 9, 9, 9, 9, | 491 | txt_drawf_small("phase", x, y, COL_BG); |
492 | // 9, 9, 9, 9, 9, 9, 9, 9, | 492 | } break; |
493 | // // 32 half bytes (Wave B) | 493 | case 2: { |
494 | // 0, 0, 0, 0, 0, 0, 0, 0, | 494 | x += 4 + PARAMS_BOX_OFFSET_X * 2; |
495 | // 0, 0, 0, 0, 0, 0, 0, 0, | 495 | y += PARAMS_BOX_H - 7; |
496 | // 9, 9, 9, 9, 9, 9, 9, 9, | 496 | txt_drawf_small("shape", x, y, COL_BG); |
497 | // 9, 9, 9, 9, 9, 9, 9, 9, | 497 | } break; |
498 | // // Default wave A. | 498 | case 3: { |
499 | // 21, 21, 21, 21, | 499 | x += 4 + PARAMS_BOX_OFFSET_X * 3; |
500 | // // Default wave B. | 500 | y += PARAMS_BOX_H - 7; |
501 | // 21, 21, 21, 21, | 501 | txt_drawf_small("phase", x, y, COL_BG); |
502 | // // Mode selection. | 502 | } break; |
503 | // 21, | 503 | case 4: { |
504 | // // Volume selection. | 504 | x += 6 + PARAMS_BOX_OFFSET_X * 4; |
505 | // 1, | 505 | y += PARAMS_BOX_H - 7; |
506 | // }; | 506 | txt_drawf_small("prob", x, y, COL_BG); |
507 | // size_t cursor_length = 0; | 507 | } break; |
508 | // if (i < 64) { | 508 | case 5: { |
509 | // cursor_length = 4; | 509 | x += 6 + PARAMS_BOX_OFFSET_X * 0; |
510 | // } else if (i < 72) { | 510 | y += PARAMS_BOX_H - 7 + PARAMS_BOX_OFFSET_Y; |
511 | // cursor_length = 13; | 511 | txt_drawf_small("mode", x, y, COL_BG); |
512 | // } else { | 512 | } break; |
513 | // cursor_length = 30; | 513 | case 6: { |
514 | // } | 514 | x += 8 + PARAMS_BOX_OFFSET_X * 1; |
515 | // size_t x = PARAMS_START_X + x_positions[i] - 1; | 515 | y += PARAMS_BOX_H - 7 + PARAMS_BOX_OFFSET_Y; |
516 | // size_t y = PARAMS_START_Y + PARAMS_H - 25 + y_positions[i]; | 516 | txt_drawf_small("vol", x, y, COL_BG); |
517 | // switch (settings.cursor) { | 517 | } break; |
518 | // case CURSOR_THICK_LINE: { | 518 | default: break; |
519 | // draw_line(x, y, x + cursor_length, y, clr); | 519 | } |
520 | // draw_line(x, y + 1, x + cursor_length, y + 1, clr); | 520 | } |
521 | // } break; | ||
522 | // default: { | ||
523 | // draw_line(x, y, x + cursor_length, y, clr); | ||
524 | // } break; | ||
525 | // } | ||
526 | } | 521 | } |
527 | 522 | ||
528 | void | 523 | void |
529 | draw_params_cursor_noise(size_t i, u8 clr) { | 524 | draw_params_cursor_noise(size_t i, u8 clr) { |
530 | // u8 x_positions[] = { | 525 | size_t x = PARAMS_START_X + (i % 5) * PARAMS_BOX_OFFSET_X; |
531 | // 0, // Bit mode. | 526 | size_t y = PARAMS_START_Y + PARAMS_BOX_H; |
532 | // 31, // Env. Vol. | 527 | if (i >= 5) { |
533 | // 59, // Env. Direction. | 528 | y += PARAMS_BOX_OFFSET_Y; |
534 | // 87, // Env. Time. | 529 | } |
535 | // }; | 530 | u8 x0 = x; |
536 | // u8 y_positions[] = { | 531 | u8 x1 = x + PARAMS_BOX_W; |
537 | // 20, // Bit mode. | 532 | u8 y0 = y - 6; |
538 | // 20, // Env. Vol. | 533 | u8 y1 = y; |
539 | // 20, // Env. Direction. | 534 | draw_filled_rect(x0 + 1, y0, x1 - 1, y1, clr); |
540 | // 20, // Env. Time. | 535 | draw_line(x0, y0 + 1, x0, y1 - 1, clr); |
541 | // }; | 536 | draw_line(x1, y0 + 1, x1, y1 - 1, clr); |
542 | // size_t cursor_length = 24; | 537 | { |
543 | // size_t x = PARAMS_START_X + x_positions[i] + 30; | 538 | size_t x = PARAMS_START_X; |
544 | // size_t y = PARAMS_START_Y + PARAMS_H - 24 + y_positions[i]; | 539 | size_t y = PARAMS_START_Y; |
545 | // switch (settings.cursor) { | 540 | switch (i) { |
546 | // case CURSOR_THICK_LINE: { | 541 | case 0: { |
547 | // draw_line(x, y, x + cursor_length, y, clr); | 542 | x += 6 + PARAMS_BOX_OFFSET_X * 0; |
548 | // draw_line(x, y + 1, x + cursor_length, y + 1, clr); | 543 | y += PARAMS_BOX_H - 7; |
549 | // } break; | 544 | txt_drawf_small("mode", x, y, COL_BG); |
550 | // default: { | 545 | } break; |
551 | // draw_line(x, y, x + cursor_length, y, clr); | 546 | case 1: { |
552 | // } break; | 547 | x += 8 + PARAMS_BOX_OFFSET_X * 1; |
553 | // } | 548 | y += PARAMS_BOX_H - 7; |
549 | txt_drawf_small("vol", x, y, COL_BG); | ||
550 | } break; | ||
551 | case 2: { | ||
552 | x += 6 + PARAMS_BOX_OFFSET_X * 2; | ||
553 | y += PARAMS_BOX_H - 7; | ||
554 | txt_drawf_small("time", x, y, COL_BG); | ||
555 | } break; | ||
556 | case 3: { | ||
557 | x += 8 + PARAMS_BOX_OFFSET_X * 3; | ||
558 | y += PARAMS_BOX_H - 7; | ||
559 | txt_drawf_small("dir", x, y, COL_BG); | ||
560 | } break; | ||
561 | case 4: { | ||
562 | x += 6 + PARAMS_BOX_OFFSET_X * 4; | ||
563 | y += PARAMS_BOX_H - 7; | ||
564 | txt_drawf_small("prob", x, y, COL_BG); | ||
565 | } break; | ||
566 | default: break; | ||
567 | } | ||
568 | } | ||
554 | } | 569 | } |
555 | 570 | ||
556 | void | 571 | void |
@@ -709,9 +724,9 @@ draw_parameters_wave(ChannelWaveParams *params, bool global) { | |||
709 | { | 724 | { |
710 | size_t x = PARAMS_START_X; | 725 | size_t x = PARAMS_START_X; |
711 | size_t y = PARAMS_START_Y; | 726 | size_t y = PARAMS_START_Y; |
712 | txt_drawf_small("sin", x + 8 + PARAMS_BOX_OFFSET_X * 0, y + PARAMS_BOX_H - 7, col_fg); | 727 | txt_drawf_small("shape", x + 4 + PARAMS_BOX_OFFSET_X * 0, y + PARAMS_BOX_H - 7, col_fg); |
713 | txt_drawf_small("phase", x + 4 + PARAMS_BOX_OFFSET_X * 1, y + PARAMS_BOX_H - 7, col_fg); | 728 | txt_drawf_small("phase", x + 4 + PARAMS_BOX_OFFSET_X * 1, y + PARAMS_BOX_H - 7, col_fg); |
714 | txt_drawf_small("saw", x + 8 + PARAMS_BOX_OFFSET_X * 2, y + PARAMS_BOX_H - 7, col_fg); | 729 | txt_drawf_small("shape", x + 4 + PARAMS_BOX_OFFSET_X * 2, y + PARAMS_BOX_H - 7, col_fg); |
715 | txt_drawf_small("phase", x + 4 + PARAMS_BOX_OFFSET_X * 3, y + PARAMS_BOX_H - 7, col_fg); | 730 | txt_drawf_small("phase", x + 4 + PARAMS_BOX_OFFSET_X * 3, y + PARAMS_BOX_H - 7, col_fg); |
716 | txt_drawf_small("prob", x + 6 + PARAMS_BOX_OFFSET_X * 4, y + PARAMS_BOX_H - 7, col_fg); | 731 | txt_drawf_small("prob", x + 6 + PARAMS_BOX_OFFSET_X * 4, y + PARAMS_BOX_H - 7, col_fg); |
717 | y += PARAMS_BOX_OFFSET_Y; | 732 | y += PARAMS_BOX_OFFSET_Y; |