vn/code/vn_workspace.h

157 lines
3.7 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
2023-08-22 03:19:51 +00:00
////////////////////////////////
//~ sixten: Workspace Types
2023-06-17 17:00:55 +00:00
// sixten(TODO): Remove this type entirely.
enum workspace_toolbar_menu
2023-06-17 17:00:55 +00:00
{
W_ToolbarMenu_None = 0,
W_ToolbarMenu_Panel,
W_ToolbarMenu_View,
W_ToolbarMenu_Window,
2023-06-17 17:00:55 +00:00
};
struct workspace_panel_view
{
struct workspace_panel *Parent;
workspace_panel_view *Next;
workspace_panel_view *Prev;
struct workspace_view *View;
};
struct workspace_panel_view_list
{
workspace_panel_view *First;
workspace_panel_view *Last;
s64 Count;
};
2023-06-17 17:00:55 +00:00
struct workspace_panel
{
workspace_panel *First;
workspace_panel *Last;
workspace_panel *Next;
workspace_panel *Prev;
workspace_panel *Parent;
workspace_view *FirstView;
workspace_view *LastView;
2023-06-17 17:00:55 +00:00
workspace_view *CurrentView;
2023-06-17 17:00:55 +00:00
axis2 SplitAxis;
r32 PercentOfParent;
};
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
{
2023-08-22 03:19:51 +00:00
W_DragPayload_Inactive = 0,
W_DragPayload_Active,
W_DragPayload_Released,
2023-06-17 17:00:55 +00:00
};
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: Command Allocation
arena *CommandArena;
arena *CommandDataArena;
2023-06-17 17:00:55 +00:00
workspace_command *FirstFreeCommand;
workspace_command *LastFreeCommand;
// sixten: Command List
workspace_command *FirstCommand;
workspace_command *LastCommand;
// sixten: Panels
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;
arena *PanelViewArena;
workspace_panel_view_list PanelViewFreeList;
workspace_toolbar_menu Menu;
2023-06-17 17:00:55 +00:00
v2 MenuP;
r32 MenuT;
2023-06-17 17:00:55 +00:00
workspace_panel *RootPanel;
workspace_panel *CurrentPanel;
};
#include "vn_workspace_file_lister.h"
2023-08-22 03:19:51 +00:00
#include "vn_workspace_text_editor.h"
#include "vn_workspace_nav_editor.h"
2023-08-22 03:19:51 +00:00
#include "vn_workspace_view.h"
////////////////////////////////
//~ sixten: Workspace Functions
2023-07-19 15:09:41 +00:00
//- sixten: State management
2023-08-22 03:19:51 +00:00
static void W_SetState(workspace *Workspace);
static workspace *W_GetState(void);
2023-07-19 15:09:41 +00:00
2023-06-17 17:00:55 +00:00
//- sixten: Commands
static void W_IssueCommand(workspace_command_sig *Sig, u64 Argument = 0);
2023-08-22 03:19:51 +00:00
static void W_ProcessCommands(void);
2023-06-17 17:00:55 +00:00
//- sixten: Panels
2023-08-22 03:19:51 +00:00
static workspace_panel *W_CreateNewPanel(workspace_panel *Parent);
static void W_DeletePanel(workspace_panel *Panel);
static void W_SplitPanel(workspace_panel *Panel, axis2 Axis);
2023-06-17 17:00:55 +00:00
//- sixten: Views
static b32 W_ViewIsDragged(workspace_view *View);
//- sixten: Panel Views
static void W_PanelViewPush(workspace_panel_view_list *List, workspace_panel_view *PanelView);
static void W_PanelViewRemove(workspace_panel_view_list *List, workspace_panel_view *PanelView);
static workspace_panel_view *W_CreatePanelView(void);
static void W_DeletePanelView(workspace_panel_view *PanelView);
2023-06-17 17:00:55 +00:00
//- sixten: Builder code
static ui_signal W_BuildToolbarButton(char *Text, workspace_toolbar_menu Menu);
2023-08-22 03:19:51 +00:00
static ui_signal W_BuildMenuItem(u32 Icon, char *Text, char *Shortcut);
static void W_BuildToolbar(void);
2023-06-17 17:00:55 +00:00
//- sixten: Workspace
2023-08-22 03:19:51 +00:00
static void W_Init(workspace *Workspace);
static void W_Update(workspace *Workspace, vn_render_commands *RenderCommands, vn_input *Input, glyph_atlas *GlyphAtlas);
2023-06-17 17:00:55 +00:00
#endif //VN_WORKSPACE_H