ui corner anti aliasing
This commit is contained in:
parent
f8ab74eafe
commit
7b4edbdfbb
@ -102,7 +102,8 @@ void V_BeginCommandsWidget(V_CommandsWidget *widget)
|
||||
{
|
||||
ZeroStruct(&widget->build);
|
||||
widget->build.cp = UI_PushCP(UI_NilKey);
|
||||
UI_Push(Tag, HashF("commands widget"));
|
||||
widget->key = UI_KeyF("commands widget");
|
||||
UI_Push(Tag, widget->key.hash);
|
||||
}
|
||||
|
||||
V_CommandsWidgetItemReport V_PushCommandsWidgetItem(V_CommandsWidget *widget, V_CommandsWidgetItemDesc desc)
|
||||
@ -131,11 +132,10 @@ void V_EndCommandsWidget(V_CommandsWidget *widget)
|
||||
V_WidgetTheme theme = V_GetWidgetTheme();
|
||||
Vec2 cursor_pos = UI_CursorPos();
|
||||
|
||||
UI_Push(Tag, HashF("commands widget"));
|
||||
|
||||
UI_Key titlebar_key = UI_KeyF("title bar");
|
||||
|
||||
Vec4 window_background_color = theme.window_background_color;
|
||||
// Vec4 window_background_color = VEC4(0, 0, 0, 0);
|
||||
Vec4 window_border_color = theme.window_border_color;
|
||||
Vec4 titlebar_color = Zi;
|
||||
Vec4 titlebar_border_color = Zi;
|
||||
@ -153,14 +153,13 @@ void V_EndCommandsWidget(V_CommandsWidget *widget)
|
||||
UI_Push(BackgroundColor, window_background_color);
|
||||
UI_Push(BorderColor, window_border_color);
|
||||
UI_Push(Border, theme.window_border);
|
||||
// UI_Push(Rounding, UI_RPIX(15));
|
||||
UI_Push(Rounding, UI_RPIX(15));
|
||||
UI_Push(Width, UI_PIX(theme.window_width, 0));
|
||||
UI_Push(Height, UI_SHRINK(0, 0));
|
||||
UI_Push(ChildLayoutAxis, Axis_Y);
|
||||
UI_Push(FloatingPos, widget->pos);
|
||||
UI_SetNext(Flags, UI_BoxFlag_Floating);
|
||||
UI_PushCP(UI_BuildBoxEx(UI_KeyF("titlebar")));
|
||||
UI_PushCP(UI_BuildBoxEx(widget->key));
|
||||
{
|
||||
// Title bar
|
||||
UI_PushCP(UI_NilKey);
|
||||
@ -621,7 +620,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
for (Button btn = 0; btn < countof(frame->held_buttons); ++btn)
|
||||
{
|
||||
if (btn == Button_M1 || btn == Button_M2)
|
||||
if (btn == Button_M1 || btn == Button_M2 || btn == Button_M3)
|
||||
{
|
||||
if (!has_mouse_focus)
|
||||
{
|
||||
@ -646,7 +645,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
b32 ignore = 0;
|
||||
if (down)
|
||||
{
|
||||
if (cev.button == Button_M1 || cev.button == Button_M2)
|
||||
if (cev.button == Button_M1 || cev.button == Button_M2 || cev.button == Button_M3)
|
||||
{
|
||||
if (!has_mouse_focus)
|
||||
{
|
||||
|
||||
@ -133,6 +133,7 @@ Struct(V_CommandsWidget)
|
||||
{
|
||||
// Persistent state
|
||||
Vec2 pos;
|
||||
UI_Key key;
|
||||
|
||||
// Per-build state
|
||||
struct
|
||||
|
||||
@ -25,7 +25,7 @@ ComputeShader2D(V_BackdropCS, 8, 8)
|
||||
f32 half_bounds_size = params.world_size * 0.5;
|
||||
Vec2 bounds_screen_p0 = mul(params.world_to_draw_xf, Vec3(-half_bounds_size, -half_bounds_size, 1));
|
||||
Vec2 bounds_screen_p1 = mul(params.world_to_draw_xf, Vec3(half_bounds_size, half_bounds_size, 1));
|
||||
b32 is_in_bounds = screen_pos.x > (bounds_screen_p0.x - half_thickness) &&
|
||||
bool is_in_bounds = screen_pos.x > (bounds_screen_p0.x - half_thickness) &&
|
||||
screen_pos.y > (bounds_screen_p0.y - half_thickness) &&
|
||||
screen_pos.x < (bounds_screen_p1.x + half_thickness) &&
|
||||
screen_pos.y < (bounds_screen_p1.y + half_thickness);
|
||||
|
||||
@ -695,7 +695,7 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
|
||||
case ControllerEventKind_ButtonDown:
|
||||
{
|
||||
if (cev.button == Button_M1 || cev.button == Button_M2)
|
||||
if (cev.button == Button_M1 || cev.button == Button_M2 || cev.button == Button_M3)
|
||||
{
|
||||
if (hovered_box)
|
||||
{
|
||||
@ -709,6 +709,10 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
{
|
||||
hovered_box->report.is_m2_held = 1;
|
||||
}
|
||||
else if (cev.button == Button_M3)
|
||||
{
|
||||
hovered_box->report.is_m3_held = 1;
|
||||
}
|
||||
active_box = hovered_box;
|
||||
}
|
||||
}
|
||||
@ -716,7 +720,7 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
|
||||
case ControllerEventKind_ButtonUp:
|
||||
{
|
||||
if (cev.button == Button_M1 || cev.button == Button_M2)
|
||||
if (cev.button == Button_M1 || cev.button == Button_M2 || cev.button == Button_M3)
|
||||
{
|
||||
if (active_box)
|
||||
{
|
||||
@ -733,6 +737,10 @@ UI_Frame *UI_BeginFrame(UI_FrameFlag frame_flags, Vec4 swapchain_color)
|
||||
{
|
||||
active_box->report.is_m2_held = 0;
|
||||
}
|
||||
else if (cev.button == Button_M3)
|
||||
{
|
||||
active_box->report.is_m3_held = 0;
|
||||
}
|
||||
active_box = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,6 +176,7 @@ Struct(UI_Report)
|
||||
{
|
||||
b32 is_m1_held;
|
||||
b32 is_m2_held;
|
||||
b32 is_m3_held;
|
||||
b32 is_hovered;
|
||||
b32 is_hot;
|
||||
|
||||
|
||||
@ -82,29 +82,28 @@ PixelShader(UI_DRectPS, UI_DRectPSOutput, UI_DRectPSInput input)
|
||||
}
|
||||
}
|
||||
|
||||
Vec4 final_color = 0;
|
||||
{
|
||||
// Background color
|
||||
Vec4 background_color = 0;
|
||||
if (G_IsRefNil(rect.tex))
|
||||
{
|
||||
if (rect_dist <= 0)
|
||||
{
|
||||
if (border_dist <= 0)
|
||||
{
|
||||
background_color = border_color;
|
||||
}
|
||||
else if (!G_IsRefNil(rect.tex))
|
||||
{
|
||||
Texture2D<Vec4> tex = G_Dereference<Vec4>(rect.tex);
|
||||
background_color = tex.Sample(sampler, input.tex_uv);
|
||||
final_color = input.background_lin;
|
||||
}
|
||||
else
|
||||
{
|
||||
background_color = input.background_lin;
|
||||
}
|
||||
Texture2D<Vec4> tex = G_Dereference<Vec4>(rect.tex);
|
||||
final_color = tex.Sample(sampler, input.tex_uv);
|
||||
}
|
||||
final_color *= rect_dist <= 0;
|
||||
|
||||
// Border color
|
||||
{
|
||||
f32 half_border_dist_fwidth = fwidth(border_dist) * 0.5;
|
||||
f32 border_alpha = smoothstep(half_border_dist_fwidth, -half_border_dist_fwidth, border_dist);
|
||||
final_color = lerp(final_color, border_color, border_alpha);
|
||||
}
|
||||
|
||||
// Final color
|
||||
Vec4 final_color = background_color;
|
||||
// Tint
|
||||
final_color *= input.tint_lin;
|
||||
|
||||
// Debug color
|
||||
@ -112,6 +111,7 @@ PixelShader(UI_DRectPS, UI_DRectPSOutput, UI_DRectPSInput input)
|
||||
{
|
||||
final_color = rect.debug_lin;
|
||||
}
|
||||
}
|
||||
|
||||
UI_DRectPSOutput output;
|
||||
output.sv_target0 = final_color;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user