editor panels prototyping
This commit is contained in:
parent
7531e18245
commit
83f7c48369
@ -792,17 +792,151 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
//////////////////////////////
|
||||
//- Build editor UI
|
||||
|
||||
// if (frame->is_editing)
|
||||
// {
|
||||
// UI_SetNext(BackgroundColor, VEC4(0, 0, 0, 1));
|
||||
/* TODO: Remove this (testing) */
|
||||
if (!V.root_space);
|
||||
{
|
||||
V_Space *space = PushStruct(perm, V_Space);
|
||||
space->axis = Axis_Y;
|
||||
V.root_space = space;
|
||||
|
||||
{
|
||||
V_Panel *panel = PushStruct(perm, V_Panel);
|
||||
panel->space = space;
|
||||
DllQueuePushNP(space->first_panel, space->last_panel, panel, next_in_space, prev_in_space);
|
||||
++space->panels_count;
|
||||
|
||||
{
|
||||
V_Window *window = PushStruct(perm, V_Window);
|
||||
window->panel = panel;
|
||||
// window->is_tile_window = 1;
|
||||
DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel);
|
||||
++panel->windows_count;
|
||||
}
|
||||
{
|
||||
V_Window *window = PushStruct(perm, V_Window);
|
||||
window->panel = panel;
|
||||
window->is_tile_window = 1;
|
||||
DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel);
|
||||
++panel->windows_count;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
V_Panel *panel = PushStruct(perm, V_Panel);
|
||||
panel->space = space;
|
||||
DllQueuePushNP(space->first_panel, space->last_panel, panel, next_in_space, prev_in_space);
|
||||
++space->panels_count;
|
||||
|
||||
{
|
||||
V_Window *window = PushStruct(perm, V_Window);
|
||||
window->panel = panel;
|
||||
window->is_tile_window = 1;
|
||||
DllQueuePushNP(panel->first_window, panel->last_window, window, next_in_panel, prev_in_panel);
|
||||
++panel->windows_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (frame->is_editing)
|
||||
{
|
||||
Struct(DfsNode) { DfsNode *next; b32 visited; V_Space *space; UI_Checkpoint cp; };
|
||||
DfsNode *first_dfs = PushStruct(frame->arena, DfsNode);
|
||||
first_dfs->space = V.root_space;
|
||||
|
||||
while (first_dfs)
|
||||
{
|
||||
DfsNode *dfs = first_dfs;
|
||||
V_Space *space = dfs->space;
|
||||
if (!dfs->visited)
|
||||
{
|
||||
dfs->visited = 1;
|
||||
for (V_Space *child = space->last; child; child = child->prev)
|
||||
{
|
||||
DfsNode *n = PushStruct(frame->arena, DfsNode);
|
||||
n->space = child;
|
||||
SllStackPush(first_dfs, n);
|
||||
}
|
||||
|
||||
UI_Key space_key = UI_TransKey();
|
||||
if (space->axis == Axis_X)
|
||||
{
|
||||
UI_BuildRowEx(space_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_BuildColumnEx(space_key);
|
||||
}
|
||||
dfs->cp = UI_PushCP(space_key);
|
||||
|
||||
for (V_Panel *panel = space->first_panel; panel; panel = panel->next_in_space)
|
||||
{
|
||||
i64 active_window_idx = ClampI64(panel->active_window_idx, 0, MaxI64(panel->windows_count - 1, 0));
|
||||
/* Build tabs */
|
||||
V_Window *window = 0;
|
||||
{
|
||||
UI_SetNext(Width, UI_SHRINK(0, 1));
|
||||
UI_SetNext(Height, UI_SHRINK(0, 1));
|
||||
UI_PushCP(UI_BuildRow());
|
||||
i64 window_idx = 0;
|
||||
for (V_Window *tab_window = panel->first_window; tab_window; tab_window = tab_window->next_in_panel)
|
||||
{
|
||||
if (window_idx == active_window_idx)
|
||||
{
|
||||
window = tab_window;
|
||||
UI_SetNext(BorderColor, VEC4(0.9, 0.5, 0.5, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_SetNext(BorderColor, VEC4(0.5, 0.5, 0.5, 1));
|
||||
}
|
||||
UI_SetNext(BackgroundColor, VEC4(0.2, 0.2, 0.2, 1));
|
||||
UI_SetNext(Border, 1);
|
||||
UI_SetNext(Width, UI_SHRINK(0, 1));
|
||||
UI_SetNext(Height, UI_SHRINK(0, 1));
|
||||
UI_PushCP(UI_BuildRow());
|
||||
{
|
||||
if (tab_window->is_tile_window)
|
||||
{
|
||||
UI_BuildLabelF("Tiles");
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_BuildLabelF("Unknown");
|
||||
}
|
||||
}
|
||||
UI_PopCP(UI_TopCP());
|
||||
window_idx += 1;
|
||||
}
|
||||
UI_PopCP(UI_TopCP());
|
||||
}
|
||||
/* Build active window */
|
||||
if (window)
|
||||
{
|
||||
if (window->is_tile_window)
|
||||
{
|
||||
UI_SetNext(BackgroundColor, VEC4(0, 0, 0, 1));
|
||||
UI_SetNext(BorderColor, VEC4(0.5, 0.5, 0.5, 1));
|
||||
UI_SetNext(Border, 1);
|
||||
UI_SetNext(Width, UI_PIX(100, 1));
|
||||
UI_SetNext(Height, UI_PIX(100, 1));
|
||||
// UI_SetNext(Width, UI_SHRINK(0, 1));
|
||||
// UI_SetNext(Height, UI_SHRINK(0, 1));
|
||||
// UI_PushCP(UI_BuildRow());
|
||||
// {
|
||||
UI_PushCP(UI_BuildRow());
|
||||
{
|
||||
// UI_BuildLabelF("Tiles");
|
||||
// }
|
||||
// UI_PopCP(UI_TopCP());
|
||||
// }
|
||||
}
|
||||
UI_PopCP(UI_TopCP());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UI_PopCP(dfs->cp);
|
||||
SllStackPop(first_dfs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- Build command palette
|
||||
|
||||
@ -144,6 +144,47 @@ Struct(V_CommandsWidget)
|
||||
} build;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Window types
|
||||
|
||||
/* TODO: Move boolean fields into bitwise property flags */
|
||||
|
||||
Struct(V_Space)
|
||||
{
|
||||
V_Space *parent;
|
||||
V_Space *next;
|
||||
V_Space *prev;
|
||||
V_Space *first;
|
||||
V_Space *last;
|
||||
|
||||
i64 panels_count;
|
||||
struct V_Panel *first_panel;
|
||||
struct V_Panel *last_panel;
|
||||
|
||||
Axis axis;
|
||||
};
|
||||
|
||||
Struct(V_Panel)
|
||||
{
|
||||
V_Space *space;
|
||||
V_Panel *next_in_space;
|
||||
V_Panel *prev_in_space;
|
||||
|
||||
i64 active_window_idx;
|
||||
i64 windows_count;
|
||||
struct V_Window *first_window;
|
||||
struct V_Window *last_window;
|
||||
};
|
||||
|
||||
Struct(V_Window)
|
||||
{
|
||||
V_Panel *panel;
|
||||
V_Window *next_in_panel;
|
||||
V_Window *prev_in_panel;
|
||||
|
||||
b32 is_tile_window;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Context types
|
||||
|
||||
@ -233,6 +274,8 @@ Struct(V_Ctx)
|
||||
S_Lookup lookup;
|
||||
S_Key player_key;
|
||||
|
||||
V_Space *root_space;
|
||||
|
||||
Atomic32 shutdown;
|
||||
Fence shutdown_complete;
|
||||
|
||||
|
||||
@ -838,14 +838,10 @@ void UI_EndFrame(UI_Frame *frame)
|
||||
frame->boxes_post = boxes_post;
|
||||
{
|
||||
Struct(BoxNode) { BoxNode *next; b32 visited; UI_Box *box; };
|
||||
BoxNode *first_dfs = 0;
|
||||
BoxNode *first_dfs = PushStruct(scratch.arena, BoxNode);
|
||||
u64 pre_index = 0;
|
||||
u64 post_index = 0;
|
||||
{
|
||||
BoxNode *n = PushStruct(scratch.arena, BoxNode);
|
||||
n->box = frame->root_box;
|
||||
SllStackPush(first_dfs, n);
|
||||
}
|
||||
first_dfs->box = frame->root_box;
|
||||
while (first_dfs)
|
||||
{
|
||||
BoxNode *n = first_dfs;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user