summaryrefslogtreecommitdiffstats
path: root/scene/gui/color_picker.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-05-22 13:48:43 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-05-22 13:48:43 +0200
commit0f0f233d37cf011e595d50607ae6f889fe92bfcd (patch)
tree2df0ccaaf1efb55a2d75602835eb2a1d88f91063 /scene/gui/color_picker.cpp
parent6b3a79261ab35cc7764d0c65a565c08ecf0fceb0 (diff)
parenta132ed0ca49de6e2e7e202c3dce8e6a21d9282c0 (diff)
downloadredot-engine-0f0f233d37cf011e595d50607ae6f889fe92bfcd.tar.gz
Merge pull request #76751 from anvilfolk/swatch
Fix adding colors to swatches not updating in previous ColorPickers.
Diffstat (limited to 'scene/gui/color_picker.cpp')
-rw-r--r--scene/gui/color_picker.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index f79557aded..2a03786471 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -615,13 +615,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
}