aboutsummaryrefslogtreecommitdiffstats
path: root/code/editor/editor_app.h
blob: f4cd397cc85c64792c7f2aa4798d681aab36d779 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* date = January 27th 2026 7:06 pm */

#ifndef EDITOR_APP_H
#define EDITOR_APP_H

//~ Types

typedef struct ui_box ui_box;

typedef struct panel panel;
struct panel
{
    panel *First;
    panel *Last;
    panel *Next;
    panel *Prev;
    panel *Parent;
    
    s32 Axis;
    f32 ParentPct;
    
    ui_box *Root;
    
    v4 Region;
    
    b32 CannotClose;
};
raddbg_type_view(panel, 
                 no_addr(rows($,
                              (&First == NilPanel || &First == 0),
                              ParentPct, 
                              (Axis == Axis2_X ? "X" : "Y"))));
#define EachChildPanel(Child, Parent) (panel *Child = Parent->First; !IsNilPanel(Child); Child = Child->Next)

typedef struct app_text app_text; 
struct app_text
{
    u64 Cursor;
    u64 Count;
    u64 Capacity;
    u64 Trail;
    u64 CurRelLine;
    f32 CursorAnimTime;
    rune *Data;
    
    u64 PrevCursor;
    // Computed each frame
    u64 Lines;
};

typedef struct panel_node panel_node;
struct panel_node
{
    panel *Value;
    app_text *Text;
    
    // TODO(luca): Double Linked List
    panel_node *Next;
};
#define EachPanel(Index, First) EachNode(Index, panel_node, First)

typedef struct app_state app_state;
struct app_state
{
    // TODO(luca): This is already in the FontAtlas, so it should go away?
    font Font;
    font_atlas FontAtlas;
    arena *FontAtlasArena; 
    f32 PreviousHeightPx;
    f32 HeightPx;
    
    // TODO(luca): Move to UI state ?
    arena *UIArena;
    
    panel *TitlebarPanel;
    
    panel_node *TextPanels;
    arena *TextArena;
    
    panel *SelectedPanel;
    panel *FirstPanel;
    panel_node *FreePanel;
    arena *PanelArena;
    panel *DebugPanel;
    
    u64 FrameIdx;
    
    gl_render_state Render;
    
    // Nils
    ui_box *TrackerForUI_NilBox;
    panel *TrackerForNilPanel;
};

//~ Globals
#define DefaultHeightPx 24

global_variable arena *FrameArena = 0;

#endif //EDITOR_APP_H