-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.c
85 lines (77 loc) · 2.12 KB
/
render.c
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
#include "application.h"
#include "checktag/checktag.h"
#include "element/element.h"
#include "main.h"
#include "editor/editor.h"
#include <stdio.h>
point_t sidebar(AppContext *app, point_t constraints, void *conf) {
rect(app, constraints, &(rect_t){(color_t){237,242,247,255}});
with_offset(&app->oplist, (point_t){20,20}) {
column(app, constraints, &(column_t){
.spacing = 0,
.children = element_children(
{
.widget = widget(text, &(text_t){
.color = (color_t){0, 0, 0, 255},
.content = "Title",
.font = &app->font_fallback,
.size = 20,
}),
},
),
});
}
return constraints;
}
point_t editingarea(AppContext *app, point_t constraints, void *conf) {
rect(app, constraints, &(rect_t){(color_t){255,255,255,255}});
if (!editor_state) {
editor_state = malloc(sizeof(editor_t));
*editor_state = editor_create("Some initial content and here is some more");
editor_import_markdown(editor_state, " \
# Headline\n \
\n \
Some text\n \
\n \
## Subheadline\n \
\n \
Even more content\n \
");
}
with_offset(&app->oplist, (point_t){unit_length_in_px((unit_length_t){25, unit_percent}, constraints.x),100}) {
editor(
app,
(point_t){
.x = unit_length_in_px((unit_length_t){50, unit_percent}, constraints.x),
.y = constraints.y - 150,
},
editor_state
);
}
return constraints;
}
point_t mainlayout(AppContext *app, point_t constraints, void *conf) {
row(app, constraints, &(row_t){
.spacing = 0,
.children = element_children(
/*{
.width = {15, unit_percent},
.height = {100, unit_percent},
.widget = widget(sidebar, NULL),
},*/
{
.width = {100, unit_percent},
.height = {100, unit_percent},
.widget = widget(editingarea, NULL),
},
),
});
return constraints;
}
void draw(AppContext *app, State *state) {
point_t window_dimensions = (point_t){app->window.width, app->window.height};
mainlayout(app, window_dimensions, NULL);
}
hr_guest_t hr_guest_draw = {
.draw = (AppLoopFunction) draw,
};