Fix faders, z indexing, svg rendering
This commit is contained in:
@@ -105,8 +105,8 @@ static void emit_shadow(Clay_BoundingBox bb, F32 ox, F32 oy, F32 radius,
|
||||
.backgroundColor = {0, 0, 0, per_layer},
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS + expand),
|
||||
.floating = {
|
||||
.parentId = parent_id,
|
||||
.offset = { -expand + ox, -expand + oy },
|
||||
.parentId = parent_id,
|
||||
.zIndex = z,
|
||||
.attachPoints = {
|
||||
.element = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
@@ -732,8 +732,8 @@ B32 ui_text_input(const char *id, char *buf, S32 buf_size) {
|
||||
},
|
||||
.backgroundColor = bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = border_color, .width = { 1, 1, 1, 1 } },
|
||||
.custom = { .customData = inset_grad },
|
||||
.border = { .color = border_color, .width = { 1, 1, 1, 1 } },
|
||||
) {
|
||||
if (len == 0 && !is_focused) {
|
||||
// Placeholder
|
||||
@@ -850,8 +850,8 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
},
|
||||
.backgroundColor = bg,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = is_open ? g_theme.accent : g_theme.border, .width = { 1, 1, 1, 1 } },
|
||||
.custom = { .customData = dd_grad },
|
||||
.border = { .color = is_open ? g_theme.accent : g_theme.border, .width = { 1, 1, 1, 1 } },
|
||||
) {
|
||||
CLAY(text_eid,
|
||||
.layout = {
|
||||
@@ -902,7 +902,6 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
},
|
||||
.backgroundColor = g_theme.bg_dark,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(CORNER_RADIUS),
|
||||
.border = { .color = g_theme.border, .width = { 1, 1, 1, 1 } },
|
||||
.floating = {
|
||||
.parentId = eid.id,
|
||||
.zIndex = 2000,
|
||||
@@ -911,7 +910,8 @@ B32 ui_dropdown(const char *id, const char **options, S32 count, S32 *selected)
|
||||
.parent = CLAY_ATTACH_POINT_LEFT_BOTTOM,
|
||||
},
|
||||
.attachTo = CLAY_ATTACH_TO_ELEMENT_WITH_ID,
|
||||
}
|
||||
},
|
||||
.border = { .color = g_theme.border, .width = { 1, 1, 1, 1 } },
|
||||
) {
|
||||
for (S32 i = 0; i < count; i++) {
|
||||
B32 is_item_selected = (*selected == i);
|
||||
@@ -1056,8 +1056,8 @@ S32 ui_modal(const char *id, const char *title, const char *message,
|
||||
},
|
||||
.backgroundColor = g_theme.title_bar,
|
||||
.cornerRadius = { CORNER_RADIUS, CORNER_RADIUS, 0, 0 },
|
||||
.border = { .color = g_theme.border, .width = { .bottom = 1 } },
|
||||
.custom = { .customData = mtb_grad },
|
||||
.border = { .color = g_theme.border, .width = { .bottom = 1 } },
|
||||
) {
|
||||
CLAY_TEXT(clay_str(title), &g_widget_text_config);
|
||||
}
|
||||
@@ -1264,8 +1264,8 @@ B32 ui_window(const char *id, const char *title, B32 *open,
|
||||
},
|
||||
.backgroundColor = g_theme.title_bar,
|
||||
.cornerRadius = { CORNER_RADIUS, CORNER_RADIUS, 0, 0 },
|
||||
.border = { .color = g_theme.border, .width = { .bottom = 1 } },
|
||||
.custom = { .customData = tb_grad },
|
||||
.border = { .color = g_theme.border, .width = { .bottom = 1 } },
|
||||
) {
|
||||
// Title text (grows to push close button right)
|
||||
CLAY(WIDI(id, 3002),
|
||||
@@ -1916,7 +1916,6 @@ B32 ui_slider_h(const char *id, const char *label, F32 *value, F32 max_val, B32
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(thumb_w), .height = CLAY_SIZING_FIXED(thumb_h) },
|
||||
},
|
||||
.custom = { .customData = idata },
|
||||
.floating = {
|
||||
.offset = {
|
||||
.x = normalized * (track_w - thumb_w),
|
||||
@@ -1928,7 +1927,9 @@ B32 ui_slider_h(const char *id, const char *label, F32 *value, F32 max_val, B32
|
||||
},
|
||||
.pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
|
||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||
}
|
||||
.clipTo = CLAY_CLIP_TO_ATTACHED_PARENT,
|
||||
},
|
||||
.custom = { .customData = idata },
|
||||
) {}
|
||||
}
|
||||
}
|
||||
@@ -2092,7 +2093,6 @@ B32 ui_slider_v(const char *id, const char *label, F32 *value, F32 max_val, B32
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(thumb_w), .height = CLAY_SIZING_FIXED(thumb_h) },
|
||||
},
|
||||
.custom = { .customData = idata },
|
||||
.floating = {
|
||||
.offset = {
|
||||
.x = 0,
|
||||
@@ -2104,7 +2104,9 @@ B32 ui_slider_v(const char *id, const char *label, F32 *value, F32 max_val, B32
|
||||
},
|
||||
.pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
|
||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||
}
|
||||
.clipTo = CLAY_CLIP_TO_ATTACHED_PARENT,
|
||||
},
|
||||
.custom = { .customData = idata },
|
||||
) {}
|
||||
}
|
||||
}
|
||||
@@ -2210,9 +2212,12 @@ B32 ui_fader(const char *id, const char *label, F32 *value, F32 max_val, B32 is_
|
||||
S32 val_len = 0;
|
||||
char *val_text = is_editing ? nullptr : value_format_text(*value, is_signed, &val_len);
|
||||
|
||||
// Dimmed accent for fill bar
|
||||
Clay_Color fill_color = g_theme.accent;
|
||||
fill_color.a = 160;
|
||||
// Tick mark dimensions
|
||||
F32 tick_major_w = WIDGET_FADER_TICK_MAJOR_W;
|
||||
F32 tick_minor_w = WIDGET_FADER_TICK_MINOR_W;
|
||||
F32 tick_h = WIDGET_FADER_TICK_H;
|
||||
S32 num_ticks = 10;
|
||||
F32 track_left = (cap_w - track_w) / 2.0f;
|
||||
|
||||
// Layout: vertical column (label → hit area with track → value/edit)
|
||||
CLAY(WID(id),
|
||||
@@ -2236,43 +2241,31 @@ B32 ui_fader(const char *id, const char *label, F32 *value, F32 max_val, B32 is_
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER },
|
||||
}
|
||||
) {
|
||||
// Visible track (centered inside hit area)
|
||||
// Visible track (centered inside hit area, empty)
|
||||
CLAY(CLAY_IDI("FdrTrack", (int)hash),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(track_w), .height = CLAY_SIZING_FIXED(track_h) },
|
||||
.childAlignment = { .y = CLAY_ALIGN_Y_BOTTOM },
|
||||
},
|
||||
.backgroundColor = g_theme.bg_dark,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(track_w / 2.0f)
|
||||
) {
|
||||
// Fill bar (from bottom)
|
||||
F32 fill_h = normalized * track_h;
|
||||
if (fill_h < 1.0f) fill_h = 1.0f;
|
||||
CLAY(CLAY_IDI("FdrFill", (int)hash),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_GROW(), .height = CLAY_SIZING_FIXED(fill_h) },
|
||||
},
|
||||
.backgroundColor = fill_color,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(track_w / 2.0f)
|
||||
) {}
|
||||
}
|
||||
) {}
|
||||
|
||||
// Floating fader cap (icon, silver colored)
|
||||
if (g_icon_pool_count < UI_MAX_ICONS_PER_FRAME) {
|
||||
CustomIconData *idata = &g_icon_pool[g_icon_pool_count++];
|
||||
idata->type = CUSTOM_RENDER_ICON;
|
||||
idata->icon_id = (S32)UI_ICON_FADER;
|
||||
idata->color = Clay_Color{200, 200, 210, 255};
|
||||
// Tick marks on both sides of the track
|
||||
for (S32 i = 0; i <= num_ticks; i++) {
|
||||
F32 norm = (F32)i / (F32)num_ticks;
|
||||
F32 tick_y = (1.0f - norm) * (track_h - tick_h);
|
||||
F32 tw = (i % 5 == 0) ? tick_major_w : tick_minor_w;
|
||||
|
||||
CLAY(CLAY_IDI("FdrCap", (int)hash),
|
||||
// Left tick
|
||||
CLAY(CLAY_IDI("FdrTkL", (int)(hash * 100 + i)),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(cap_w), .height = CLAY_SIZING_FIXED(cap_h) },
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(tw), .height = CLAY_SIZING_FIXED(tick_h) },
|
||||
},
|
||||
.custom = { .customData = idata },
|
||||
.backgroundColor = g_theme.text_dim,
|
||||
.floating = {
|
||||
.offset = {
|
||||
.x = 0,
|
||||
.y = (1.0f - normalized) * (track_h - cap_h),
|
||||
.x = track_left - tw,
|
||||
.y = tick_y,
|
||||
},
|
||||
.attachPoints = {
|
||||
.element = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
@@ -2280,7 +2273,78 @@ B32 ui_fader(const char *id, const char *label, F32 *value, F32 max_val, B32 is_
|
||||
},
|
||||
.pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
|
||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||
}
|
||||
.clipTo = CLAY_CLIP_TO_ATTACHED_PARENT,
|
||||
},
|
||||
) {}
|
||||
|
||||
// Right tick
|
||||
CLAY(CLAY_IDI("FdrTkR", (int)(hash * 100 + i)),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(tw), .height = CLAY_SIZING_FIXED(tick_h) },
|
||||
},
|
||||
.backgroundColor = g_theme.text_dim,
|
||||
.floating = {
|
||||
.offset = {
|
||||
.x = track_left + track_w,
|
||||
.y = tick_y,
|
||||
},
|
||||
.attachPoints = {
|
||||
.element = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
.parent = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
},
|
||||
.pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
|
||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||
.clipTo = CLAY_CLIP_TO_ATTACHED_PARENT,
|
||||
},
|
||||
) {}
|
||||
}
|
||||
|
||||
// Floating fader cap (RGBA icon from asset SVG)
|
||||
if (g_icon_pool_count < UI_MAX_ICONS_PER_FRAME) {
|
||||
CustomIconData *idata = &g_icon_pool[g_icon_pool_count++];
|
||||
idata->type = CUSTOM_RENDER_ICON;
|
||||
idata->icon_id = (S32)UI_ICON_FADER;
|
||||
idata->color = Clay_Color{255, 255, 255, 255};
|
||||
|
||||
F32 cap_y = (1.0f - normalized) * (track_h - cap_h);
|
||||
|
||||
CLAY(CLAY_IDI("FdrCap", (int)hash),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(cap_w), .height = CLAY_SIZING_FIXED(cap_h) },
|
||||
},
|
||||
.floating = {
|
||||
.offset = { .x = 0, .y = cap_y },
|
||||
.attachPoints = {
|
||||
.element = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
.parent = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
},
|
||||
.pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
|
||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||
.clipTo = CLAY_CLIP_TO_ATTACHED_PARENT,
|
||||
},
|
||||
.custom = { .customData = idata },
|
||||
) {}
|
||||
|
||||
// Color tint overlay on top of fader cap
|
||||
Clay_Color tint = g_theme.accent;
|
||||
tint.a = 80;
|
||||
F32 cap_corner = cap_w * (3.0f / 62.2f);
|
||||
CLAY(CLAY_IDI("FdrTint", (int)hash),
|
||||
.layout = {
|
||||
.sizing = { .width = CLAY_SIZING_FIXED(cap_w), .height = CLAY_SIZING_FIXED(cap_h) },
|
||||
},
|
||||
.backgroundColor = tint,
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(cap_corner),
|
||||
.floating = {
|
||||
.offset = { .x = 0, .y = cap_y },
|
||||
.attachPoints = {
|
||||
.element = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
.parent = CLAY_ATTACH_POINT_LEFT_TOP,
|
||||
},
|
||||
.pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH,
|
||||
.attachTo = CLAY_ATTACH_TO_PARENT,
|
||||
.clipTo = CLAY_CLIP_TO_ATTACHED_PARENT,
|
||||
},
|
||||
) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user