summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/saw/main.c149
1 files changed, 90 insertions, 59 deletions
diff --git a/source/saw/main.c b/source/saw/main.c
index c179564..123dcbd 100644
--- a/source/saw/main.c
+++ b/source/saw/main.c
@@ -590,80 +590,105 @@ static void saw_ui_track(saw_track_t *track, i64 x0, i64 y0,
i64 width, i64 height, str_t title) {
i64 frame_height = sapp_height();
- i64 text_height = 35;
- i64 border = 2;
+ i64 text_height = 35;
+ i64 header_offset = 60;
+ i64 border = 2;
+ i64 column_width = 200;
- // Title
+ // Draw text
//
nvgBeginPath(saw_nvg);
nvgFontSize(saw_nvg, text_height);
nvgFontFaceId(saw_nvg, saw_font);
nvgFillColor(saw_nvg, nvgRGBA(255, 255, 255, 255));
+
nvgText(saw_nvg, x0 + border * 2,
frame_height - y0 - height + text_height - border * 2,
title.values, title.values + title.size);
- nvgFill(saw_nvg);
-
- // Instrument
- //
-
- char buf_instr[][100] = { "Sine wave" };
- nvgBeginPath(saw_nvg);
- nvgFontSize(saw_nvg, text_height);
- nvgFontFaceId(saw_nvg, saw_font);
- nvgFillColor(saw_nvg, nvgRGBA(255, 255, 255, 255));
+ char buf_instr[][100] = { "Sine" };
nvgText(saw_nvg, x0 + border * 2,
- frame_height - y0 - height + text_height * 2 - border * 2,
+ frame_height - y0 - height + header_offset + text_height -
+ border * 2,
+ "Instrument", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset + text_height -
+ border * 2,
buf_instr[track->instrument], 0);
- nvgFill(saw_nvg);
- // Phase
- //
-
- char buf_phase[100];
- sprintf(buf_phase, "Phase: %d", (int) (track->phase * 100 + 0.5));
-
- nvgBeginPath(saw_nvg);
- nvgFontSize(saw_nvg, text_height);
- nvgFontFaceId(saw_nvg, saw_font);
- nvgFillColor(saw_nvg, nvgRGBA(255, 255, 255, 255));
+ char buf[100];
+ sprintf(buf, "%d", (i32) (track->phase * 100 + 0.5));
nvgText(saw_nvg, x0 + border * 2,
- frame_height - y0 - height + text_height * 3 - border * 2,
- buf_phase, 0);
- nvgFill(saw_nvg);
-
- // Stereo width
- //
-
- char buf_stereo_width[100];
- sprintf(buf_stereo_width, "Stereo width: %d",
- (int) (track->stereo_width * 100 + 0.5));
-
- nvgBeginPath(saw_nvg);
- nvgFontSize(saw_nvg, text_height);
- nvgFontFaceId(saw_nvg, saw_font);
- nvgFillColor(saw_nvg, nvgRGBA(255, 255, 255, 255));
+ frame_height - y0 - height + header_offset +
+ text_height * 2 - border * 2,
+ "Phase", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 2 - border * 2,
+ buf, 0);
+
+ sprintf(buf, "%d", (i32) (track->stereo_width * 100 + 0.5));
nvgText(saw_nvg, x0 + border * 2,
- frame_height - y0 - height + text_height * 4 - border * 2,
- buf_stereo_width, 0);
- nvgFill(saw_nvg);
-
- // Volume
- //
-
- char buf_volume[100];
- sprintf(buf_volume, "Volume: %d",
- (int) (track->volume * 100 + 0.5));
+ frame_height - y0 - height + header_offset +
+ text_height * 3 - border * 2,
+ "Stereo width", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 3 - border * 2,
+ buf, 0);
+
+ sprintf(buf, "%d", (i32) (track->volume * 100 + 0.5));
+ nvgText(saw_nvg, x0 + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 4 - border * 2,
+ "Volume", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 4 - border * 2,
+ buf, 0);
- nvgBeginPath(saw_nvg);
- nvgFontSize(saw_nvg, text_height);
- nvgFontFaceId(saw_nvg, saw_font);
- nvgFillColor(saw_nvg, nvgRGBA(255, 255, 255, 255));
nvgText(saw_nvg, x0 + border * 2,
- frame_height - y0 - height + text_height * 5 - border * 2,
- buf_volume, 0);
+ frame_height - y0 - height + header_offset +
+ text_height * 6 - border * 2,
+ "Envelope", 0);
+ sprintf(buf, "%.3f", (f32) track->envelope.sustain);
+ nvgText(saw_nvg, x0 + column_width / 4 + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 7 - border * 2,
+ "Sustain", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 7 - border * 2,
+ buf, 0);
+ sprintf(buf, "%.1f ms", (f32) (track->envelope.attack * 1000));
+ nvgText(saw_nvg, x0 + column_width / 4 + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 8 - border * 2,
+ "Attack", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 8 - border * 2,
+ buf, 0);
+ sprintf(buf, "%.1f ms", (f32) (track->envelope.decay * 1000));
+ nvgText(saw_nvg, x0 + column_width / 4 + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 9 - border * 2,
+ "Decay", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 9 - border * 2,
+ buf, 0);
+ sprintf(buf, "%.1f ms", (f32) (track->envelope.release * 1000));
+ nvgText(saw_nvg, x0 + column_width / 4 + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 10 - border * 2,
+ "Release", 0);
+ nvgText(saw_nvg, x0 + column_width + border * 2,
+ frame_height - y0 - height + header_offset +
+ text_height * 10 - border * 2,
+ buf, 0);
+
nvgFill(saw_nvg);
}
@@ -1079,7 +1104,13 @@ static void saw_frame(void) {
nvgBeginFrame(saw_nvg, frame_width, frame_height, sapp_dpi_scale());
- saw_ui_compose(0, (frame_height * 3) / 5, (frame_width * 4) / 5,
+ i32 track_width = frame_width / 5;
+ if (track_width < 330)
+ track_width = 330;
+ if (track_width > frame_width / 2)
+ track_width = frame_width / 2;
+
+ saw_ui_compose(0, (frame_height * 3) / 5, frame_width - track_width,
(frame_height * 2) / 5);
if (saw_current_track != -1) {
@@ -1087,7 +1118,7 @@ static void saw_frame(void) {
sprintf(buf, "Track %lld", saw_current_track + 1);
saw_ui_track(saw_tracks + saw_current_track,
- (frame_width * 4) / 5, 0, frame_width / 5,
+ frame_width - track_width, 0, track_width,
frame_height, kit_str(strlen(buf), buf));
}
@@ -1096,7 +1127,7 @@ static void saw_frame(void) {
sprintf(buf, "Sheet %lld", saw_current_roll + 1);
saw_ui_roll(saw_rolls + saw_current_roll, 0, 0,
- (frame_width * 4) / 5, (frame_height * 3) / 5,
+ frame_width - track_width, (frame_height * 3) / 5,
kit_str(strlen(buf), buf));
}