scrollbar styling
This commit is contained in:
parent
5c2ff7ca9f
commit
122741f580
@ -5175,29 +5175,14 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
|
||||
|
||||
//- Scrollbar
|
||||
if (scrollbar_visible)
|
||||
{
|
||||
Vec2 scrollbar_pos = scrollbar_reps.draw.screen_rect.p0;
|
||||
Vec2 scrollbar_dims = DimsFromRng2(scrollbar_reps.draw.screen_rect);
|
||||
Vec2 thumb_dims = DimsFromRng2(thumb_reps.draw.screen_rect);
|
||||
// Vec2 half_thumb_dims = MulVec2(thumb_dims, 0.5);
|
||||
UI_Key scrollbar_up = UI_KeyF("scrollbar up");
|
||||
UI_Key scrollbar_down = UI_KeyF("scrollbar down");
|
||||
|
||||
|
||||
// f32 range_min = tweak_var.range.min;
|
||||
// f32 range_max = tweak_var.range.max;
|
||||
// if (range_max <= range_min)
|
||||
// {
|
||||
// range_max = range_min + 1;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// f32 ratio = 0;
|
||||
// ratio = (tweak_float - range_min) / (range_max - range_min);
|
||||
// ratio = ClampF32(ratio, 0, 1);
|
||||
UI_BoxReports up_reps = UI_ReportsFromKey(scrollbar_up);
|
||||
UI_BoxReports down_reps = UI_ReportsFromKey(scrollbar_down);
|
||||
|
||||
if (thumb_reps.draw.m1.downs)
|
||||
{
|
||||
@ -5209,32 +5194,75 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
}
|
||||
palette->scroll = MaxF32(palette->scroll, 0);
|
||||
|
||||
// f32 thumb_offset = 50;
|
||||
f32 thumb_offset = palette->scroll;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
UI_BuildSpacer(window_padding, Axis_X);
|
||||
|
||||
UI_SetNext(Width, scrollbar_width);
|
||||
UI_PushCP(UI_BuildBoxEx(scrollbar_key));
|
||||
{
|
||||
UI_Size thumb_height = UI_FNT(10, 1);
|
||||
//- Scrollbar up button
|
||||
{
|
||||
Vec4 bg = Zi;
|
||||
Vec4 bd = bg;
|
||||
bd = LerpSrgb(bg, theme.col.button_active, up_reps.draw.hot);
|
||||
UI_SetNext(ChildAlignment, UI_Region_Center);
|
||||
UI_SetNext(BackgroundColor, bg);
|
||||
UI_SetNext(BorderColor, bd);
|
||||
UI_SetNext(BorderSize, 1);
|
||||
UI_SetNext(Rounding, UI_RGROW(theme.rounding * 0.5));
|
||||
UI_SetNext(TextColor, theme.col.hint);
|
||||
UI_SetNext(Width, UI_GROW(1, 1));
|
||||
UI_SetNext(Height, UI_FNT(1.5, 1));
|
||||
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
|
||||
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6);
|
||||
UI_BuildIconEx(scrollbar_up, theme.icon_font, UI_Icon_ArrowUp2);
|
||||
}
|
||||
|
||||
Vec4 thumb_color = VEC4(0, 0.5, 1, 1);
|
||||
thumb_color.a = thumb_reps.draw.hot * 0.5 + 0.5;
|
||||
//- Scrollbar thumb
|
||||
{
|
||||
// UI_SetNext(
|
||||
UI_PushCP(UI_BuildBox());
|
||||
{
|
||||
UI_Size thumb_height = UI_FNT(10, 1);
|
||||
|
||||
UI_SetNext(BackgroundColor, thumb_color);
|
||||
UI_SetNext(Width, UI_GROW(1, 0));
|
||||
UI_SetNext(Height, thumb_height);
|
||||
UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding));
|
||||
UI_SetNext(FloatingPos, VEC2(0, thumb_offset));
|
||||
// UI_SetNext(Anchor, UI_Region_Center);
|
||||
UI_SetNext(Anchor, UI_Region_Top);
|
||||
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Floating);
|
||||
UI_SetNext(Anchor, UI_Region_Top);
|
||||
UI_BuildBoxEx(thumb_key);
|
||||
Vec4 bg = theme.col.button_hot;
|
||||
Vec4 bd = bg;
|
||||
bg = LerpSrgb(bg, theme.col.button_active, thumb_reps.draw.active);
|
||||
bd = LerpSrgb(bg, theme.col.button_active, thumb_reps.draw.hot);
|
||||
|
||||
UI_SetNext(BackgroundColor, bg);
|
||||
UI_SetNext(Width, UI_GROW(1, 0));
|
||||
UI_SetNext(Height, thumb_height);
|
||||
UI_SetNext(BorderSize, 1);
|
||||
UI_SetNext(BorderColor, bd);
|
||||
UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding));
|
||||
UI_SetNext(FloatingPos, VEC2(0, thumb_offset));
|
||||
UI_SetNext(Anchor, UI_Region_Center);
|
||||
UI_SetNext(Anchor, UI_Region_Top);
|
||||
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Floating);
|
||||
UI_SetNext(Anchor, UI_Region_Top);
|
||||
UI_BuildBoxEx(thumb_key);
|
||||
}
|
||||
UI_PopCP(UI_TopCP());
|
||||
}
|
||||
|
||||
//- Scrollbar down button
|
||||
{
|
||||
Vec4 bg = Zi;
|
||||
Vec4 bd = bg;
|
||||
bd = LerpSrgb(bg, theme.col.button_active, down_reps.draw.hot);
|
||||
UI_SetNext(ChildAlignment, UI_Region_Center);
|
||||
UI_SetNext(BackgroundColor, bg);
|
||||
UI_SetNext(BorderColor, bd);
|
||||
UI_SetNext(BorderSize, 1);
|
||||
UI_SetNext(Rounding, UI_RGROW(theme.rounding * 0.5));
|
||||
UI_SetNext(TextColor, theme.col.hint);
|
||||
UI_SetNext(Width, UI_GROW(1, 1));
|
||||
UI_SetNext(Height, UI_FNT(1.5, 1));
|
||||
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
|
||||
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h6);
|
||||
UI_BuildIconEx(scrollbar_down, theme.icon_font, UI_Icon_ArrowDown2);
|
||||
}
|
||||
}
|
||||
UI_PopCP(UI_TopCP());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user