/* date = April 1st 2024 9:04 pm */

#ifndef UI_META_H
#define UI_META_H

// TODO(anton): This code should be generated by a metaprogram at some point.

//~ Node structs

typedef struct UI_ParentNode UI_ParentNode; struct UI_ParentNode{UI_ParentNode *next; UI_Box * v;};
typedef struct UI_FlagsNode UI_FlagsNode; struct UI_FlagsNode{UI_FlagsNode *next; UI_BoxFlags v;};
typedef struct UI_FixedXNode UI_FixedXNode; struct UI_FixedXNode{UI_FixedXNode *next; F32 v;};
typedef struct UI_FixedYNode UI_FixedYNode; struct UI_FixedYNode{UI_FixedYNode *next; F32 v;};
typedef struct UI_FixedWidthNode UI_FixedWidthNode; struct UI_FixedWidthNode{UI_FixedWidthNode *next; F32 v;};
typedef struct UI_FixedHeightNode UI_FixedHeightNode; struct UI_FixedHeightNode{UI_FixedHeightNode *next; F32 v;};
typedef struct UI_PrefWidthNode UI_PrefWidthNode; struct UI_PrefWidthNode{UI_PrefWidthNode *next; UI_Size v;};
typedef struct UI_PrefHeightNode UI_PrefHeightNode; struct UI_PrefHeightNode{UI_PrefHeightNode *next; UI_Size v;};
typedef struct UI_ChildLayoutAxisNode UI_ChildLayoutAxisNode; struct UI_ChildLayoutAxisNode{UI_ChildLayoutAxisNode *next; Axis2 v;};
typedef struct UI_SeedKeyNode UI_SeedKeyNode; struct UI_SeedKeyNode{UI_SeedKeyNode *next; UI_Key v;};


//~ Declaration macros for use in the UI_State

//- Stacks 
#define UI_declare_stacks \
struct \
{ \
struct { UI_ParentNode *top; UI_ParentNode *free; B32 auto_pop; } parent_stack; \
struct { UI_FlagsNode *top; UI_FlagsNode *free; B32 auto_pop; } flags_stack; \
struct { UI_FixedXNode *top; UI_FixedXNode *free; B32 auto_pop; } fixed_x_stack; \
struct { UI_FixedYNode *top; UI_FixedYNode *free; B32 auto_pop; } fixed_y_stack; \
struct { UI_FixedWidthNode *top; UI_FixedWidthNode *free; B32 auto_pop; } fixed_width_stack; \
struct { UI_FixedHeightNode *top; UI_FixedHeightNode *free; B32 auto_pop; } fixed_height_stack; \
struct { UI_PrefWidthNode *top; UI_PrefWidthNode *free; B32 auto_pop; } pref_width_stack; \
struct { UI_PrefHeightNode *top; UI_PrefHeightNode *free; B32 auto_pop; } pref_height_stack; \
struct { UI_ChildLayoutAxisNode *top; UI_ChildLayoutAxisNode *free; B32 auto_pop; } child_layout_axis_stack; \
struct { UI_SeedKeyNode *top; UI_SeedKeyNode *free; B32 auto_pop; } seed_key_stack; \
}

#define UI_init_stacks(state) \
state->parent_stack.top = &state->parent_nil_stack_top; state->parent_stack.free = 0; state->parent_stack.auto_pop = 0; \
state->flags_stack.top = &state->flags_nil_stack_top; state->flags_stack.free = 0; state->flags_stack.auto_pop = 0; \
state->fixed_x_stack.top = &state->fixed_x_nil_stack_top; state->fixed_x_stack.free = 0; state->fixed_x_stack.auto_pop = 0;\
state->fixed_y_stack.top = &state->fixed_y_nil_stack_top; state->fixed_y_stack.free = 0; state->fixed_y_stack.auto_pop = 0;\
state->fixed_width_stack.top = &state->fixed_width_nil_stack_top; state->fixed_width_stack.free = 0; state->fixed_width_stack.auto_pop = 0;\
state->fixed_height_stack.top = &state->fixed_height_nil_stack_top; state->fixed_height_stack.free = 0; state->fixed_height_stack.auto_pop = 0;\
state->pref_width_stack.top = &state->pref_width_nil_stack_top; state->pref_width_stack.free = 0; state->pref_width_stack.auto_pop = 0; \
state->pref_height_stack.top = &state->pref_height_nil_stack_top; state->pref_height_stack.free = 0; state->pref_height_stack.auto_pop = 0; \
state->child_layout_axis_stack.top = &state->child_layout_axis_nil_stack_top; state->child_layout_axis_stack.free = 0; state->child_layout_axis_stack.auto_pop = 0; \
state->seed_key_stack.top = &state->seed_key_nil_stack_top; state->seed_key_stack.free = 0; state->seed_key_stack.auto_pop = 0; \


//- Stack nils 
#define UI_declare_stack_nils \
struct \
{ \
UI_ParentNode parent_nil_stack_top; \
UI_FlagsNode flags_nil_stack_top; \
UI_FixedXNode fixed_x_nil_stack_top; \
UI_FixedYNode fixed_y_nil_stack_top; \
UI_FixedWidthNode fixed_width_nil_stack_top; \
UI_FixedHeightNode fixed_height_nil_stack_top; \
UI_PrefWidthNode pref_width_nil_stack_top; \
UI_PrefHeightNode pref_height_nil_stack_top; \
UI_ChildLayoutAxisNode child_layout_axis_nil_stack_top; \
UI_SeedKeyNode seed_key_nil_stack_top; \
}
#define UI_init_stack_nils(state) \
state->parent_nil_stack_top.v = &ui_g_nil_box; \
state->flags_nil_stack_top.v = 0; \
state->fixed_x_nil_stack_top.v = 0; \
state->fixed_y_nil_stack_top.v = 0; \
state->fixed_width_nil_stack_top.v = 0; \
state->fixed_height_nil_stack_top.v = 0; \
state->pref_width_nil_stack_top.v = UI_pixels(200.f, 1.f); \
state->pref_height_nil_stack_top.v = UI_pixels(2.f, 1.f); \
state->child_layout_axis_nil_stack_top.v = Axis2_X;\
state->seed_key_nil_stack_top.v = UI_key_zero(); \

#endif //UI_META_H
