ceil final box dimensions
This commit is contained in:
parent
f8f6ea9729
commit
0ab934c4bb
@ -59,6 +59,22 @@ Inline u64 HashFnv64(u64 seed, String s)
|
||||
return hash;
|
||||
}
|
||||
|
||||
#define HashF(fmt_cstr, ...) HashF_(StringFromCstrNoLimit(fmt_cstr), __VA_ARGS__, FmtEnd)
|
||||
u64 HashF_(String fmt, ...)
|
||||
{
|
||||
TempArena scratch = BeginScratchNoConflict();
|
||||
u64 result = 0;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
{
|
||||
String str = FormatStringV(scratch.arena, fmt, args);
|
||||
result = HashFnv64(Fnv64Basis, str);
|
||||
}
|
||||
va_end(args);
|
||||
EndScratch(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Mergesort utils
|
||||
|
||||
|
||||
@ -929,9 +929,9 @@ JobDef(Build, _, __)
|
||||
PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4189")); /* local variable is initialized but not referenced */
|
||||
PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4200")); /* nonstandard extension used: zero-sized array in struct/union */
|
||||
PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4702")); /* unreachable code */
|
||||
PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4305")); /* 'initializing': truncation from 'double' to 'f32' */
|
||||
|
||||
// PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4127")); /* conditional expression is constant */
|
||||
// PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4305")); /* 'initializing': truncation from 'double' to 'f32' */
|
||||
// PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4820")); /* bytes padding added after data member */
|
||||
// PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4464")); /* relative include path contains '..' */
|
||||
// PushStringToList(arena, &cp.warnings_msvc, Lit("-wd4061")); /* enumerator is not explicitly handled by a case label */
|
||||
|
||||
48
src/pp/pp.c
48
src/pp/pp.c
@ -785,12 +785,12 @@ void PP_UpdateUser(void)
|
||||
|
||||
UI_Box *pp_root_box = 0;
|
||||
{
|
||||
UI_PushCP(UI_BuildRow(Zstr));
|
||||
UI_PushCP(UI_BuildRow(0));
|
||||
{
|
||||
UI_BuildSpacer(UI_FILL(1, 0));
|
||||
{
|
||||
UI_SetNext(Width, UI_PIX(g->ui_size.x, 1));
|
||||
UI_PushCP(UI_BuildColumn(Zstr));
|
||||
UI_PushCP(UI_BuildColumn(0));
|
||||
{
|
||||
UI_BuildSpacer(UI_FILL(1, 0));
|
||||
{
|
||||
@ -801,7 +801,7 @@ void PP_UpdateUser(void)
|
||||
}
|
||||
UI_SetNext(ChildLayoutAxis, Axis_Y);
|
||||
UI_SetNext(Height, UI_PIX(g->ui_size.y, 1));
|
||||
pp_root_box = UI_BuildBox(Lit("pp root"));
|
||||
pp_root_box = UI_BuildBox(HashF("pp root"));
|
||||
}
|
||||
UI_BuildSpacer(UI_FILL(1, 0));
|
||||
}
|
||||
@ -1984,7 +1984,7 @@ void PP_UpdateUser(void)
|
||||
UI_Push(ChildLayoutAxis, Axis_Y);
|
||||
UI_Push(FloatingPos, g->lister_pos);
|
||||
UI_SetNext(Flags, UI_BoxFlag_Floating);
|
||||
UI_Box *lister_box = UI_PushCP(UI_BuildBox(Lit("lister")));
|
||||
g->lister_key = UI_PushCP(UI_BuildBox(HashF("lister")))->key;
|
||||
{
|
||||
/* Title bar */
|
||||
UI_PushCP(0);
|
||||
@ -1995,31 +1995,51 @@ void PP_UpdateUser(void)
|
||||
UI_Push(ChildLayoutAxis, Axis_X);
|
||||
UI_Push(Width, UI_FILL(1, 0));
|
||||
UI_Push(Height, UI_FNT(2, 0));
|
||||
UI_PushCP(UI_BuildBox(Zstr));
|
||||
UI_PushCP(UI_BuildBox(0));
|
||||
{
|
||||
UI_Push(Width, UI_FILL(1, 0));
|
||||
|
||||
// /* Left title box */
|
||||
UI_BuildRow(Zstr);
|
||||
/* Left title box */
|
||||
UI_BuildRow(0);
|
||||
|
||||
/* Title box */
|
||||
UI_SetNext(ChildAlignment, UI_Alignment_Center);
|
||||
UI_SetNext(Width, UI_FIT(1));
|
||||
UI_SetNext(Text, Lit("Titleeee"));
|
||||
UI_SetNext(Text, Lit("Titleeeeeeeeeeeeeee"));
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
UI_BuildBox(Zstr);
|
||||
UI_BuildBox(0);
|
||||
|
||||
// /* Right title box */
|
||||
UI_BuildBox(Zstr);
|
||||
/* Right title box */
|
||||
UI_BuildRow(0);
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
UI_BuildDivider(UI_PIX(1, 0));
|
||||
|
||||
UI_SetNext(Tint, 0);
|
||||
UI_SetNext(Rounding, 0);
|
||||
UI_PushCP(UI_BuildColumn(0));
|
||||
{
|
||||
for (u32 i = 0; i < 10; ++i)
|
||||
{
|
||||
UI_SetNext(BorderColor, 0);
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(Rounding, UI_RPIX(2));
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
UI_SetNext(Height, UI_FNT(1.5, 0));
|
||||
UI_SetNext(Text, Lit("btn"));
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
UI_SetNext(ChildAlignment, UI_Alignment_Center);
|
||||
UI_BuildBox(HashF("btn%F", FmtSint(i)));
|
||||
}
|
||||
|
||||
UI_BuildDivider(UI_PIX(1, 0));
|
||||
}
|
||||
UI_PopCP();
|
||||
g->lister_key = lister_box->key;
|
||||
|
||||
|
||||
UI_PopCP();
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
@ -2037,7 +2057,7 @@ void PP_UpdateUser(void)
|
||||
UI_SetNext(Width, UI_FIT(1));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Tint, 0);
|
||||
UI_PushCP(UI_BuildBox(Lit("dbg")));
|
||||
UI_PushCP(UI_BuildBox(HashF("dbg")));
|
||||
{
|
||||
UI_Push(BackgroundColor, 0);
|
||||
UI_Push(BorderColor, 0);
|
||||
|
||||
@ -54,7 +54,7 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
}
|
||||
console_box = UI_BuildColumn(Lit("Console box"));
|
||||
console_box = UI_BuildColumn(HashF("Console box"));
|
||||
UI_PushCP(console_box);
|
||||
{
|
||||
/* Gather display logs */
|
||||
@ -117,7 +117,7 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
||||
UI_Push(Rounding, UI_RPIX(0));
|
||||
UI_Push(Border, 1);
|
||||
UI_Push(ChildAlignment, UI_Alignment_Left);
|
||||
UI_PushCP(UI_BuildRow(Zstr));
|
||||
UI_PushCP(UI_BuildRow(0));
|
||||
{
|
||||
// UI_SetNext(Height, UI_PIX(100, 0));
|
||||
UI_BuildSpacer(UI_PIX(10, 0));
|
||||
@ -127,7 +127,7 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
||||
UI_Push(Width, UI_FILL(1, 0));
|
||||
UI_Push(Height, UI_FIT(1));
|
||||
UI_Push(Flags, UI_BoxFlag_DrawText);
|
||||
UI_BuildBox(Zstr);
|
||||
UI_BuildBox(0);
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ UI_Box *UI_BuildLabel(String text)
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Text, text);
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
UI_Box *box = UI_BuildBox(Zstr);
|
||||
UI_Box *box = UI_BuildBox(0);
|
||||
return box;
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ UI_Box *UI_BuildSpacer(UI_Size size)
|
||||
UI_Push(Parent, old_parent);
|
||||
UI_Push(AxisSize, UI_FILL(1, 0), .axis = !axis);
|
||||
UI_Push(AxisSize, size, .axis = axis);
|
||||
box = UI_BuildBox(Zstr);
|
||||
box = UI_BuildBox(0);
|
||||
}
|
||||
UI_PopStack();
|
||||
return box;
|
||||
@ -60,7 +60,7 @@ UI_Box *UI_BuildDivider(UI_Size size)
|
||||
UI_Push(BackgroundColor, old_border_color);
|
||||
UI_Push(AxisSize, UI_FILL(1, 0), .axis = !axis);
|
||||
UI_Push(AxisSize, size, .axis = axis);
|
||||
box = UI_BuildBox(Zstr);
|
||||
box = UI_BuildBox(0);
|
||||
}
|
||||
UI_PopStack();
|
||||
return box;
|
||||
@ -69,14 +69,14 @@ UI_Box *UI_BuildDivider(UI_Size size)
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Layout helpers
|
||||
|
||||
UI_Box *UI_BuildColumn(String seed)
|
||||
UI_Box *UI_BuildColumn(u64 seed)
|
||||
{
|
||||
UI_SetNext(ChildLayoutAxis, Axis_Y);
|
||||
UI_Box *box = UI_BuildBox(seed);
|
||||
return box;
|
||||
}
|
||||
|
||||
UI_Box *UI_BuildRow(String seed)
|
||||
UI_Box *UI_BuildRow(u64 seed)
|
||||
{
|
||||
UI_SetNext(ChildLayoutAxis, Axis_X);
|
||||
UI_Box *box = UI_BuildBox(seed);
|
||||
|
||||
@ -14,5 +14,5 @@ UI_Box *UI_BuildDivider(UI_Size size);
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Layout helpers
|
||||
|
||||
UI_Box *UI_BuildColumn(String seed);
|
||||
UI_Box *UI_BuildRow(String seed);
|
||||
UI_Box *UI_BuildColumn(u64 seed);
|
||||
UI_Box *UI_BuildRow(u64 seed);
|
||||
|
||||
@ -376,7 +376,7 @@ UI_Style UI_PopStyle(UI_StyleDesc desc)
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Box
|
||||
|
||||
UI_Box *UI_BuildBox(String seed)
|
||||
UI_Box *UI_BuildBox(u64 seed)
|
||||
{
|
||||
UI_SharedState *g = &UI_shared_state;
|
||||
|
||||
@ -389,12 +389,12 @@ UI_Box *UI_BuildBox(String seed)
|
||||
UI_Box *box = PushStruct(g->build_arena, UI_Box);
|
||||
|
||||
/* Calculate key */
|
||||
if (seed.len > 0)
|
||||
if (seed != 0)
|
||||
{
|
||||
UI_Key key = ZI;
|
||||
key.hash = RandU64FromSeeds(key.hash, parent->key.hash);
|
||||
key.hash = RandU64FromSeeds(key.hash, tag.hash);
|
||||
key.hash = HashFnv64(key.hash, seed);
|
||||
key.hash = RandU64FromSeeds(key.hash, seed);
|
||||
box->key = key;
|
||||
}
|
||||
|
||||
@ -1047,7 +1047,7 @@ i64 UI_EndFrame(UI_Frame frame)
|
||||
|
||||
/* Submit position */
|
||||
box->p0 = RoundVec2(final_pos);
|
||||
box->p1 = RoundVec2(AddVec2(final_pos, dims_vec));
|
||||
box->p1 = RoundVec2(AddVec2(final_pos, CeilVec2(dims_vec)));
|
||||
box->report.screen_p0 = box->p0;
|
||||
box->report.screen_p1 = box->p1;
|
||||
}
|
||||
|
||||
@ -393,7 +393,7 @@ UI_Style UI_PopStyle(UI_StyleDesc desc);
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Box
|
||||
|
||||
UI_Box *UI_BuildBox(String seed);
|
||||
UI_Box *UI_BuildBox(u64 seed);
|
||||
|
||||
void UI_SetBackgroundTexture(UI_Box *box, GPU_Resource *texture, Vec2 uv0, Vec2 uv1);
|
||||
b32 UI_IsPointInBox(UI_Box *box, Vec2 point);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user