rename 'util' -> 'extra'
This commit is contained in:
parent
e64ae8e71c
commit
fe45ea77bc
@ -360,14 +360,14 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
||||
#define Alpha32F(color, a) ((color) & 0x00FFFFFF) | (_Rgb32U8FromF((a)) << 24)
|
||||
|
||||
//- Pre-defined colors
|
||||
#define ColorWhite Rgb32(0xFF, 0xFF, 0xFF)
|
||||
#define ColorBlack Rgb32(0x00, 0x00, 0x00)
|
||||
#define ColorRed Rgb32(0xFF, 0x00, 0x00)
|
||||
#define ColorGreen Rgb32(0x00, 0xFF, 0x00)
|
||||
#define ColorBlue Rgb32(0x00, 0x00, 0xFF)
|
||||
#define ColorYellow Rgb32(0xFF, 0xFF, 0x00)
|
||||
#define ColorOrange Rgb32(0xFF, 0xA5, 0x00)
|
||||
#define ColorPurple Rgb32(0xFF, 0x00, 0XFF)
|
||||
#define Color_White Rgb32(0xFF, 0xFF, 0xFF)
|
||||
#define Color_Black Rgb32(0x00, 0x00, 0x00)
|
||||
#define Color_Red Rgb32(0xFF, 0x00, 0x00)
|
||||
#define Color_Green Rgb32(0x00, 0xFF, 0x00)
|
||||
#define Color_Blue Rgb32(0x00, 0x00, 0xFF)
|
||||
#define Color_Yellow Rgb32(0xFF, 0xFF, 0x00)
|
||||
#define Color_Orange Rgb32(0xFF, 0xA5, 0x00)
|
||||
#define Color_Purple Rgb32(0xFF, 0x00, 0XFF)
|
||||
|
||||
////////////////////////////////
|
||||
//~ Intrinsic headers
|
||||
|
||||
@ -273,7 +273,7 @@ void D_DrawGrid(GPU_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32
|
||||
GPU_RenderCmdDesc cmd = ZI;
|
||||
cmd.kind = GP_RENDER_CMD_KIND_DRAW_MATERIAL;
|
||||
cmd.material.xf = xf;
|
||||
cmd.material.tint = ColorWhite;
|
||||
cmd.material.tint = Color_White;
|
||||
cmd.material.grid_cmd_id = grid_id;
|
||||
GPU_PushRenderCmd(sig, &cmd);
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ Struct(D_MaterialParams)
|
||||
Vec3 light_emittance;
|
||||
};
|
||||
#define D_MATERIALPARAMS(...) ((D_MaterialParams) { \
|
||||
.tint = ColorWhite, \
|
||||
.tint = Color_White, \
|
||||
.clip = AllClipped, \
|
||||
__VA_ARGS__ \
|
||||
})
|
||||
@ -27,7 +27,7 @@ Struct(D_UiRectParams)
|
||||
u32 tint;
|
||||
};
|
||||
#define D_UIRECTPARAMS(...) ((D_UiRectParams) { \
|
||||
.tint = ColorWhite, \
|
||||
.tint = Color_White, \
|
||||
.clip = AllClipped, \
|
||||
__VA_ARGS__ \
|
||||
})
|
||||
@ -94,7 +94,7 @@ Struct(D_TextParams)
|
||||
.alignment = DRAW_TEXT_ALIGNMENT_LEFT, \
|
||||
.offset_x = DRAW_TEXT_OFFSET_X_LEFT, \
|
||||
.offset_y = DRAW_TEXT_OFFSET_Y_TOP, \
|
||||
.color = ColorWhite, \
|
||||
.color = Color_White, \
|
||||
__VA_ARGS__ \
|
||||
})
|
||||
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
|
||||
//- Api
|
||||
@IncludeC gpu.h
|
||||
@IncludeC gpu_util.h
|
||||
@IncludeC gpu_extra.h
|
||||
|
||||
//- Impl
|
||||
@IncludeC gpu_util.c
|
||||
@IncludeC gpu_extra.c
|
||||
|
||||
//- Dx12 impl
|
||||
@DefaultWindowsImpl gpu_dx12
|
||||
|
||||
@ -83,32 +83,32 @@ Struct(P_LogLevelSettings)
|
||||
Global Readonly P_LogLevelSettings P_log_settings[P_LogLevel_Count] = {
|
||||
[P_LogLevel_Critical] = {
|
||||
LitNoCast("CRITICAL"),
|
||||
ColorPurple
|
||||
Color_Purple
|
||||
},
|
||||
|
||||
[P_LogLevel_Error] = {
|
||||
LitNoCast("ERROR"),
|
||||
ColorRed
|
||||
Color_Red
|
||||
},
|
||||
|
||||
[P_LogLevel_Warning] = {
|
||||
LitNoCast("WARNING"),
|
||||
ColorYellow
|
||||
Color_Yellow
|
||||
},
|
||||
|
||||
[P_LogLevel_Success] = {
|
||||
LitNoCast("SUCCESS"),
|
||||
ColorGreen
|
||||
Color_Green
|
||||
},
|
||||
|
||||
[P_LogLevel_Info] = {
|
||||
LitNoCast("INFO"),
|
||||
ColorWhite
|
||||
Color_White
|
||||
},
|
||||
|
||||
[P_LogLevel_Debug] = {
|
||||
LitNoCast("DEBUG"),
|
||||
ColorBlue
|
||||
Color_Blue
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
32
src/pp/pp.c
32
src/pp/pp.c
@ -103,7 +103,7 @@ void DrawDebugMovement(Entity *ent)
|
||||
f32 thickness = 2.f;
|
||||
f32 arrow_len = 15.f;
|
||||
|
||||
u32 color_vel = ColorOrange;
|
||||
u32 color_vel = Color_Orange;
|
||||
|
||||
Xform xf = XformFromEntity(ent);
|
||||
Vec2 velocity = ent->linear_velocity;
|
||||
@ -343,7 +343,7 @@ void DrawDebugConsole(i32 level, b32 minimized)
|
||||
FmtString(text));
|
||||
}
|
||||
|
||||
D_TextParams params = D_TEXTPARAMS(.font = font, .pos = draw_pos, .offset_y = DRAW_TEXT_OFFSET_Y_BOTTOM, .color = Alpha32F(ColorWhite, opacity), .str = text);
|
||||
D_TextParams params = D_TEXTPARAMS(.font = font, .pos = draw_pos, .offset_y = DRAW_TEXT_OFFSET_Y_BOTTOM, .color = Alpha32F(Color_White, opacity), .str = text);
|
||||
Rect bounds = draw_text(g->render_sig, params);
|
||||
|
||||
Rect draw_bounds = bounds;
|
||||
@ -995,8 +995,8 @@ void UpdateUser(P_Window *window)
|
||||
grid->bg0_srgb = color0;
|
||||
grid->bg1_srgb = color1;
|
||||
grid->line_srgb = Rgba32(0x3f, 0x3f, 0x3f, 0xFF);
|
||||
grid->x_srgb = ColorRed;
|
||||
grid->y_srgb = ColorGreen;
|
||||
grid->x_srgb = Color_Red;
|
||||
grid->y_srgb = Color_Green;
|
||||
|
||||
MaterialInstance *mat = PushStruct(g->material_instances_arena, MaterialInstance);
|
||||
*mat = DefaultMaterialInstance;
|
||||
@ -1361,7 +1361,7 @@ void UpdateUser(P_Window *window)
|
||||
Entity *e1 = EntityFromId(g->ss_blended, ent->weld_joint_data.e1);
|
||||
Xform e1_xf = XformFromEntity(e1);
|
||||
|
||||
u32 color = ColorYellow;
|
||||
u32 color = Color_Yellow;
|
||||
f32 radius = 3;
|
||||
Vec2 point = MulXformV2(e1_xf, ent->weld_joint_data.point_local_e1);
|
||||
point = MulXformV2(g->world_to_ui_xf, point);
|
||||
@ -1378,7 +1378,7 @@ void UpdateUser(P_Window *window)
|
||||
{
|
||||
Entity *target = EntityFromId(g->ss_blended, ent->mouse_joint_data.target);
|
||||
Xform target_xf = XformFromEntity(target);
|
||||
u32 color = ColorWhite;
|
||||
u32 color = Color_White;
|
||||
Vec2 point_start = MulXformV2(target_xf, ent->mouse_joint_data.point_local_start);
|
||||
Vec2 point_end = g->world_cursor;
|
||||
point_start = MulXformV2(g->world_to_ui_xf, point_start);
|
||||
@ -1407,7 +1407,7 @@ void UpdateUser(P_Window *window)
|
||||
for (u32 i = 0; i < collider.count; ++i)
|
||||
{
|
||||
Vec2 p = MulXformV2(MulXform(g->world_to_ui_xf, xf), collider.points[i]);
|
||||
D_DrawCircle(g->render_sig, p, 3, ColorBlue, 10);
|
||||
D_DrawCircle(g->render_sig, p, 3, Color_Blue, 10);
|
||||
}
|
||||
}
|
||||
if (collider.count == 1 && collider.radius > 0)
|
||||
@ -1424,7 +1424,7 @@ void UpdateUser(P_Window *window)
|
||||
{
|
||||
Vec2 p = collider_support_point(&collider, xf, ent->control.focus);
|
||||
p = MulXformV2(g->world_to_ui_xf, p);
|
||||
D_DrawCircle(g->render_sig, p, 3, ColorRed, 10);
|
||||
D_DrawCircle(g->render_sig, p, 3, Color_Red, 10);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1447,7 +1447,7 @@ void UpdateUser(P_Window *window)
|
||||
f32 radius = 5;
|
||||
for (u32 i = 0; i < data->num_points; ++i)
|
||||
{
|
||||
u32 color = (data->skip_solve || data->wrong_dir) ? Alpha32F(ColorYellow, 0.3) : Rgba32F(0.8, 0.2, 0.2, 1);
|
||||
u32 color = (data->skip_solve || data->wrong_dir) ? Alpha32F(Color_Yellow, 0.3) : Rgba32F(0.8, 0.2, 0.2, 1);
|
||||
ContactPoint point = data->points[i];
|
||||
Vec2 dbg_pt = point.dbg_pt;
|
||||
|
||||
@ -1657,7 +1657,7 @@ void UpdateUser(P_Window *window)
|
||||
/* Draw simplex */
|
||||
{
|
||||
f32 thickness = 2;
|
||||
u32 line_color = ColorYellow;
|
||||
u32 line_color = Color_Yellow;
|
||||
u32 color_first = Rgba32F(1, 0, 0, 0.75);
|
||||
u32 color_second = Rgba32F(0, 1, 0, 0.75);
|
||||
u32 color_third = Rgba32F(0, 0, 1, 0.75);
|
||||
@ -1690,7 +1690,7 @@ void UpdateUser(P_Window *window)
|
||||
|
||||
/* Draw normal */
|
||||
{
|
||||
u32 color = ColorWhite;
|
||||
u32 color = Color_White;
|
||||
f32 len = 0.1f;
|
||||
f32 arrow_thickness = 4;
|
||||
f32 arrowhead_height = 10;
|
||||
@ -2005,12 +2005,14 @@ void UpdateUser(P_Window *window)
|
||||
{
|
||||
__profn("Draw debug info");
|
||||
|
||||
UI_SetNext(LayoutAxis, Axis_Y);
|
||||
UI_Box *dbg_box = UI_BuildBox(0, UI_NilKey);
|
||||
UI_PushCheckpoint();
|
||||
{
|
||||
UI_Push(Parent, dbg_box);
|
||||
UI_Push(Width, UI_PixelSize(5, 0));
|
||||
UI_Push(Height, UI_PixelSize(5, 0));
|
||||
UI_Push(Width, UI_TextSize(0));
|
||||
UI_Push(Height, UI_TextSize(0));
|
||||
UI_Push(BackgroundColor, Color_White);
|
||||
|
||||
UI_BuildLabelF("blended world entities: %F/%F", FmtUint(g->ss_blended->num_ents_allocated), FmtUint(g->ss_blended->num_ents_reserved));
|
||||
UI_BuildSeparator();
|
||||
@ -2104,7 +2106,7 @@ void UpdateUser(P_Window *window)
|
||||
#if 0
|
||||
Vec2 pos = VEC2(10, g->ui_size.y);
|
||||
D_TextOffsetY offset_y = DRAW_TEXT_OFFSET_Y_BOTTOM;
|
||||
draw_text(g->render_sig, D_TEXTPARAMS(.font = font, .pos = pos, .str = text, .offset_y = offset_y, .color = ColorWhite));
|
||||
draw_text(g->render_sig, D_TEXTPARAMS(.font = font, .pos = pos, .str = text, .offset_y = offset_y, .color = Color_White));
|
||||
#endif
|
||||
}
|
||||
UI_PopCheckpoint();
|
||||
@ -2216,7 +2218,7 @@ void UpdateUser(P_Window *window)
|
||||
|
||||
Vec2 pos = VEC2(10, g->ui_size.y);
|
||||
D_TextOffsetY offset_y = DRAW_TEXT_OFFSET_Y_BOTTOM;
|
||||
draw_text(g->render_sig, D_TEXTPARAMS(.font = font, .pos = pos, .str = text, .offset_y = offset_y, .color = ColorWhite));
|
||||
draw_text(g->render_sig, D_TEXTPARAMS(.font = font, .pos = pos, .str = text, .offset_y = offset_y, .color = Color_White));
|
||||
EndTempArena(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ Struct(MaterialInstance)
|
||||
.grid_id = U32Max, \
|
||||
.xf = XformIdentity, \
|
||||
.uv1 = VEC2(1, 1), \
|
||||
.tint_srgb = ColorWhite, \
|
||||
.tint_srgb = Color_White, \
|
||||
}
|
||||
|
||||
Struct(MaterialGrid)
|
||||
@ -47,8 +47,8 @@ Struct(MaterialGrid)
|
||||
#define DefaultMaterialGrid (MaterialGrid) { \
|
||||
.line_thickness = 1, \
|
||||
.line_spacing = 1, \
|
||||
.bg0_srgb = ColorBlack, \
|
||||
.bg0_srgb = ColorWhite \
|
||||
.bg0_srgb = Color_Black, \
|
||||
.bg0_srgb = Color_White \
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@ -65,7 +65,7 @@ void StartupSim(void)
|
||||
g->nil_ent->mass_unscaled = 1;
|
||||
g->nil_ent->inertia_unscaled = 1;
|
||||
g->nil_ent->sprite_local_xform = XformIdentity;
|
||||
g->nil_ent->sprite_tint = ColorWhite;
|
||||
g->nil_ent->sprite_tint = Color_White;
|
||||
|
||||
/* Lock nil arena */
|
||||
SetArenaReadonly(g->nil_arena);
|
||||
|
||||
@ -260,8 +260,8 @@ void SpawnTestEntities2(Entity *parent, Vec2 pos)
|
||||
e->sprite = ResourceFromStore(&GameResources, Lit("sprite/tile.ase"));
|
||||
e->layer = Layer_Shoulders;
|
||||
|
||||
//e->sprite_tint = Alpha32F(ColorBlue, 0.75);
|
||||
//e->sprite_tint = Alpha32F(ColorWhite, 1);
|
||||
//e->sprite_tint = Alpha32F(Color_Blue, 0.75);
|
||||
//e->sprite_tint = Alpha32F(Color_White, 1);
|
||||
|
||||
EnableProp(e, Prop_Solid);
|
||||
Quad collider_quad = QuadFromRect(RectFromScalar(-0.5, -0.5, 1, 1));
|
||||
@ -330,7 +330,7 @@ void SpawnTestEntities3(Entity *parent, Vec2 pos)
|
||||
e->sprite = ResourceFromStore(&GameResources, Lit("sprite/box.ase"));
|
||||
e->layer = Layer_Shoulders;
|
||||
|
||||
e->sprite_tint = ColorRed;
|
||||
e->sprite_tint = Color_Red;
|
||||
|
||||
EnableProp(e, Prop_Solid);
|
||||
Quad collider_quad = QuadFromRect(RectFromScalar(-0.5, -0.5, 1, 1));
|
||||
@ -381,7 +381,7 @@ void SpawnTestTile(Snapshot *world, Vec2 world_pos)
|
||||
|
||||
e->layer = Layer_Walls;
|
||||
e->sprite = ResourceFromStore(GameResources, Lit("sprite/tile.ase"));
|
||||
e->sprite_tint = ColorRed;
|
||||
e->sprite_tint = Color_Red;
|
||||
|
||||
S_Sheet *sheet = S_SheetFromResource(e->sprite);
|
||||
e->sprite_local_xform = XformFromTrs(.s = DivVec2(sheet->frame_size, PIXELS_PER_UNIT));
|
||||
|
||||
40
src/ui/ui.c
40
src/ui/ui.c
@ -57,9 +57,9 @@ void UI_PopCheckpoint(void)
|
||||
while (n && n->checkpoint >= v)
|
||||
{
|
||||
UI_StyleNode *next = n->next;
|
||||
g->style_tops[kind] = next;
|
||||
n->next = g->first_free_style_node;
|
||||
g->first_free_style_node = n;
|
||||
g->style_tops[kind] = next;
|
||||
n = next;
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@ void UI_PopCheckpoint(void)
|
||||
////////////////////////////////
|
||||
//~ Style stack helpers
|
||||
|
||||
UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_touched, UI_Style desc)
|
||||
UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_used, UI_Style desc)
|
||||
{
|
||||
UI_SharedState *g = &UI_shared_state;
|
||||
UI_StyleNode *n = g->first_free_style_node;
|
||||
@ -83,7 +83,7 @@ UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_touched, UI_Style
|
||||
{
|
||||
n = PushStruct(g->build_arena, UI_StyleNode);
|
||||
}
|
||||
n->pop_when_touched = pop_when_touched;
|
||||
n->pop_when_used = pop_when_used;
|
||||
n->style = desc;
|
||||
n->next = g->style_tops[kind];
|
||||
n->checkpoint = g->top_checkpoint->v;
|
||||
@ -109,12 +109,12 @@ UI_StyleNode *UI_PeekStyleNode(UI_StyleKind kind)
|
||||
return n;
|
||||
}
|
||||
|
||||
UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 touch)
|
||||
UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 use)
|
||||
{
|
||||
UI_SharedState *g = &UI_shared_state;
|
||||
UI_StyleNode *n = g->style_tops[kind];
|
||||
UI_Style style = n->style;
|
||||
if (touch && n->pop_when_touched)
|
||||
if (use && n->pop_when_used)
|
||||
{
|
||||
g->style_tops[kind] = n->next;
|
||||
n->next = g->first_free_style_node;
|
||||
@ -124,7 +124,7 @@ UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 touch)
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Box helper s
|
||||
//~ Box helpers
|
||||
|
||||
UI_Box *UI_BuildBox(UI_Flag flags, UI_Key key)
|
||||
{
|
||||
@ -172,13 +172,12 @@ UI_Box *UI_BuildBox(UI_Flag flags, UI_Key key)
|
||||
box->key = key;
|
||||
box->flags = flags;
|
||||
|
||||
box->tint = 0xFFFFFFFF;
|
||||
|
||||
/* Pull from style stack */
|
||||
box->parent = UI_TouchTop(Parent);
|
||||
box->pref_size[Axis_X] = UI_TouchTop(Width);
|
||||
box->pref_size[Axis_Y] = UI_TouchTop(Height);
|
||||
box->layout_axis = UI_TouchTop(LayoutAxis);
|
||||
box->parent = UI_UseTop(Parent);
|
||||
box->pref_size[Axis_X] = UI_UseTop(Width);
|
||||
box->pref_size[Axis_Y] = UI_UseTop(Height);
|
||||
box->layout_axis = UI_UseTop(LayoutAxis);
|
||||
box->background_color = UI_UseTop(BackgroundColor);
|
||||
|
||||
DllPushBack(box->parent->first, box->parent->last, box);
|
||||
++box->parent->count;
|
||||
@ -246,15 +245,11 @@ void UI_BeginBuild(void)
|
||||
UI_Style *style = &n->style;
|
||||
style->kind = kind;
|
||||
g->style_tops[kind] = n;
|
||||
switch(kind)
|
||||
{
|
||||
default: break;
|
||||
case UI_StyleKind_Tag: { style->Tag = HashFnv64(Fnv64Basis, Lit("root")); } break;
|
||||
case UI_StyleKind_Parent: { style->Parent = g->root_box; } break;
|
||||
case UI_StyleKind_Width: { style->Width = UI_RatioSize(1, 0); } break;
|
||||
case UI_StyleKind_Height: { style->Height = UI_RatioSize(1, 0); } break;
|
||||
}
|
||||
}
|
||||
g->style_tops[UI_StyleKind_Tag]->style.Tag = HashFnv64(Fnv64Basis, Lit("root"));
|
||||
g->style_tops[UI_StyleKind_Parent]->style.Parent = g->root_box;
|
||||
g->style_tops[UI_StyleKind_Width]->style.Width = UI_RatioSize(1, 0);
|
||||
g->style_tops[UI_StyleKind_Height]->style.Height = UI_RatioSize(1, 0);
|
||||
}
|
||||
|
||||
if (!g->back_build_arena)
|
||||
@ -379,13 +374,12 @@ GPU_Resource *UI_EndBuild(Rect render_viewport)
|
||||
b32 is_layout_x = parent->layout_axis == Axis_X;
|
||||
f32 layout_cursor = parent->layout_cursor;
|
||||
Vec2 offset = VEC2(layout_cursor * is_layout_x, layout_cursor * !is_layout_x);
|
||||
parent->layout_cursor += final_size.x * is_layout_x + final_size.y * is_layout_x;
|
||||
parent->layout_cursor += final_size.x * is_layout_x + final_size.y * !is_layout_x;
|
||||
box->p0 = AddVec2(parent->p0, offset);
|
||||
}
|
||||
box->p1 = AddVec2(box->p0, final_size);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: Remove this */
|
||||
#if 0
|
||||
{
|
||||
@ -451,7 +445,7 @@ GPU_Resource *UI_EndBuild(Rect render_viewport)
|
||||
rect->flags = box->flags;
|
||||
rect->p0 = box->p0;
|
||||
rect->p1 = box->p1;
|
||||
rect->tint_srgb = box->tint;
|
||||
rect->background_srgb = box->background_color;
|
||||
|
||||
if (box->flags & UI_Flag_DrawImage, box->display_image)
|
||||
{
|
||||
|
||||
37
src/ui/ui.h
37
src/ui/ui.h
@ -53,7 +53,7 @@ Struct(UI_Box)
|
||||
GPU_Resource *display_image;
|
||||
UI_Size pref_size[Axis_CountXY];
|
||||
Axis layout_axis;
|
||||
u32 tint;
|
||||
u32 background_color;
|
||||
|
||||
//- Layout data
|
||||
f32 solved_dims[Axis_CountXY];
|
||||
@ -73,17 +73,14 @@ Struct(UI_BoxBin)
|
||||
////////////////////////////////
|
||||
//~ Style types
|
||||
|
||||
//- Style data
|
||||
#define UI_StyleKindsXMacro(x) \
|
||||
x(Tag, u64) \
|
||||
x(Parent, UI_Box *) \
|
||||
x(LayoutAxis, Axis) \
|
||||
x(Width, UI_Size) \
|
||||
x(Height, UI_Size) \
|
||||
x(BackgroundColor, u32) \
|
||||
x(Opacity, f32) \
|
||||
#define UI_StyleKindsXMacro(x) \
|
||||
x(Tag, u64) \
|
||||
x(Parent, UI_Box *) \
|
||||
x(LayoutAxis, Axis) \
|
||||
x(Width, UI_Size) \
|
||||
x(Height, UI_Size) \
|
||||
x(BackgroundColor, u32)
|
||||
|
||||
//- Style node
|
||||
Enum(UI_StyleKind)
|
||||
{
|
||||
#define X(name, type) UI_StyleKind_##name,
|
||||
@ -96,7 +93,7 @@ Enum(UI_StyleKind)
|
||||
Struct(UI_Style)
|
||||
{
|
||||
UI_StyleKind kind;
|
||||
/* Union of all style data types */
|
||||
/* Union of all style fields */
|
||||
union
|
||||
{
|
||||
#define X(name, type) type name;
|
||||
@ -108,7 +105,7 @@ Struct(UI_Style)
|
||||
Struct(UI_StyleNode)
|
||||
{
|
||||
UI_StyleNode *next;
|
||||
b32 pop_when_touched;
|
||||
b32 pop_when_used;
|
||||
u64 checkpoint;
|
||||
UI_Style style;
|
||||
};
|
||||
@ -173,16 +170,16 @@ void UI_PopCheckpoint(void);
|
||||
////////////////////////////////
|
||||
//~ Style stack helpers
|
||||
|
||||
UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_touched, UI_Style desc);
|
||||
UI_StyleNode *UI_PushStyleNode(UI_StyleKind kind, b32 pop_when_used, UI_Style desc);
|
||||
UI_Style UI_PopStyleNode(UI_StyleKind kind);
|
||||
UI_StyleNode *UI_PeekTopStyleNode(UI_StyleKind kind);
|
||||
UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 touch);
|
||||
UI_Style UI_StyleFromTopNode(UI_StyleKind kind, b32 use);
|
||||
|
||||
#define UI_SetNext(name, ...) UI_PushStyleNode(UI_StyleKind_##name, 1, (UI_Style) { .name = __VA_ARGS__ })
|
||||
#define UI_Push(name, ...) UI_PushStyleNode(UI_StyleKind_##name, 0, (UI_Style) { .name = __VA_ARGS__ })
|
||||
#define UI_Pop(name, ...) UI_PopStyleNode(UI_StyleKind_##name).name
|
||||
#define UI_TouchTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 1).name
|
||||
#define UI_PeekTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 0).name
|
||||
#define UI_SetNext(name, v) UI_PushStyleNode(UI_StyleKind_##name, 1, (UI_Style) { .name = v })
|
||||
#define UI_Push(name, v) UI_PushStyleNode(UI_StyleKind_##name, 0, (UI_Style) { .name = v })
|
||||
#define UI_Pop(name, v) UI_PopStyleNode(UI_StyleKind_##name).name
|
||||
#define UI_UseTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 1).name
|
||||
#define UI_PeekTop(name) UI_StyleFromTopNode(UI_StyleKind_##name, 0).name
|
||||
|
||||
////////////////////////////////
|
||||
//~ Size helpers
|
||||
|
||||
@ -6,14 +6,14 @@
|
||||
//- Api
|
||||
@IncludeC ui_flags.h
|
||||
@IncludeC ui.h
|
||||
@IncludeC ui_util.h
|
||||
@IncludeC ui_extra.h
|
||||
@IncludeC ui_draw.h
|
||||
@IncludeGpu ui_flags.h
|
||||
@IncludeGpu ui_draw.h
|
||||
|
||||
//- Impl
|
||||
@IncludeC ui.c
|
||||
@IncludeC ui_util.c
|
||||
@IncludeC ui_extra.c
|
||||
@IncludeGpu ui_draw.gpu
|
||||
|
||||
//- Shaders
|
||||
|
||||
@ -7,7 +7,7 @@ Struct(UI_RectPS_Input)
|
||||
{
|
||||
|
||||
Semantic(Vec4, sv_position);
|
||||
Semantic(Vec4, tint_lin);
|
||||
Semantic(Vec4, background_lin);
|
||||
Semantic(Vec2, uv);
|
||||
Semantic(nointerpolation u32, instance_idx);
|
||||
};
|
||||
@ -37,7 +37,7 @@ UI_RectPS_Input VSDef(UI_RectVS, Semantic(u32, sv_instanceid), Semantic(u32, sv_
|
||||
|
||||
UI_RectPS_Input result;
|
||||
result.sv_position = Vec4(ndc.xy, 0, 1);
|
||||
result.tint_lin = LinearFromSrgbU32(instance.tint_srgb);
|
||||
result.background_lin = LinearFromSrgbU32(instance.background_srgb);
|
||||
result.instance_idx = sv_instanceid;
|
||||
result.uv = uv;
|
||||
|
||||
@ -52,13 +52,13 @@ UI_RectPS_Output PSDef(UI_RectPS, UI_RectPS_Input input)
|
||||
StructuredBuffer<UI_RectInstance> instances = UniformResourceFromRid(sig.instances);
|
||||
UI_RectInstance instance = instances[input.instance_idx];
|
||||
|
||||
Vec4 color = input.tint_lin;
|
||||
Vec4 color = input.background_lin;
|
||||
|
||||
if (instance.flags & UI_Flag_DrawImage)
|
||||
{
|
||||
SamplerState sampler = UniformSamplerFromRid(sig.sampler);
|
||||
Texture2D<Vec4> tex = NonUniformResourceFromRid(instance.image_tex);
|
||||
color *= tex.Sample(sampler, input.uv);
|
||||
color = tex.Sample(sampler, input.uv);
|
||||
}
|
||||
|
||||
UI_RectPS_Output result;
|
||||
|
||||
@ -16,7 +16,7 @@ Struct(UI_RectInstance)
|
||||
u32 flags;
|
||||
Vec2 p0;
|
||||
Vec2 p1;
|
||||
u32 tint_srgb;
|
||||
u32 background_srgb;
|
||||
Texture2DRid image_tex;
|
||||
};
|
||||
#define UI_DefaultRectInstance (UI_RectInstance) { \
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
UI_Box *UI_BuildLabel(String text)
|
||||
{
|
||||
UI_Key key = UI_KeyFromString(0, text);
|
||||
UI_Box *box = UI_BuildBox(UI_Flag_DrawText, key);
|
||||
UI_Box *box = UI_BuildBox(UI_Flag_DrawText, UI_NilKey);
|
||||
UI_SetDisplayText(box, text);
|
||||
return box;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user