-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdoc.h
More file actions
87 lines (66 loc) · 2.2 KB
/
Copy pathdoc.h
File metadata and controls
87 lines (66 loc) · 2.2 KB
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
#pragma once
#include "data/struct/linked_list.h"
#include "string/slice.h"
#include "draw/draw.h"
#include "keyboard_input.h"
#include "mouse_input.h"
#include "files/data_signatures.h"
typedef enum {
leading,
horizontal_center,
trailing,
} horizontal_alignment;
typedef enum {
top,
bottom,
vertical_center,
} vertical_alignment;
typedef enum { doc_text_none, doc_text_body, doc_text_title, doc_text_subtitle, doc_text_heading, doc_text_subheading, doc_text_footnote, doc_text_caption } doc_text_size;
typedef enum { doc_layout_none, doc_layout_vertical, doc_layout_horizontal, doc_layout_depth } doc_layout_types;
typedef enum { doc_gen_type_none, doc_gen_text, doc_gen_layout, doc_gen_button } doc_gen_type;
typedef enum {
size_none, //No rules for size
size_fit, //Fit to content
size_fill, //Fill parent
size_relative, //Percentage of parent
size_absolute //Absolute positioning within parent
} size_rule;
typedef struct {
int type;
doc_gen_type general_type;
color bg_color;
color fg_color;
size_rule sizing_rule;//TODO: x,y
gpu_rect rect;
u32 padding;
float percentage;//TODO: x,y
horizontal_alignment horiz_alignment;
vertical_alignment vert_alignment;
gpu_point offset;
wrap_policy text_wrap_policy;
text_format_arr text_formatting;
bool use_absolute_position;
} node_info;
typedef struct document_node document_node;
typedef struct {
int tag;
bool (*keyboard_input)(document_node* node,kbd_event event, u8 modifier);
bool (*mouse_input)(document_node*,mouse_data, u8 modifier);
void* (*on_copy)(document_node*,size_t *out_size);
bool (*on_paste)(document_node*,void* buf, size_t data);
} uno_input_info;
typedef struct document_node {
node_info info;
linked_list_t *children;
string_slice content;
uno_input_info input;
void *ctx;
} document_node;
typedef struct {
document_node *root;
} document_data;
void layout_document(gpu_rect canvas, document_data doc);
void render_document(draw_ctx *ctx, document_data doc);
void debug_document(document_data doc);
int text_to_scale(doc_text_size type);
data_signature supported_data(doc_gen_type type);