scrollbar styling
This commit is contained in:
parent
5c2ff7ca9f
commit
122741f580
@ -5175,29 +5175,14 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//- Scrollbar
|
||||||
if (scrollbar_visible)
|
if (scrollbar_visible)
|
||||||
{
|
{
|
||||||
Vec2 scrollbar_pos = scrollbar_reps.draw.screen_rect.p0;
|
UI_Key scrollbar_up = UI_KeyF("scrollbar up");
|
||||||
Vec2 scrollbar_dims = DimsFromRng2(scrollbar_reps.draw.screen_rect);
|
UI_Key scrollbar_down = UI_KeyF("scrollbar down");
|
||||||
Vec2 thumb_dims = DimsFromRng2(thumb_reps.draw.screen_rect);
|
|
||||||
// Vec2 half_thumb_dims = MulVec2(thumb_dims, 0.5);
|
|
||||||
|
|
||||||
|
UI_BoxReports up_reps = UI_ReportsFromKey(scrollbar_up);
|
||||||
// f32 range_min = tweak_var.range.min;
|
UI_BoxReports down_reps = UI_ReportsFromKey(scrollbar_down);
|
||||||
// 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);
|
|
||||||
|
|
||||||
if (thumb_reps.draw.m1.downs)
|
if (thumb_reps.draw.m1.downs)
|
||||||
{
|
{
|
||||||
@ -5209,28 +5194,50 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
}
|
}
|
||||||
palette->scroll = MaxF32(palette->scroll, 0);
|
palette->scroll = MaxF32(palette->scroll, 0);
|
||||||
|
|
||||||
// f32 thumb_offset = 50;
|
|
||||||
f32 thumb_offset = palette->scroll;
|
f32 thumb_offset = palette->scroll;
|
||||||
|
UI_BuildSpacer(window_padding, Axis_X);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UI_SetNext(Width, scrollbar_width);
|
UI_SetNext(Width, scrollbar_width);
|
||||||
UI_PushCP(UI_BuildBoxEx(scrollbar_key));
|
UI_PushCP(UI_BuildBoxEx(scrollbar_key));
|
||||||
|
{
|
||||||
|
//- 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Scrollbar thumb
|
||||||
|
{
|
||||||
|
// UI_SetNext(
|
||||||
|
UI_PushCP(UI_BuildBox());
|
||||||
{
|
{
|
||||||
UI_Size thumb_height = UI_FNT(10, 1);
|
UI_Size thumb_height = UI_FNT(10, 1);
|
||||||
|
|
||||||
Vec4 thumb_color = VEC4(0, 0.5, 1, 1);
|
Vec4 bg = theme.col.button_hot;
|
||||||
thumb_color.a = thumb_reps.draw.hot * 0.5 + 0.5;
|
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, thumb_color);
|
UI_SetNext(BackgroundColor, bg);
|
||||||
UI_SetNext(Width, UI_GROW(1, 0));
|
UI_SetNext(Width, UI_GROW(1, 0));
|
||||||
UI_SetNext(Height, thumb_height);
|
UI_SetNext(Height, thumb_height);
|
||||||
|
UI_SetNext(BorderSize, 1);
|
||||||
|
UI_SetNext(BorderColor, bd);
|
||||||
UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding));
|
UI_SetNext(Rounding, UI_RGROW(1 * theme.rounding));
|
||||||
UI_SetNext(FloatingPos, VEC2(0, thumb_offset));
|
UI_SetNext(FloatingPos, VEC2(0, thumb_offset));
|
||||||
// UI_SetNext(Anchor, UI_Region_Center);
|
UI_SetNext(Anchor, UI_Region_Center);
|
||||||
UI_SetNext(Anchor, UI_Region_Top);
|
UI_SetNext(Anchor, UI_Region_Top);
|
||||||
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Floating);
|
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_Floating);
|
||||||
UI_SetNext(Anchor, UI_Region_Top);
|
UI_SetNext(Anchor, UI_Region_Top);
|
||||||
@ -5238,6 +5245,27 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
}
|
}
|
||||||
UI_PopCP(UI_TopCP());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
UI_PopCP(UI_TopCP());
|
UI_PopCP(UI_TopCP());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user