Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix preset cache usage in ColorPicker #104496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FeniXb3
Copy link
Contributor

@FeniXb3 FeniXb3 commented Mar 22, 2025

Fixes #104223

It also fixes two additional bugs (click to expand)
  1. Palette name was not being cleared in editor in other ColorPickers. Video of incorrect behaviour from 4.4.stable:
Nagrywanie.ekranu.2025-03-23.001706.mp4
  1. Cached presets had wrong size when adding ColorPicker in runtime. Video of incorrect behaviour from 4.4.stable:
Nagrywanie.ekranu.2025-03-23.001306.mp4

Correct behaviour, fixed with this PR:

Nagrywanie.ekranu.2025-03-23.003851.mp4
Nagrywanie.ekranu.2025-03-23.004156.mp4

@FeniXb3 FeniXb3 requested a review from a team as a code owner March 22, 2025 23:45
@FeniXb3 FeniXb3 force-pushed the fix-color-palette-cache branch from 9c864b4 to eb47eef Compare March 22, 2025 23:52
@fire fire requested a review from a team March 23, 2025 02:43
@Chaosus Chaosus added this to the 4.5 milestone Mar 23, 2025
@FeniXb3 FeniXb3 force-pushed the fix-color-palette-cache branch from eb47eef to 240861f Compare March 27, 2025 22:08
@akien-mga akien-mga requested a review from KoBeWi March 27, 2025 22:59
for (int i = 1; i < preset_container->get_child_count(); i++) {
preset_container->get_child(i)->queue_free();
}
if (presets.is_empty() || Engine::get_singleton()->is_editor_hint()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this points at the main problem here.

The reported issue was about standalone ColorPicker, while the preset update code assumes that the ColorPicker always comes from ColorPickerButton. I think we should always update the presets in the latter case. For that the ColorPicker needs to know whether it's standalone or from a button.

@FeniXb3 FeniXb3 force-pushed the fix-color-palette-cache branch from 240861f to 98a3ca1 Compare March 29, 2025 22:07
@@ -730,10 +731,10 @@ void ColorPicker::_update_color(bool p_update_sliders) {

void ColorPicker::_update_presets() {
int preset_size = _get_preset_size();
btn_add_preset->set_custom_minimum_size(Size2(preset_size * 1, preset_size));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
btn_add_preset->set_custom_minimum_size(Size2(preset_size * 1, preset_size));
btn_add_preset->set_custom_minimum_size(Size2(preset_size, preset_size));

@@ -170,6 +170,7 @@ class ColorPicker : public VBoxContainer {
Button *btn_pick = nullptr;
Label *palette_name = nullptr;
String palette_path;
bool presets_just_loaded;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool presets_just_loaded;
bool presets_just_loaded = false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong color presets displayed after saving color palette with multiple ColorPickers in the scene
3 participants