Skip to content

Commit

Permalink
Merge pull request godotengine#101913 from Giganzo/color-hide-button
Browse files Browse the repository at this point in the history
Fix ColorPicker hide save/load swatches for presets_visible
  • Loading branch information
Repiteo committed Jan 28, 2025
2 parents 3c80c14 + e9b164a commit 3c3ff85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2038,8 +2038,7 @@ void ColorPicker::set_presets_visible(bool p_visible) {
return;
}
presets_visible = p_visible;
btn_preset->set_visible(p_visible);
btn_recent_preset->set_visible(p_visible);
swatches_vbc->set_visible(p_visible);
}

bool ColorPicker::are_presets_visible() const {
Expand Down Expand Up @@ -2348,6 +2347,9 @@ ColorPicker::ColorPicker() {
_update_controls();
updating = false;

swatches_vbc = memnew(VBoxContainer);
real_vbox->add_child(swatches_vbc);

preset_container = memnew(GridContainer);
preset_container->set_h_size_flags(SIZE_EXPAND_FILL);
preset_container->set_columns(PRESET_COLUMN_COUNT);
Expand All @@ -2357,7 +2359,7 @@ ColorPicker::ColorPicker() {

HBoxContainer *palette_box = memnew(HBoxContainer);
palette_box->set_h_size_flags(SIZE_EXPAND_FILL);
real_vbox->add_child(palette_box);
swatches_vbc->add_child(palette_box);

btn_preset = memnew(Button);
btn_preset->set_text("Swatches");
Expand All @@ -2379,9 +2381,9 @@ ColorPicker::ColorPicker() {
palette_name = memnew(Label);
palette_name->hide();
palette_name->set_mouse_filter(MOUSE_FILTER_PASS);
real_vbox->add_child(palette_name);
swatches_vbc->add_child(palette_name);

real_vbox->add_child(preset_container);
swatches_vbc->add_child(preset_container);

recent_preset_hbc = memnew(HBoxContainer);
recent_preset_hbc->set_v_size_flags(SIZE_SHRINK_BEGIN);
Expand All @@ -2395,9 +2397,9 @@ ColorPicker::ColorPicker() {
btn_recent_preset->set_focus_mode(FOCUS_NONE);
btn_recent_preset->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
btn_recent_preset->connect(SceneStringName(toggled), callable_mp(this, &ColorPicker::_show_hide_preset).bind(btn_recent_preset, recent_preset_hbc));
real_vbox->add_child(btn_recent_preset);
swatches_vbc->add_child(btn_recent_preset);

real_vbox->add_child(recent_preset_hbc);
swatches_vbc->add_child(recent_preset_hbc);

set_pick_color(Color(1, 1, 1));

Expand Down
1 change: 1 addition & 0 deletions scene/gui/color_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class ColorPicker : public VBoxContainer {
Control *wheel = nullptr;
Control *wheel_uv = nullptr;
TextureRect *sample = nullptr;
VBoxContainer *swatches_vbc = nullptr;
GridContainer *preset_container = nullptr;
HBoxContainer *recent_preset_hbc = nullptr;
Button *btn_add_preset = nullptr;
Expand Down

0 comments on commit 3c3ff85

Please sign in to comment.