Fix UIFrame RenderTexture positioning and toggling issues
- Fix #223: Use `position` instead of `box.getPosition()` for render_sprite positioning. The box was being set to (0,0) for texture rendering and never restored, causing frames to render at wrong positions. - Fix #224: Add disableRenderTexture() method and call it when toggling clip_children or cache_subtree off. This properly cleans up the texture and prevents stale rendering. - Fix #225: Improve dirty propagation in markContentDirty() to propagate to parent even when already dirty, if the parent was cleared (rendered) since last propagation. Prevents child changes from being invisible. - Fix #226: Add fallback to standard rendering when RenderTexture can't be created (e.g., zero-size frame). Prevents inconsistent state. Closes #223, closes #224, closes #225, closes #226 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c23da11d7d
commit
3fea6418ff
4 changed files with 135 additions and 7 deletions
|
|
@ -419,11 +419,20 @@ void UIDrawable::enableRenderTexture(unsigned int width, unsigned int height) {
|
|||
}
|
||||
render_sprite.setTexture(render_texture->getTexture());
|
||||
}
|
||||
|
||||
|
||||
use_render_texture = true;
|
||||
render_dirty = true;
|
||||
}
|
||||
|
||||
void UIDrawable::disableRenderTexture() {
|
||||
if (!use_render_texture) return;
|
||||
|
||||
render_texture.reset();
|
||||
render_sprite = sf::Sprite(); // Clear stale texture reference
|
||||
use_render_texture = false;
|
||||
render_dirty = true;
|
||||
}
|
||||
|
||||
void UIDrawable::updateRenderTexture() {
|
||||
if (!use_render_texture || !render_texture) {
|
||||
return;
|
||||
|
|
@ -907,14 +916,14 @@ bool UIDrawable::contains_point(float x, float y) const {
|
|||
|
||||
// #144: Content dirty - texture needs rebuild
|
||||
void UIDrawable::markContentDirty() {
|
||||
if (render_dirty) return; // Already dirty, no need to propagate
|
||||
|
||||
bool was_dirty = render_dirty;
|
||||
render_dirty = true;
|
||||
composite_dirty = true; // If content changed, composite also needs update
|
||||
|
||||
// Propagate to parent - parent's composite is dirty (child content changed)
|
||||
// Propagate if: we weren't already dirty, OR parent was cleared (rendered) since last propagation
|
||||
auto p = parent.lock();
|
||||
if (p) {
|
||||
if (p && (!was_dirty || !p->render_dirty)) {
|
||||
p->markContentDirty(); // Parent also needs to rebuild to include our changes
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue