Merge pull request #31782 from aole/persist-ColorPicker-color-mode

Persist ColorPicker color mode
This commit is contained in:
Rémi Verschelde 2019-09-03 12:36:04 +02:00 committed by GitHub
commit dd7c4c62ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 0 deletions

View file

@ -5637,6 +5637,8 @@ EditorNode::EditorNode() {
EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true);
EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true);
EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "SpatialMaterial,Script,MeshLibrary,TileSet");
EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT));
EDITOR_DEF("run/auto_save/save_before_running", true);
theme_base = memnew(Control);

View file

@ -1842,10 +1842,20 @@ void EditorPropertyColor::_popup_closed() {
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");
if (default_color_mode == 1)
picker->get_picker()->set_hsv_mode(true);
else if (default_color_mode == 2)
picker->get_picker()->set_raw_mode(true);
}
void EditorPropertyColor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_color_changed"), &EditorPropertyColor::_color_changed);
ClassDB::bind_method(D_METHOD("_popup_closed"), &EditorPropertyColor::_popup_closed);
ClassDB::bind_method(D_METHOD("_picker_created"), &EditorPropertyColor::_picker_created);
}
void EditorPropertyColor::update_property() {
@ -1864,6 +1874,7 @@ EditorPropertyColor::EditorPropertyColor() {
picker->set_flat(true);
picker->connect("color_changed", this, "_color_changed");
picker->connect("popup_closed", this, "_popup_closed");
picker->connect("picker_created", this, "_picker_created");
}
////////////// NODE PATH //////////////////////

View file

@ -493,6 +493,7 @@ class EditorPropertyColor : public EditorProperty {
ColorPickerButton *picker;
void _color_changed(const Color &p_color);
void _popup_closed();
void _picker_created();
protected:
static void _bind_methods();

View file

@ -1741,6 +1741,13 @@ ScriptTextEditor::ScriptTextEditor() {
color_panel->add_child(color_picker);
color_picker->connect("color_changed", this, "_color_changed");
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
if (default_color_mode == 1)
color_picker->set_hsv_mode(true);
else if (default_color_mode == 2)
color_picker->set_raw_mode(true);
edit_hb = memnew(HBoxContainer);
edit_menu = memnew(MenuButton);

View file

@ -859,6 +859,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
add_child(color_picker);
color_picker->hide();
color_picker->connect("color_changed", this, "_color_changed");
// get default color picker mode from editor settings
int default_color_mode = EDITOR_GET("interface/inspector/default_color_picker_mode");
if (default_color_mode == 1)
color_picker->set_hsv_mode(true);
else if (default_color_mode == 2)
color_picker->set_raw_mode(true);
}
color_picker->show();

View file

@ -964,6 +964,7 @@ void ColorPickerButton::_update_picker() {
popup->connect("popup_hide", this, "set_pressed", varray(false));
picker->set_pick_color(color);
picker->set_edit_alpha(edit_alpha);
emit_signal("picker_created");
}
}
@ -980,6 +981,7 @@ void ColorPickerButton::_bind_methods() {
ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
ADD_SIGNAL(MethodInfo("popup_closed"));
ADD_SIGNAL(MethodInfo("picker_created"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_pick_color", "get_pick_color");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha");
}