more padding testing
This commit is contained in:
parent
53d315e9ff
commit
630221ab90
@ -1999,7 +1999,8 @@ void PP_UpdateUser(void)
|
|||||||
|
|
||||||
UI_PushCP(center_box);
|
UI_PushCP(center_box);
|
||||||
{
|
{
|
||||||
UI_SetNext(Text, Lit("Title"));
|
UI_SetNext(Width, UI_FIT(1));
|
||||||
|
UI_SetNext(Text, Lit("Titleeee"));
|
||||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||||
UI_SetNext(Padding, UI_PADALL(UI_FILL(1, 0)));
|
UI_SetNext(Padding, UI_PADALL(UI_FILL(1, 0)));
|
||||||
UI_Box *title_box = UI_BuildBox(Zstr);
|
UI_Box *title_box = UI_BuildBox(Zstr);
|
||||||
|
|||||||
@ -33,8 +33,8 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
|||||||
i64 fade_time_ns = max_time_ns;
|
i64 fade_time_ns = max_time_ns;
|
||||||
if (minimized)
|
if (minimized)
|
||||||
{
|
{
|
||||||
// max_time_ns = NsFromSeconds(10);
|
max_time_ns = NsFromSeconds(10);
|
||||||
// fade_time_ns = max_time_ns;
|
fade_time_ns = max_time_ns;
|
||||||
}
|
}
|
||||||
f32 fade_curve = 0.5;
|
f32 fade_curve = 0.5;
|
||||||
|
|
||||||
|
|||||||
173
src/ui/ui_core.c
173
src/ui/ui_core.c
@ -344,94 +344,96 @@ UI_Box *UI_BuildBox(String seed)
|
|||||||
UI_Size width = UI_UseTop(Width);
|
UI_Size width = UI_UseTop(Width);
|
||||||
UI_Size height = UI_UseTop(Height);
|
UI_Size height = UI_UseTop(Height);
|
||||||
|
|
||||||
/* Create initial padding boxes */
|
//////////////////////////////
|
||||||
UI_Size start_padding = ZI;
|
//- Build initial padding
|
||||||
UI_Size end_padding = ZI;
|
|
||||||
b32 has_start_padding = 0;
|
|
||||||
b32 has_end_padding = 0;
|
|
||||||
UI_Box *parent = UI_UseTop(Parent);
|
|
||||||
{
|
|
||||||
Axis axis = parent->layout_axis;
|
|
||||||
UI_Size axis_size = width;
|
|
||||||
UI_Size axis_start_padding = padding.left;
|
|
||||||
UI_Size axis_end_padding = padding.right;
|
|
||||||
UI_Size non_axis_start_padding = padding.top;
|
|
||||||
UI_Size non_axis_end_padding = padding.bottom;
|
|
||||||
if (axis == Axis_Y)
|
|
||||||
{
|
|
||||||
axis_size = height;
|
|
||||||
axis_start_padding = padding.top;
|
|
||||||
axis_end_padding = padding.bottom;
|
|
||||||
non_axis_start_padding = padding.left;
|
|
||||||
non_axis_end_padding = padding.right;
|
|
||||||
}
|
|
||||||
b32 has_axis_start_padding = !(axis_start_padding.kind == UI_SizeKind_Pixel && axis_start_padding.v == 0);
|
|
||||||
b32 has_axis_end_padding = !(axis_end_padding.kind == UI_SizeKind_Pixel && axis_end_padding.v == 0);
|
|
||||||
b32 has_non_axis_start_padding = !(non_axis_start_padding.kind == UI_SizeKind_Pixel && non_axis_start_padding.v == 0);
|
|
||||||
b32 has_non_axis_end_padding = !(non_axis_end_padding.kind == UI_SizeKind_Pixel && non_axis_end_padding.v == 0);
|
|
||||||
if (has_axis_start_padding || has_axis_end_padding || has_non_axis_start_padding || has_non_axis_end_padding)
|
|
||||||
{
|
|
||||||
UI_PushStack();
|
|
||||||
UI_PushCP(parent);
|
|
||||||
{
|
|
||||||
if (has_non_axis_start_padding || has_non_axis_end_padding)
|
|
||||||
{
|
|
||||||
if (has_axis_start_padding)
|
|
||||||
{
|
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(axis, axis_start_padding));
|
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(!axis, UI_PIX(0, 0)));
|
|
||||||
UI_BuildBox(Zstr);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
UI_Pad subpad = ZI;
|
|
||||||
if (has_axis_end_padding)
|
|
||||||
{
|
|
||||||
if (axis == Axis_X)
|
|
||||||
{
|
|
||||||
subpad.right = axis_end_padding;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
subpad.bottom = axis_end_padding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UI_SetNext(Padding, subpad);
|
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(axis, axis_size));
|
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(!axis, UI_FIT(0)));
|
|
||||||
UI_SetNext(LayoutAxis, !axis);
|
|
||||||
parent = UI_BuildBox(Zstr);
|
|
||||||
}
|
|
||||||
start_padding = non_axis_start_padding;
|
|
||||||
end_padding = non_axis_end_padding;
|
|
||||||
has_start_padding = has_non_axis_start_padding;
|
|
||||||
has_end_padding = has_non_axis_end_padding;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
start_padding = axis_start_padding;
|
|
||||||
end_padding = axis_end_padding;
|
|
||||||
has_start_padding = has_axis_start_padding;
|
|
||||||
has_end_padding = has_axis_end_padding;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UI_PopStack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Build start padding */
|
UI_Box *parent = UI_UseTop(Parent);
|
||||||
if (has_start_padding)
|
Axis axis = parent->layout_axis;
|
||||||
|
UI_Size axis_size = width;
|
||||||
|
UI_Size non_axis_size = height;
|
||||||
|
UI_Size axis_start_padding = padding.left;
|
||||||
|
UI_Size axis_end_padding = padding.right;
|
||||||
|
UI_Size non_axis_start_padding = padding.top;
|
||||||
|
UI_Size non_axis_end_padding = padding.bottom;
|
||||||
|
if (axis == Axis_Y)
|
||||||
|
{
|
||||||
|
axis_size = height;
|
||||||
|
non_axis_size = width;
|
||||||
|
axis_start_padding = padding.top;
|
||||||
|
axis_end_padding = padding.bottom;
|
||||||
|
non_axis_start_padding = padding.left;
|
||||||
|
non_axis_end_padding = padding.right;
|
||||||
|
}
|
||||||
|
b32 has_axis_start_padding = !(axis_start_padding.kind == UI_SizeKind_Pixel && axis_start_padding.v == 0);
|
||||||
|
b32 has_axis_end_padding = !(axis_end_padding.kind == UI_SizeKind_Pixel && axis_end_padding.v == 0);
|
||||||
|
b32 has_non_axis_start_padding = !(non_axis_start_padding.kind == UI_SizeKind_Pixel && non_axis_start_padding.v == 0);
|
||||||
|
b32 has_non_axis_end_padding = !(non_axis_end_padding.kind == UI_SizeKind_Pixel && non_axis_end_padding.v == 0);
|
||||||
|
if (has_axis_start_padding || has_axis_end_padding || has_non_axis_start_padding || has_non_axis_end_padding)
|
||||||
{
|
{
|
||||||
UI_PushStack();
|
UI_PushStack();
|
||||||
UI_PushCP(parent);
|
UI_PushCP(parent);
|
||||||
{
|
{
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(parent->layout_axis, start_padding));
|
if (has_non_axis_start_padding || has_non_axis_end_padding)
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(!parent->layout_axis, UI_PIX(0, 0)));
|
{
|
||||||
|
if (has_axis_start_padding)
|
||||||
|
{
|
||||||
|
UI_SetNext(AxisSize, UI_AXSIZE(axis, axis_start_padding));
|
||||||
|
UI_SetNext(AxisSize, UI_AXSIZE(!axis, non_axis_size));
|
||||||
|
UI_BuildBox(Zstr);
|
||||||
|
has_axis_start_padding = 0;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
UI_Pad subpad = ZI;
|
||||||
|
if (has_axis_end_padding)
|
||||||
|
{
|
||||||
|
if (axis == Axis_X)
|
||||||
|
{
|
||||||
|
subpad.right = axis_end_padding;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
subpad.bottom = axis_end_padding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UI_SetNext(Padding, subpad);
|
||||||
|
UI_SetNext(AxisSize, UI_AXSIZE(axis, axis_size));
|
||||||
|
UI_SetNext(AxisSize, UI_AXSIZE(!axis, UI_FIT(0)));
|
||||||
|
UI_SetNext(LayoutAxis, !axis);
|
||||||
|
parent = UI_BuildBox(Zstr);
|
||||||
|
}
|
||||||
|
axis = !axis;
|
||||||
|
axis_start_padding = non_axis_start_padding;
|
||||||
|
axis_end_padding = non_axis_end_padding;
|
||||||
|
has_axis_start_padding = has_non_axis_start_padding;
|
||||||
|
has_axis_end_padding = has_non_axis_end_padding;
|
||||||
|
{
|
||||||
|
UI_Size tmp = axis_size;
|
||||||
|
axis_size = non_axis_size;
|
||||||
|
non_axis_size = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UI_PopStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
//- Build starting padding
|
||||||
|
|
||||||
|
if (has_axis_start_padding)
|
||||||
|
{
|
||||||
|
UI_PushStack();
|
||||||
|
UI_PushCP(parent);
|
||||||
|
{
|
||||||
|
UI_SetNext(AxisSize, UI_AXSIZE(axis, axis_start_padding));
|
||||||
|
UI_SetNext(AxisSize, UI_AXSIZE(!axis, non_axis_size));
|
||||||
UI_BuildBox(Zstr);
|
UI_BuildBox(Zstr);
|
||||||
}
|
}
|
||||||
UI_PopStack();
|
UI_PopStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create box */
|
//////////////////////////////
|
||||||
|
//- Create box
|
||||||
|
|
||||||
UI_Box *box = 0;
|
UI_Box *box = 0;
|
||||||
{
|
{
|
||||||
/* Calculate key */
|
/* Calculate key */
|
||||||
@ -505,14 +507,16 @@ UI_Box *UI_BuildBox(String seed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build end padding */
|
//////////////////////////////
|
||||||
if (has_end_padding)
|
//- Build ending padding
|
||||||
|
|
||||||
|
if (has_axis_end_padding)
|
||||||
{
|
{
|
||||||
UI_PushStack();
|
UI_PushStack();
|
||||||
UI_PushCP(parent);
|
UI_PushCP(parent);
|
||||||
{
|
{
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(parent->layout_axis, end_padding));
|
UI_SetNext(AxisSize, UI_AXSIZE(axis, axis_end_padding));
|
||||||
UI_SetNext(AxisSize, UI_AXSIZE(!parent->layout_axis, UI_PIX(0, 0)));
|
UI_SetNext(AxisSize, UI_AXSIZE(!axis, non_axis_size));
|
||||||
UI_BuildBox(Zstr);
|
UI_BuildBox(Zstr);
|
||||||
}
|
}
|
||||||
UI_PopStack();
|
UI_PopStack();
|
||||||
@ -1040,8 +1044,8 @@ i64 UI_EndFrame(UI_Frame frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Submit position */
|
/* Submit position */
|
||||||
box->p0 = final_pos;
|
box->p0 = RoundVec2(final_pos);
|
||||||
box->p1 = AddVec2(final_pos, dims);
|
box->p1 = RoundVec2(AddVec2(final_pos, dims));
|
||||||
box->report.screen_p0 = box->p0;
|
box->report.screen_p0 = box->p0;
|
||||||
box->report.screen_p1 = box->p1;
|
box->report.screen_p1 = box->p1;
|
||||||
}
|
}
|
||||||
@ -1228,6 +1232,7 @@ i64 UI_EndFrame(UI_Frame frame)
|
|||||||
baseline.y = box->p0.y;
|
baseline.y = box->p0.y;
|
||||||
baseline.y += box_height / 2;
|
baseline.y += box_height / 2;
|
||||||
baseline.y += baseline_height / 4;
|
baseline.y += baseline_height / 4;
|
||||||
|
baseline = RoundVec2(baseline);
|
||||||
|
|
||||||
|
|
||||||
/* Push text rects */
|
/* Push text rects */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user