feat: Implement Phase A UI hierarchy foundations (closes #122, #102, #116, #118)

Parent-Child UI System (#122):
- Add parent weak_ptr to UIDrawable for hierarchy tracking
- Add setParent(), getParent(), removeFromParent() methods
- UICollection now tracks owner and sets parent on append/insert
- Auto-remove from old parent when adding to new collection

Global Position Property (#102):
- Add get_global_position() that walks up parent chain
- Expose as read-only 'global_position' property on all UI types
- Add UIDRAWABLE_PARENT_GETSETTERS macro for consistent bindings

Dirty Flag System (#116):
- Modify markDirty() to propagate up the parent chain
- Add isDirty() and clearDirty() methods for render optimization

Scene as Drawable (#118):
- Add position, visible, opacity properties to Scene
- Add setProperty()/getProperty() for animation support
- Apply scene transformations in PyScene::render()
- Fix lifecycle callbacks to clear errors when methods don't exist
- Add GameEngine::getScene() public accessor

🤖 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 16:33:17 -05:00
commit e3d8f54d46
19 changed files with 988 additions and 67 deletions

View file

@ -35,12 +35,22 @@ public:
bool hasAction(std::string);
bool hasAction(int);
std::string action(int);
std::shared_ptr<std::vector<std::shared_ptr<UIDrawable>>> ui_elements;
//PyObject* key_callable;
std::unique_ptr<PyKeyCallable> key_callable;
void key_register(PyObject*);
void key_unregister();
// #118: Scene-level UIDrawable-like properties for animations/transitions
sf::Vector2f position{0.0f, 0.0f}; // Offset applied to all ui_elements
bool visible = true; // Controls rendering of scene
float opacity = 1.0f; // Applied to all ui_elements (0.0-1.0)
// Animation support for scene properties
bool setProperty(const std::string& name, float value);
bool setProperty(const std::string& name, const sf::Vector2f& value);
float getProperty(const std::string& name) const;
};