|
|
@ -266,8 +266,7 @@ typedef struct { |
|
|
|
#if 1 |
|
|
|
void print_node_tree(GUI_Node *node, int level) |
|
|
|
{ |
|
|
|
for(int i = 0; i < level; i++) |
|
|
|
{ |
|
|
|
for(int i = 0; i < level; i++) { |
|
|
|
printf("-"); |
|
|
|
} |
|
|
|
|
|
|
@ -278,13 +277,33 @@ void print_node_tree(GUI_Node *node, int level) |
|
|
|
printf("\n"); |
|
|
|
|
|
|
|
GUI_Node *child = GUI_NODE_FIRST_CHILD(node); |
|
|
|
while(child != NULL) |
|
|
|
{ |
|
|
|
while(child != NULL) { |
|
|
|
print_node_tree(child, level+1); |
|
|
|
child = GUI_NODE_SIBLING(child); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#if 1 |
|
|
|
void print_subtree_tree(GUI_Subtree *node, int level, bool print_nodes) |
|
|
|
{ |
|
|
|
for(int i = 0; i < level; i++) { |
|
|
|
printf("="); |
|
|
|
} |
|
|
|
|
|
|
|
printf(" (%p)", node); |
|
|
|
printf("\n"); |
|
|
|
|
|
|
|
if(print_nodes) { |
|
|
|
print_node_tree((GUI_Node*)node->rdic.root, level+1); |
|
|
|
} |
|
|
|
|
|
|
|
GUI_Subtree *child = GUI_SUBTREE_FIRST_CHILD(node); |
|
|
|
while(child != NULL) { |
|
|
|
print_subtree_tree(child, level+1, print_nodes); |
|
|
|
child = GUI_SUBTREE_SIBLING(child); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// ---
|
|
|
|
|
|
|
@ -463,7 +482,11 @@ GUI_Node_Reference gui_get_node( |
|
|
|
return (GUI_Node_Reference){0}; |
|
|
|
} |
|
|
|
GUI_Subtree *current_subtree = |
|
|
|
(GUI_Subtree*)current_layer->subtree_rdic.frame_current_node; |
|
|
|
//(GUI_Subtree*)current_layer->subtree_rdic.frame_current_node;
|
|
|
|
// TODO(Zelaven): This has to do with me always pushing the newest subtree
|
|
|
|
// as a parent, which honestly doesn't sound ideal to me. I should look
|
|
|
|
// into what what my options are.
|
|
|
|
(GUI_Subtree*)current_layer->subtree_rdic.current_parent; |
|
|
|
int get_node_flags = 0; |
|
|
|
GUI_Node_Reference new_reference = { |
|
|
|
.rdic_ref = rdic_get_node( |
|
|
@ -1614,7 +1637,7 @@ void test_gui__subtree( |
|
|
|
GUI_Context *context, |
|
|
|
GUI_Rectangle full_gui_rectangle) |
|
|
|
{ |
|
|
|
static GUI_Style root_style = {0x44,0x44,0x44, 0x00999999,2,0}; |
|
|
|
static GUI_Style root_style = {0x44,0x33,0x33, 0x00999999,2,0}; |
|
|
|
static GUI_Style element_style = {0,0x33,0x33, 0x00009999,2,0}; |
|
|
|
static GUI_Size element_size[2] = { |
|
|
|
{GUI_SIZERULE_PERCENTOFPARENT, 100, 100}, |
|
|
@ -1645,6 +1668,8 @@ void test_gui__subtree( |
|
|
|
|
|
|
|
static GUI_Node_Reference slider = {0}; |
|
|
|
static float slider_value = 0.25f; |
|
|
|
bool should_dirty = false; |
|
|
|
bool set_pixels = false; |
|
|
|
top = gui_layout( |
|
|
|
context, top, GUI_LAYOUT_HORIZONTAL, &outer_style, top_bottom_size); |
|
|
|
gui_push_parent(context, top); |
|
|
@ -1663,10 +1688,31 @@ void test_gui__subtree( |
|
|
|
// variable, then there is no issue, though.
|
|
|
|
gui_slider(context, &slider, &slider_inner, |
|
|
|
&slider_value, &slider_background, &slider_bar, slider_size); |
|
|
|
|
|
|
|
static GUI_Node_Reference dirty_button = {0}; |
|
|
|
static GUI_Style button_style = {0x99,0x99,0x99, 0x00222222,2,0}; |
|
|
|
static GUI_Size button_size[2] = { |
|
|
|
{GUI_SIZERULE_PIXELS, 200, 100}, |
|
|
|
{GUI_SIZERULE_PIXELS, 40, 100}}; |
|
|
|
if(gui_dumb_button( |
|
|
|
context, &dirty_button, GUI_STRING("Dirty middle"), |
|
|
|
&button_style, button_size)) |
|
|
|
{ |
|
|
|
should_dirty = true; |
|
|
|
} |
|
|
|
static GUI_Node_Reference dirty_button2 = {0}; |
|
|
|
if(gui_dumb_button( |
|
|
|
context, &dirty_button2, GUI_STRING("Set Pixels"), |
|
|
|
&button_style, button_size)) |
|
|
|
{ |
|
|
|
set_pixels = true; |
|
|
|
printf("Setting pixels.\n"); |
|
|
|
} |
|
|
|
} gui_pop_parent(context); // middle.
|
|
|
|
|
|
|
|
middle = gui_dumb_block(context, middle, &outer_style, middle_size); |
|
|
|
|
|
|
|
#if 1 |
|
|
|
static GUI_Subtree_Reference middle_subtree = {0}; |
|
|
|
middle_subtree = gui_get_subtree(context, middle_subtree); |
|
|
|
static GUI_Node_Reference middle_subtree_root = {0}; |
|
|
@ -1695,6 +1741,7 @@ void test_gui__subtree( |
|
|
|
inner_top = gui_dumb_block(context, inner_top, &outer_style, element_size); |
|
|
|
((GUI_Node*)inner_top.node)->image = &test_image; |
|
|
|
} gui_pop_subtree(context); |
|
|
|
#endif |
|
|
|
#if 0 |
|
|
|
int middle_height = |
|
|
|
((GUI_Node*)middle.node)->computed_size[GUI_AXIS2_Y]; |
|
|
@ -1713,20 +1760,73 @@ void test_gui__subtree( |
|
|
|
middle_subtree.flat_offset_y = 0; |
|
|
|
} |
|
|
|
#else |
|
|
|
printf("slider value: %f\n", slider_value); |
|
|
|
//printf("slider value: %f\n", slider_value);
|
|
|
|
middle_subtree.node->offset_relative_node_percentage_y = slider_value*100; |
|
|
|
middle_subtree.node->offset_own_size_percentage_y = slider_value*-100; |
|
|
|
#endif |
|
|
|
((GUI_Node*)middle_subtree_root.node)->dirty = ((GUI_Node*)slider.node)->dirty; |
|
|
|
|
|
|
|
bottom = gui_dumb_block(context, bottom, &outer_style, top_bottom_size); |
|
|
|
bottom = gui_dumb_block(context, bottom, &element_style, top_bottom_size); |
|
|
|
|
|
|
|
middle.node->dirty |= should_dirty; |
|
|
|
|
|
|
|
if(set_pixels) |
|
|
|
{ |
|
|
|
#define SET_PIXEL(pixel_buffer, x, y, color) (pixel_buffer)->pixels[(y)*(pixel_buffer)->width + (x)] = (color) |
|
|
|
Pixel_Buffer *pixbuf = context->background_layer.pixel_buffer; |
|
|
|
SET_PIXEL(pixbuf, 500, 500, 0x00ff0000); |
|
|
|
SET_PIXEL(pixbuf, 500, 501, 0); |
|
|
|
SET_PIXEL(pixbuf, 501, 500, 0); |
|
|
|
SET_PIXEL(pixbuf, 501, 501, 0); |
|
|
|
|
|
|
|
SET_PIXEL(pixbuf, 500, 900, 0x00ff0000); |
|
|
|
SET_PIXEL(pixbuf, 500, 901, 0); |
|
|
|
SET_PIXEL(pixbuf, 501, 900, 0); |
|
|
|
SET_PIXEL(pixbuf, 501, 901, 0); |
|
|
|
#undef SET_PIXEL |
|
|
|
} |
|
|
|
|
|
|
|
gui_context_finish_frame(context); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
void test_gui__tmp( |
|
|
|
GUI_Context *context, |
|
|
|
GUI_Rectangle full_gui_rectangle) |
|
|
|
{ |
|
|
|
static GUI_Style root_style = {0x44,0x33,0x33, 0x00999999,2,0}; |
|
|
|
static GUI_Style block_style = {0x33,0x33,0x33, 0x00999999,2,0}; |
|
|
|
static GUI_Size block_size[2] = { |
|
|
|
{GUI_SIZERULE_PIXELS, 200, 100}, |
|
|
|
{GUI_SIZERULE_PIXELS, 200, 100}}; |
|
|
|
|
|
|
|
static GUI_Node_Reference root = {0}; |
|
|
|
root = gui_context_start_frame( |
|
|
|
context, root, |
|
|
|
full_gui_rectangle.x1-full_gui_rectangle.x0, |
|
|
|
full_gui_rectangle.y1-full_gui_rectangle.y0, |
|
|
|
GUI_LAYOUT_VERTICAL, |
|
|
|
&root_style); |
|
|
|
|
|
|
|
|
|
|
|
static GUI_Node_Reference block1 = {0}; |
|
|
|
static GUI_Node_Reference empty_layout = {0}; |
|
|
|
static GUI_Node_Reference block2 = {0}; |
|
|
|
|
|
|
|
block1 = gui_dumb_block(context, block1, &block_style, block_size); |
|
|
|
|
|
|
|
empty_layout = gui_layout( |
|
|
|
context, empty_layout, GUI_LAYOUT_HORIZONTAL, &block_style, block_size); |
|
|
|
gui_push_parent(context, empty_layout); |
|
|
|
{ |
|
|
|
} gui_pop_parent(context); |
|
|
|
|
|
|
|
block2 = gui_dumb_block(context, block2, &block_style, block_size); |
|
|
|
|
|
|
|
gui_context_finish_frame(context); |
|
|
|
} |
|
|
|
|
|
|
|
#if 0 |
|
|
|
void test_gui_layout( |
|
|
|
GUI_Context *context, |
|
|
@ -3278,6 +3378,7 @@ int main(void) |
|
|
|
//gui = test_gui__scrollbars;
|
|
|
|
//gui = test_gui__draw_command_using_sliders;
|
|
|
|
gui = test_gui__subtree; |
|
|
|
//gui = test_gui__tmp;
|
|
|
|
|
|
|
|
X11_Window xwindow = {0}; |
|
|
|
int xinit_status = init_x11(&xwindow); |
|
|
@ -3446,8 +3547,8 @@ int main(void) |
|
|
|
{ |
|
|
|
gui(&context, screen_rectangle); |
|
|
|
if(0)print_node_tree( |
|
|
|
(GUI_Node*)((GUI_Subtree*)context.background_layer.subtree_rdic.root)->rdic.root |
|
|
|
, 1); |
|
|
|
(GUI_Node*)((GUI_Subtree*)context.background_layer.subtree_rdic.root)->rdic.root, 1); |
|
|
|
if(1)print_subtree_tree((GUI_Subtree*)context.background_layer.subtree_rdic.root, 1, true); |
|
|
|
//gui_layout_nodes(&context);
|
|
|
|
#if 1 |
|
|
|
gui_layout_and_draw(&context); |
|
|
|