summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/classes/EditorResourceTooltipPlugin.xml21
-rw-r--r--editor/editor_node.cpp6
-rw-r--r--editor/editor_properties.cpp777
-rw-r--r--editor/editor_properties.h127
-rw-r--r--editor/editor_properties_array_dict.cpp1
-rw-r--r--editor/editor_properties_vector.cpp258
-rw-r--r--editor/editor_properties_vector.h110
-rw-r--r--editor/editor_themes.cpp2
-rw-r--r--editor/filesystem_dock.cpp12
-rw-r--r--editor/plugins/editor_resource_tooltip_plugins.cpp17
-rw-r--r--editor/plugins/editor_resource_tooltip_plugins.h7
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp1
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h1
-rw-r--r--editor/plugins/tiles/atlas_merging_dialog.cpp1
-rw-r--r--editor/plugins/tiles/atlas_merging_dialog.h1
-rw-r--r--editor/plugins/tiles/tile_proxies_manager_dialog.cpp1
-rw-r--r--editor/plugins/tiles/tile_proxies_manager_dialog.h1
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp1
-rw-r--r--editor/register_editor_types.cpp2
-rw-r--r--scene/resources/particle_process_material.cpp6
20 files changed, 418 insertions, 935 deletions
diff --git a/doc/classes/EditorResourceTooltipPlugin.xml b/doc/classes/EditorResourceTooltipPlugin.xml
index ada91c4e7c..f6ce99b878 100644
--- a/doc/classes/EditorResourceTooltipPlugin.xml
+++ b/doc/classes/EditorResourceTooltipPlugin.xml
@@ -18,20 +18,23 @@
</description>
</method>
<method name="_make_tooltip_for_path" qualifiers="virtual const">
- <return type="Object" />
+ <return type="Control" />
<param index="0" name="path" type="String" />
<param index="1" name="metadata" type="Dictionary" />
+ <param index="2" name="base" type="Control" />
<description>
- Create and return a tooltip that will be displayed when the user hovers resource under given [param path] in filesystem dock. For best results, use [method make_default_tooltip] as a base.
+ Create and return a tooltip that will be displayed when the user hovers a resource under the given [param path] in filesystem dock.
The [param metadata] dictionary is provided by preview generator (see method EditorResourcePreviewGenerator._generate]).
+ [param base] is the base default tooltip, which is a [VBoxContainer] with a file name, type and size labels. If another plugin handled the same file type, [param base] will be output from the previous plugin. For best result, make sure the base tooltip is part of the returned [Control].
[b]Note:[/b] It's unadvised to use [method ResourceLoader.load], especially with heavy resources like models or textures, because it will make the editor unresponsive when creating the tooltip. You can use [method request_thumbnail] if you want to display a preview in your tooltip.
- </description>
- </method>
- <method name="make_default_tooltip" qualifiers="static">
- <return type="VBoxContainer" />
- <param index="0" name="path" type="String" />
- <description>
- Creates a default file tooltip. The tooltip includes file name, file size and [Resource] type if available.
+ [b]Note:[/b] If you decide to discard the [param base], make sure to call [method Node.queue_free], because it's not freed automatically.
+ [codeblock]
+ func _make_tooltip_for_path(path, metadata, base):
+ var t_rect = TextureRect.new()
+ request_thumbnail(path, t_rect)
+ base.add_child(t_rect) # The TextureRect will appear at the bottom of the tooltip.
+ return base
+ [/codeblock]
</description>
</method>
<method name="request_thumbnail" qualifiers="const">
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 188b01ff94..6383dc5aba 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -736,6 +736,8 @@ void EditorNode::_notification(int p_what) {
get_window()->set_theme(theme);
gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles")));
+ main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, gui_base->get_theme_constant(SNAME("window_border_margin"), SNAME("Editor")));
+ main_vbox->add_theme_constant_override("separation", gui_base->get_theme_constant(SNAME("top_bar_separation"), SNAME("Editor")));
scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles")));
bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("BottomPanel"), SNAME("EditorStyles")));
tabbar_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("tabbar_background"), SNAME("TabContainer")));
@@ -7001,8 +7003,8 @@ EditorNode::EditorNode() {
main_vbox = memnew(VBoxContainer);
gui_base->add_child(main_vbox);
- main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, 8);
- main_vbox->add_theme_constant_override("separation", 8 * EDSCALE);
+ main_vbox->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT, Control::PRESET_MODE_MINSIZE, gui_base->get_theme_constant(SNAME("window_border_margin"), SNAME("Editor")));
+ main_vbox->add_theme_constant_override("separation", gui_base->get_theme_constant(SNAME("top_bar_separation"), SNAME("Editor")));
title_bar = memnew(EditorTitleBar);
main_vbox->add_child(title_bar);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 0484a2efc9..44dfed8c7e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -35,6 +35,7 @@
#include "editor/create_dialog.h"
#include "editor/editor_node.h"
#include "editor/editor_properties_array_dict.h"
+#include "editor/editor_properties_vector.h"
#include "editor/editor_resource_picker.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
@@ -1700,137 +1701,6 @@ EditorPropertyEasing::EditorPropertyEasing() {
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 /////////////////////////
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 /////////////////////////
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 /////////////////////////
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
}
}
-///////////////////// 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 /////////////////////////
@@ -4430,7 +3663,7 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
case Variant::VECTOR2I: {
EditorPropertyVector2i *editor = memnew(EditorPropertyVector2i(p_wide));
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;
} break;
@@ -4457,21 +3690,21 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
case Variant::VECTOR3I: {
EditorPropertyVector3i *editor = memnew(EditorPropertyVector3i(p_wide));
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;
} break;
case Variant::VECTOR4: {
EditorPropertyVector4 *editor = memnew(EditorPropertyVector4);
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;
} break;
case Variant::VECTOR4I: {
EditorPropertyVector4i *editor = memnew(EditorPropertyVector4i);
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;
} break;
diff --git a/editor/editor_properties.h b/editor/editor_properties.h
index 015c65b4c6..1505d77de1 100644
--- a/editor/editor_properties.h
+++ b/editor/editor_properties.h
@@ -455,26 +455,6 @@ public:
EditorPropertyEasing();
};
-class EditorPropertyVector2 : public EditorProperty {
- GDCLASS(EditorPropertyVector2, EditorProperty);
- EditorSpinSlider *spin[2];
- bool setting = false;
- double ratio_xy = 1.0;
- double ratio_yx = 1.0;
- TextureButton *linked = nullptr;
- void _update_ratio();
- void _value_changed(double p_val, const String &p_name);
-
-protected:
- virtual void _set_read_only(bool p_read_only) override;
- void _notification(int p_what);
-
-public:
- virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link = false, const String &p_suffix = String());
- EditorPropertyVector2(bool p_force_wide = false);
-};
-
class EditorPropertyRect2 : public EditorProperty {
GDCLASS(EditorPropertyRect2, EditorProperty);
EditorSpinSlider *spin[4];
@@ -492,54 +472,6 @@ public:
EditorPropertyRect2(bool p_force_wide = false);
};
-class EditorPropertyVector3 : public EditorProperty {
- GDCLASS(EditorPropertyVector3, EditorProperty);
- EditorSpinSlider *spin[3];
- bool setting = false;
- bool angle_in_radians = false;
- double ratio_yx = 1.0;
- double ratio_zx = 1.0;
- double ratio_xy = 1.0;
- double ratio_zy = 1.0;
- double ratio_xz = 1.0;
- double ratio_yz = 1.0;
- TextureButton *linked = nullptr;
- void _update_ratio();
- void _value_changed(double p_val, const String &p_name);
-
-protected:
- virtual void _set_read_only(bool p_read_only) override;
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- virtual void update_property() override;
- virtual void update_using_vector(Vector3 p_vector);
- virtual Vector3 get_vector();
- void setup(double p_min, double p_max, double p_step, bool p_hide_slider, bool p_link = false, const String &p_suffix = String(), bool p_angle_in_radians = false);
- EditorPropertyVector3(bool p_force_wide = false);
-};
-
-class EditorPropertyVector2i : public EditorProperty {
- GDCLASS(EditorPropertyVector2i, EditorProperty);
- EditorSpinSlider *spin[2];
- bool setting = false;
- double ratio_xy = 1.0;
- double ratio_yx = 1.0;
- TextureButton *linked = nullptr;
- void _update_ratio();
- void _value_changed(double p_val, const String &p_name);
-
-protected:
- virtual void _set_read_only(bool p_read_only) override;
- void _notification(int p_what);
-
-public:
- virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_link = false, const String &p_suffix = String());
- EditorPropertyVector2i(bool p_force_wide = false);
-};
-
class EditorPropertyRect2i : public EditorProperty {
GDCLASS(EditorPropertyRect2i, EditorProperty);
EditorSpinSlider *spin[4];
@@ -557,31 +489,6 @@ public:
EditorPropertyRect2i(bool p_force_wide = false);
};
-class EditorPropertyVector3i : public EditorProperty {
- GDCLASS(EditorPropertyVector3i, EditorProperty);
- EditorSpinSlider *spin[3];
- bool setting = false;
- double ratio_yx = 1.0;
- double ratio_zx = 1.0;
- double ratio_xy = 1.0;
- double ratio_zy = 1.0;
- double ratio_xz = 1.0;
- double ratio_yz = 1.0;
- TextureButton *linked = nullptr;
- void _update_ratio();
- void _value_changed(double p_val, const String &p_name);
-
-protected:
- virtual void _set_read_only(bool p_read_only) override;
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- virtual void update_property() override;
- void setup(int p_min, int p_max, bool p_link = false, const String &p_suffix = String());
- EditorPropertyVector3i(bool p_force_wide = false);
-};
-
class EditorPropertyPlane : public EditorProperty {
GDCLASS(EditorPropertyPlane, EditorProperty);
EditorSpinSlider *spin[4];
@@ -633,40 +540,6 @@ public:
EditorPropertyQuaternion();
};
-class EditorPropertyVector4 : public EditorProperty {
- GDCLASS(EditorPropertyVector4, EditorProperty);
- EditorSpinSlider *spin[4];
- bool setting = false;
- void _value_changed(double p_val, const String &p_name);
-
-protected:
- virtual void _set_read_only(bool p_read_only) override;
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- virtual void update_property() override;
- void setup(double p_min, double p_max, double p_step, bool p_hide_slider, const String &p_suffix = String());
- EditorPropertyVector4();
-};
-
-class EditorPropertyVector4i : public EditorProperty {
- GDCLASS(EditorPropertyVector4i, EditorProperty);
- EditorSpinSlider *spin[4];
- bool setting = false;
- void _value_changed(double p_val, const String &p_name);
-
-protected:
- virtual void _set_read_only(bool p_read_only) override;
- void _notification(int p_what);
- static void _bind_methods();
-
-public:
- virtual void update_property() override;
- void setup(double p_min, double p_max, const String &p_suffix = String());
- EditorPropertyVector4i();
-};
-
class EditorPropertyAABB : public EditorProperty {
GDCLASS(EditorPropertyAABB, EditorProperty);
EditorSpinSlider *spin[6];
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index 078ebb34fd..88e62b700e 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -33,6 +33,7 @@
#include "core/input/input.h"
#include "core/io/marshalls.h"
#include "editor/editor_properties.h"
+#include "editor/editor_properties_vector.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/gui/editor_spin_slider.h"
diff --git a/editor/editor_properties_vector.cpp b/editor/editor_properties_vector.cpp
new file mode 100644
index 0000000000..28ea0dc36d
--- /dev/null
+++ b/editor/editor_properties_vector.cpp
@@ -0,0 +1,258 @@
+/**************************************************************************/
+/* editor_properties_vector.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "editor_properties_vector.h"
+
+#include "editor/editor_settings.h"
+#include "editor/gui/editor_spin_slider.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/texture_button.h"
+
+const String EditorPropertyVectorN::COMPONENT_LABELS[4] = { "x", "y", "z", "w" };
+
+int EditorPropertyVectorN::_get_ratio_component(int p_idx, int p_component) const {
+ int i = p_idx / (component_count - 1);
+ if (p_component == 1) {
+ return i;
+ } else {
+ return (i + p_idx % (component_count - 1) + 1) % component_count;
+ }
+}
+
+void EditorPropertyVectorN::_set_read_only(bool p_read_only) {
+ for (EditorSpinSlider *spin : spin_sliders) {
+ spin->set_read_only(p_read_only);
+ }
+}
+
+void EditorPropertyVectorN::_value_changed(double val, const String &p_name) {
+ if (linked->is_pressed()) {
+ // TODO: The logic here can be simplified. _get_ratio_component() only exists,
+ // because the exact code was difficult to figure out.
+ for (int i = 0; i < component_count; i++) {
+ if (p_name == COMPONENT_LABELS[i]) {
+ for (int j = 0; j < ratio.size(); j++) {
+ if (_get_ratio_component(j, 1) == i) {
+ for (int k = 0; k < component_count - 1; k++) {
+ spin_sliders[_get_ratio_component(j + k, 0)]->set_value_no_signal(spin_sliders[_get_ratio_component(j + k, 1)]->get_value() * ratio[j + k]);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ Variant v;
+ Callable::CallError cerror;
+ Variant::construct(vector_type, v, nullptr, 0, cerror);
+
+ for (int i = 0; i < component_count; i++) {
+ if (angle_in_radians) {
+ v.set(i, Math::deg_to_rad(spin_sliders[i]->get_value()));
+ } else {
+ v.set(i, spin_sliders[i]->get_value());
+ }
+ }
+ emit_changed(get_edited_property(), v, linked->is_pressed() ? "" : p_name);
+}
+
+void EditorPropertyVectorN::update_property() {
+ Variant val = get_edited_property_value();
+ for (int i = 0; i < component_count; i++) {
+ if (angle_in_radians) {
+ spin_sliders[i]->set_value_no_signal(Math::rad_to_deg((real_t)val.get(i)));
+ } else {
+ spin_sliders[i]->set_value_no_signal(val.get(i));
+ }
+ }
+ _update_ratio();
+}
+
+void EditorPropertyVectorN::_update_ratio() {
+ linked->set_modulate(Color(1, 1, 1, linked->is_pressed() ? 1.0 : 0.5));
+
+ bool non_zero = true;
+ for (int i = 0; i < component_count; i++) {
+ if (spin_sliders[i]->get_value() == 0) {
+ non_zero = false;
+ break;
+ }
+ }
+
+ double *ratio_write = ratio.ptrw();
+ for (int i = 0; i < ratio.size(); i++) {
+ if (non_zero) {
+ ratio_write[i] = spin_sliders[_get_ratio_component(i, 0)]->get_value() / spin_sliders[_get_ratio_component(i, 1)]->get_value();
+ } else {
+ ratio_write[i] = 1.0;
+ }
+ }
+}
+
+void EditorPropertyVectorN::_store_link(bool p_linked) {
+ if (!get_edited_object()) {
+ return;
+ }
+ const String key = vformat("%s:%s", get_edited_object()->get_class(), get_edited_property());
+ EditorSettings::get_singleton()->set_project_metadata("linked_properties", key, p_linked);
+}
+
+void EditorPropertyVectorN::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ if (linked->is_visible()) {
+ const String key = vformat("%s:%s", get_edited_object()->get_class(), get_edited_property());
+ linked->set_pressed(EditorSettings::get_singleton()->get_project_metadata("linked_properties", key, true));
+ }
+ } break;
+
+ 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 < component_count; i++) {
+ spin_sliders[i]->add_theme_color_override("label_color", colors[i]);
+ }
+ } break;
+ }
+}
+
+void EditorPropertyVectorN::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 (EditorSpinSlider *spin : spin_sliders) {
+ spin->set_min(p_min);
+ spin->set_max(p_max);
+ spin->set_step(p_step);
+ spin->set_hide_slider(p_hide_slider);
+ spin->set_allow_greater(true);
+ spin->set_allow_lesser(true);
+ spin->set_suffix(p_suffix);
+ }
+
+ if (!p_link) {
+ linked->hide();
+ }
+}
+
+EditorPropertyVectorN::EditorPropertyVectorN(Variant::Type p_type, bool p_force_wide, bool p_horizontal) {
+ vector_type = p_type;
+ switch (vector_type) {
+ case Variant::VECTOR2:
+ case Variant::VECTOR2I:
+ component_count = 2;
+ break;
+
+ case Variant::VECTOR3:
+ case Variant::VECTOR3I:
+ component_count = 3;
+ break;
+
+ case Variant::VECTOR4:
+ case Variant::VECTOR4I:
+ component_count = 4;
+ break;
+
+ default: // Needed to silence a warning.
+ ERR_PRINT("Not a Vector type.");
+ break;
+ }
+ bool horizontal = p_force_wide || p_horizontal;
+
+ 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);
+
+ spin_sliders.resize(component_count);
+ EditorSpinSlider **spin = spin_sliders.ptrw();
+
+ for (int i = 0; i < component_count; i++) {
+ spin[i] = memnew(EditorSpinSlider);
+ spin[i]->set_flat(true);
+ spin[i]->set_label(String(COMPONENT_LABELS[i]));
+ bc->add_child(spin[i]);
+ add_focusable(spin[i]);
+ spin[i]->connect("value_changed", callable_mp(this, &EditorPropertyVectorN::_value_changed).bind(String(COMPONENT_LABELS[i])));
+ if (horizontal) {
+ spin[i]->set_h_size_flags(SIZE_EXPAND_FILL);
+ }
+ }
+
+ ratio.resize(component_count * (component_count - 1));
+ ratio.fill(1.0);
+
+ linked = memnew(TextureButton);
+ linked->set_toggle_mode(true);
+ linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED);
+ linked->set_tooltip_text(TTR("Lock/Unlock Component Ratio"));
+ linked->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyVectorN::_update_ratio));
+ linked->connect(SNAME("toggled"), callable_mp(this, &EditorPropertyVectorN::_store_link));
+ hb->add_child(linked);
+
+ add_child(hb);
+ if (!horizontal) {
+ set_label_reference(spin_sliders[0]); // Show text and buttons around this.
+ }
+}
+
+EditorPropertyVector2::EditorPropertyVector2(bool p_force_wide) :
+ EditorPropertyVectorN(Variant::VECTOR2, p_force_wide, EDITOR_GET("interface/inspector/horizontal_vector2_editing")) {}
+
+EditorPropertyVector2i::EditorPropertyVector2i(bool p_force_wide) :
+ EditorPropertyVectorN(Variant::VECTOR2I, p_force_wide, EDITOR_GET("interface/inspector/horizontal_vector2_editing")) {}
+
+EditorPropertyVector3::EditorPropertyVector3(bool p_force_wide) :
+ EditorPropertyVectorN(Variant::VECTOR3, p_force_wide, EDITOR_GET("interface/inspector/horizontal_vector_types_editing")) {}
+
+EditorPropertyVector3i::EditorPropertyVector3i(bool p_force_wide) :
+ EditorPropertyVectorN(Variant::VECTOR3I, p_force_wide, EDITOR_GET("interface/inspector/horizontal_vector_types_editing")) {}
+
+EditorPropertyVector4::EditorPropertyVector4(bool p_force_wide) :
+ EditorPropertyVectorN(Variant::VECTOR4, p_force_wide, EDITOR_GET("interface/inspector/horizontal_vector_types_editing")) {}
+
+EditorPropertyVector4i::EditorPropertyVector4i(bool p_force_wide) :
+ EditorPropertyVectorN(Variant::VECTOR4I, p_force_wide, EDITOR_GET("interface/inspector/horizontal_vector_types_editing")) {}
diff --git a/editor/editor_properties_vector.h b/editor/editor_properties_vector.h
new file mode 100644
index 0000000000..c4b650a490
--- /dev/null
+++ b/editor/editor_properties_vector.h
@@ -0,0 +1,110 @@
+/**************************************************************************/
+/* editor_properties_vector.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef EDITOR_PROPERTIES_VECTOR_H
+#define EDITOR_PROPERTIES_VECTOR_H
+
+#include "editor/editor_inspector.h"
+
+class EditorSpinSlider;
+class TextureButton;
+
+class EditorPropertyVectorN : public EditorProperty {
+ GDCLASS(EditorPropertyVectorN, EditorProperty);
+
+ static const String COMPONENT_LABELS[4];
+
+ int component_count = 0;
+ Variant::Type vector_type;
+
+ Vector<EditorSpinSlider *> spin_sliders;
+ TextureButton *linked = nullptr;
+ Vector<double> ratio;
+
+ bool angle_in_radians = false;
+
+ void _update_ratio();
+ int _get_ratio_component(int p_idx, int p_component) const;
+ void _store_link(bool p_linked);
+ void _value_changed(double p_val, const String &p_name);
+
+protected:
+ virtual void _set_read_only(bool p_read_only) override;
+ void _notification(int p_what);
+
+public:
+ virtual void update_property() override;
+ void setup(double p_min, double p_max, double p_step = 1.0, bool p_hide_slider = true, bool p_link = false, const String &p_suffix = String(), bool p_angle_in_radians = false);
+ EditorPropertyVectorN(Variant::Type p_type, bool p_force_wide, bool p_horizontal);
+};
+
+class EditorPropertyVector2 : public EditorPropertyVectorN {
+ GDCLASS(EditorPropertyVector2, EditorPropertyVectorN);
+
+public:
+ EditorPropertyVector2(bool p_force_wide = false);
+};
+
+class EditorPropertyVector2i : public EditorPropertyVectorN {
+ GDCLASS(EditorPropertyVector2i, EditorPropertyVectorN);
+
+public:
+ EditorPropertyVector2i(bool p_force_wide = false);
+};
+
+class EditorPropertyVector3 : public EditorPropertyVectorN {
+ GDCLASS(EditorPropertyVector3, EditorPropertyVectorN);
+
+public:
+ EditorPropertyVector3(bool p_force_wide = false);
+};
+
+class EditorPropertyVector3i : public EditorPropertyVectorN {
+ GDCLASS(EditorPropertyVector3i, EditorPropertyVectorN);
+
+public:
+ EditorPropertyVector3i(bool p_force_wide = false);
+};
+
+class EditorPropertyVector4 : public EditorPropertyVectorN {
+ GDCLASS(EditorPropertyVector4, EditorPropertyVectorN);
+
+public:
+ EditorPropertyVector4(bool p_force_wide = false);
+};
+
+class EditorPropertyVector4i : public EditorPropertyVectorN {
+ GDCLASS(EditorPropertyVector4i, EditorPropertyVectorN);
+
+public:
+ EditorPropertyVector4i(bool p_force_wide = false);
+};
+
+#endif // EDITOR_PROPERTIES_VECTOR_H
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 190d06afb2..2ff53dd9f1 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -626,6 +626,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_constant("dark_theme", "Editor", dark_theme);
theme->set_constant("color_picker_button_height", "Editor", 28 * EDSCALE);
theme->set_constant("gizmo_handle_scale", "Editor", gizmo_handle_scale);
+ theme->set_constant("window_border_margin", "Editor", 8);
+ theme->set_constant("top_bar_separation", "Editor", 8 * EDSCALE);
// Register editor icons.
// If the settings are comparable to the old theme, then just copy them over.
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 1c43c29c33..f21229edc8 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2291,20 +2291,12 @@ Control *FileSystemDock::create_tooltip_for_path(const String &p_path) const {
}
const String type = ResourceLoader::get_resource_type(p_path);
- Control *tooltip = nullptr;
+ Control *tooltip = EditorResourceTooltipPlugin::make_default_tooltip(p_path);
for (const Ref<EditorResourceTooltipPlugin> &plugin : tooltip_plugins) {
if (plugin->handles(type)) {
- tooltip = plugin->make_tooltip_for_path(p_path, EditorResourcePreview::get_singleton()->get_preview_metadata(p_path));
+ tooltip = plugin->make_tooltip_for_path(p_path, EditorResourcePreview::get_singleton()->get_preview_metadata(p_path), tooltip);
}
-
- if (tooltip) {
- break;
- }
- }
-
- if (!tooltip) {
- tooltip = EditorResourceTooltipPlugin::make_default_tooltip(p_path);
}
return tooltip;
}
diff --git a/editor/plugins/editor_resource_tooltip_plugins.cpp b/editor/plugins/editor_resource_tooltip_plugins.cpp
index 26371360e9..36852e79b5 100644
--- a/editor/plugins/editor_resource_tooltip_plugins.cpp
+++ b/editor/plugins/editor_resource_tooltip_plugins.cpp
@@ -33,7 +33,6 @@
#include "editor/editor_resource_preview.h"
#include "editor/editor_scale.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/control.h"
#include "scene/gui/label.h"
#include "scene/gui/texture_rect.h"
@@ -50,12 +49,10 @@ void EditorResourceTooltipPlugin::_thumbnail_ready(const String &p_path, const R
void EditorResourceTooltipPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("_thumbnail_ready"), &EditorResourceTooltipPlugin::_thumbnail_ready);
-
- ClassDB::bind_static_method("EditorResourceTooltipPlugin", D_METHOD("make_default_tooltip", "path"), &EditorResourceTooltipPlugin::make_default_tooltip);
ClassDB::bind_method(D_METHOD("request_thumbnail", "path", "control"), &EditorResourceTooltipPlugin::request_thumbnail);
GDVIRTUAL_BIND(_handles, "type");
- GDVIRTUAL_BIND(_make_tooltip_for_path, "path", "metadata");
+ GDVIRTUAL_BIND(_make_tooltip_for_path, "path", "metadata", "base");
}
VBoxContainer *EditorResourceTooltipPlugin::make_default_tooltip(const String &p_resource_path) {
@@ -91,10 +88,10 @@ bool EditorResourceTooltipPlugin::handles(const String &p_resource_type) const {
return ret;
}
-Control *EditorResourceTooltipPlugin::make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata) const {
- Object *ret = nullptr;
- GDVIRTUAL_CALL(_make_tooltip_for_path, p_resource_path, p_metadata, ret);
- return Object::cast_to<Control>(ret);
+Control *EditorResourceTooltipPlugin::make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata, Control *p_base) const {
+ Control *ret = nullptr;
+ GDVIRTUAL_CALL(_make_tooltip_for_path, p_resource_path, p_metadata, p_base, ret);
+ return ret;
}
// EditorTextureTooltipPlugin
@@ -103,9 +100,9 @@ bool EditorTextureTooltipPlugin::handles(const String &p_resource_type) const {
return ClassDB::is_parent_class(p_resource_type, "Texture2D") || ClassDB::is_parent_class(p_resource_type, "Image");
}
-Control *EditorTextureTooltipPlugin::make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata) const {
+Control *EditorTextureTooltipPlugin::make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata, Control *p_base) const {
HBoxContainer *hb = memnew(HBoxContainer);
- VBoxContainer *vb = EditorResourceTooltipPlugin::make_default_tooltip(p_resource_path);
+ VBoxContainer *vb = Object::cast_to<VBoxContainer>(p_base);
vb->set_alignment(BoxContainer::ALIGNMENT_CENTER);
Vector2 dimensions = p_metadata.get("dimensions", Vector2());
diff --git a/editor/plugins/editor_resource_tooltip_plugins.h b/editor/plugins/editor_resource_tooltip_plugins.h
index dfccbb80ed..3720396842 100644
--- a/editor/plugins/editor_resource_tooltip_plugins.h
+++ b/editor/plugins/editor_resource_tooltip_plugins.h
@@ -34,6 +34,7 @@
#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
#include "core/object/script_language.h"
+#include <scene/gui/control.h>
class Control;
class Texture2D;
@@ -49,14 +50,14 @@ protected:
static void _bind_methods();
GDVIRTUAL1RC(bool, _handles, String)
- GDVIRTUAL2RC(Object *, _make_tooltip_for_path, String, Dictionary)
+ GDVIRTUAL3RC(Control *, _make_tooltip_for_path, String, Dictionary, Control *)
public:
static VBoxContainer *make_default_tooltip(const String &p_resource_path);
void request_thumbnail(const String &p_path, TextureRect *p_for_control) const;
virtual bool handles(const String &p_resource_type) const;
- virtual Control *make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata) const;
+ virtual Control *make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata, Control *p_base) const;
};
class EditorTextureTooltipPlugin : public EditorResourceTooltipPlugin {
@@ -64,7 +65,7 @@ class EditorTextureTooltipPlugin : public EditorResourceTooltipPlugin {
public:
virtual bool handles(const String &p_resource_type) const override;
- virtual Control *make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata) const override;
+ virtual Control *make_tooltip_for_path(const String &p_resource_path, const Dictionary &p_metadata, Control *p_base) const override;
};
#endif // EDITOR_RESOURCE_TOOLTIP_PLUGINS_H
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 90f054275a..4e5a3eb095 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/io/resource_saver.h"
#include "editor/editor_node.h"
#include "editor/editor_properties.h"
+#include "editor/editor_properties_vector.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h
index 8168e02e3e..14158ac9a9 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_3d_editor_plugin.h
@@ -41,6 +41,7 @@
#include "scene/resources/immediate_mesh.h"
class EditorInspectorPluginSkeleton;
+class EditorPropertyVector3;
class Joint;
class PhysicalBone3D;
class Skeleton3DEditorPlugin;
diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp
index a91ee9fa6c..7ed9c9d61b 100644
--- a/editor/plugins/tiles/atlas_merging_dialog.cpp
+++ b/editor/plugins/tiles/atlas_merging_dialog.cpp
@@ -30,6 +30,7 @@
#include "atlas_merging_dialog.h"
+#include "editor/editor_properties_vector.h"
#include "editor/editor_scale.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_file_dialog.h"
diff --git a/editor/plugins/tiles/atlas_merging_dialog.h b/editor/plugins/tiles/atlas_merging_dialog.h
index bf1b56894f..324cc82490 100644
--- a/editor/plugins/tiles/atlas_merging_dialog.h
+++ b/editor/plugins/tiles/atlas_merging_dialog.h
@@ -38,6 +38,7 @@
#include "scene/resources/tile_set.h"
class EditorFileDialog;
+class EditorPropertyVector2i;
class AtlasMergingDialog : public ConfirmationDialog {
GDCLASS(AtlasMergingDialog, ConfirmationDialog);
diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.cpp b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp
index f6aeffa13f..0e244412ab 100644
--- a/editor/plugins/tiles/tile_proxies_manager_dialog.cpp
+++ b/editor/plugins/tiles/tile_proxies_manager_dialog.cpp
@@ -30,6 +30,7 @@
#include "tile_proxies_manager_dialog.h"
+#include "editor/editor_properties_vector.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
diff --git a/editor/plugins/tiles/tile_proxies_manager_dialog.h b/editor/plugins/tiles/tile_proxies_manager_dialog.h
index 9fcdea8db9..357eefcb15 100644
--- a/editor/plugins/tiles/tile_proxies_manager_dialog.h
+++ b/editor/plugins/tiles/tile_proxies_manager_dialog.h
@@ -36,6 +36,7 @@
#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
+class EditorPropertyVector2i;
class EditorUndoRedoManager;
class TileProxiesManagerDialog : public ConfirmationDialog {
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 890194dbac..d631958ce9 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -37,6 +37,7 @@
#include "core/os/keyboard.h"
#include "editor/editor_node.h"
#include "editor/editor_properties.h"
+#include "editor/editor_properties_vector.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
diff --git a/editor/register_editor_types.cpp b/editor/register_editor_types.cpp
index 0dd11d8948..b674ce5967 100644
--- a/editor/register_editor_types.cpp
+++ b/editor/register_editor_types.cpp
@@ -132,8 +132,8 @@ void register_editor_types() {
GDREGISTER_CLASS(EditorNode3DGizmo);
GDREGISTER_CLASS(EditorNode3DGizmoPlugin);
GDREGISTER_ABSTRACT_CLASS(EditorResourcePreview);
- GDREGISTER_ABSTRACT_CLASS(EditorResourceTooltipPlugin);
GDREGISTER_CLASS(EditorResourcePreviewGenerator);
+ GDREGISTER_CLASS(EditorResourceTooltipPlugin);
GDREGISTER_ABSTRACT_CLASS(EditorFileSystem);
GDREGISTER_CLASS(EditorFileSystemDirectory);
GDREGISTER_CLASS(EditorVCSInterface);
diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp
index e5257abec9..76e4360810 100644
--- a/scene/resources/particle_process_material.cpp
+++ b/scene/resources/particle_process_material.cpp
@@ -1356,7 +1356,11 @@ float ParticleProcessMaterial::get_turbulence_noise_strength() const {
void ParticleProcessMaterial::set_turbulence_noise_scale(float p_turbulence_noise_scale) {
turbulence_noise_scale = p_turbulence_noise_scale;
- float shader_turbulence_noise_scale = (pow(p_turbulence_noise_scale, 0.25) * 5.6234 / 10.0) * 4.0 - 3.0;
+ const float noise_frequency_when_slider_is_zero = 4.0;
+ const float max_slider_value = 10.0;
+ const float curve_exponent = 0.25;
+ const float curve_rescale = noise_frequency_when_slider_is_zero / pow(max_slider_value, curve_exponent);
+ float shader_turbulence_noise_scale = pow(p_turbulence_noise_scale, curve_exponent) * curve_rescale - noise_frequency_when_slider_is_zero;
RenderingServer::get_singleton()->material_set_param(_get_material(), shader_names->turbulence_noise_scale, shader_turbulence_noise_scale);
}