WIP subtree offsetting
The current wip code is problematic because it relies on the computed_size of the nodes, which conflicts with dirty-redrawing because it is always be a frame behind.
This commit is contained in:
1 parent
3477b9b33b
commit
9ed7d82d09
1 file changed
+24
-1
@@ -170,6 +170,9 @@ struct GUI_Subtree {
|
||||
GUI_Subtree *structural_parent;
|
||||
|
||||
RDIC_Node_Reference relative_to;
|
||||
int flat_offset_x;
|
||||
int flat_offset_y;
|
||||
|
||||
GUI_Draw_Command *first_draw_command;
|
||||
int num_draw_commands;
|
||||
Pixel_Buffer *pixel_buffer;
|
||||
@@ -639,6 +642,8 @@ void gui_generate_draw_commands(
|
||||
y_offset = relative_rectangle->y0;
|
||||
//printf("%.*s: %d, %d\n", relative_node->debug_string.length, relative_node->debug_string.cstring, x_offset, y_offset);
|
||||
}
|
||||
x_offset += subtree->flat_offset_x;
|
||||
y_offset += subtree->flat_offset_y;
|
||||
|
||||
GUI_Node *root = (GUI_Node*)subtree->rdic.root;
|
||||
assert(root != NULL);
|
||||
@@ -1386,6 +1391,7 @@ void test_gui__subtree(
|
||||
static RDIC_Node_Reference middle = {0};
|
||||
static RDIC_Node_Reference bottom = {0};
|
||||
|
||||
static RDIC_Node_Reference slider = {0};
|
||||
static float slider_value = 0.25f;
|
||||
top = gui_layout(
|
||||
context, top, GUI_LAYOUT_HORIZONTAL, &outer_style, top_bottom_size);
|
||||
@@ -1396,7 +1402,7 @@ void test_gui__subtree(
|
||||
static GUI_Size slider_size[2] = {
|
||||
{GUI_SIZERULE_PIXELS, 200, 100},
|
||||
{GUI_SIZERULE_PIXELS, 40, 100}};
|
||||
static RDIC_Node_Reference slider = {0};
|
||||
//static RDIC_Node_Reference slider = {0};
|
||||
static RDIC_Node_Reference slider_inner = {0};
|
||||
// NOTE(Zelaven): This line is not good because it causes jankyness when
|
||||
// using the slider, and the slider behaves properly without it.
|
||||
@@ -1436,6 +1442,23 @@ 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);
|
||||
int middle_height =
|
||||
((GUI_Node*)middle.node)->computed_size[GUI_AXIS2_Y];
|
||||
int subtree_height =
|
||||
((GUI_Node*)middle_subtree_root.node)->computed_size[GUI_AXIS2_Y];
|
||||
int overfill = subtree_height - middle_height;
|
||||
printf("\n%d = %d - %d\n", overfill, subtree_height, middle_height);
|
||||
if(overfill >= 0)
|
||||
{
|
||||
printf("?\n");
|
||||
middle_subtree.flat_offset_y = -(slider_value * overfill);
|
||||
printf("%d\n", middle_subtree.flat_offset_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
middle_subtree.flat_offset_y = 0;
|
||||
}
|
||||
((GUI_Node*)middle_subtree_root.node)->dirty = ((GUI_Node*)slider.node)->dirty;
|
||||
|
||||
bottom = gui_dumb_block(context, bottom, &outer_style, top_bottom_size);
|
||||
|
||||
|
||||
Reference in new issue
Block a user