Redraw `TreeItem` on more changes

* Custom font changes
* Custom draw changes
* Custom as button
This commit is contained in:
A Thousand Ships 2024-01-20 16:42:28 +01:00
parent 0bcc0e92b3
commit 552594ffdc
No known key found for this signature in database
GPG Key ID: 2033189A662F8BD7
1 changed files with 20 additions and 0 deletions

View File

@ -590,6 +590,8 @@ void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName
cells.write[p_column].custom_draw_obj = p_object->get_instance_id(); cells.write[p_column].custom_draw_obj = p_object->get_instance_id();
cells.write[p_column].custom_draw_callback = p_callback; cells.write[p_column].custom_draw_callback = p_callback;
_changed_notify(p_column);
} }
void TreeItem::set_collapsed(bool p_collapsed) { void TreeItem::set_collapsed(bool p_collapsed) {
@ -1306,8 +1308,14 @@ void TreeItem::clear_custom_color(int p_column) {
void TreeItem::set_custom_font(int p_column, const Ref<Font> &p_font) { void TreeItem::set_custom_font(int p_column, const Ref<Font> &p_font) {
ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_column, cells.size());
if (cells[p_column].custom_font == p_font) {
return;
}
cells.write[p_column].custom_font = p_font; cells.write[p_column].custom_font = p_font;
cells.write[p_column].cached_minimum_size_dirty = true; cells.write[p_column].cached_minimum_size_dirty = true;
_changed_notify(p_column);
} }
Ref<Font> TreeItem::get_custom_font(int p_column) const { Ref<Font> TreeItem::get_custom_font(int p_column) const {
@ -1318,8 +1326,14 @@ Ref<Font> TreeItem::get_custom_font(int p_column) const {
void TreeItem::set_custom_font_size(int p_column, int p_font_size) { void TreeItem::set_custom_font_size(int p_column, int p_font_size) {
ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_column, cells.size());
if (cells[p_column].custom_font_size == p_font_size) {
return;
}
cells.write[p_column].custom_font_size = p_font_size; cells.write[p_column].custom_font_size = p_font_size;
cells.write[p_column].cached_minimum_size_dirty = true; cells.write[p_column].cached_minimum_size_dirty = true;
_changed_notify(p_column);
} }
int TreeItem::get_custom_font_size(int p_column) const { int TreeItem::get_custom_font_size(int p_column) const {
@ -1368,8 +1382,14 @@ Color TreeItem::get_custom_bg_color(int p_column) const {
void TreeItem::set_custom_as_button(int p_column, bool p_button) { void TreeItem::set_custom_as_button(int p_column, bool p_button) {
ERR_FAIL_INDEX(p_column, cells.size()); ERR_FAIL_INDEX(p_column, cells.size());
if (cells[p_column].custom_button == p_button) {
return;
}
cells.write[p_column].custom_button = p_button; cells.write[p_column].custom_button = p_button;
cells.write[p_column].cached_minimum_size_dirty = true; cells.write[p_column].cached_minimum_size_dirty = true;
_changed_notify(p_column);
} }
bool TreeItem::is_custom_set_as_button(int p_column) const { bool TreeItem::is_custom_set_as_button(int p_column) const {