type alias refactor
This commit is contained in:
184
src/main.cpp
184
src/main.cpp
@@ -70,9 +70,9 @@ struct AppState {
|
||||
B32 show_log;
|
||||
B32 show_midi_devices;
|
||||
#ifdef __APPLE__
|
||||
uint64_t freq_numer;
|
||||
uint64_t freq_denom;
|
||||
uint64_t last_time;
|
||||
U64 freq_numer;
|
||||
U64 freq_denom;
|
||||
U64 last_time;
|
||||
#else
|
||||
LARGE_INTEGER freq;
|
||||
LARGE_INTEGER last_time;
|
||||
@@ -88,11 +88,11 @@ struct AppState {
|
||||
// Demo widget state
|
||||
B32 demo_checkbox_a;
|
||||
B32 demo_checkbox_b;
|
||||
int32_t demo_radio_sel;
|
||||
int32_t demo_dropdown_sel;
|
||||
S32 demo_radio_sel;
|
||||
S32 demo_dropdown_sel;
|
||||
char demo_text_a[128];
|
||||
char demo_text_b[128];
|
||||
int32_t demo_button_count;
|
||||
S32 demo_button_count;
|
||||
|
||||
// Modal / window demo state
|
||||
B32 show_settings_window;
|
||||
@@ -163,22 +163,22 @@ struct AppState {
|
||||
#define PIANO_BLACK_W 11.0f
|
||||
#define PIANO_BLACK_H_PCT 0.6f
|
||||
|
||||
static bool piano_is_black_key(int note) {
|
||||
int n = note % 12;
|
||||
static B32 piano_is_black_key(S32 note) {
|
||||
S32 n = note % 12;
|
||||
return n == 1 || n == 3 || n == 6 || n == 8 || n == 10;
|
||||
}
|
||||
|
||||
// Velocity-based color: blue (vel 0) → green (mid) → red (vel 127)
|
||||
static Clay_Color velocity_color(int32_t velocity) {
|
||||
float t = (float)velocity / 127.0f;
|
||||
float r, g, b;
|
||||
static Clay_Color velocity_color(S32 velocity) {
|
||||
F32 t = (F32)velocity / 127.0f;
|
||||
F32 r, g, b;
|
||||
if (t < 0.5f) {
|
||||
float s = t * 2.0f;
|
||||
F32 s = t * 2.0f;
|
||||
r = 40.0f + s * (76.0f - 40.0f);
|
||||
g = 120.0f + s * (175.0f - 120.0f);
|
||||
b = 220.0f + s * (80.0f - 220.0f);
|
||||
} else {
|
||||
float s = (t - 0.5f) * 2.0f;
|
||||
F32 s = (t - 0.5f) * 2.0f;
|
||||
r = 76.0f + s * (220.0f - 76.0f);
|
||||
g = 175.0f + s * (50.0f - 175.0f);
|
||||
b = 80.0f + s * (40.0f - 80.0f);
|
||||
@@ -198,14 +198,14 @@ static void update_piano_input(AppState *app) {
|
||||
|
||||
// Find hovered piano key — check black keys first (they're on top)
|
||||
S32 hovered_note = -1;
|
||||
for (int note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
for (S32 note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
if (piano_is_black_key(note) && Clay_PointerOver(CLAY_IDI("PKey", note))) {
|
||||
hovered_note = note;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hovered_note == -1) {
|
||||
for (int note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
for (S32 note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
if (!piano_is_black_key(note) && Clay_PointerOver(CLAY_IDI("PKey", note))) {
|
||||
hovered_note = note;
|
||||
break;
|
||||
@@ -225,7 +225,7 @@ static void build_browser_panel(AppState *app) {
|
||||
if (!app->show_browser) return;
|
||||
|
||||
Clay_Color bp_top = g_theme.bg_medium;
|
||||
Clay_Color bp_bot = {(float)Max((int)bp_top.r-8,0), (float)Max((int)bp_top.g-8,0), (float)Max((int)bp_top.b-8,0), 255};
|
||||
Clay_Color bp_bot = {(F32)Max((S32)bp_top.r-8,0), (F32)Max((S32)bp_top.g-8,0), (F32)Max((S32)bp_top.b-8,0), 255};
|
||||
CustomGradientData *bp_grad = alloc_gradient(bp_top, bp_bot);
|
||||
|
||||
CLAY(CLAY_ID("BrowserPanel"),
|
||||
@@ -262,7 +262,7 @@ static void build_browser_panel(AppState *app) {
|
||||
|
||||
static void build_main_panel(AppState *app) {
|
||||
Clay_Color mp_top = g_theme.bg_light;
|
||||
Clay_Color mp_bot = {(float)Max((int)mp_top.r-8,0), (float)Max((int)mp_top.g-8,0), (float)Max((int)mp_top.b-8,0), 255};
|
||||
Clay_Color mp_bot = {(F32)Max((S32)mp_top.r-8,0), (F32)Max((S32)mp_top.g-8,0), (F32)Max((S32)mp_top.b-8,0), 255};
|
||||
CustomGradientData *mp_grad = alloc_gradient(mp_top, mp_bot);
|
||||
|
||||
CLAY(CLAY_ID("MainPanel"),
|
||||
@@ -469,14 +469,14 @@ static void build_main_panel(AppState *app) {
|
||||
{
|
||||
Clay_ScrollContainerData scroll_data = Clay_GetScrollContainerData(CLAY_ID("MainContent"));
|
||||
if (scroll_data.found && scroll_data.contentDimensions.height > scroll_data.scrollContainerDimensions.height) {
|
||||
float track_h = scroll_data.scrollContainerDimensions.height;
|
||||
float content_h = scroll_data.contentDimensions.height;
|
||||
float visible_ratio = track_h / content_h;
|
||||
float thumb_h = Max(visible_ratio * track_h, uis(24));
|
||||
float scroll_range = content_h - track_h;
|
||||
float scroll_pct = scroll_range > 0 ? -scroll_data.scrollPosition->y / scroll_range : 0;
|
||||
float thumb_y = scroll_pct * (track_h - thumb_h);
|
||||
float bar_w = uis(8);
|
||||
F32 track_h = scroll_data.scrollContainerDimensions.height;
|
||||
F32 content_h = scroll_data.contentDimensions.height;
|
||||
F32 visible_ratio = track_h / content_h;
|
||||
F32 thumb_h = Max(visible_ratio * track_h, uis(24));
|
||||
F32 scroll_range = content_h - track_h;
|
||||
F32 scroll_pct = scroll_range > 0 ? -scroll_data.scrollPosition->y / scroll_range : 0;
|
||||
F32 thumb_y = scroll_pct * (track_h - thumb_h);
|
||||
F32 bar_w = uis(8);
|
||||
|
||||
// Handle scrollbar drag
|
||||
Clay_ElementId thumb_id = CLAY_ID("MainScrollThumb");
|
||||
@@ -493,8 +493,8 @@ static void build_main_panel(AppState *app) {
|
||||
} else if (mouse_clicked && track_hovered && !thumb_hovered) {
|
||||
// Click on track: jump scroll position so thumb centers on click
|
||||
Clay_BoundingBox track_bb = Clay_GetElementData(track_id).boundingBox;
|
||||
float click_rel = input.mouse_pos.y - track_bb.y;
|
||||
float target_pct = (click_rel - thumb_h / 2) / (track_h - thumb_h);
|
||||
F32 click_rel = input.mouse_pos.y - track_bb.y;
|
||||
F32 target_pct = (click_rel - thumb_h / 2) / (track_h - thumb_h);
|
||||
if (target_pct < 0) target_pct = 0;
|
||||
if (target_pct > 1) target_pct = 1;
|
||||
scroll_data.scrollPosition->y = -target_pct * scroll_range;
|
||||
@@ -509,9 +509,9 @@ static void build_main_panel(AppState *app) {
|
||||
}
|
||||
|
||||
if (app->scrollbar_dragging) {
|
||||
float dy = input.mouse_pos.y - app->scrollbar_drag_start_y;
|
||||
float scroll_per_px = scroll_range / (track_h - thumb_h);
|
||||
float new_scroll = app->scrollbar_drag_start_scroll - dy * scroll_per_px;
|
||||
F32 dy = input.mouse_pos.y - app->scrollbar_drag_start_y;
|
||||
F32 scroll_per_px = scroll_range / (track_h - thumb_h);
|
||||
F32 new_scroll = app->scrollbar_drag_start_scroll - dy * scroll_per_px;
|
||||
if (new_scroll > 0) new_scroll = 0;
|
||||
if (new_scroll < -scroll_range) new_scroll = -scroll_range;
|
||||
scroll_data.scrollPosition->y = new_scroll;
|
||||
@@ -521,9 +521,9 @@ static void build_main_panel(AppState *app) {
|
||||
Clay_Color thumb_color = g_theme.scrollbar_grab;
|
||||
if (app->scrollbar_dragging || thumb_hovered) {
|
||||
thumb_color = Clay_Color{
|
||||
(float)Min((int)thumb_color.r + 30, 255),
|
||||
(float)Min((int)thumb_color.g + 30, 255),
|
||||
(float)Min((int)thumb_color.b + 30, 255),
|
||||
(F32)Min((S32)thumb_color.r + 30, 255),
|
||||
(F32)Min((S32)thumb_color.g + 30, 255),
|
||||
(F32)Min((S32)thumb_color.b + 30, 255),
|
||||
thumb_color.a
|
||||
};
|
||||
}
|
||||
@@ -562,7 +562,7 @@ static void build_right_panel(AppState *app) {
|
||||
static const char *right_tabs[] = { "Properties", "MIDI Devices" };
|
||||
|
||||
Clay_Color rp_top = g_theme.bg_medium;
|
||||
Clay_Color rp_bot = {(float)Max((int)rp_top.r-8,0), (float)Max((int)rp_top.g-8,0), (float)Max((int)rp_top.b-8,0), 255};
|
||||
Clay_Color rp_bot = {(F32)Max((S32)rp_top.r-8,0), (F32)Max((S32)rp_top.g-8,0), (F32)Max((S32)rp_top.b-8,0), 255};
|
||||
CustomGradientData *rp_grad = alloc_gradient(rp_top, rp_bot);
|
||||
|
||||
CLAY(CLAY_ID("RightPanel"),
|
||||
@@ -627,7 +627,7 @@ static void build_right_panel(AppState *app) {
|
||||
}
|
||||
|
||||
static char device_bufs[64][128];
|
||||
int32_t device_count = midi_get_device_count(midi);
|
||||
S32 device_count = midi_get_device_count(midi);
|
||||
|
||||
// --- Inputs section ---
|
||||
CLAY_TEXT(CLAY_STRING("Inputs"), &g_text_config_dim);
|
||||
@@ -642,12 +642,12 @@ static void build_right_panel(AppState *app) {
|
||||
box_text_config.wrapMode = CLAY_TEXT_WRAP_NONE;
|
||||
|
||||
B32 has_inputs = 0;
|
||||
for (int32_t i = 0; i < device_count && i < 64; i++) {
|
||||
for (S32 i = 0; i < device_count && i < 64; i++) {
|
||||
MidiDeviceInfo *dev = midi_get_device(midi, i);
|
||||
if (!dev->is_input) continue;
|
||||
has_inputs = 1;
|
||||
|
||||
int len = snprintf(device_bufs[i], sizeof(device_bufs[i]), "%s", dev->name);
|
||||
S32 len = snprintf(device_bufs[i], sizeof(device_bufs[i]), "%s", dev->name);
|
||||
Clay_String device_str = { .isStaticallyAllocated = false, .length = len, .chars = device_bufs[i] };
|
||||
|
||||
// Velocity-based color: blue (vel 0) → green (mid) → red (vel 127)
|
||||
@@ -662,10 +662,10 @@ static void build_right_panel(AppState *app) {
|
||||
}
|
||||
|
||||
// Box text: note name when held, "OFF" when releasing, "---" when idle
|
||||
int nlen;
|
||||
S32 nlen;
|
||||
if (dev->active) {
|
||||
int pitch = dev->note % 12;
|
||||
int octave = (dev->note / 12) - 1;
|
||||
S32 pitch = dev->note % 12;
|
||||
S32 octave = (dev->note / 12) - 1;
|
||||
nlen = snprintf(note_bufs[i], sizeof(note_bufs[i]), "%s%d", note_names[pitch], octave);
|
||||
} else if (dev->releasing) {
|
||||
nlen = snprintf(note_bufs[i], sizeof(note_bufs[i]), "OFF");
|
||||
@@ -682,7 +682,7 @@ static void build_right_panel(AppState *app) {
|
||||
if (dev->releasing) box_txt = &box_text_dark;
|
||||
|
||||
// Velocity text
|
||||
int vlen;
|
||||
S32 vlen;
|
||||
if (dev->active)
|
||||
vlen = snprintf(vel_bufs[i], sizeof(vel_bufs[i]), "%d", dev->velocity);
|
||||
else
|
||||
@@ -723,12 +723,12 @@ static void build_right_panel(AppState *app) {
|
||||
CLAY_TEXT(CLAY_STRING("Outputs"), &g_text_config_dim);
|
||||
|
||||
B32 has_outputs = 0;
|
||||
for (int32_t i = 0; i < device_count && i < 64; i++) {
|
||||
for (S32 i = 0; i < device_count && i < 64; i++) {
|
||||
MidiDeviceInfo *dev = midi_get_device(midi, i);
|
||||
if (dev->is_input) continue;
|
||||
has_outputs = 1;
|
||||
|
||||
int len = snprintf(device_bufs[i], sizeof(device_bufs[i]), "%s", dev->name);
|
||||
S32 len = snprintf(device_bufs[i], sizeof(device_bufs[i]), "%s", dev->name);
|
||||
Clay_String device_str = { .isStaticallyAllocated = false, .length = len, .chars = device_bufs[i] };
|
||||
|
||||
CLAY(CLAY_IDI("MidiOut", i),
|
||||
@@ -752,7 +752,7 @@ static void build_log_panel(AppState *app) {
|
||||
if (!app->show_log) return;
|
||||
|
||||
Clay_Color lp_top = g_theme.bg_medium;
|
||||
Clay_Color lp_bot = {(float)Max((int)lp_top.r-8,0), (float)Max((int)lp_top.g-8,0), (float)Max((int)lp_top.b-8,0), 255};
|
||||
Clay_Color lp_bot = {(F32)Max((S32)lp_top.r-8,0), (F32)Max((S32)lp_top.g-8,0), (F32)Max((S32)lp_top.b-8,0), 255};
|
||||
CustomGradientData *lp_grad = alloc_gradient(lp_top, lp_bot);
|
||||
|
||||
CLAY(CLAY_ID("LogPanel"),
|
||||
@@ -808,7 +808,7 @@ static void build_log_panel(AppState *app) {
|
||||
if (black_key_w < uis(8)) black_key_w = uis(8);
|
||||
|
||||
// White keys (grow to fill width and height)
|
||||
for (int note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
for (S32 note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
if (piano_is_black_key(note)) continue;
|
||||
|
||||
B32 midi_held = midi_is_note_held(app->midi, note);
|
||||
@@ -832,7 +832,7 @@ static void build_log_panel(AppState *app) {
|
||||
}
|
||||
|
||||
// Black keys (floating, attached to left white key)
|
||||
for (int note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
for (S32 note = PIANO_FIRST_NOTE; note <= PIANO_LAST_NOTE; note++) {
|
||||
if (!piano_is_black_key(note)) continue;
|
||||
|
||||
Clay_ElementId parent_wkey = CLAY_IDI("PKey", note - 1);
|
||||
@@ -923,9 +923,9 @@ static void settings_window_content(void *user_data) {
|
||||
ui_label("SettingsLblAudio", "Audio Device");
|
||||
|
||||
static const char *audio_options[AUDIO_MAX_DEVICES + 1];
|
||||
int32_t audio_count = audio_get_device_count(app->audio);
|
||||
S32 audio_count = audio_get_device_count(app->audio);
|
||||
audio_options[0] = "None";
|
||||
for (int32_t i = 0; i < audio_count && i < AUDIO_MAX_DEVICES; i++) {
|
||||
for (S32 i = 0; i < audio_count && i < AUDIO_MAX_DEVICES; i++) {
|
||||
AudioDeviceInfo *dev = audio_get_device(app->audio, i);
|
||||
audio_options[i + 1] = dev ? dev->name : "???";
|
||||
}
|
||||
@@ -954,8 +954,8 @@ static void settings_window_content(void *user_data) {
|
||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||
}
|
||||
) {
|
||||
bool device_open = (app->audio_device_sel > 0);
|
||||
bool tone_playing = audio_is_test_tone_playing(app->audio);
|
||||
B32 device_open = (app->audio_device_sel > 0);
|
||||
B32 tone_playing = audio_is_test_tone_playing(app->audio);
|
||||
|
||||
if (device_open && !tone_playing) {
|
||||
if (ui_button("BtnTestTone", "Play Test Tone")) {
|
||||
@@ -1062,7 +1062,7 @@ static void update_panel_splitters(AppState *app) {
|
||||
|
||||
static void build_header_bar(AppState *app) {
|
||||
Clay_Color bar_bg = g_theme.bg_dark;
|
||||
Clay_Color border_bot = {(float)Max((int)bar_bg.r - 12, 0), (float)Max((int)bar_bg.g - 12, 0), (float)Max((int)bar_bg.b - 12, 0), 255};
|
||||
Clay_Color border_bot = {(F32)Max((S32)bar_bg.r - 12, 0), (F32)Max((S32)bar_bg.g - 12, 0), (F32)Max((S32)bar_bg.b - 12, 0), 255};
|
||||
|
||||
static Clay_TextElementConfig header_btn_active_text = {};
|
||||
header_btn_active_text.textColor = Clay_Color{255, 255, 255, 255};
|
||||
@@ -1084,7 +1084,7 @@ static void build_header_bar(AppState *app) {
|
||||
header_indicator_label.fontSize = FONT_SIZE_SMALL;
|
||||
header_indicator_label.wrapMode = CLAY_TEXT_WRAP_NONE;
|
||||
|
||||
Clay_Color inset_bg = {(float)Max((int)bar_bg.r - 8, 0), (float)Max((int)bar_bg.g - 8, 0), (float)Max((int)bar_bg.b - 8, 0), 255};
|
||||
Clay_Color inset_bg = {(F32)Max((S32)bar_bg.r - 8, 0), (F32)Max((S32)bar_bg.g - 8, 0), (F32)Max((S32)bar_bg.b - 8, 0), 255};
|
||||
|
||||
CLAY(CLAY_ID("HeaderBar"),
|
||||
.layout = {
|
||||
@@ -1297,7 +1297,7 @@ static void build_header_bar(AppState *app) {
|
||||
|
||||
static void build_mix_view(AppState *app) {
|
||||
Clay_Color mv_top = g_theme.bg_medium;
|
||||
Clay_Color mv_bot = {(float)Max((int)mv_top.r - 8, 0), (float)Max((int)mv_top.g - 8, 0), (float)Max((int)mv_top.b - 8, 0), 255};
|
||||
Clay_Color mv_bot = {(F32)Max((S32)mv_top.r - 8, 0), (F32)Max((S32)mv_top.g - 8, 0), (F32)Max((S32)mv_top.b - 8, 0), 255};
|
||||
CustomGradientData *mv_grad = alloc_gradient(mv_top, mv_bot);
|
||||
|
||||
CLAY(CLAY_ID("MixView"),
|
||||
@@ -1314,7 +1314,7 @@ static void build_mix_view(AppState *app) {
|
||||
static char fader_id_bufs[8][16];
|
||||
static char pan_id_bufs[8][16];
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (S32 i = 0; i < 8; i++) {
|
||||
snprintf(ch_label_bufs[i], sizeof(ch_label_bufs[i]), "Ch %d", i + 1);
|
||||
snprintf(fader_id_bufs[i], sizeof(fader_id_bufs[i]), "MixFader%d", i);
|
||||
snprintf(pan_id_bufs[i], sizeof(pan_id_bufs[i]), "MixPan%d", i);
|
||||
@@ -1333,7 +1333,7 @@ static void build_mix_view(AppState *app) {
|
||||
.border = { .color = g_theme.border, .width = { .right = 1 } },
|
||||
) {
|
||||
// Channel label
|
||||
int llen = snprintf(ch_label_bufs[i], sizeof(ch_label_bufs[i]), "Ch %d", i + 1);
|
||||
S32 llen = snprintf(ch_label_bufs[i], sizeof(ch_label_bufs[i]), "Ch %d", i + 1);
|
||||
Clay_String ch_str = { .isStaticallyAllocated = false, .length = llen, .chars = ch_label_bufs[i] };
|
||||
CLAY_TEXT(ch_str, &g_text_config_dim);
|
||||
|
||||
@@ -1367,9 +1367,9 @@ static void build_mix_view(AppState *app) {
|
||||
// Master strip (slightly wider, accent-tinted)
|
||||
{
|
||||
Clay_Color master_bg = {
|
||||
(float)Min((int)g_theme.bg_medium.r + 6, 255),
|
||||
(float)Min((int)g_theme.bg_medium.g + 6, 255),
|
||||
(float)Min((int)g_theme.bg_medium.b + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_medium.r + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_medium.g + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_medium.b + 6, 255),
|
||||
255
|
||||
};
|
||||
static F32 master_fader = 0.0f;
|
||||
@@ -1420,7 +1420,7 @@ static void build_mix_view(AppState *app) {
|
||||
|
||||
static void build_patch_view(AppState *app) {
|
||||
Clay_Color pv_top = g_theme.bg_medium;
|
||||
Clay_Color pv_bot = {(float)Max((int)pv_top.r - 8, 0), (float)Max((int)pv_top.g - 8, 0), (float)Max((int)pv_top.b - 8, 0), 255};
|
||||
Clay_Color pv_bot = {(F32)Max((S32)pv_top.r - 8, 0), (F32)Max((S32)pv_top.g - 8, 0), (F32)Max((S32)pv_top.b - 8, 0), 255};
|
||||
CustomGradientData *pv_grad = alloc_gradient(pv_top, pv_bot);
|
||||
|
||||
CLAY(CLAY_ID("PatchView"),
|
||||
@@ -1495,7 +1495,7 @@ static void build_patch_view(AppState *app) {
|
||||
CLAY(CLAY_ID("IntOutputLabel"),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIT(), .height = CLAY_SIZING_FIT() },
|
||||
.padding = { (uint16_t)label_w, 0, 0, 0 },
|
||||
.padding = { (U16)label_w, 0, 0, 0 },
|
||||
}
|
||||
) {
|
||||
CLAY_TEXT(CLAY_STRING("OUTPUT >"), &matrix_axis_text);
|
||||
@@ -1526,8 +1526,8 @@ static void build_patch_view(AppState *app) {
|
||||
}
|
||||
|
||||
static char int_dst_bufs[MATRIX_OUTPUTS][8];
|
||||
for (int d = 0; d < MATRIX_OUTPUTS; d++) {
|
||||
int dlen;
|
||||
for (S32 d = 0; d < MATRIX_OUTPUTS; d++) {
|
||||
S32 dlen;
|
||||
if (d == 0)
|
||||
dlen = snprintf(int_dst_bufs[d], sizeof(int_dst_bufs[d]), "Mst");
|
||||
else
|
||||
@@ -1547,8 +1547,8 @@ static void build_patch_view(AppState *app) {
|
||||
|
||||
// Rows
|
||||
static char int_src_bufs[MATRIX_INPUTS][8];
|
||||
for (int s = 0; s < MATRIX_INPUTS; s++) {
|
||||
int slen = snprintf(int_src_bufs[s], sizeof(int_src_bufs[s]), "Ch %d", s + 1);
|
||||
for (S32 s = 0; s < MATRIX_INPUTS; s++) {
|
||||
S32 slen = snprintf(int_src_bufs[s], sizeof(int_src_bufs[s]), "Ch %d", s + 1);
|
||||
Clay_String src_str = { .isStaticallyAllocated = false, .length = slen, .chars = int_src_bufs[s] };
|
||||
|
||||
CLAY(CLAY_IDI("IntRow", s),
|
||||
@@ -1567,8 +1567,8 @@ static void build_patch_view(AppState *app) {
|
||||
CLAY_TEXT(src_str, &matrix_hdr_text);
|
||||
}
|
||||
|
||||
for (int d = 0; d < MATRIX_OUTPUTS; d++) {
|
||||
int cell_idx = s * MATRIX_OUTPUTS + d;
|
||||
for (S32 d = 0; d < MATRIX_OUTPUTS; d++) {
|
||||
S32 cell_idx = s * MATRIX_OUTPUTS + d;
|
||||
Clay_ElementId cell_eid = CLAY_IDI("IntCell", cell_idx);
|
||||
B32 cell_hovered = Clay_PointerOver(cell_eid);
|
||||
|
||||
@@ -1580,9 +1580,9 @@ static void build_patch_view(AppState *app) {
|
||||
Clay_Color cell_bg;
|
||||
if (is_feedback) {
|
||||
cell_bg = Clay_Color{
|
||||
(float)Max((int)g_theme.bg_dark.r - 10, 0),
|
||||
(float)Max((int)g_theme.bg_dark.g - 10, 0),
|
||||
(float)Max((int)g_theme.bg_dark.b - 10, 0), 255
|
||||
(F32)Max((S32)g_theme.bg_dark.r - 10, 0),
|
||||
(F32)Max((S32)g_theme.bg_dark.g - 10, 0),
|
||||
(F32)Max((S32)g_theme.bg_dark.b - 10, 0), 255
|
||||
};
|
||||
} else if (active) {
|
||||
cell_bg = g_theme.accent;
|
||||
@@ -1592,17 +1592,17 @@ static void build_patch_view(AppState *app) {
|
||||
cell_bg = g_theme.bg_dark;
|
||||
} else {
|
||||
cell_bg = Clay_Color{
|
||||
(float)Min((int)g_theme.bg_dark.r + 6, 255),
|
||||
(float)Min((int)g_theme.bg_dark.g + 6, 255),
|
||||
(float)Min((int)g_theme.bg_dark.b + 6, 255), 255
|
||||
(F32)Min((S32)g_theme.bg_dark.r + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_dark.g + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_dark.b + 6, 255), 255
|
||||
};
|
||||
}
|
||||
|
||||
if (d == 0 && !active && !cell_hovered && !is_feedback) {
|
||||
cell_bg = Clay_Color{
|
||||
(float)Min((int)cell_bg.r + 10, 255),
|
||||
(float)Min((int)cell_bg.g + 10, 255),
|
||||
(float)Min((int)cell_bg.b + 12, 255), 255
|
||||
(F32)Min((S32)cell_bg.r + 10, 255),
|
||||
(F32)Min((S32)cell_bg.g + 10, 255),
|
||||
(F32)Min((S32)cell_bg.b + 12, 255), 255
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1647,7 +1647,7 @@ static void build_patch_view(AppState *app) {
|
||||
CLAY(CLAY_ID("HwOutputLabel"),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIT(), .height = CLAY_SIZING_FIT() },
|
||||
.padding = { (uint16_t)label_w, 0, 0, 0 },
|
||||
.padding = { (U16)label_w, 0, 0, 0 },
|
||||
}
|
||||
) {
|
||||
CLAY_TEXT(CLAY_STRING("HW OUTPUT >"), &matrix_axis_text);
|
||||
@@ -1678,8 +1678,8 @@ static void build_patch_view(AppState *app) {
|
||||
}
|
||||
|
||||
static char hw_dst_bufs[HW_OUTPUTS][8];
|
||||
for (int d = 0; d < HW_OUTPUTS; d++) {
|
||||
int dlen = snprintf(hw_dst_bufs[d], sizeof(hw_dst_bufs[d]), "%d", d + 1);
|
||||
for (S32 d = 0; d < HW_OUTPUTS; d++) {
|
||||
S32 dlen = snprintf(hw_dst_bufs[d], sizeof(hw_dst_bufs[d]), "%d", d + 1);
|
||||
Clay_String dst_str = { .isStaticallyAllocated = false, .length = dlen, .chars = hw_dst_bufs[d] };
|
||||
|
||||
CLAY(CLAY_IDI("HwDstHdr", d),
|
||||
@@ -1695,8 +1695,8 @@ static void build_patch_view(AppState *app) {
|
||||
|
||||
// Rows
|
||||
static char hw_src_bufs[HW_OUTPUTS][8];
|
||||
for (int s = 0; s < HW_OUTPUTS; s++) {
|
||||
int slen = snprintf(hw_src_bufs[s], sizeof(hw_src_bufs[s]), "Out %d", s + 1);
|
||||
for (S32 s = 0; s < HW_OUTPUTS; s++) {
|
||||
S32 slen = snprintf(hw_src_bufs[s], sizeof(hw_src_bufs[s]), "Out %d", s + 1);
|
||||
Clay_String src_str = { .isStaticallyAllocated = false, .length = slen, .chars = hw_src_bufs[s] };
|
||||
|
||||
CLAY(CLAY_IDI("HwRow", s),
|
||||
@@ -1715,8 +1715,8 @@ static void build_patch_view(AppState *app) {
|
||||
CLAY_TEXT(src_str, &matrix_hdr_text);
|
||||
}
|
||||
|
||||
for (int d = 0; d < HW_OUTPUTS; d++) {
|
||||
int cell_idx = s * HW_OUTPUTS + d;
|
||||
for (S32 d = 0; d < HW_OUTPUTS; d++) {
|
||||
S32 cell_idx = s * HW_OUTPUTS + d;
|
||||
Clay_ElementId cell_eid = CLAY_IDI("HwCell", cell_idx);
|
||||
B32 cell_hovered = Clay_PointerOver(cell_eid);
|
||||
B32 active = app->hw_matrix[s][d];
|
||||
@@ -1730,9 +1730,9 @@ static void build_patch_view(AppState *app) {
|
||||
cell_bg = g_theme.bg_dark;
|
||||
} else {
|
||||
cell_bg = Clay_Color{
|
||||
(float)Min((int)g_theme.bg_dark.r + 6, 255),
|
||||
(float)Min((int)g_theme.bg_dark.g + 6, 255),
|
||||
(float)Min((int)g_theme.bg_dark.b + 6, 255), 255
|
||||
(F32)Min((S32)g_theme.bg_dark.r + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_dark.g + 6, 255),
|
||||
(F32)Min((S32)g_theme.bg_dark.b + 6, 255), 255
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1870,7 +1870,7 @@ static void build_ui(AppState *app) {
|
||||
static void do_frame(AppState *app) {
|
||||
// Timing
|
||||
#ifdef __APPLE__
|
||||
uint64_t now = mach_absolute_time();
|
||||
U64 now = mach_absolute_time();
|
||||
F32 dt = (F32)(now - app->last_time) * (F32)app->freq_numer / ((F32)app->freq_denom * 1e9f);
|
||||
app->last_time = now;
|
||||
#else
|
||||
@@ -2043,7 +2043,7 @@ int main(int argc, char **argv) {
|
||||
app.log_height = 180.0f;
|
||||
app.panel_drag = 0;
|
||||
app.master_layout = 0;
|
||||
for (int i = 0; i < 8; i++) { app.mix_faders[i] = 0.0f; app.mix_pans[i] = 0.0f; }
|
||||
for (S32 i = 0; i < 8; i++) { app.mix_faders[i] = 0.0f; app.mix_pans[i] = 0.0f; }
|
||||
app.mix_master_pan = 0.0f;
|
||||
app.patch_tab = 0;
|
||||
memset(app.patch_matrix, 0, sizeof(app.patch_matrix));
|
||||
@@ -2061,11 +2061,12 @@ int main(int argc, char **argv) {
|
||||
|
||||
platform_set_frame_callback(window, frame_callback, &app);
|
||||
|
||||
while (platform_poll_events(window)) {
|
||||
B32 running = 1;
|
||||
while (running && platform_poll_events(window)) {
|
||||
// Menu commands
|
||||
int32_t menu_cmd = platform_poll_menu_command(window);
|
||||
S32 menu_cmd = platform_poll_menu_command(window);
|
||||
switch (menu_cmd) {
|
||||
case MENU_FILE_EXIT: goto exit_app;
|
||||
case MENU_FILE_EXIT: running = 0; break;
|
||||
case MENU_VIEW_BROWSER: app.show_browser = !app.show_browser; break;
|
||||
case MENU_VIEW_PROPERTIES:app.show_props = !app.show_props; break;
|
||||
case MENU_VIEW_LOG: app.show_log = !app.show_log; break;
|
||||
@@ -2073,10 +2074,9 @@ int main(int argc, char **argv) {
|
||||
default: break;
|
||||
}
|
||||
|
||||
do_frame(&app);
|
||||
if (running) do_frame(&app);
|
||||
}
|
||||
|
||||
exit_app:
|
||||
audio_destroy(audio);
|
||||
midi_destroy(midi);
|
||||
ui_destroy(ui);
|
||||
|
||||
Reference in New Issue
Block a user