diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-11 13:49:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 13:49:22 +0100 |
commit | 2b1f2ac60aec93b32faeea919cc9379faf67e0e4 (patch) | |
tree | 1c08d2a80dccd5a0a4c23a78f82a5cffeee1913c | |
parent | d83b9d62da975a0f58907e8bca7e5da9c3688665 (diff) | |
parent | a00ac12ae96fcd3b35ae76c0ed4ad6e731b9698e (diff) |
Merge pull request #45042 from KoBeWi/ok_maybe_it_changed
Emit changed signal from Color Picker when changed
-rw-r--r-- | editor/editor_properties.cpp | 12 | ||||
-rw-r--r-- | editor/editor_properties.h | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 3fa183e10c..4d8a4f46b2 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2148,6 +2148,12 @@ void EditorPropertyColor::_color_changed(const Color &p_color) { emit_changed(get_edited_property(), p_color, "", true); } +void EditorPropertyColor::_popup_closed() { + if (picker->get_pick_color() != last_color) { + emit_changed(get_edited_property(), picker->get_pick_color(), "", false); + } +} + void EditorPropertyColor::_picker_created() { // get default color picker mode from editor settings int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode"); @@ -2158,6 +2164,10 @@ void EditorPropertyColor::_picker_created() { } } +void EditorPropertyColor::_picker_opening() { + last_color = picker->get_pick_color(); +} + void EditorPropertyColor::_bind_methods() { } @@ -2191,7 +2201,9 @@ EditorPropertyColor::EditorPropertyColor() { add_child(picker); picker->set_flat(true); picker->connect("color_changed", callable_mp(this, &EditorPropertyColor::_color_changed)); + picker->connect("popup_closed", callable_mp(this, &EditorPropertyColor::_popup_closed)); picker->connect("picker_created", callable_mp(this, &EditorPropertyColor::_picker_created)); + picker->get_popup()->connect("about_to_popup", callable_mp(this, &EditorPropertyColor::_picker_opening)); } ////////////// NODE PATH ////////////////////// diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 856a406e62..4775259111 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -547,7 +547,11 @@ class EditorPropertyColor : public EditorProperty { GDCLASS(EditorPropertyColor, EditorProperty); ColorPickerButton *picker; void _color_changed(const Color &p_color); + void _popup_closed(); void _picker_created(); + void _picker_opening(); + + Color last_color; protected: static void _bind_methods(); |