96 lines
3.4 KiB
C
96 lines
3.4 KiB
C
#include "pango/pango-font.h"
|
|
#define RAVEN_IMPLEMENTATION
|
|
#include "libraven.h"
|
|
|
|
typedef struct AppState {
|
|
PangoFontDescription *desc;
|
|
PangoFontDescription *bold_desc;
|
|
} AppState;
|
|
|
|
UINode *main_view_scaffold(UINode *root, AppState *state)
|
|
{
|
|
{
|
|
background_node_new(root, UISlate50, 0);
|
|
UIBoxLayoutNode *layout = box_layout_new(root, UI_DIRECTION_VERTICAL);
|
|
box_layout_set_margins(layout, 36);
|
|
layout->gap = 26;
|
|
}
|
|
|
|
{
|
|
UINode *input_container;
|
|
|
|
{
|
|
input_container = node_new(root, "input_container");
|
|
input_container->width_policy = UI_SIZE_POLICY_GROW;
|
|
UIBoxLayoutNode *layout = box_layout_new(input_container, UI_DIRECTION_HORIZONTAL);
|
|
layout->gap = 8;
|
|
layout->justify_secondary = UI_BOX_LAYOUT_JUSTIFY_CENTER;
|
|
}
|
|
|
|
{
|
|
UINode *input = (UINode*)text_input_new(input_container);
|
|
background_node_new(input, UISlate100, 10);
|
|
input->width_policy = UI_SIZE_POLICY_GROW;
|
|
input->height_policy = UI_SIZE_POLICY_STATIC;
|
|
input->rect.h = 42;
|
|
|
|
UIBoxLayoutNode *layout = box_layout_new(input, UI_DIRECTION_HORIZONTAL);
|
|
layout->justify_secondary = UI_BOX_LAYOUT_JUSTIFY_CENTER;
|
|
layout->margin_left = 6;
|
|
|
|
UINode *input_text_container = node_new(input, "input_text_container");
|
|
UITextNode *input_text = text_node_new(input_text_container, state->desc, UINeutral950, NULL);
|
|
((UITextInputNode*)input)->text_node = input_text;
|
|
}
|
|
|
|
{
|
|
UINode *add_button = node_new(input_container, "button");
|
|
add_button->width_policy = UI_SIZE_POLICY_STATIC;
|
|
add_button->height_policy = UI_SIZE_POLICY_GROW;
|
|
add_button->rect.w = 42;
|
|
state_background_node_new(add_button, UIIndigo500, UIIndigo600, UIIndigo700, 8.0);
|
|
UIBoxLayoutNode *layout = box_layout_new(add_button, UI_DIRECTION_HORIZONTAL);
|
|
layout->justify_secondary = UI_BOX_LAYOUT_JUSTIFY_CENTER;
|
|
box_layout_set_margins(layout, 8);
|
|
UINode *text_container = node_new(add_button, "text_container");
|
|
text_node_new(text_container, state->desc, UINeutral50, "+");
|
|
}
|
|
}
|
|
|
|
{
|
|
UINode *item = node_new(root, "item");
|
|
item->width_policy = UI_SIZE_POLICY_GROW;
|
|
box_layout_new(item, UI_DIRECTION_HORIZONTAL)->justify_secondary = UI_BOX_LAYOUT_JUSTIFY_CENTER;
|
|
UINode *item_text_container = node_new(item, "item_text_container");
|
|
text_node_new(item_text_container, state->bold_desc, UINeutral950, "Test");
|
|
UINode *separator = node_new(item, "separator");
|
|
separator->width_policy = UI_SIZE_POLICY_GROW;
|
|
UINode *remove_button = node_new(item, "remove_button");
|
|
text_node_new(remove_button, state->desc, UINeutral700, "remove");
|
|
}
|
|
|
|
return root;
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
UIWindow *window = window_new(800, 600);
|
|
if (!window) {
|
|
fprintf(stderr, "err: failed to create window\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
AppState state = {
|
|
.desc = pango_font_description_from_string("Roboto 12"),
|
|
.bold_desc = pango_font_description_from_string("Roboto Demi-Bold 12")
|
|
};
|
|
|
|
UINode *root = node_new(NULL, "[root]");
|
|
window_attach_root(window, root);
|
|
main_view_scaffold(root, &state);
|
|
|
|
window_turn(window);
|
|
window_free(window);
|
|
|
|
return 0;
|
|
}
|