47 lines
2.8 KiB
Markdown
47 lines
2.8 KiB
Markdown
@table(Name, Type, BoxName)
|
|
UIStyleStacks:
|
|
{
|
|
{ Parent `ui_box *` `Parent` }
|
|
{ Width `ui_size` `SemanticSize[Axis2_X]` }
|
|
{ Height `ui_size` `SemanticSize[Axis2_Y]` }
|
|
{ FixedX `r32` `FixedP.E[Axis2_X]` }
|
|
{ FixedY `r32` `FixedP.E[Axis2_Y]` }
|
|
{ TextColor `v4_r32` `TextColor` }
|
|
{ BackgroundColor `v4_r32` `BackgroundColor` }
|
|
{ BorderColor `v4_r32` `BorderColor` }
|
|
{ BorderThickness `r32` `BorderThickness` }
|
|
{ LayoutAxis `axis2` `LayoutAxis` }
|
|
{ CornerRadii `v4_r32` `CornerRadii` }
|
|
{ Font `font_id` `Font` }
|
|
{ FontSize `r32` `FontSize` }
|
|
{ OffsetX `r32` `Offset.x` }
|
|
{ OffsetY `r32` `Offset.y` }
|
|
{ HoverCursor `platform_cursor` `HoverCursor` }
|
|
}
|
|
|
|
@table_gen
|
|
{
|
|
`struct ui_style_stacks`;
|
|
`{`;
|
|
@expand(UIStyleStacks s) `$(s.Type) $(s.Name)Stack[64]; s32 $(s.Name)StackUsed; b32 AutoPop$(s.Name);`;
|
|
`};`;
|
|
}
|
|
|
|
@c @table_gen
|
|
{
|
|
@expand(UIStyleStacks s) `inline void UI_Push$(s.Name)($(s.Type) Element) $(=>50) { ui *UI = UI_GetState(); Assert(UI->Stacks.$(s.Name)StackUsed $(=>125) + 1 < ArrayCount(UI->Stacks.$(s.Name)Stack)); $(=>180) UI->Stacks.$(s.Name)Stack[UI->Stacks.$(s.Name)StackUsed++] $(=>260) = Element; }`;
|
|
@expand(UIStyleStacks s) `inline void UI_Pop$(s.Name)(void) $(=>50) { ui *UI = UI_GetState(); Assert(UI->Stacks.$(s.Name)StackUsed $(=>125) > 0); $(=>180) --UI->Stacks.$(s.Name)StackUsed; $(=>271) }`;
|
|
@expand(UIStyleStacks s) `inline void UI_SetNext$(s.Name)($(s.Type) Element) { ui *UI = UI_GetState(); UI_Push$(s.Name)(Element); UI->Stacks.AutoPop$(s.Name) = true; }`;
|
|
@expand(UIStyleStacks s) `inline $(s.Type) UI_First$(s.Name)(void) { ui *UI = UI_GetState(); return(UI->Stacks.$(s.Name)Stack[0]); }`;
|
|
@expand(UIStyleStacks s) `inline $(s.Type) UI_Top$(s.Name)(void) { ui *UI = UI_GetState(); return(UI->Stacks.$(s.Name)Stack[UI->Stacks.$(s.Name)StackUsed - 1]); }`;
|
|
@expand(UIStyleStacks s) `#define UI_$(s.Name)(Element) DeferLoop(UI_Push$(s.Name)(Element), UI_Pop$(s.Name)())`
|
|
}
|
|
|
|
@c @table_gen
|
|
{
|
|
`static void UI_ApplyStyles(ui_box *Box)`;
|
|
`{`;
|
|
`ui *UI = UI_GetState();`;
|
|
@expand(UIStyleStacks s) `Assert(UI->Stacks.$(s.Name)StackUsed > 0); $(=>50) Box->$(s.BoxName) $(=>75) = UI->Stacks.$(s.Name)Stack[UI->Stacks.$(s.Name)StackUsed - 1]; $(=>160) if(UI->Stacks.AutoPop$(s.Name)) $(=>200) { UI_Pop$(s.Name)(); $(=>230) UI->Stacks.AutoPop$(s.Name) = false; $(=>260) }`
|
|
`}`;
|
|
} |