Skip to content

Commit

Permalink
Don't instantiate ColorPicker in EditorPropertyColor constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
larspet committed Jan 15, 2025
1 parent 4ce466d commit a85e747
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,9 +2606,13 @@ void EditorPropertyColor::_popup_closed() {
}
}

void EditorPropertyColor::_picker_opening() {
last_color = picker->get_pick_color();
was_checked = !is_checkable() || is_checked();
void EditorPropertyColor::_picker_toggled(bool p_toggled_on) {
if (p_toggled_on) {
last_color = picker->get_pick_color();
was_checked = !is_checkable() || is_checked();

EditorNode::get_singleton()->setup_color_picker(picker->get_picker());
}
}

void EditorPropertyColor::_notification(int p_what) {
Expand Down Expand Up @@ -2655,8 +2659,7 @@ EditorPropertyColor::EditorPropertyColor() {
picker->set_flat(true);
picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed));
picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed), CONNECT_DEFERRED);
picker->get_popup()->connect("about_to_popup", callable_mp(EditorNode::get_singleton(), &EditorNode::setup_color_picker).bind(picker->get_picker()));
picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_picker_opening));
picker->connect(SceneStringName(toggled), callable_mp(this, &EditorPropertyColor::_picker_toggled));
}

////////////// NODE PATH //////////////////////
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ class EditorPropertyColor : public EditorProperty {
ColorPickerButton *picker = nullptr;
void _color_changed(const Color &p_color);
void _popup_closed();
void _picker_opening();
void _picker_toggled(bool p_toggled_on);

Color last_color;
bool live_changes_enabled = true;
Expand Down

0 comments on commit a85e747

Please sign in to comment.