|
@@ -35,6 +35,7 @@
|
|
#include "editor/create_dialog.h"
|
|
#include "editor/create_dialog.h"
|
|
#include "editor/editor_node.h"
|
|
#include "editor/editor_node.h"
|
|
#include "editor/editor_properties_array_dict.h"
|
|
#include "editor/editor_properties_array_dict.h"
|
|
|
|
+#include "editor/editor_properties_vector.h"
|
|
#include "editor/editor_resource_picker.h"
|
|
#include "editor/editor_resource_picker.h"
|
|
#include "editor/editor_scale.h"
|
|
#include "editor/editor_scale.h"
|
|
#include "editor/editor_settings.h"
|
|
#include "editor/editor_settings.h"
|
|
@@ -1700,137 +1701,6 @@ EditorPropertyEasing::EditorPropertyEasing() {
|
|
add_child(spin);
|
|
add_child(spin);
|
|
}
|
|
}
|
|
|
|
|
|
-///////////////////// VECTOR2 /////////////////////////
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2::_set_read_only(bool p_read_only) {
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i]->set_read_only(p_read_only);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2::_value_changed(double val, const String &p_name) {
|
|
|
|
- if (setting) {
|
|
|
|
- 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;
|
|
|
|
- v2.x = spin[0]->get_value();
|
|
|
|
- v2.y = spin[1]->get_value();
|
|
|
|
- emit_changed(get_edited_property(), v2, linked->is_pressed() ? "" : p_name);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2::update_property() {
|
|
|
|
- Vector2 val = get_edited_property_value();
|
|
|
|
- setting = true;
|
|
|
|
- spin[0]->set_value(val.x);
|
|
|
|
- spin[1]->set_value(val.y);
|
|
|
|
- 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) {
|
|
|
|
- switch (p_what) {
|
|
|
|
- case NOTIFICATION_ENTER_TREE:
|
|
|
|
- case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
- linked->set_texture_normal(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons")));
|
|
|
|
- linked->set_texture_pressed(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")));
|
|
|
|
-
|
|
|
|
- const Color *colors = _get_property_colors();
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i]->add_theme_color_override("label_color", colors[i]);
|
|
|
|
- }
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link, const String &p_suffix) {
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i]->set_min(p_min);
|
|
|
|
- spin[i]->set_max(p_max);
|
|
|
|
- spin[i]->set_step(p_step);
|
|
|
|
- spin[i]->set_hide_slider(p_hide_slider);
|
|
|
|
- spin[i]->set_allow_greater(true);
|
|
|
|
- spin[i]->set_allow_lesser(true);
|
|
|
|
- spin[i]->set_suffix(p_suffix);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!p_link) {
|
|
|
|
- linked->hide();
|
|
|
|
- } else {
|
|
|
|
- linked->set_pressed(true);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorPropertyVector2::EditorPropertyVector2(bool p_force_wide) {
|
|
|
|
- bool horizontal = p_force_wide || bool(EDITOR_GET("interface/inspector/horizontal_vector2_editing"));
|
|
|
|
-
|
|
|
|
- HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- BoxContainer *bc;
|
|
|
|
-
|
|
|
|
- if (p_force_wide) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- } else if (horizontal) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- set_bottom_editor(hb);
|
|
|
|
- } else {
|
|
|
|
- bc = memnew(VBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- }
|
|
|
|
- bc->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- static const char *desc[2] = { "x", "y" };
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i] = memnew(EditorSpinSlider);
|
|
|
|
- spin[i]->set_flat(true);
|
|
|
|
- spin[i]->set_label(desc[i]);
|
|
|
|
- bc->add_child(spin[i]);
|
|
|
|
- add_focusable(spin[i]);
|
|
|
|
- spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector2::_value_changed).bind(desc[i]));
|
|
|
|
- if (horizontal) {
|
|
|
|
- spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- linked = memnew(TextureButton);
|
|
|
|
- linked->set_toggle_mode(true);
|
|
|
|
- linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
|
|
|
- linked->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyVector2::_update_ratio));
|
|
|
|
- hb->add_child(linked);
|
|
|
|
-
|
|
|
|
- add_child(hb);
|
|
|
|
- if (!horizontal) {
|
|
|
|
- set_label_reference(spin[0]); //show text and buttons around this
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
///////////////////// RECT2 /////////////////////////
|
|
///////////////////// RECT2 /////////////////////////
|
|
|
|
|
|
void EditorPropertyRect2::_set_read_only(bool p_read_only) {
|
|
void EditorPropertyRect2::_set_read_only(bool p_read_only) {
|
|
@@ -1934,315 +1804,6 @@ EditorPropertyRect2::EditorPropertyRect2(bool p_force_wide) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-///////////////////// VECTOR3 /////////////////////////
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3::_set_read_only(bool p_read_only) {
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i]->set_read_only(p_read_only);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3::_value_changed(double val, const String &p_name) {
|
|
|
|
- if (setting) {
|
|
|
|
- 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;
|
|
|
|
- v3.x = spin[0]->get_value();
|
|
|
|
- v3.y = spin[1]->get_value();
|
|
|
|
- v3.z = spin[2]->get_value();
|
|
|
|
- if (angle_in_radians) {
|
|
|
|
- v3.x = Math::deg_to_rad(v3.x);
|
|
|
|
- v3.y = Math::deg_to_rad(v3.y);
|
|
|
|
- v3.z = Math::deg_to_rad(v3.z);
|
|
|
|
- }
|
|
|
|
- emit_changed(get_edited_property(), v3, linked->is_pressed() ? "" : p_name);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3::update_property() {
|
|
|
|
- update_using_vector(get_edited_property_value());
|
|
|
|
- _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::update_using_vector(Vector3 p_vector) {
|
|
|
|
- if (angle_in_radians) {
|
|
|
|
- p_vector.x = Math::rad_to_deg(p_vector.x);
|
|
|
|
- p_vector.y = Math::rad_to_deg(p_vector.y);
|
|
|
|
- p_vector.z = Math::rad_to_deg(p_vector.z);
|
|
|
|
- }
|
|
|
|
- setting = true;
|
|
|
|
- spin[0]->set_value(p_vector.x);
|
|
|
|
- spin[1]->set_value(p_vector.y);
|
|
|
|
- spin[2]->set_value(p_vector.z);
|
|
|
|
- setting = false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-Vector3 EditorPropertyVector3::get_vector() {
|
|
|
|
- Vector3 v3;
|
|
|
|
- v3.x = spin[0]->get_value();
|
|
|
|
- v3.y = spin[1]->get_value();
|
|
|
|
- v3.z = spin[2]->get_value();
|
|
|
|
- if (angle_in_radians) {
|
|
|
|
- v3.x = Math::deg_to_rad(v3.x);
|
|
|
|
- v3.y = Math::deg_to_rad(v3.y);
|
|
|
|
- v3.z = Math::deg_to_rad(v3.z);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return v3;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3::_notification(int p_what) {
|
|
|
|
- switch (p_what) {
|
|
|
|
- case NOTIFICATION_ENTER_TREE:
|
|
|
|
- case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
- linked->set_texture_normal(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons")));
|
|
|
|
- linked->set_texture_pressed(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")));
|
|
|
|
-
|
|
|
|
- const Color *colors = _get_property_colors();
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i]->add_theme_color_override("label_color", colors[i]);
|
|
|
|
- }
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3::_bind_methods() {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3::setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link, const String &p_suffix, bool p_angle_in_radians) {
|
|
|
|
- angle_in_radians = p_angle_in_radians;
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i]->set_min(p_min);
|
|
|
|
- spin[i]->set_max(p_max);
|
|
|
|
- spin[i]->set_step(p_step);
|
|
|
|
- spin[i]->set_hide_slider(p_hide_slider);
|
|
|
|
- spin[i]->set_allow_greater(true);
|
|
|
|
- spin[i]->set_allow_lesser(true);
|
|
|
|
- spin[i]->set_suffix(p_suffix);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!p_link) {
|
|
|
|
- linked->hide();
|
|
|
|
- } else {
|
|
|
|
- linked->set_pressed(true);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorPropertyVector3::EditorPropertyVector3(bool p_force_wide) {
|
|
|
|
- bool horizontal = p_force_wide || bool(EDITOR_GET("interface/inspector/horizontal_vector_types_editing"));
|
|
|
|
-
|
|
|
|
- HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- BoxContainer *bc;
|
|
|
|
-
|
|
|
|
- if (p_force_wide) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- } else if (horizontal) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- set_bottom_editor(hb);
|
|
|
|
- } else {
|
|
|
|
- bc = memnew(VBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- }
|
|
|
|
- bc->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- static const char *desc[3] = { "x", "y", "z" };
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i] = memnew(EditorSpinSlider);
|
|
|
|
- spin[i]->set_flat(true);
|
|
|
|
- spin[i]->set_label(desc[i]);
|
|
|
|
- bc->add_child(spin[i]);
|
|
|
|
- add_focusable(spin[i]);
|
|
|
|
- spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector3::_value_changed).bind(desc[i]));
|
|
|
|
- if (horizontal) {
|
|
|
|
- spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- linked = memnew(TextureButton);
|
|
|
|
- linked->set_toggle_mode(true);
|
|
|
|
- linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
|
|
|
- linked->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyVector3::_update_ratio));
|
|
|
|
- hb->add_child(linked);
|
|
|
|
-
|
|
|
|
- add_child(hb);
|
|
|
|
- if (!horizontal) {
|
|
|
|
- set_label_reference(spin[0]); //show text and buttons around this
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-///////////////////// VECTOR2i /////////////////////////
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2i::_set_read_only(bool p_read_only) {
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i]->set_read_only(p_read_only);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2i::_value_changed(double val, const String &p_name) {
|
|
|
|
- if (setting) {
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Vector2i v2;
|
|
|
|
- v2.x = spin[0]->get_value();
|
|
|
|
- v2.y = spin[1]->get_value();
|
|
|
|
- emit_changed(get_edited_property(), v2, linked->is_pressed() ? "" : p_name);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2i::update_property() {
|
|
|
|
- Vector2i val = get_edited_property_value();
|
|
|
|
- setting = true;
|
|
|
|
- spin[0]->set_value(val.x);
|
|
|
|
- spin[1]->set_value(val.y);
|
|
|
|
- setting = false;
|
|
|
|
- _update_ratio();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2i::_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 EditorPropertyVector2i::_notification(int p_what) {
|
|
|
|
- switch (p_what) {
|
|
|
|
- case NOTIFICATION_ENTER_TREE:
|
|
|
|
- case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
- linked->set_texture_normal(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons")));
|
|
|
|
- linked->set_texture_pressed(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")));
|
|
|
|
-
|
|
|
|
- const Color *colors = _get_property_colors();
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i]->add_theme_color_override("label_color", colors[i]);
|
|
|
|
- }
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector2i::setup(int p_min, int p_max, bool p_link, const String &p_suffix) {
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i]->set_min(p_min);
|
|
|
|
- spin[i]->set_max(p_max);
|
|
|
|
- spin[i]->set_step(1);
|
|
|
|
- spin[i]->set_allow_greater(true);
|
|
|
|
- spin[i]->set_allow_lesser(true);
|
|
|
|
- spin[i]->set_suffix(p_suffix);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!p_link) {
|
|
|
|
- linked->hide();
|
|
|
|
- } else {
|
|
|
|
- linked->set_pressed(true);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorPropertyVector2i::EditorPropertyVector2i(bool p_force_wide) {
|
|
|
|
- bool horizontal = p_force_wide || bool(EDITOR_GET("interface/inspector/horizontal_vector2_editing"));
|
|
|
|
-
|
|
|
|
- HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- BoxContainer *bc;
|
|
|
|
-
|
|
|
|
- if (p_force_wide) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- } else if (horizontal) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- set_bottom_editor(hb);
|
|
|
|
- } else {
|
|
|
|
- bc = memnew(VBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- }
|
|
|
|
- bc->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- static const char *desc[2] = { "x", "y" };
|
|
|
|
- for (int i = 0; i < 2; i++) {
|
|
|
|
- spin[i] = memnew(EditorSpinSlider);
|
|
|
|
- spin[i]->set_flat(true);
|
|
|
|
- spin[i]->set_label(desc[i]);
|
|
|
|
- bc->add_child(spin[i]);
|
|
|
|
- add_focusable(spin[i]);
|
|
|
|
- spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector2i::_value_changed).bind(desc[i]));
|
|
|
|
- if (horizontal) {
|
|
|
|
- spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- linked = memnew(TextureButton);
|
|
|
|
- linked->set_toggle_mode(true);
|
|
|
|
- linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
|
|
|
- linked->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyVector2i::_update_ratio));
|
|
|
|
- hb->add_child(linked);
|
|
|
|
-
|
|
|
|
- add_child(hb);
|
|
|
|
- if (!horizontal) {
|
|
|
|
- set_label_reference(spin[0]); //show text and buttons around this
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
///////////////////// RECT2i /////////////////////////
|
|
///////////////////// RECT2i /////////////////////////
|
|
|
|
|
|
void EditorPropertyRect2i::_set_read_only(bool p_read_only) {
|
|
void EditorPropertyRect2i::_set_read_only(bool p_read_only) {
|
|
@@ -2345,156 +1906,6 @@ EditorPropertyRect2i::EditorPropertyRect2i(bool p_force_wide) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-///////////////////// VECTOR3I /////////////////////////
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3i::_set_read_only(bool p_read_only) {
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i]->set_read_only(p_read_only);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3i::_value_changed(double val, const String &p_name) {
|
|
|
|
- if (setting) {
|
|
|
|
- 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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Vector3i v3;
|
|
|
|
- v3.x = spin[0]->get_value();
|
|
|
|
- v3.y = spin[1]->get_value();
|
|
|
|
- v3.z = spin[2]->get_value();
|
|
|
|
- emit_changed(get_edited_property(), v3, linked->is_pressed() ? "" : p_name);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3i::update_property() {
|
|
|
|
- Vector3i val = get_edited_property_value();
|
|
|
|
- setting = true;
|
|
|
|
- spin[0]->set_value(val.x);
|
|
|
|
- spin[1]->set_value(val.y);
|
|
|
|
- spin[2]->set_value(val.z);
|
|
|
|
- setting = false;
|
|
|
|
- _update_ratio();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3i::_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 EditorPropertyVector3i::_notification(int p_what) {
|
|
|
|
- switch (p_what) {
|
|
|
|
- case NOTIFICATION_ENTER_TREE:
|
|
|
|
- case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
- linked->set_texture_normal(get_theme_icon(SNAME("Unlinked"), SNAME("EditorIcons")));
|
|
|
|
- linked->set_texture_pressed(get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")));
|
|
|
|
-
|
|
|
|
- const Color *colors = _get_property_colors();
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i]->add_theme_color_override("label_color", colors[i]);
|
|
|
|
- }
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3i::_bind_methods() {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector3i::setup(int p_min, int p_max, bool p_link, const String &p_suffix) {
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i]->set_min(p_min);
|
|
|
|
- spin[i]->set_max(p_max);
|
|
|
|
- spin[i]->set_step(1);
|
|
|
|
- spin[i]->set_hide_slider(false);
|
|
|
|
- spin[i]->set_allow_greater(true);
|
|
|
|
- spin[i]->set_allow_lesser(true);
|
|
|
|
- spin[i]->set_suffix(p_suffix);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!p_link) {
|
|
|
|
- linked->hide();
|
|
|
|
- } else {
|
|
|
|
- linked->set_pressed(true);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorPropertyVector3i::EditorPropertyVector3i(bool p_force_wide) {
|
|
|
|
- bool horizontal = p_force_wide || bool(EDITOR_GET("interface/inspector/horizontal_vector_types_editing"));
|
|
|
|
-
|
|
|
|
- HBoxContainer *hb = memnew(HBoxContainer);
|
|
|
|
- hb->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- BoxContainer *bc;
|
|
|
|
- if (p_force_wide) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- } else if (horizontal) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- set_bottom_editor(hb);
|
|
|
|
- } else {
|
|
|
|
- bc = memnew(VBoxContainer);
|
|
|
|
- hb->add_child(bc);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static const char *desc[3] = { "x", "y", "z" };
|
|
|
|
- for (int i = 0; i < 3; i++) {
|
|
|
|
- spin[i] = memnew(EditorSpinSlider);
|
|
|
|
- spin[i]->set_flat(true);
|
|
|
|
- spin[i]->set_label(desc[i]);
|
|
|
|
- bc->add_child(spin[i]);
|
|
|
|
- add_focusable(spin[i]);
|
|
|
|
- spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector3i::_value_changed).bind(desc[i]));
|
|
|
|
- if (horizontal) {
|
|
|
|
- spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- bc->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
-
|
|
|
|
- linked = memnew(TextureButton);
|
|
|
|
- linked->set_toggle_mode(true);
|
|
|
|
- linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
|
|
|
|
- linked->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyVector3i::_update_ratio));
|
|
|
|
- hb->add_child(linked);
|
|
|
|
-
|
|
|
|
- add_child(hb);
|
|
|
|
- if (!horizontal) {
|
|
|
|
- set_label_reference(spin[0]); //show text and buttons around this
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
///////////////////// PLANE /////////////////////////
|
|
///////////////////// PLANE /////////////////////////
|
|
|
|
|
|
void EditorPropertyPlane::_set_read_only(bool p_read_only) {
|
|
void EditorPropertyPlane::_set_read_only(bool p_read_only) {
|
|
@@ -2804,184 +2215,6 @@ EditorPropertyQuaternion::EditorPropertyQuaternion() {
|
|
set_label_reference(spin[0]); //show text and buttons around this
|
|
set_label_reference(spin[0]); //show text and buttons around this
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-///////////////////// VECTOR4 /////////////////////////
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4::_set_read_only(bool p_read_only) {
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i]->set_read_only(p_read_only);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4::_value_changed(double val, const String &p_name) {
|
|
|
|
- if (setting) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Vector4 p;
|
|
|
|
- p.x = spin[0]->get_value();
|
|
|
|
- p.y = spin[1]->get_value();
|
|
|
|
- p.z = spin[2]->get_value();
|
|
|
|
- p.w = spin[3]->get_value();
|
|
|
|
- emit_changed(get_edited_property(), p, p_name);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4::update_property() {
|
|
|
|
- Vector4 val = get_edited_property_value();
|
|
|
|
- setting = true;
|
|
|
|
- spin[0]->set_value(val.x);
|
|
|
|
- spin[1]->set_value(val.y);
|
|
|
|
- spin[2]->set_value(val.z);
|
|
|
|
- spin[3]->set_value(val.w);
|
|
|
|
- setting = false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4::_notification(int p_what) {
|
|
|
|
- switch (p_what) {
|
|
|
|
- case NOTIFICATION_ENTER_TREE:
|
|
|
|
- case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
- const Color *colors = _get_property_colors();
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i]->add_theme_color_override("label_color", colors[i]);
|
|
|
|
- }
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4::_bind_methods() {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4::setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix) {
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i]->set_min(p_min);
|
|
|
|
- spin[i]->set_max(p_max);
|
|
|
|
- spin[i]->set_step(p_step);
|
|
|
|
- spin[i]->set_hide_slider(p_hide_slider);
|
|
|
|
- spin[i]->set_allow_greater(true);
|
|
|
|
- spin[i]->set_allow_lesser(true);
|
|
|
|
- spin[i]->set_suffix(p_suffix);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorPropertyVector4::EditorPropertyVector4() {
|
|
|
|
- bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
|
|
|
|
-
|
|
|
|
- BoxContainer *bc;
|
|
|
|
-
|
|
|
|
- if (horizontal) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- add_child(bc);
|
|
|
|
- set_bottom_editor(bc);
|
|
|
|
- } else {
|
|
|
|
- bc = memnew(VBoxContainer);
|
|
|
|
- add_child(bc);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static const char *desc[4] = { "x", "y", "z", "w" };
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i] = memnew(EditorSpinSlider);
|
|
|
|
- spin[i]->set_flat(true);
|
|
|
|
- spin[i]->set_label(desc[i]);
|
|
|
|
- bc->add_child(spin[i]);
|
|
|
|
- add_focusable(spin[i]);
|
|
|
|
- spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector4::_value_changed).bind(desc[i]));
|
|
|
|
- if (horizontal) {
|
|
|
|
- spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!horizontal) {
|
|
|
|
- set_label_reference(spin[0]); //show text and buttons around this
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-///////////////////// VECTOR4I /////////////////////////
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4i::_set_read_only(bool p_read_only) {
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i]->set_read_only(p_read_only);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4i::_value_changed(double val, const String &p_name) {
|
|
|
|
- if (setting) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Vector4i p;
|
|
|
|
- p.x = spin[0]->get_value();
|
|
|
|
- p.y = spin[1]->get_value();
|
|
|
|
- p.z = spin[2]->get_value();
|
|
|
|
- p.w = spin[3]->get_value();
|
|
|
|
- emit_changed(get_edited_property(), p, p_name);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4i::update_property() {
|
|
|
|
- Vector4i val = get_edited_property_value();
|
|
|
|
- setting = true;
|
|
|
|
- spin[0]->set_value(val.x);
|
|
|
|
- spin[1]->set_value(val.y);
|
|
|
|
- spin[2]->set_value(val.z);
|
|
|
|
- spin[3]->set_value(val.w);
|
|
|
|
- setting = false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4i::_notification(int p_what) {
|
|
|
|
- switch (p_what) {
|
|
|
|
- case NOTIFICATION_ENTER_TREE:
|
|
|
|
- case NOTIFICATION_THEME_CHANGED: {
|
|
|
|
- const Color *colors = _get_property_colors();
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i]->add_theme_color_override("label_color", colors[i]);
|
|
|
|
- }
|
|
|
|
- } break;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4i::_bind_methods() {
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void EditorPropertyVector4i::setup(double p_min, double p_max, const String &p_suffix) {
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i]->set_min(p_min);
|
|
|
|
- spin[i]->set_max(p_max);
|
|
|
|
- spin[i]->set_step(1);
|
|
|
|
- spin[i]->set_allow_greater(true);
|
|
|
|
- spin[i]->set_allow_lesser(true);
|
|
|
|
- spin[i]->set_suffix(p_suffix);
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-EditorPropertyVector4i::EditorPropertyVector4i() {
|
|
|
|
- bool horizontal = EDITOR_GET("interface/inspector/horizontal_vector_types_editing");
|
|
|
|
-
|
|
|
|
- BoxContainer *bc;
|
|
|
|
-
|
|
|
|
- if (horizontal) {
|
|
|
|
- bc = memnew(HBoxContainer);
|
|
|
|
- add_child(bc);
|
|
|
|
- set_bottom_editor(bc);
|
|
|
|
- } else {
|
|
|
|
- bc = memnew(VBoxContainer);
|
|
|
|
- add_child(bc);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- static const char *desc[4] = { "x", "y", "z", "w" };
|
|
|
|
- for (int i = 0; i < 4; i++) {
|
|
|
|
- spin[i] = memnew(EditorSpinSlider);
|
|
|
|
- spin[i]->set_flat(true);
|
|
|
|
- spin[i]->set_label(desc[i]);
|
|
|
|
- bc->add_child(spin[i]);
|
|
|
|
- add_focusable(spin[i]);
|
|
|
|
- spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVector4i::_value_changed).bind(desc[i]));
|
|
|
|
- if (horizontal) {
|
|
|
|
- spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (!horizontal) {
|
|
|
|
- set_label_reference(spin[0]); //show text and buttons around this
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
|
|
///////////////////// AABB /////////////////////////
|
|
///////////////////// AABB /////////////////////////
|
|
|
|
|
|
@@ -4430,7 +3663,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
|
case Variant::VECTOR2I: {
|
|
case Variant::VECTOR2I: {
|
|
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide));
|
|
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide));
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
|
|
- editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
|
|
|
|
|
+ editor->setup(hint.min, hint.max, 1, true, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
|
return editor;
|
|
return editor;
|
|
|
|
|
|
} break;
|
|
} break;
|
|
@@ -4457,21 +3690,21 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
|
case Variant::VECTOR3I: {
|
|
case Variant::VECTOR3I: {
|
|
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide));
|
|
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide));
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
|
|
- editor->setup(hint.min, hint.max, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
|
|
|
|
|
+ editor->setup(hint.min, hint.max, 1, true, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
|
return editor;
|
|
return editor;
|
|
|
|
|
|
} break;
|
|
} break;
|
|
case Variant::VECTOR4: {
|
|
case Variant::VECTOR4: {
|
|
EditorPropertyVector4 *editor = memnew(EditorPropertyVector4);
|
|
EditorPropertyVector4 *editor = memnew(EditorPropertyVector4);
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, default_float_step);
|
|
- editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, hint.suffix);
|
|
|
|
|
|
+ editor->setup(hint.min, hint.max, hint.step, hint.hide_slider, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
|
return editor;
|
|
return editor;
|
|
|
|
|
|
} break;
|
|
} break;
|
|
case Variant::VECTOR4I: {
|
|
case Variant::VECTOR4I: {
|
|
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
|
|
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
|
|
EditorPropertyRangeHint hint = _parse_range_hint(p_hint, p_hint_text, 1, true);
|
|
- editor->setup(hint.min, hint.max, hint.suffix);
|
|
|
|
|
|
+ editor->setup(hint.min, hint.max, 1, true, p_hint == PROPERTY_HINT_LINK, hint.suffix);
|
|
return editor;
|
|
return editor;
|
|
|
|
|
|
} break;
|
|
} break;
|