Introduced GUI_Node_Reference wrapper type
This commit is contained in:
1 parent
7563677f37
commit
69c810702d
1 file changed
+113
-92
@@ -150,7 +150,21 @@ typedef struct GUI_Node {
|
|||||||
#define GUI_NODE_SIBLING(node) ((GUI_Node*)(node)->rdic_node.sibling)
|
#define GUI_NODE_SIBLING(node) ((GUI_Node*)(node)->rdic_node.sibling)
|
||||||
#define GUI_NODE_FIRST_CHILD(node) ((GUI_Node*)(node)->rdic_node.first_child)
|
#define GUI_NODE_FIRST_CHILD(node) ((GUI_Node*)(node)->rdic_node.first_child)
|
||||||
|
|
||||||
|
typedef union GUI_Node_Reference {
|
||||||
|
RDIC_Node_Reference rdic;
|
||||||
|
struct {
|
||||||
|
GUI_Node *node;
|
||||||
|
unsigned int generation;
|
||||||
|
};
|
||||||
|
} GUI_Node_Reference;
|
||||||
|
#define gui_node_references_equal(n, m) rdic_node_references_equal((n).rdic,(m).rdic)
|
||||||
|
#if 0
|
||||||
|
// NOTE(Zelaven): This was just for debugging with better debug messages.
|
||||||
|
int _gui_node_references_equal(GUI_Node_Reference n, GUI_Node_Reference m)
|
||||||
|
{
|
||||||
|
return rdic_node_references_equal(n.rdic,m.rdic);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GUI_Rectangle rectangle;
|
GUI_Rectangle rectangle;
|
||||||
@@ -169,7 +183,7 @@ struct GUI_Subtree {
|
|||||||
GUI_Subtree *next;
|
GUI_Subtree *next;
|
||||||
GUI_Subtree *structural_parent;
|
GUI_Subtree *structural_parent;
|
||||||
|
|
||||||
RDIC_Node_Reference relative_to;
|
GUI_Node_Reference relative_to;
|
||||||
int flat_offset_x;
|
int flat_offset_x;
|
||||||
int flat_offset_y;
|
int flat_offset_y;
|
||||||
int offset_relative_node_percentage_x;
|
int offset_relative_node_percentage_x;
|
||||||
@@ -190,9 +204,9 @@ typedef struct {
|
|||||||
GUI_Subtree *last_subtree;
|
GUI_Subtree *last_subtree;
|
||||||
GUI_Subtree *current_subtree;
|
GUI_Subtree *current_subtree;
|
||||||
|
|
||||||
RDIC_Node_Reference focused_node;
|
GUI_Node_Reference focused_node;
|
||||||
RDIC_Node_Reference hovered_node;
|
GUI_Node_Reference hovered_node;
|
||||||
RDIC_Node_Reference top_node_under_cursor;
|
GUI_Node_Reference top_node_under_cursor;
|
||||||
int mouse_pressed;
|
int mouse_pressed;
|
||||||
int mouse_down;
|
int mouse_down;
|
||||||
int mouse_x;
|
int mouse_x;
|
||||||
@@ -315,7 +329,7 @@ void gui_apply_input(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context->top_node_under_cursor.node = &top_node_under_cursor->rdic_node;
|
context->top_node_under_cursor.node = top_node_under_cursor;
|
||||||
context->top_node_under_cursor.generation =
|
context->top_node_under_cursor.generation =
|
||||||
top_node_under_cursor->rdic_node.generation;
|
top_node_under_cursor->rdic_node.generation;
|
||||||
DEBUG("Top node under cursor: %.*s\n",
|
DEBUG("Top node under cursor: %.*s\n",
|
||||||
@@ -324,17 +338,19 @@ void gui_apply_input(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RDIC_Node_Reference gui_get_node(
|
GUI_Node_Reference gui_get_node(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference last_reference,
|
GUI_Node_Reference last_reference,
|
||||||
GUI_Layout_Direction direction,
|
GUI_Layout_Direction direction,
|
||||||
GUI_Style *style,
|
GUI_Style *style,
|
||||||
GUI_Size size[static 2])
|
GUI_Size size[static 2])
|
||||||
{
|
{
|
||||||
int get_node_flags = 0;
|
int get_node_flags = 0;
|
||||||
RDIC_Node_Reference new_reference =
|
GUI_Node_Reference new_reference = {
|
||||||
rdic_get_node(&context->current_subtree->rdic, last_reference, &get_node_flags);
|
.rdic = rdic_get_node(
|
||||||
GUI_Node *node = (GUI_Node*)new_reference.node;
|
&context->current_subtree->rdic, last_reference.rdic, &get_node_flags),
|
||||||
|
};
|
||||||
|
GUI_Node *node = new_reference.node;
|
||||||
node->layout_direction = direction;
|
node->layout_direction = direction;
|
||||||
node->style = style;
|
node->style = style;
|
||||||
node->semantic_size[GUI_AXIS2_X] = size[GUI_AXIS2_X];
|
node->semantic_size[GUI_AXIS2_X] = size[GUI_AXIS2_X];
|
||||||
@@ -372,9 +388,9 @@ RDIC_Node_Reference gui_get_node(
|
|||||||
// ref.node->dirty = true?
|
// ref.node->dirty = true?
|
||||||
// That is one option, specifying the dirty flag as a part of the API itself.
|
// That is one option, specifying the dirty flag as a part of the API itself.
|
||||||
// I think I like that option.
|
// I think I like that option.
|
||||||
RDIC_Node_Reference gui_context_start_frame(
|
GUI_Node_Reference gui_context_start_frame(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference last_root_reference,
|
GUI_Node_Reference last_root_reference,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
GUI_Layout_Direction layout_direction,
|
GUI_Layout_Direction layout_direction,
|
||||||
GUI_Style *style)
|
GUI_Style *style)
|
||||||
@@ -393,9 +409,13 @@ RDIC_Node_Reference gui_context_start_frame(
|
|||||||
context->last_subtree = &background_subtree;
|
context->last_subtree = &background_subtree;
|
||||||
context->current_subtree = &background_subtree;
|
context->current_subtree = &background_subtree;
|
||||||
|
|
||||||
RDIC_Node_Reference new_root_reference = rdic_context_start_frame(
|
GUI_Node_Reference new_root_reference = {
|
||||||
&background_subtree.rdic,
|
.rdic = rdic_context_start_frame(
|
||||||
last_root_reference);
|
&background_subtree.rdic, last_root_reference.rdic)
|
||||||
|
};
|
||||||
|
//RDIC_Node_Reference new_root_reference = rdic_context_start_frame(
|
||||||
|
// &background_subtree.rdic,
|
||||||
|
// last_root_reference);
|
||||||
GUI_Node *root = (GUI_Node*)new_root_reference.node;
|
GUI_Node *root = (GUI_Node*)new_root_reference.node;
|
||||||
root->dirty = false;
|
root->dirty = false;
|
||||||
if(!gui_node_references_equal(last_root_reference, new_root_reference)) {
|
if(!gui_node_references_equal(last_root_reference, new_root_reference)) {
|
||||||
@@ -424,14 +444,14 @@ void gui_context_finish_frame(
|
|||||||
context->node_freelist = context->first_subtree->rdic.node_freelist;
|
context->node_freelist = context->first_subtree->rdic.node_freelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
RDIC_Node_Reference gui_push_subtree(
|
GUI_Node_Reference gui_push_subtree(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
GUI_Subtree *subtree,
|
GUI_Subtree *subtree,
|
||||||
RDIC_Node_Reference last_root_reference,
|
GUI_Node_Reference last_root_reference,
|
||||||
GUI_Layout_Direction layout_direction,
|
GUI_Layout_Direction layout_direction,
|
||||||
GUI_Style *style,
|
GUI_Style *style,
|
||||||
GUI_Size size[static 2],
|
GUI_Size size[static 2],
|
||||||
RDIC_Node_Reference relative_to)
|
GUI_Node_Reference relative_to)
|
||||||
{
|
{
|
||||||
context->node_freelist = context->current_subtree->rdic.node_freelist;
|
context->node_freelist = context->current_subtree->rdic.node_freelist;
|
||||||
subtree->rdic.node_freelist = context->node_freelist;
|
subtree->rdic.node_freelist = context->node_freelist;
|
||||||
@@ -444,9 +464,10 @@ RDIC_Node_Reference gui_push_subtree(
|
|||||||
context->current_subtree = subtree;
|
context->current_subtree = subtree;
|
||||||
subtree->relative_to = relative_to;
|
subtree->relative_to = relative_to;
|
||||||
|
|
||||||
RDIC_Node_Reference new_root_reference = rdic_context_start_frame(
|
GUI_Node_Reference new_root_reference = {
|
||||||
&subtree->rdic,
|
.rdic = rdic_context_start_frame(
|
||||||
last_root_reference);
|
&subtree->rdic, last_root_reference.rdic)
|
||||||
|
};
|
||||||
GUI_Node *root = (GUI_Node*)new_root_reference.node;
|
GUI_Node *root = (GUI_Node*)new_root_reference.node;
|
||||||
root->dirty = false;
|
root->dirty = false;
|
||||||
if(!gui_node_references_equal(last_root_reference, new_root_reference)) {
|
if(!gui_node_references_equal(last_root_reference, new_root_reference)) {
|
||||||
@@ -476,9 +497,9 @@ void gui_pop_subtree(
|
|||||||
|
|
||||||
void gui_push_parent(
|
void gui_push_parent(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference parent)
|
GUI_Node_Reference parent)
|
||||||
{
|
{
|
||||||
rdic_push_parent(&context->current_subtree->rdic, parent);
|
rdic_push_parent(&context->current_subtree->rdic, parent.rdic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_pop_parent(
|
void gui_pop_parent(
|
||||||
@@ -679,16 +700,16 @@ void gui_generate_draw_commands(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
RDIC_Node_Reference gui_layout(
|
GUI_Node_Reference gui_layout(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference last_reference,
|
GUI_Node_Reference last_reference,
|
||||||
GUI_Layout_Direction direction,
|
GUI_Layout_Direction direction,
|
||||||
GUI_Style *style,
|
GUI_Style *style,
|
||||||
GUI_Size size[static 2])
|
GUI_Size size[static 2])
|
||||||
{
|
{
|
||||||
RDIC_Node_Reference new_reference = gui_get_node(
|
GUI_Node_Reference new_reference = gui_get_node(
|
||||||
context, last_reference, direction, style, size);
|
context, last_reference, direction, style, size);
|
||||||
GUI_Node *node = (GUI_Node*)new_reference.node;
|
GUI_Node *node = new_reference.node;
|
||||||
node->text_string = (GUI_String){0};
|
node->text_string = (GUI_String){0};
|
||||||
node->debug_string = GUI_STRING("gui_layout");
|
node->debug_string = GUI_STRING("gui_layout");
|
||||||
return new_reference;
|
return new_reference;
|
||||||
@@ -698,15 +719,15 @@ RDIC_Node_Reference gui_layout(
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
|
|
||||||
RDIC_Node_Reference gui_dumb_block(
|
GUI_Node_Reference gui_dumb_block(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference last_reference,
|
GUI_Node_Reference last_reference,
|
||||||
GUI_Style *style,
|
GUI_Style *style,
|
||||||
GUI_Size size[static 2])
|
GUI_Size size[static 2])
|
||||||
{
|
{
|
||||||
RDIC_Node_Reference new_reference = gui_get_node(
|
GUI_Node_Reference new_reference = gui_get_node(
|
||||||
context, last_reference, GUI_LAYOUT_NONE, style, size);
|
context, last_reference, GUI_LAYOUT_NONE, style, size);
|
||||||
GUI_Node *node = (GUI_Node*)new_reference.node;
|
GUI_Node *node = new_reference.node;
|
||||||
node->text_string = (GUI_String){0};
|
node->text_string = (GUI_String){0};
|
||||||
node->debug_string = GUI_STRING("gui_dumb_block");
|
node->debug_string = GUI_STRING("gui_dumb_block");
|
||||||
return new_reference;
|
return new_reference;
|
||||||
@@ -716,14 +737,14 @@ RDIC_Node_Reference gui_dumb_block(
|
|||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
bool gui_dumb_button(
|
bool gui_dumb_button(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference *last_reference,
|
GUI_Node_Reference *last_reference,
|
||||||
GUI_String text,
|
GUI_String text,
|
||||||
GUI_Style *style,
|
GUI_Style *style,
|
||||||
GUI_Size size[static 2])
|
GUI_Size size[static 2])
|
||||||
{
|
{
|
||||||
RDIC_Node_Reference new_reference = gui_get_node(
|
GUI_Node_Reference new_reference = gui_get_node(
|
||||||
context, *last_reference, GUI_LAYOUT_NONE, style, size);
|
context, *last_reference, GUI_LAYOUT_NONE, style, size);
|
||||||
GUI_Node *node = (GUI_Node*)new_reference.node;
|
GUI_Node *node = new_reference.node;
|
||||||
node->debug_string = text;
|
node->debug_string = text;
|
||||||
node->text_string = text;
|
node->text_string = text;
|
||||||
|
|
||||||
@@ -763,14 +784,14 @@ bool gui_dumb_button(
|
|||||||
#define ENABLE_DEBUG 0
|
#define ENABLE_DEBUG 0
|
||||||
bool gui_slider(
|
bool gui_slider(
|
||||||
GUI_Context *context,
|
GUI_Context *context,
|
||||||
RDIC_Node_Reference *last_reference,
|
GUI_Node_Reference *last_reference,
|
||||||
RDIC_Node_Reference *inner_box_reference,
|
GUI_Node_Reference *inner_box_reference,
|
||||||
float *value,
|
float *value,
|
||||||
GUI_Style *background_style,
|
GUI_Style *background_style,
|
||||||
GUI_Style *bar_style,
|
GUI_Style *bar_style,
|
||||||
GUI_Size size[static 2])
|
GUI_Size size[static 2])
|
||||||
{
|
{
|
||||||
RDIC_Node_Reference new_reference = gui_get_node(
|
GUI_Node_Reference new_reference = gui_get_node(
|
||||||
context, *last_reference, GUI_LAYOUT_NONE, background_style, size);
|
context, *last_reference, GUI_LAYOUT_NONE, background_style, size);
|
||||||
GUI_Node *node = (GUI_Node*)new_reference.node;
|
GUI_Node *node = (GUI_Node*)new_reference.node;
|
||||||
node->debug_string = GUI_STRING("gui_slider");
|
node->debug_string = GUI_STRING("gui_slider");
|
||||||
@@ -778,7 +799,7 @@ bool gui_slider(
|
|||||||
|
|
||||||
// NOTE(Zelaven): We need a handle to this node, but we set its values later.
|
// NOTE(Zelaven): We need a handle to this node, but we set its values later.
|
||||||
gui_push_parent(context, new_reference);
|
gui_push_parent(context, new_reference);
|
||||||
RDIC_Node_Reference new_inner_reference = gui_get_node(
|
GUI_Node_Reference new_inner_reference = gui_get_node(
|
||||||
context, *inner_box_reference, GUI_LAYOUT_NONE, bar_style, size);
|
context, *inner_box_reference, GUI_LAYOUT_NONE, bar_style, size);
|
||||||
|
|
||||||
bool value_changed = false;
|
bool value_changed = false;
|
||||||
@@ -886,7 +907,7 @@ void test_gui(
|
|||||||
{GUI_SIZERULE_PIXELS, 24, 100}};
|
{GUI_SIZERULE_PIXELS, 24, 100}};
|
||||||
static GUI_Style other_dumb_button_style = {24, 42, 88, 0x0000ffff,0,0};
|
static GUI_Style other_dumb_button_style = {24, 42, 88, 0x0000ffff,0,0};
|
||||||
|
|
||||||
static RDIC_Node_Reference root = {0};
|
static GUI_Node_Reference root = {0};
|
||||||
root = gui_context_start_frame(
|
root = gui_context_start_frame(
|
||||||
context, root,
|
context, root,
|
||||||
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
||||||
@@ -894,7 +915,7 @@ void test_gui(
|
|||||||
GUI_LAYOUT_HORIZONTAL,
|
GUI_LAYOUT_HORIZONTAL,
|
||||||
&root_style);
|
&root_style);
|
||||||
|
|
||||||
static RDIC_Node_Reference dumb_button = {0};
|
static GUI_Node_Reference dumb_button = {0};
|
||||||
if(my_bool)
|
if(my_bool)
|
||||||
if(gui_dumb_button(
|
if(gui_dumb_button(
|
||||||
context,
|
context,
|
||||||
@@ -913,7 +934,7 @@ void test_gui(
|
|||||||
my_bool = false;
|
my_bool = false;
|
||||||
((GUI_Node*)root.node)->dirty = true;
|
((GUI_Node*)root.node)->dirty = true;
|
||||||
}
|
}
|
||||||
static RDIC_Node_Reference dumb_button2 = {0};
|
static GUI_Node_Reference dumb_button2 = {0};
|
||||||
if(gui_dumb_button(
|
if(gui_dumb_button(
|
||||||
context,
|
context,
|
||||||
&dumb_button2,
|
&dumb_button2,
|
||||||
@@ -938,7 +959,7 @@ void test_gui(
|
|||||||
static GUI_Size layout_size[2] = {
|
static GUI_Size layout_size[2] = {
|
||||||
{GUI_SIZERULE_PIXELS, 400, 100},
|
{GUI_SIZERULE_PIXELS, 400, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 400, 100}};
|
{GUI_SIZERULE_PIXELS, 400, 100}};
|
||||||
static RDIC_Node_Reference layout = {0};
|
static GUI_Node_Reference layout = {0};
|
||||||
layout = gui_layout(
|
layout = gui_layout(
|
||||||
context, layout, GUI_LAYOUT_VERTICAL, &layout_style, layout_size);
|
context, layout, GUI_LAYOUT_VERTICAL, &layout_style, layout_size);
|
||||||
gui_push_parent(context, layout);
|
gui_push_parent(context, layout);
|
||||||
@@ -949,25 +970,25 @@ void test_gui(
|
|||||||
static GUI_Style inner_block_2_style = {200, 253, 235, 0,0,0};
|
static GUI_Style inner_block_2_style = {200, 253, 235, 0,0,0};
|
||||||
static GUI_Style inner_block_3_style = {235, 253, 200, 0,0,0};
|
static GUI_Style inner_block_3_style = {235, 253, 200, 0,0,0};
|
||||||
static GUI_Style inner_block_4_style = {0 , 0, 0, 0,0,0};
|
static GUI_Style inner_block_4_style = {0 , 0, 0, 0,0,0};
|
||||||
static RDIC_Node_Reference dumb_block2 = {0};
|
static GUI_Node_Reference dumb_block2 = {0};
|
||||||
dumb_block2 = gui_dumb_block(
|
dumb_block2 = gui_dumb_block(
|
||||||
context,
|
context,
|
||||||
dumb_block2,
|
dumb_block2,
|
||||||
&inner_block_2_style,
|
&inner_block_2_style,
|
||||||
dumb_button_size);
|
dumb_button_size);
|
||||||
static RDIC_Node_Reference dumb_block3 = {0};
|
static GUI_Node_Reference dumb_block3 = {0};
|
||||||
dumb_block3 = gui_dumb_block(
|
dumb_block3 = gui_dumb_block(
|
||||||
context,
|
context,
|
||||||
dumb_block3,
|
dumb_block3,
|
||||||
&inner_block_3_style,
|
&inner_block_3_style,
|
||||||
dumb_button_size);
|
dumb_button_size);
|
||||||
static RDIC_Node_Reference dumb_block4 = {0};
|
static GUI_Node_Reference dumb_block4 = {0};
|
||||||
dumb_block4 = gui_dumb_block(
|
dumb_block4 = gui_dumb_block(
|
||||||
context,
|
context,
|
||||||
dumb_block4,
|
dumb_block4,
|
||||||
&inner_block_4_style,
|
&inner_block_4_style,
|
||||||
dumb_button_size);
|
dumb_button_size);
|
||||||
static RDIC_Node_Reference dumb_button3 = {0};
|
static GUI_Node_Reference dumb_button3 = {0};
|
||||||
if(gui_dumb_button(
|
if(gui_dumb_button(
|
||||||
context,
|
context,
|
||||||
&dumb_button3,
|
&dumb_button3,
|
||||||
@@ -984,7 +1005,7 @@ void test_gui(
|
|||||||
static GUI_Size dumb_block5_size[2] = {
|
static GUI_Size dumb_block5_size[2] = {
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 42, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 42, 100},
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 24, 100}};
|
{GUI_SIZERULE_PERCENTOFPARENT, 24, 100}};
|
||||||
static RDIC_Node_Reference dumb_block5 = {0};
|
static GUI_Node_Reference dumb_block5 = {0};
|
||||||
dumb_block5 = gui_dumb_block(
|
dumb_block5 = gui_dumb_block(
|
||||||
context,
|
context,
|
||||||
dumb_block5,
|
dumb_block5,
|
||||||
@@ -998,8 +1019,8 @@ void test_gui(
|
|||||||
static GUI_Size slider_size[2] = {
|
static GUI_Size slider_size[2] = {
|
||||||
{GUI_SIZERULE_PIXELS, 100, 100},
|
{GUI_SIZERULE_PIXELS, 100, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 40, 100}};
|
{GUI_SIZERULE_PIXELS, 40, 100}};
|
||||||
static RDIC_Node_Reference slider = {0};
|
static GUI_Node_Reference slider = {0};
|
||||||
static RDIC_Node_Reference slider_inner = {0};
|
static GUI_Node_Reference slider_inner = {0};
|
||||||
static float slider_value = 0.25f;
|
static float slider_value = 0.25f;
|
||||||
//slider_bar.blue = 255 * slider_value;
|
//slider_bar.blue = 255 * slider_value;
|
||||||
//slider_value += 0.01f;
|
//slider_value += 0.01f;
|
||||||
@@ -1025,7 +1046,7 @@ void test_gui(
|
|||||||
static GUI_Size block_after_layout_size[2] = {
|
static GUI_Size block_after_layout_size[2] = {
|
||||||
{GUI_SIZERULE_PIXELS, 50, 100},
|
{GUI_SIZERULE_PIXELS, 50, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 50, 100}};
|
{GUI_SIZERULE_PIXELS, 50, 100}};
|
||||||
static RDIC_Node_Reference dumb_block_after_layout = {0};
|
static GUI_Node_Reference dumb_block_after_layout = {0};
|
||||||
dumb_block_after_layout = gui_dumb_block(
|
dumb_block_after_layout = gui_dumb_block(
|
||||||
context,
|
context,
|
||||||
dumb_block_after_layout,
|
dumb_block_after_layout,
|
||||||
@@ -1038,7 +1059,7 @@ void test_gui(
|
|||||||
{GUI_SIZERULE_PIXELS, 100, 100},
|
{GUI_SIZERULE_PIXELS, 100, 100},
|
||||||
};
|
};
|
||||||
my_style.border_thickness = border_thickness;
|
my_style.border_thickness = border_thickness;
|
||||||
static RDIC_Node_Reference new_style_gui_dumb_block = {0};
|
static GUI_Node_Reference new_style_gui_dumb_block = {0};
|
||||||
new_style_gui_dumb_block = gui_dumb_block(
|
new_style_gui_dumb_block = gui_dumb_block(
|
||||||
context,
|
context,
|
||||||
new_style_gui_dumb_block,
|
new_style_gui_dumb_block,
|
||||||
@@ -1071,7 +1092,7 @@ void test_gui__calculator(
|
|||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 25, 100}};
|
{GUI_SIZERULE_PERCENTOFPARENT, 25, 100}};
|
||||||
|
|
||||||
static RDIC_Node_Reference root = {0};
|
static GUI_Node_Reference root = {0};
|
||||||
root = gui_context_start_frame(
|
root = gui_context_start_frame(
|
||||||
context, root,
|
context, root,
|
||||||
//full_gui_rectangle.x1-full_gui_rectangle.x0,
|
//full_gui_rectangle.x1-full_gui_rectangle.x0,
|
||||||
@@ -1081,8 +1102,8 @@ void test_gui__calculator(
|
|||||||
&root_style);
|
&root_style);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
static RDIC_Node_Reference rows[4] = {0};
|
static GUI_Node_Reference rows[4] = {0};
|
||||||
static RDIC_Node_Reference buttons[4][4] = {0};
|
static GUI_Node_Reference buttons[4][4] = {0};
|
||||||
GUI_String button_labels[4][4] = {
|
GUI_String button_labels[4][4] = {
|
||||||
{GUI_STRING("1"), GUI_STRING("2"), GUI_STRING("3"), GUI_STRING("+")},
|
{GUI_STRING("1"), GUI_STRING("2"), GUI_STRING("3"), GUI_STRING("+")},
|
||||||
{GUI_STRING("4"), GUI_STRING("5"), GUI_STRING("6"), GUI_STRING("-")},
|
{GUI_STRING("4"), GUI_STRING("5"), GUI_STRING("6"), GUI_STRING("-")},
|
||||||
@@ -1108,11 +1129,11 @@ void test_gui__calculator(
|
|||||||
gui_pop_parent(context);
|
gui_pop_parent(context);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static RDIC_Node_Reference row1 = {0};
|
static GUI_Node_Reference row1 = {0};
|
||||||
row1 = gui_layout2(
|
row1 = gui_layout2(
|
||||||
context, row1, GUI_LAYOUT_HORIZONTAL, &row_style, row_size);
|
context, row1, GUI_LAYOUT_HORIZONTAL, &row_style, row_size);
|
||||||
gui_push_parent(context, row1);
|
gui_push_parent(context, row1);
|
||||||
static RDIC_Node_Reference row1_buttons[4] = {0};
|
static GUI_Node_Reference row1_buttons[4] = {0};
|
||||||
char *row1_button_labels[4] = {"1", "2", "3", "+"};
|
char *row1_button_labels[4] = {"1", "2", "3", "+"};
|
||||||
for(size_t i = 0; i < ARRAYLENGTH(row1_buttons); i++)
|
for(size_t i = 0; i < ARRAYLENGTH(row1_buttons); i++)
|
||||||
{
|
{
|
||||||
@@ -1157,7 +1178,7 @@ void test_gui__scrollbars(
|
|||||||
{GUI_SIZERULE_PERCENTOFPARENT, 50, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 50, 100},
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}};
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}};
|
||||||
|
|
||||||
static RDIC_Node_Reference root = {0};
|
static GUI_Node_Reference root = {0};
|
||||||
root = gui_context_start_frame(
|
root = gui_context_start_frame(
|
||||||
context, root,
|
context, root,
|
||||||
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
||||||
@@ -1167,23 +1188,23 @@ void test_gui__scrollbars(
|
|||||||
&root_style);
|
&root_style);
|
||||||
|
|
||||||
|
|
||||||
static RDIC_Node_Reference top = {0};
|
static GUI_Node_Reference top = {0};
|
||||||
static RDIC_Node_Reference middle = {0};
|
static GUI_Node_Reference middle = {0};
|
||||||
static RDIC_Node_Reference bottom = {0};
|
static GUI_Node_Reference bottom = {0};
|
||||||
|
|
||||||
top = gui_dumb_block(context, top, &outer_style, top_bottom_size);
|
top = gui_dumb_block(context, top, &outer_style, top_bottom_size);
|
||||||
|
|
||||||
middle = gui_layout(
|
middle = gui_layout(
|
||||||
context, middle, GUI_LAYOUT_HORIZONTAL, &outer_style, middle_size);
|
context, middle, GUI_LAYOUT_HORIZONTAL, &outer_style, middle_size);
|
||||||
gui_push_parent(context, middle); {
|
gui_push_parent(context, middle); {
|
||||||
static RDIC_Node_Reference left = {0};
|
static GUI_Node_Reference left = {0};
|
||||||
static RDIC_Node_Reference center = {0};
|
static GUI_Node_Reference center = {0};
|
||||||
static RDIC_Node_Reference right = {0};
|
static GUI_Node_Reference right = {0};
|
||||||
|
|
||||||
left = gui_dumb_block(context, left, &outer_style, side_size);
|
left = gui_dumb_block(context, left, &outer_style, side_size);
|
||||||
center = gui_dumb_block(context, center, &outer_style, center_size);
|
center = gui_dumb_block(context, center, &outer_style, center_size);
|
||||||
gui_push_parent(context, center); {
|
gui_push_parent(context, center); {
|
||||||
static RDIC_Node_Reference scrollbox_layout = {0};
|
static GUI_Node_Reference scrollbox_layout = {0};
|
||||||
static GUI_Size full_size[2] = {
|
static GUI_Size full_size[2] = {
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}};
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}};
|
||||||
@@ -1191,8 +1212,8 @@ void test_gui__scrollbars(
|
|||||||
context, scrollbox_layout, GUI_LAYOUT_HORIZONTAL, &outer_style, full_size);
|
context, scrollbox_layout, GUI_LAYOUT_HORIZONTAL, &outer_style, full_size);
|
||||||
|
|
||||||
gui_push_parent(context, scrollbox_layout); {
|
gui_push_parent(context, scrollbox_layout); {
|
||||||
static RDIC_Node_Reference scrollregion_layout = {0};
|
static GUI_Node_Reference scrollregion_layout = {0};
|
||||||
static RDIC_Node_Reference scrollbar_layout = {0};
|
static GUI_Node_Reference scrollbar_layout = {0};
|
||||||
static GUI_Size scrollregion_size[2] = {
|
static GUI_Size scrollregion_size[2] = {
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 90, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 90, 100},
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}};
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}};
|
||||||
@@ -1203,7 +1224,7 @@ void test_gui__scrollbars(
|
|||||||
context, scrollregion_layout, GUI_LAYOUT_VERTICAL,
|
context, scrollregion_layout, GUI_LAYOUT_VERTICAL,
|
||||||
&outer_style, scrollregion_size);
|
&outer_style, scrollregion_size);
|
||||||
gui_push_parent(context, scrollregion_layout); {
|
gui_push_parent(context, scrollregion_layout); {
|
||||||
static RDIC_Node_Reference elements[6] = {0};
|
static GUI_Node_Reference elements[6] = {0};
|
||||||
for(size_t i = 0; i < ARRAYLENGTH(elements); i++)
|
for(size_t i = 0; i < ARRAYLENGTH(elements); i++)
|
||||||
{
|
{
|
||||||
elements[i] = gui_dumb_block(
|
elements[i] = gui_dumb_block(
|
||||||
@@ -1231,9 +1252,9 @@ void test_gui__scrollbars(
|
|||||||
bar_upper_spacer_size[GUI_AXIS2_Y].value = spacer_upper;
|
bar_upper_spacer_size[GUI_AXIS2_Y].value = spacer_upper;
|
||||||
bar_lower_spacer_size[GUI_AXIS2_Y].value = spacer_lower;
|
bar_lower_spacer_size[GUI_AXIS2_Y].value = spacer_lower;
|
||||||
|
|
||||||
static RDIC_Node_Reference scrollbar_upper_spacer = {0};
|
static GUI_Node_Reference scrollbar_upper_spacer = {0};
|
||||||
static RDIC_Node_Reference scrollbar_knob = {0};
|
static GUI_Node_Reference scrollbar_knob = {0};
|
||||||
static RDIC_Node_Reference scrollbar_lower_spacer = {0};
|
static GUI_Node_Reference scrollbar_lower_spacer = {0};
|
||||||
scrollbar_upper_spacer = gui_dumb_block(
|
scrollbar_upper_spacer = gui_dumb_block(
|
||||||
context, scrollbar_upper_spacer, &outer_style, bar_upper_spacer_size);
|
context, scrollbar_upper_spacer, &outer_style, bar_upper_spacer_size);
|
||||||
scrollbar_knob = gui_dumb_block(
|
scrollbar_knob = gui_dumb_block(
|
||||||
@@ -1267,7 +1288,7 @@ void test_gui__draw_command_using_sliders(
|
|||||||
//static float border_thickness = 0;
|
//static float border_thickness = 0;
|
||||||
|
|
||||||
static GUI_Style root_style = {42, 24, 88, 0,0,0};
|
static GUI_Style root_style = {42, 24, 88, 0,0,0};
|
||||||
static RDIC_Node_Reference root = {0};
|
static GUI_Node_Reference root = {0};
|
||||||
root = gui_context_start_frame(
|
root = gui_context_start_frame(
|
||||||
context, root,
|
context, root,
|
||||||
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
||||||
@@ -1278,7 +1299,7 @@ void test_gui__draw_command_using_sliders(
|
|||||||
static GUI_Size layout_size[2] = {
|
static GUI_Size layout_size[2] = {
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
||||||
{GUI_SIZERULE_PERCENTOFPARENT, 50, 100}};
|
{GUI_SIZERULE_PERCENTOFPARENT, 50, 100}};
|
||||||
static RDIC_Node_Reference layout = {0};
|
static GUI_Node_Reference layout = {0};
|
||||||
layout = gui_layout(
|
layout = gui_layout(
|
||||||
context, layout, GUI_LAYOUT_VERTICAL, &root_style, layout_size);
|
context, layout, GUI_LAYOUT_VERTICAL, &root_style, layout_size);
|
||||||
gui_push_parent(context, layout);
|
gui_push_parent(context, layout);
|
||||||
@@ -1288,8 +1309,8 @@ void test_gui__draw_command_using_sliders(
|
|||||||
static GUI_Size slider_size[2] = {
|
static GUI_Size slider_size[2] = {
|
||||||
{GUI_SIZERULE_PIXELS, 200, 100},
|
{GUI_SIZERULE_PIXELS, 200, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 40, 100}};
|
{GUI_SIZERULE_PIXELS, 40, 100}};
|
||||||
static RDIC_Node_Reference slider = {0};
|
static GUI_Node_Reference slider = {0};
|
||||||
static RDIC_Node_Reference slider_inner = {0};
|
static GUI_Node_Reference slider_inner = {0};
|
||||||
|
|
||||||
static GUI_Style button_style = {200, 0, 0, 0,5,0};
|
static GUI_Style button_style = {200, 0, 0, 0,5,0};
|
||||||
static GUI_Size button_size[2] = {
|
static GUI_Size button_size[2] = {
|
||||||
@@ -1310,7 +1331,7 @@ void test_gui__draw_command_using_sliders(
|
|||||||
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 40, 100}};
|
{GUI_SIZERULE_PIXELS, 40, 100}};
|
||||||
|
|
||||||
static RDIC_Node_Reference row1_layout = {0};
|
static GUI_Node_Reference row1_layout = {0};
|
||||||
row1_layout = gui_layout(
|
row1_layout = gui_layout(
|
||||||
context, row1_layout, GUI_LAYOUT_HORIZONTAL, &root_style, row_layout_size);
|
context, row1_layout, GUI_LAYOUT_HORIZONTAL, &root_style, row_layout_size);
|
||||||
#if 1
|
#if 1
|
||||||
@@ -1327,11 +1348,11 @@ void test_gui__draw_command_using_sliders(
|
|||||||
&slider_value, &slider_background, &slider_bar, slider_size);
|
&slider_value, &slider_background, &slider_bar, slider_size);
|
||||||
border_thickness = 51.*slider_value;
|
border_thickness = 51.*slider_value;
|
||||||
|
|
||||||
static RDIC_Node_Reference spacer1 = {0};
|
static GUI_Node_Reference spacer1 = {0};
|
||||||
spacer1 = gui_dumb_block(
|
spacer1 = gui_dumb_block(
|
||||||
context, spacer1, &button_spacer_style, button_spacer_size);
|
context, spacer1, &button_spacer_style, button_spacer_size);
|
||||||
|
|
||||||
static RDIC_Node_Reference button_thickness_down = {0};
|
static GUI_Node_Reference button_thickness_down = {0};
|
||||||
if(gui_dumb_button(context, &button_thickness_down,
|
if(gui_dumb_button(context, &button_thickness_down,
|
||||||
GUI_STRING("-"), &button_style, button_size))
|
GUI_STRING("-"), &button_style, button_size))
|
||||||
{
|
{
|
||||||
@@ -1339,11 +1360,11 @@ void test_gui__draw_command_using_sliders(
|
|||||||
printf("-\n");
|
printf("-\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static RDIC_Node_Reference spacer2 = {0};
|
static GUI_Node_Reference spacer2 = {0};
|
||||||
spacer2 = gui_dumb_block(
|
spacer2 = gui_dumb_block(
|
||||||
context, spacer2, &button_spacer_style, button_spacer_size);
|
context, spacer2, &button_spacer_style, button_spacer_size);
|
||||||
|
|
||||||
static RDIC_Node_Reference button_thickness_up = {0};
|
static GUI_Node_Reference button_thickness_up = {0};
|
||||||
if(gui_dumb_button(context, &button_thickness_up,
|
if(gui_dumb_button(context, &button_thickness_up,
|
||||||
GUI_STRING("+"), &button_style, button_size))
|
GUI_STRING("+"), &button_style, button_size))
|
||||||
{
|
{
|
||||||
@@ -1354,12 +1375,12 @@ void test_gui__draw_command_using_sliders(
|
|||||||
gui_pop_parent(context);
|
gui_pop_parent(context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static RDIC_Node_Reference slider_spacer = {0};
|
static GUI_Node_Reference slider_spacer = {0};
|
||||||
slider_spacer = gui_dumb_block(
|
slider_spacer = gui_dumb_block(
|
||||||
context, slider_spacer, &slider_spacer_style, slider_spacer_size);
|
context, slider_spacer, &slider_spacer_style, slider_spacer_size);
|
||||||
|
|
||||||
static RDIC_Node_Reference slider2 = {0};
|
static GUI_Node_Reference slider2 = {0};
|
||||||
static RDIC_Node_Reference slider2_inner = {0};
|
static GUI_Node_Reference slider2_inner = {0};
|
||||||
static float slider2_value = 0.25f;
|
static float slider2_value = 0.25f;
|
||||||
slider2_value = ((float)roundedness) / 100.;
|
slider2_value = ((float)roundedness) / 100.;
|
||||||
gui_slider(context, &slider2, &slider2_inner,
|
gui_slider(context, &slider2, &slider2_inner,
|
||||||
@@ -1393,7 +1414,7 @@ void test_gui__subtree(
|
|||||||
{GUI_SIZERULE_PIXELS, 200, 100},
|
{GUI_SIZERULE_PIXELS, 200, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 600, 100}};
|
{GUI_SIZERULE_PIXELS, 600, 100}};
|
||||||
|
|
||||||
static RDIC_Node_Reference root = {0};
|
static GUI_Node_Reference root = {0};
|
||||||
root = gui_context_start_frame(
|
root = gui_context_start_frame(
|
||||||
context, root,
|
context, root,
|
||||||
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
full_gui_rectangle.x1-full_gui_rectangle.x0,
|
||||||
@@ -1402,11 +1423,11 @@ void test_gui__subtree(
|
|||||||
&root_style);
|
&root_style);
|
||||||
|
|
||||||
|
|
||||||
static RDIC_Node_Reference top = {0};
|
static GUI_Node_Reference top = {0};
|
||||||
static RDIC_Node_Reference middle = {0};
|
static GUI_Node_Reference middle = {0};
|
||||||
static RDIC_Node_Reference bottom = {0};
|
static GUI_Node_Reference bottom = {0};
|
||||||
|
|
||||||
static RDIC_Node_Reference slider = {0};
|
static GUI_Node_Reference slider = {0};
|
||||||
static float slider_value = 0.25f;
|
static float slider_value = 0.25f;
|
||||||
top = gui_layout(
|
top = gui_layout(
|
||||||
context, top, GUI_LAYOUT_HORIZONTAL, &outer_style, top_bottom_size);
|
context, top, GUI_LAYOUT_HORIZONTAL, &outer_style, top_bottom_size);
|
||||||
@@ -1417,8 +1438,8 @@ void test_gui__subtree(
|
|||||||
static GUI_Size slider_size[2] = {
|
static GUI_Size slider_size[2] = {
|
||||||
{GUI_SIZERULE_PIXELS, 200, 100},
|
{GUI_SIZERULE_PIXELS, 200, 100},
|
||||||
{GUI_SIZERULE_PIXELS, 40, 100}};
|
{GUI_SIZERULE_PIXELS, 40, 100}};
|
||||||
//static RDIC_Node_Reference slider = {0};
|
//static GUI_Node_Reference slider = {0};
|
||||||
static RDIC_Node_Reference slider_inner = {0};
|
static GUI_Node_Reference slider_inner = {0};
|
||||||
// NOTE(Zelaven): This line is not good because it causes jankyness when
|
// NOTE(Zelaven): This line is not good because it causes jankyness when
|
||||||
// using the slider, and the slider behaves properly without it.
|
// using the slider, and the slider behaves properly without it.
|
||||||
// NOTE(Zelaven): This line is actually necessary if the value is writable
|
// NOTE(Zelaven): This line is actually necessary if the value is writable
|
||||||
@@ -1431,7 +1452,7 @@ void test_gui__subtree(
|
|||||||
middle = gui_dumb_block(context, middle, &outer_style, middle_size);
|
middle = gui_dumb_block(context, middle, &outer_style, middle_size);
|
||||||
|
|
||||||
static GUI_Subtree middle_subtree = {0};
|
static GUI_Subtree middle_subtree = {0};
|
||||||
static RDIC_Node_Reference middle_subtree_root = {0};
|
static GUI_Node_Reference middle_subtree_root = {0};
|
||||||
middle_subtree_root = gui_push_subtree(
|
middle_subtree_root = gui_push_subtree(
|
||||||
context, &middle_subtree, middle_subtree_root,
|
context, &middle_subtree, middle_subtree_root,
|
||||||
GUI_LAYOUT_VERTICAL, &element_style, test_size, middle);
|
GUI_LAYOUT_VERTICAL, &element_style, test_size, middle);
|
||||||
@@ -1453,7 +1474,7 @@ void test_gui__subtree(
|
|||||||
.width = 10,
|
.width = 10,
|
||||||
.height = 10,
|
.height = 10,
|
||||||
};
|
};
|
||||||
static RDIC_Node_Reference inner_top = {0};
|
static GUI_Node_Reference inner_top = {0};
|
||||||
inner_top = gui_dumb_block(context, inner_top, &outer_style, element_size);
|
inner_top = gui_dumb_block(context, inner_top, &outer_style, element_size);
|
||||||
((GUI_Node*)inner_top.node)->image = &test_image;
|
((GUI_Node*)inner_top.node)->image = &test_image;
|
||||||
} gui_pop_subtree(context);
|
} gui_pop_subtree(context);
|
||||||
|
|||||||
Reference in new issue
Block a user