PushCP & PopCP helpers
This commit is contained in:
parent
e7410b917a
commit
a3f6191247
37
src/pp/pp.c
37
src/pp/pp.c
@ -1939,7 +1939,7 @@ void PP_UpdateUser(void)
|
||||
/* Draw lister */
|
||||
if (g->lister_active)
|
||||
{
|
||||
UI_PushCheckpoint();
|
||||
UI_PushCP(pp_root_box);
|
||||
{
|
||||
Vec2 size = VEC2(400, 500);
|
||||
|
||||
@ -1949,32 +1949,29 @@ void PP_UpdateUser(void)
|
||||
g->lister_pos = SubVec2(g->ui_cursor, ev.activation_offset);
|
||||
}
|
||||
|
||||
UI_SetNext(LayoutAxis, Axis_Y);
|
||||
UI_SetNext(BackgroundColor, Rgba32F(0.075, 0.075, 0.075, 0.99));
|
||||
UI_SetNext(BorderColor, Rgba32F(0.2, 0.2, 0.2, 1));
|
||||
UI_SetNext(Border, 2);
|
||||
UI_SetNext(Rounding, UI_RPIX(10));
|
||||
UI_SetNext(Parent, pp_root_box);
|
||||
UI_SetNext(Flags, UI_BoxFlag_Floating);
|
||||
UI_Push(BackgroundColor, Rgba32F(0.075, 0.075, 0.075, 0.99));
|
||||
UI_Push(BorderColor, Rgba32F(0.2, 0.2, 0.2, 1));
|
||||
UI_Push(Border, 2);
|
||||
|
||||
UI_SetNext(FloatingPos, g->lister_pos);
|
||||
UI_SetNext(LayoutAxis, Axis_Y);
|
||||
UI_SetNext(Rounding, UI_RPIX(10));
|
||||
UI_SetNext(Flags, UI_BoxFlag_Floating);
|
||||
UI_SetNext(Width, UI_PIX(size.x, 0));
|
||||
UI_SetNext(Height, UI_PIX(size.y, 0));
|
||||
UI_Box *lister_box = UI_BuildBox(Lit("lister"));
|
||||
g->lister_key = lister_box->key;
|
||||
|
||||
UI_PushCheckpoint();
|
||||
UI_PushCP(lister_box);
|
||||
{
|
||||
UI_Push(Parent, lister_box);
|
||||
UI_Push(BackgroundColor, 0);
|
||||
// UI_BuildSpacer(UI_PIX(10, 0));
|
||||
{
|
||||
UI_SetNext(LayoutAxis, Axis_X);
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
UI_SetNext(Height, UI_FNT(1, 0));
|
||||
// UI_SetNext(BackgroundColor, 0);
|
||||
// UI_SetNext(Border, 0);
|
||||
UI_Box *title_bar = UI_BuildBox(Zstr);
|
||||
UI_PushCP(title_bar);
|
||||
{
|
||||
UI_Push(Parent, title_bar);
|
||||
UI_Push(Width, UI_FILL(1, 0));
|
||||
UI_Push(Padding, 0);
|
||||
UI_Push(BackgroundColor, 0);
|
||||
@ -1990,13 +1987,16 @@ void PP_UpdateUser(void)
|
||||
}
|
||||
{
|
||||
UI_Box *right_box = UI_BuildBox(Zstr);
|
||||
|
||||
}
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
}
|
||||
UI_PopCheckpoint();
|
||||
UI_PopCP();
|
||||
g->lister_key = lister_box->key;
|
||||
}
|
||||
UI_PopCheckpoint();
|
||||
UI_PopCP();
|
||||
}
|
||||
|
||||
/* Draw debug info */
|
||||
@ -2013,9 +2013,8 @@ void PP_UpdateUser(void)
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Tint, 0);
|
||||
UI_Box *dbg_box = UI_BuildBox(Lit("dbg"));
|
||||
UI_PushCheckpoint();
|
||||
UI_PushCP(dbg_box);
|
||||
{
|
||||
UI_Push(Parent, dbg_box);
|
||||
UI_Push(BackgroundColor, 0);
|
||||
UI_Push(BorderColor, 0);
|
||||
UI_Push(Padding, 2);
|
||||
@ -2081,7 +2080,7 @@ void PP_UpdateUser(void)
|
||||
//UI_BuildLabelF(\n"));
|
||||
#endif
|
||||
}
|
||||
UI_PopCheckpoint();
|
||||
UI_PopCP();
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
@ -42,27 +42,24 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
||||
|
||||
i64 now_ns = TimeNs();
|
||||
UI_Box *console_box = 0;
|
||||
UI_PushCheckpoint();
|
||||
{
|
||||
UI_SetNext(LayoutAxis, Axis_Y);
|
||||
UI_SetNext(Border, 0);
|
||||
if (minimized)
|
||||
{
|
||||
UI_SetNext(LayoutAxis, Axis_Y);
|
||||
UI_SetNext(Border, 0);
|
||||
if (minimized)
|
||||
{
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(Width, UI_PIX(500, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_SetNext(BackgroundColor, Rgba32F(1, 1, 1, 0.02));
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
// UI_SetNext(Height, UI_FILL(0.33, 1));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
}
|
||||
console_box = UI_BuildBox(Lit("Console box"));
|
||||
UI_Push(Parent, console_box);
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(Width, UI_PIX(500, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_SetNext(BackgroundColor, Rgba32F(1, 1, 1, 0.02));
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
// UI_SetNext(Height, UI_FILL(0.33, 1));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
}
|
||||
console_box = UI_BuildBox(Lit("Console box"));
|
||||
UI_PushCP(console_box);
|
||||
{
|
||||
/* Gather display logs */
|
||||
u64 max = 20;
|
||||
@ -112,7 +109,7 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
||||
FmtUintZ(datetime.milliseconds, 3),
|
||||
FmtString(text));
|
||||
}
|
||||
UI_PushCheckpoint();
|
||||
UI_PushCP(0);
|
||||
{
|
||||
UI_Push(Tint, Alpha32F(0xFFFFFFFF, opacity));
|
||||
{
|
||||
@ -125,24 +122,26 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
|
||||
UI_SetNext(Rounding, UI_RPIX(0));
|
||||
UI_SetNext(Border, 1);
|
||||
UI_Box *log_box = UI_BuildBox(Zstr);
|
||||
UI_Push(Parent, log_box);
|
||||
}
|
||||
{
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(Border, 0);
|
||||
UI_SetNext(Padding, 6);
|
||||
UI_SetNext(Text, text);
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
UI_Box *log_textbox = UI_BuildBox(Zstr);
|
||||
UI_PushCP(log_box);
|
||||
{
|
||||
UI_SetNext(BackgroundColor, 0);
|
||||
UI_SetNext(Border, 0);
|
||||
UI_SetNext(Padding, 6);
|
||||
UI_SetNext(Text, text);
|
||||
UI_SetNext(Width, UI_FILL(1, 0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
UI_Box *log_textbox = UI_BuildBox(Zstr);
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
}
|
||||
UI_PopCheckpoint();
|
||||
UI_PopCP();
|
||||
}
|
||||
}
|
||||
UI_PopCP();
|
||||
}
|
||||
UI_PopCheckpoint();
|
||||
|
||||
EndScratch(scratch);
|
||||
return console_box;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
UI_Box *UI_BuildLabel(String text)
|
||||
{
|
||||
UI_SetNext(Width, UI_FIT(1));
|
||||
UI_SetNext(Width, UI_FIT(0));
|
||||
UI_SetNext(Height, UI_FIT(1));
|
||||
UI_SetNext(Text, text);
|
||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||
|
||||
@ -62,7 +62,7 @@ UI_Box *UI_FrontBoxFromKey(UI_Key key)
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Checkpoint helpers
|
||||
|
||||
void UI_PushCheckpoint(void)
|
||||
void UI_PushCP(UI_Box *parent)
|
||||
{
|
||||
UI_SharedState *g = &UI_shared_state;
|
||||
UI_Checkpoint *cp = g->first_free_checkpoint;
|
||||
@ -78,9 +78,13 @@ void UI_PushCheckpoint(void)
|
||||
cp->next = g->top_checkpoint;
|
||||
cp->v = g->top_checkpoint->v + 1;
|
||||
g->top_checkpoint = cp;
|
||||
if (parent != 0)
|
||||
{
|
||||
UI_Push(Parent, parent);
|
||||
}
|
||||
}
|
||||
|
||||
void UI_PopCheckpoint(void)
|
||||
void UI_PopCP(void)
|
||||
{
|
||||
UI_SharedState *g = &UI_shared_state;
|
||||
UI_Checkpoint *cp = g->top_checkpoint;
|
||||
@ -696,7 +700,10 @@ i64 UI_EndBuild(GPU_Resource *render_target, Xform ui_to_screen_xf)
|
||||
}
|
||||
else
|
||||
{
|
||||
new_size = MinF32(flex, box_size);
|
||||
if (size > box_size)
|
||||
{
|
||||
new_size = MaxF32(size - flex, box_size);
|
||||
}
|
||||
}
|
||||
child->solved_dims[axis] = new_size;
|
||||
}
|
||||
|
||||
@ -265,8 +265,8 @@ UI_Box *UI_FrontBoxFromKey(UI_Key key);
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Checkpoint helpers
|
||||
|
||||
void UI_PushCheckpoint(void);
|
||||
void UI_PopCheckpoint(void);
|
||||
void UI_PushCP(UI_Box *parent);
|
||||
void UI_PopCP(void);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Style helpers
|
||||
|
||||
Loading…
Reference in New Issue
Block a user