vn/code/vn_workspace.h

132 lines
3.2 KiB
C
Raw Normal View History

2023-06-17 17:00:55 +00:00
/* date = May 5th 2023 10:12 am */
#ifndef VN_WORKSPACE_H
#define VN_WORKSPACE_H
#include "vn_workspace_editor.h"
2023-07-19 15:09:41 +00:00
#include "vn_workspace_text_editor.h"
2023-06-17 17:00:55 +00:00
// sixten(TODO): Remove this type entirely.
enum toolbar_menu
{
ToolbarMenu_None = 0,
ToolbarMenu_Panel,
ToolbarMenu_View,
ToolbarMenu_Window,
};
struct workspace_panel
{
workspace_panel *First;
workspace_panel *Last;
workspace_panel *Next;
workspace_panel *Prev;
workspace_panel *Parent;
struct workspace_view *FirstView;
struct workspace_view *LastView;
struct workspace_view *CurrentView;
axis2 SplitAxis;
r32 PercentOfParent;
};
#include "vn_workspace_view.h"
2023-07-19 15:09:41 +00:00
#define WORKSPACE_COMMAND(name, ...) void name(u64 Argument)
2023-06-17 17:00:55 +00:00
typedef WORKSPACE_COMMAND(workspace_command_sig);
struct workspace_command
{
workspace_command_sig *Command;
u64 Argument;
workspace_command *Next;
workspace_command *Prev;
};
struct workspace_keybind
{
platform_key Key;
platform_modifiers Modifiers;
workspace_command_sig *Command;
u64 Argument;
};
enum workspace_drag_payload_state
{
Workspace_DragPayload_Inactive = 0,
Workspace_DragPayload_Active,
Workspace_DragPayload_Released,
};
struct workspace_drag_payload
{
ui_key Key;
workspace_view *View;
};
struct workspace
{
2023-06-19 17:12:26 +00:00
vn_input *Input;
2023-06-17 17:00:55 +00:00
platform_event_list *EventList;
// sixten: General Purpose Allocation
memory_arena *FrameArena;
2023-06-17 17:00:55 +00:00
// sixten: Command Allocation
2023-07-19 15:09:41 +00:00
memory_arena *CommandArena;
2023-06-17 17:00:55 +00:00
workspace_command *FirstFreeCommand;
workspace_command *LastFreeCommand;
// sixten: Command List
workspace_command *FirstCommand;
workspace_command *LastCommand;
// sixten: Keybinds
workspace_keybind Keybinds[256];
s32 KeybindCount;
// sixten: Panels
2023-07-19 15:09:41 +00:00
memory_arena *PanelArena;
2023-06-17 17:00:55 +00:00
workspace_panel *FirstFreePanel;
workspace_panel *LastFreePanel;
workspace_drag_payload_state DragPayloadState;
workspace_drag_payload DragPayload;
toolbar_menu Menu;
v2 MenuP;
r32 MenuTransition;
workspace_panel *RootPanel;
workspace_panel *CurrentPanel;
};
2023-07-19 15:09:41 +00:00
//- sixten: State management
static void Workspace_SetState(workspace *Workspace);
static workspace *Workspace_GetState(void);
static memory_arena *Workspace_FrameArena(void);
2023-07-19 15:09:41 +00:00
2023-06-17 17:00:55 +00:00
//- sixten: Commands
2023-07-19 15:09:41 +00:00
static void Workspace_IssueCommand(workspace_command_sig *Sig, u64 Argument);
static void Workspace_ProcessCommands(void);
2023-06-17 17:00:55 +00:00
//- sixten: Panels
2023-07-19 15:09:41 +00:00
static workspace_panel *Workspace_CreateNewPanel(workspace_panel *Parent);
static void Workspace_DeletePanel(workspace_panel *Panel);
static void Workspace_SplitPanel(workspace_panel *Panel, axis2 Axis);
2023-06-17 17:00:55 +00:00
//- sixten: Builder code
2023-07-19 15:09:41 +00:00
static ui_signal Workspace_BuildToolbarButton(char *Text, toolbar_menu Menu);
2023-06-17 17:00:55 +00:00
static ui_signal Workspace_BuildMenuItem(u32 Icon, char *Text, char *Shortcut);
2023-07-19 15:09:41 +00:00
static void Workspace_BuildToolbar(r32 dtForFrame);
2023-06-17 17:00:55 +00:00
//- sixten: Workspace
static void Workspace_Init(workspace *Workspace);
static void Workspace_Update(workspace *Workspace, vn_render_commands *RenderCommands,
vn_input *Input, glyph_atlas *GlyphAtlas);
#endif //VN_WORKSPACE_H