feat: Add AABB/hit testing foundation (#138)

C++ additions:
- get_global_bounds(): returns bounds in screen coordinates
- contains_point(x, y): hit test using global bounds

Python properties (on all UIDrawable types):
- bounds: (x, y, w, h) tuple in local coordinates
- global_bounds: (x, y, w, h) tuple in screen coordinates

These enable the mouse event system (#140, #141, #142) by providing
a way to determine which drawable is under the mouse cursor.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-11-27 22:36:08 -05:00
commit 6d5a5e9e16
4 changed files with 236 additions and 0 deletions

View file

@ -175,6 +175,14 @@ static int UIDrawable_set_opacity(T* self, PyObject* value, void* closure)
MCRF_PROPERTY(global_position, \
"Global screen position (read-only). " \
"Calculates absolute position by walking up the parent chain." \
), (void*)type_enum}, \
{"bounds", (getter)UIDrawable::get_bounds_py, NULL, \
MCRF_PROPERTY(bounds, \
"Bounding rectangle (x, y, width, height) in local coordinates." \
), (void*)type_enum}, \
{"global_bounds", (getter)UIDrawable::get_global_bounds_py, NULL, \
MCRF_PROPERTY(global_bounds, \
"Bounding rectangle (x, y, width, height) in screen coordinates." \
), (void*)type_enum}
// UIEntity specializations are defined in UIEntity.cpp after UIEntity class is complete