Add missing markDirty()/markCompositeDirty() to all Python property setters
Fixes a systemic bug where Python tp_getset property setters bypassed the render cache dirty flag system (#144). The animation/C++ setProperty() path had correct dirty propagation, but direct Python property assignments (e.g. frame.x = 50, caption.text = "Hello") did not invalidate the parent Frame's render cache when clip_children or cache_subtree was enabled. Changes by file: - UIDrawable.cpp: Add markCompositeDirty() to set_float_member (x/y), set_pos, set_grid_pos; add markDirty() for w/h resize - UICaption.cpp: Add markDirty() to set_text, set_color_member, set_float_member (outline/font_size); markCompositeDirty() for position - UICollection.cpp: Add markContentDirty() on owner in append, remove, pop, insert, extend, setitem, and slice assignment/deletion - UISprite.cpp: Add markDirty() to scale/sprite_index/texture setters; markCompositeDirty() to position setters - UICircle.cpp: Add markDirty() to radius/fill_color/outline_color/outline; markCompositeDirty() to center setter - UILine.cpp: Add markDirty() to start/end/color/thickness setters - UIArc.cpp: Add markDirty() to radius/angles/color/thickness setters; markCompositeDirty() to center setter - UIGrid.cpp: Add markDirty() to center/zoom/camera_rotation/fill_color/ size/perspective/fov setters Closes #288, closes #289, closes #290, closes #291 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d73a207535
commit
e58b44ef82
9 changed files with 403 additions and 14 deletions
|
|
@ -1074,7 +1074,8 @@ int UIGrid::set_size(PyUIGridObject* self, PyObject* value, void* closure) {
|
|||
tex_height = std::min(tex_height, 4096u);
|
||||
|
||||
self->data->renderTexture.create(tex_width, tex_height);
|
||||
|
||||
self->data->markDirty(); // #291: size change
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1091,6 +1092,7 @@ int UIGrid::set_center(PyUIGridObject* self, PyObject* value, void* closure) {
|
|||
}
|
||||
self->data->center_x = x;
|
||||
self->data->center_y = y;
|
||||
self->data->markDirty(); // #291: camera position change
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1186,6 +1188,14 @@ int UIGrid::set_float_member(PyUIGridObject* self, PyObject* value, void* closur
|
|||
else if (member_ptr == 7) self->view->camera_rotation = val;
|
||||
self->view->position = self->view->box.getPosition();
|
||||
}
|
||||
|
||||
// #291: Dirty flag propagation for visual property changes
|
||||
if (member_ptr == 0 || member_ptr == 1) {
|
||||
self->data->markCompositeDirty(); // position change
|
||||
} else {
|
||||
self->data->markDirty(); // content/size change
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// TODO (7DRL Day 2, item 5.) return Texture object
|
||||
|
|
@ -1310,6 +1320,7 @@ int UIGrid::set_fill_color(PyUIGridObject* self, PyObject* value, void* closure)
|
|||
|
||||
PyColorObject* color = (PyColorObject*)value;
|
||||
self->data->fill_color = color->data;
|
||||
self->data->markDirty(); // #291: color change
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1342,6 +1353,7 @@ int UIGrid::set_perspective(PyUIGridObject* self, PyObject* value, void* closure
|
|||
if (value == Py_None) {
|
||||
// Clear perspective but keep perspective_enabled unchanged
|
||||
self->data->perspective_entity.reset();
|
||||
self->data->markDirty(); // #291: FOV rendering change
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1354,6 +1366,7 @@ int UIGrid::set_perspective(PyUIGridObject* self, PyObject* value, void* closure
|
|||
PyUIEntityObject* entity_obj = (PyUIEntityObject*)value;
|
||||
self->data->perspective_entity = entity_obj->data;
|
||||
self->data->perspective_enabled = true; // Enable perspective when entity assigned
|
||||
self->data->markDirty(); // #291: FOV rendering change
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1369,6 +1382,7 @@ int UIGrid::set_perspective_enabled(PyUIGridObject* self, PyObject* value, void*
|
|||
return -1; // Error occurred
|
||||
}
|
||||
self->data->perspective_enabled = enabled;
|
||||
self->data->markDirty(); // #291: FOV rendering toggle
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1401,6 +1415,7 @@ int UIGrid::set_fov(PyUIGridObject* self, PyObject* value, void* closure)
|
|||
return -1;
|
||||
}
|
||||
self->data->fov_algorithm = algo;
|
||||
self->data->markDirty(); // #291: FOV algorithm change
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1425,6 +1440,7 @@ int UIGrid::set_fov_radius(PyUIGridObject* self, PyObject* value, void* closure)
|
|||
return -1;
|
||||
}
|
||||
self->data->fov_radius = (int)radius;
|
||||
self->data->markDirty(); // #291: FOV radius change
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue