refactor: Use property setter pattern for parent assignment

Instead of separate getParent()/setParent()/removeFromParent() methods,
the parent property now supports the Pythonic getter/setter pattern:
- child.parent       # Get parent (or None)
- child.parent = f   # Set parent (adds to f.children)
- child.parent = None # Remove from parent

This matches the existing pattern used by the click property callback.

🤖 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 21:01:11 -05:00
commit 41a704a010
4 changed files with 149 additions and 3 deletions

View file

@ -165,10 +165,11 @@ static int UIDrawable_set_opacity(T* self, PyObject* value, void* closure)
// #122 & #102: Macro for parent/global_position properties (requires closure with type enum)
// These need the PyObjectsEnum value in closure, so they're added separately in each class
#define UIDRAWABLE_PARENT_GETSETTERS(type_enum) \
{"parent", (getter)UIDrawable::get_parent, NULL, \
{"parent", (getter)UIDrawable::get_parent, (setter)UIDrawable::set_parent, \
MCRF_PROPERTY(parent, \
"Parent drawable (read-only). " \
"Returns the parent Frame/Grid if nested, or None if at scene level." \
"Parent drawable. " \
"Get: Returns the parent Frame/Grid if nested, or None if at scene level. " \
"Set: Assign a Frame/Grid to reparent, or None to remove from parent." \
), (void*)type_enum}, \
{"global_position", (getter)UIDrawable::get_global_pos, NULL, \
MCRF_PROPERTY(global_position, \