|
@@ -1509,10 +1509,22 @@ void EditorPropertyVector2::_value_changed(double val, const String &p_name) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (linked->is_pressed()) {
|
|
|
|
+ setting = true;
|
|
|
|
+ if (p_name == "x") {
|
|
|
|
+ spin[1]->set_value(spin[0]->get_value() * ratio_yx);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (p_name == "y") {
|
|
|
|
+ spin[0]->set_value(spin[1]->get_value() * ratio_xy);
|
|
|
|
+ }
|
|
|
|
+ setting = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
Vector2 v2;
|
|
Vector2 v2;
|
|
v2.x = spin[0]->get_value();
|
|
v2.x = spin[0]->get_value();
|
|
v2.y = spin[1]->get_value();
|
|
v2.y = spin[1]->get_value();
|
|
- emit_changed(get_edited_property(), v2, p_name);
|
|
|
|
|
|
+ emit_changed(get_edited_property(), v2, linked->is_pressed() ? "" : p_name);
|
|
}
|
|
}
|
|
|
|
|
|
void EditorPropertyVector2::update_property() {
|
|
void EditorPropertyVector2::update_property() {
|
|
@@ -1521,24 +1533,46 @@ void EditorPropertyVector2::update_property() {
|
|
spin[0]->set_value(val.x);
|
|
spin[0]->set_value(val.x);
|
|
spin[1]->set_value(val.y);
|
|
spin[1]->set_value(val.y);
|
|
setting = false;
|
|
setting = false;
|
|
|
|
+ _update_ratio();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void EditorPropertyVector2::_update_ratio() {
|
|
|
|
+ linked->set_modulate(Color(1, 1, 1, linked->is_pressed() ? 1.0 : 0.5));
|
|
|
|
+
|
|
|
|
+ if (spin[0]->get_value() != 0 && spin[1]->get_value() != 0) {
|
|
|
|
+ ratio_xy = spin[0]->get_value() / spin[1]->get_value();
|
|
|
|
+ ratio_yx = spin[1]->get_value() / spin[0]->get_value();
|
|
|
|
+ } else {
|
|
|
|
+ ratio_xy = 1.0;
|
|
|
|
+ ratio_yx = 1.0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void EditorPropertyVector2::_notification(int p_what) {
|
|
void EditorPropertyVector2::_notification(int p_what) {
|
|
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
|
|
|
- Color base = get_color("accent_color", "Editor");
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- Color c = base;
|
|
|
|
- c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
|
|
|
|
- spin[i]->set_custom_label_color(true, c);
|
|
|
|
- }
|
|
|
|
|
|
+ switch (p_what) {
|
|
|
|
+ case NOTIFICATION_ENTER_TREE:
|
|
|
|
+ case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
+ Ref<Texture> normal_icon = get_icon("Unlinked", "EditorIcons");
|
|
|
|
+ linked->set_custom_minimum_size(Vector2(normal_icon->get_width(), 0));
|
|
|
|
+ linked->set_normal_texture(normal_icon);
|
|
|
|
+ linked->set_pressed_texture(get_icon("Instance", "EditorIcons"));
|
|
|
|
+
|
|
|
|
+ Color base = get_color("accent_color", "Editor");
|
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
|
+ Color c = base;
|
|
|
|
+ c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
|
|
|
|
+ spin[i]->set_custom_label_color(true, c);
|
|
|
|
+ }
|
|
|
|
+ } break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void EditorPropertyVector2::_bind_methods() {
|
|
void EditorPropertyVector2::_bind_methods() {
|
|
|
|
+ ClassDB::bind_method(D_METHOD("_update_ratio"), &EditorPropertyVector2::_update_ratio);
|
|
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyVector2::_value_changed);
|
|
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyVector2::_value_changed);
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, bool p_no_slider) {
|
|
|
|
|
|
+void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_link) {
|
|
for (int i = 0; i < 2; i++) {
|
|
for (int i = 0; i < 2; i++) {
|
|
spin[i]->set_min(p_min);
|
|
spin[i]->set_min(p_min);
|
|
spin[i]->set_max(p_max);
|
|
spin[i]->set_max(p_max);
|
|
@@ -1547,21 +1581,31 @@ void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, boo
|
|
spin[i]->set_allow_greater(true);
|
|
spin[i]->set_allow_greater(true);
|
|
spin[i]->set_allow_lesser(true);
|
|
spin[i]->set_allow_lesser(true);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!p_link) {
|
|
|
|
+ linked->hide();
|
|
|
|
+ } else {
|
|
|
|
+ linked->set_pressed(true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
EditorPropertyVector2::EditorPropertyVector2() {
|
|
EditorPropertyVector2::EditorPropertyVector2() {
|
|
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector2_editing");
|
|
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector2_editing");
|
|
|
|
|
|
|
|
+ HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
+ hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
+
|
|
BoxContainer *bc;
|
|
BoxContainer *bc;
|
|
|
|
|
|
if (horizontal) {
|
|
if (horizontal) {
|
|
bc = memnew(HBoxContainer);
|
|
bc = memnew(HBoxContainer);
|
|
- add_child(bc);
|
|
|
|
- set_bottom_editor(bc);
|
|
|
|
|
|
+ hb->add_child(bc);
|
|
|
|
+ set_bottom_editor(hb);
|
|
} else {
|
|
} else {
|
|
bc = memnew(VBoxContainer);
|
|
bc = memnew(VBoxContainer);
|
|
- add_child(bc);
|
|
|
|
|
|
+ hb->add_child(bc);
|
|
}
|
|
}
|
|
|
|
+ bc->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
|
static const char *desc[2] = { "x", "y" };
|
|
static const char *desc[2] = { "x", "y" };
|
|
for (int i = 0; i < 2; i++) {
|
|
for (int i = 0; i < 2; i++) {
|
|
@@ -1576,6 +1620,14 @@ EditorPropertyVector2::EditorPropertyVector2() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ linked = memnew(TextureButton);
|
|
|
|
+ linked->set_toggle_mode(true);
|
|
|
|
+ linked->set_expand(true);
|
|
|
|
+ linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
|
|
|
+ linked->connect("pressed", this, "_update_ratio");
|
|
|
|
+ hb->add_child(linked);
|
|
|
|
+
|
|
|
|
+ add_child(hb);
|
|
if (!horizontal) {
|
|
if (!horizontal) {
|
|
set_label_reference(spin[0]); //show text and buttons around this
|
|
set_label_reference(spin[0]); //show text and buttons around this
|
|
}
|
|
}
|
|
@@ -1671,11 +1723,30 @@ void EditorPropertyVector3::_value_changed(double val, const String &p_name) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (linked->is_pressed()) {
|
|
|
|
+ setting = true;
|
|
|
|
+ if (p_name == "x") {
|
|
|
|
+ spin[1]->set_value(spin[0]->get_value() * ratio_yx);
|
|
|
|
+ spin[2]->set_value(spin[0]->get_value() * ratio_zx);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (p_name == "y") {
|
|
|
|
+ spin[0]->set_value(spin[1]->get_value() * ratio_xy);
|
|
|
|
+ spin[2]->set_value(spin[1]->get_value() * ratio_zy);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (p_name == "z") {
|
|
|
|
+ spin[0]->set_value(spin[2]->get_value() * ratio_xz);
|
|
|
|
+ spin[1]->set_value(spin[2]->get_value() * ratio_yz);
|
|
|
|
+ }
|
|
|
|
+ setting = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
Vector3 v3;
|
|
Vector3 v3;
|
|
v3.x = spin[0]->get_value();
|
|
v3.x = spin[0]->get_value();
|
|
v3.y = spin[1]->get_value();
|
|
v3.y = spin[1]->get_value();
|
|
v3.z = spin[2]->get_value();
|
|
v3.z = spin[2]->get_value();
|
|
- emit_changed(get_edited_property(), v3, p_name);
|
|
|
|
|
|
+ emit_changed(get_edited_property(), v3, linked->is_pressed() ? "" : p_name);
|
|
}
|
|
}
|
|
|
|
|
|
void EditorPropertyVector3::update_property() {
|
|
void EditorPropertyVector3::update_property() {
|
|
@@ -1685,22 +1756,54 @@ void EditorPropertyVector3::update_property() {
|
|
spin[1]->set_value(val.y);
|
|
spin[1]->set_value(val.y);
|
|
spin[2]->set_value(val.z);
|
|
spin[2]->set_value(val.z);
|
|
setting = false;
|
|
setting = false;
|
|
|
|
+
|
|
|
|
+ _update_ratio();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+void EditorPropertyVector3::_update_ratio() {
|
|
|
|
+ linked->set_modulate(Color(1, 1, 1, linked->is_pressed() ? 1.0 : 0.5));
|
|
|
|
+
|
|
|
|
+ if (spin[0]->get_value() != 0 && spin[1]->get_value() != 0) {
|
|
|
|
+ ratio_yx = spin[1]->get_value() / spin[0]->get_value();
|
|
|
|
+ ratio_zx = spin[2]->get_value() / spin[0]->get_value();
|
|
|
|
+ ratio_xy = spin[0]->get_value() / spin[1]->get_value();
|
|
|
|
+ ratio_zy = spin[2]->get_value() / spin[1]->get_value();
|
|
|
|
+ ratio_xz = spin[0]->get_value() / spin[2]->get_value();
|
|
|
|
+ ratio_yz = spin[1]->get_value() / spin[2]->get_value();
|
|
|
|
+ } else {
|
|
|
|
+ ratio_yx = 1.0;
|
|
|
|
+ ratio_zx = 1.0;
|
|
|
|
+ ratio_xy = 1.0;
|
|
|
|
+ ratio_zy = 1.0;
|
|
|
|
+ ratio_xz = 1.0;
|
|
|
|
+ ratio_yz = 1.0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void EditorPropertyVector3::_notification(int p_what) {
|
|
void EditorPropertyVector3::_notification(int p_what) {
|
|
- if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
|
|
|
|
- Color base = get_color("accent_color", "Editor");
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- Color c = base;
|
|
|
|
- c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
|
|
|
|
- spin[i]->set_custom_label_color(true, c);
|
|
|
|
- }
|
|
|
|
|
|
+ switch (p_what) {
|
|
|
|
+ case NOTIFICATION_ENTER_TREE:
|
|
|
|
+ case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
+ Ref<Texture> normal_icon = get_icon("Unlinked", "EditorIcons");
|
|
|
|
+ linked->set_custom_minimum_size(Vector2(normal_icon->get_width(), 0));
|
|
|
|
+ linked->set_normal_texture(normal_icon);
|
|
|
|
+ linked->set_pressed_texture(get_icon("Instance", "EditorIcons"));
|
|
|
|
+
|
|
|
|
+ Color base = get_color("accent_color", "Editor");
|
|
|
|
+ for (int i = 0; i < 3; i++) {
|
|
|
|
+ Color c = base;
|
|
|
|
+ c.set_hsv(float(i) / 3.0 + 0.05, c.get_s() * 0.75, c.get_v());
|
|
|
|
+ spin[i]->set_custom_label_color(true, c);
|
|
|
|
+ }
|
|
|
|
+ } break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
void EditorPropertyVector3::_bind_methods() {
|
|
void EditorPropertyVector3::_bind_methods() {
|
|
|
|
+ ClassDB::bind_method(D_METHOD("_update_ratio"), &EditorPropertyVector3::_update_ratio);
|
|
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyVector3::_value_changed);
|
|
ClassDB::bind_method(D_METHOD("_value_changed"), &EditorPropertyVector3::_value_changed);
|
|
}
|
|
}
|
|
|
|
|
|
-void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, bool p_no_slider) {
|
|
|
|
|
|
+void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, bool p_no_slider, bool p_link) {
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int i = 0; i < 3; i++) {
|
|
spin[i]->set_min(p_min);
|
|
spin[i]->set_min(p_min);
|
|
spin[i]->set_max(p_max);
|
|
spin[i]->set_max(p_max);
|
|
@@ -1709,21 +1812,31 @@ void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, boo
|
|
spin[i]->set_allow_greater(true);
|
|
spin[i]->set_allow_greater(true);
|
|
spin[i]->set_allow_lesser(true);
|
|
spin[i]->set_allow_lesser(true);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!p_link) {
|
|
|
|
+ linked->hide();
|
|
|
|
+ } else {
|
|
|
|
+ linked->set_pressed(true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
EditorPropertyVector3::EditorPropertyVector3() {
|
|
EditorPropertyVector3::EditorPropertyVector3() {
|
|
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
|
|
bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
|
|
|
|
|
|
|
|
+ HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
+ hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
+
|
|
BoxContainer *bc;
|
|
BoxContainer *bc;
|
|
|
|
|
|
if (horizontal) {
|
|
if (horizontal) {
|
|
bc = memnew(HBoxContainer);
|
|
bc = memnew(HBoxContainer);
|
|
- add_child(bc);
|
|
|
|
- set_bottom_editor(bc);
|
|
|
|
|
|
+ hb->add_child(bc);
|
|
|
|
+ set_bottom_editor(hb);
|
|
} else {
|
|
} else {
|
|
bc = memnew(VBoxContainer);
|
|
bc = memnew(VBoxContainer);
|
|
- add_child(bc);
|
|
|
|
|
|
+ hb->add_child(bc);
|
|
}
|
|
}
|
|
|
|
+ bc->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
|
|
static const char *desc[3] = { "x", "y", "z" };
|
|
static const char *desc[3] = { "x", "y", "z" };
|
|
for (int i = 0; i < 3; i++) {
|
|
for (int i = 0; i < 3; i++) {
|
|
@@ -1738,11 +1851,21 @@ EditorPropertyVector3::EditorPropertyVector3() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ linked = memnew(TextureButton);
|
|
|
|
+ linked->set_toggle_mode(true);
|
|
|
|
+ linked->set_expand(true);
|
|
|
|
+ linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
|
|
|
+ linked->connect("pressed", this, "_update_ratio");
|
|
|
|
+ hb->add_child(linked);
|
|
|
|
+
|
|
|
|
+ add_child(hb);
|
|
if (!horizontal) {
|
|
if (!horizontal) {
|
|
set_label_reference(spin[0]); //show text and buttons around this
|
|
set_label_reference(spin[0]); //show text and buttons around this
|
|
}
|
|
}
|
|
setting = false;
|
|
setting = false;
|
|
|
|
+ _update_ratio();
|
|
}
|
|
}
|
|
|
|
+
|
|
///////////////////// PLANE /////////////////////////
|
|
///////////////////// PLANE /////////////////////////
|
|
|
|
|
|
void EditorPropertyPlane::_value_changed(double val, const String &p_name) {
|
|
void EditorPropertyPlane::_value_changed(double val, const String &p_name) {
|
|
@@ -2485,7 +2608,10 @@ void EditorPropertyResource::_resource_selected(const RES &p_resource, bool p_ed
|
|
void EditorPropertyResource::_resource_changed(const RES &p_resource) {
|
|
void EditorPropertyResource::_resource_changed(const RES &p_resource) {
|
|
// Make visual script the correct type.
|
|
// Make visual script the correct type.
|
|
Ref<Script> s = p_resource;
|
|
Ref<Script> s = p_resource;
|
|
|
|
+ bool is_script = false;
|
|
if (get_edited_object() && s.is_valid()) {
|
|
if (get_edited_object() && s.is_valid()) {
|
|
|
|
+ is_script = true;
|
|
|
|
+ EditorNode::get_singleton()->get_inspector_dock()->store_script_properties(get_edited_object());
|
|
s->call("set_instance_base_type", get_edited_object()->get_class());
|
|
s->call("set_instance_base_type", get_edited_object()->get_class());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2511,6 +2637,11 @@ void EditorPropertyResource::_resource_changed(const RES &p_resource) {
|
|
emit_changed(get_edited_property(), p_resource);
|
|
emit_changed(get_edited_property(), p_resource);
|
|
update_property();
|
|
update_property();
|
|
|
|
|
|
|
|
+ if (is_script) {
|
|
|
|
+ // Restore properties if script was changed.
|
|
|
|
+ EditorNode::get_singleton()->get_inspector_dock()->apply_script_properties(get_edited_object());
|
|
|
|
+ }
|
|
|
|
+
|
|
// Automatically suggest setting up the path for a ViewportTexture.
|
|
// Automatically suggest setting up the path for a ViewportTexture.
|
|
if (vpt.is_valid() && vpt->get_viewport_path_in_scene().is_empty()) {
|
|
if (vpt.is_valid() && vpt->get_viewport_path_in_scene().is_empty()) {
|
|
if (!scene_tree) {
|
|
if (!scene_tree) {
|
|
@@ -3035,7 +3166,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|
hide_slider = false;
|
|
hide_slider = false;
|
|
}
|
|
}
|
|
|
|
|
|
- editor->setup(min, max, step, hide_slider);
|
|
|
|
|
|
+ editor->setup(min, max, step, hide_slider, p_hint == PROPERTY_HINT_LINK);
|
|
add_property_editor(p_path, editor);
|
|
add_property_editor(p_path, editor);
|
|
|
|
|
|
} break; // 5
|
|
} break; // 5
|
|
@@ -3070,7 +3201,7 @@ bool EditorInspectorDefaultPlugin::parse_property(Object *p_object, Variant::Typ
|
|
hide_slider = false;
|
|
hide_slider = false;
|
|
}
|
|
}
|
|
|
|
|
|
- editor->setup(min, max, step, hide_slider);
|
|
|
|
|
|
+ editor->setup(min, max, step, hide_slider, p_hint == PROPERTY_HINT_LINK);
|
|
add_property_editor(p_path, editor);
|
|
add_property_editor(p_path, editor);
|
|
|
|
|
|
} break;
|
|
} break;
|