1
0
Fork 0

Fix adding colors to swatches not updating in previous ColorPickers.

ColorPicker was only updating colors if its swatches were empty. It
should always update from the cache in case some other ColorPicker
updated the swatch cache.

(cherry picked from commit a132ed0ca4)
This commit is contained in:
ocean (they/them) 2023-06-29 16:03:21 +02:00 committed by Yuri Sizov
parent 0b8fee56e2
commit e75e104e2d
1 changed files with 7 additions and 6 deletions

View File

@ -561,13 +561,14 @@ void ColorPicker::_update_presets() {
#ifdef TOOLS_ENABLED
if (editor_settings) {
// Only load preset buttons when the only child is the add-preset button.
if (preset_container->get_child_count() == 1) {
for (int i = 0; i < preset_cache.size(); i++) {
_add_preset_button(preset_size, preset_cache[i]);
}
_notification(NOTIFICATION_VISIBILITY_CHANGED);
// Rebuild swatch color buttons, keeping the add-preset button in the first position.
for (int i = 1; i < preset_container->get_child_count(); i++) {
preset_container->get_child(i)->queue_free();
}
for (int i = 0; i < preset_cache.size(); i++) {
_add_preset_button(preset_size, preset_cache[i]);
}
_notification(NOTIFICATION_VISIBILITY_CHANGED);
}
#endif
}