Got some input working again
This commit is contained in:
1 parent
eeb0430300
commit
0cb37f5596
1 file changed
+47
@@ -345,6 +345,53 @@ void gui_apply_input(
|
|||||||
(void)context;
|
(void)context;
|
||||||
(void)mouse_x;
|
(void)mouse_x;
|
||||||
(void)mouse_y;
|
(void)mouse_y;
|
||||||
|
// --- Mouse Input ---
|
||||||
|
// NOTE(Zelaven): First hit test against layers.
|
||||||
|
GUI_Layer *hit_layer = &context->background_layer;
|
||||||
|
GUI_Subtree *hit_root_subtree = (GUI_Subtree*)hit_layer->subtree_rdic.root;
|
||||||
|
{
|
||||||
|
GUI_Layer *top_layer = &context->top_layer;
|
||||||
|
GUI_Subtree *root_subtree = (GUI_Subtree*)top_layer->subtree_rdic.root;
|
||||||
|
if(root_subtree != NULL)
|
||||||
|
{
|
||||||
|
GUI_Node *top_layer_root =
|
||||||
|
(GUI_Node*)root_subtree->rdic.root;
|
||||||
|
if(top_layer_root != NULL)
|
||||||
|
if(point_in_rect(mouse_x, mouse_y, top_layer_root->rect))
|
||||||
|
{
|
||||||
|
hit_layer = &context->top_layer;
|
||||||
|
hit_root_subtree = root_subtree;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void)hit_layer;
|
||||||
|
|
||||||
|
assert(hit_root_subtree != NULL);
|
||||||
|
|
||||||
|
GUI_Node *top_node_under_cursor = (GUI_Node*)hit_root_subtree->rdic.root;
|
||||||
|
GUI_Node *current_node = (GUI_Node*)top_node_under_cursor->rdic_node.first_child;
|
||||||
|
int mouse_over_node = 0;
|
||||||
|
while(current_node != NULL)
|
||||||
|
{
|
||||||
|
mouse_over_node = point_in_rect(mouse_x, mouse_y, current_node->rect);
|
||||||
|
if(mouse_over_node)
|
||||||
|
{
|
||||||
|
top_node_under_cursor = current_node;
|
||||||
|
current_node = (GUI_Node*)current_node->rdic_node.first_child;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current_node = (GUI_Node*)current_node->rdic_node.sibling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context->top_node_under_cursor.node = top_node_under_cursor;
|
||||||
|
context->top_node_under_cursor.generation =
|
||||||
|
top_node_under_cursor->rdic_node.generation;
|
||||||
|
DEBUG("Top node under cursor: %.*s\n",
|
||||||
|
top_node_under_cursor->debug_string.length,
|
||||||
|
top_node_under_cursor->debug_string.cstring);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
|
|||||||
Reference in new issue
Block a user