summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.cpp6
-rw-r--r--editor/plugins/abstract_polygon_2d_editor.h4
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.cpp12
-rw-r--r--editor/plugins/animation_blend_space_1d_editor.h4
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.cpp24
-rw-r--r--editor/plugins/animation_blend_space_2d_editor.h4
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp15
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.h4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp50
-rw-r--r--editor/plugins/animation_player_editor_plugin.h6
-rw-r--r--editor/plugins/animation_state_machine_editor.cpp18
-rw-r--r--editor/plugins/animation_state_machine_editor.h4
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/animation_tree_editor_plugin.h4
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp52
-rw-r--r--editor/plugins/asset_library_editor_plugin.h4
-rw-r--r--editor/plugins/audio_stream_editor_plugin.cpp14
-rw-r--r--editor/plugins/audio_stream_editor_plugin.h7
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.cpp4
-rw-r--r--editor/plugins/baked_lightmap_editor_plugin.h4
-rw-r--r--editor/plugins/camera_3d_editor_plugin.cpp32
-rw-r--r--editor/plugins/camera_3d_editor_plugin.h4
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp400
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h82
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/collision_polygon_2d_editor_plugin.h4
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/collision_polygon_3d_editor_plugin.h4
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp22
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h4
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/cpu_particles_2d_editor_plugin.h4
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.cpp6
-rw-r--r--editor/plugins/cpu_particles_3d_editor_plugin.h4
-rw-r--r--editor/plugins/curve_editor_plugin.cpp8
-rw-r--r--editor/plugins/curve_editor_plugin.h4
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp4
-rw-r--r--editor/plugins/debugger_editor_plugin.h4
-rw-r--r--editor/plugins/editor_debugger_plugin.cpp4
-rw-r--r--editor/plugins/editor_debugger_plugin.h4
-rw-r--r--editor/plugins/editor_preview_plugins.cpp20
-rw-r--r--editor/plugins/editor_preview_plugins.h4
-rw-r--r--editor/plugins/font_editor_plugin.cpp6
-rw-r--r--editor/plugins/font_editor_plugin.h4
-rw-r--r--editor/plugins/gi_probe_editor_plugin.cpp4
-rw-r--r--editor/plugins/gi_probe_editor_plugin.h4
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/gpu_particles_2d_editor_plugin.h4
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.cpp8
-rw-r--r--editor/plugins/gpu_particles_3d_editor_plugin.h4
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp4
-rw-r--r--editor/plugins/gpu_particles_collision_sdf_editor_plugin.h4
-rw-r--r--editor/plugins/gradient_editor_plugin.cpp4
-rw-r--r--editor/plugins/gradient_editor_plugin.h4
-rw-r--r--editor/plugins/item_list_editor_plugin.cpp16
-rw-r--r--editor/plugins/item_list_editor_plugin.h4
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.h4
-rw-r--r--editor/plugins/line_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/line_2d_editor_plugin.h4
-rw-r--r--editor/plugins/material_editor_plugin.cpp8
-rw-r--r--editor/plugins/material_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp6
-rw-r--r--editor/plugins/mesh_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.cpp10
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.h4
-rw-r--r--editor/plugins/mesh_library_editor_plugin.cpp10
-rw-r--r--editor/plugins/mesh_library_editor_plugin.h4
-rw-r--r--editor/plugins/multimesh_editor_plugin.cpp12
-rw-r--r--editor/plugins/multimesh_editor_plugin.h4
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp4
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.h4
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp548
-rw-r--r--editor/plugins/node_3d_editor_plugin.h18
-rw-r--r--editor/plugins/ot_features_plugin.cpp4
-rw-r--r--editor/plugins/ot_features_plugin.h4
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.cpp10
-rw-r--r--editor/plugins/packed_scene_translation_parser_plugin.h4
-rw-r--r--editor/plugins/path_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/path_2d_editor_plugin.h4
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp6
-rw-r--r--editor/plugins/path_3d_editor_plugin.h4
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/physical_bone_3d_editor_plugin.h4
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp18
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.h4
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp8
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h4
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp4
-rw-r--r--editor/plugins/root_motion_editor_plugin.h4
-rw-r--r--editor/plugins/script_editor_plugin.cpp55
-rw-r--r--editor/plugins/script_editor_plugin.h4
-rw-r--r--editor/plugins/script_text_editor.cpp26
-rw-r--r--editor/plugins/script_text_editor.h4
-rw-r--r--editor/plugins/shader_editor_plugin.cpp14
-rw-r--r--editor/plugins/shader_editor_plugin.h4
-rw-r--r--editor/plugins/shader_file_editor_plugin.cpp8
-rw-r--r--editor/plugins/shader_file_editor_plugin.h4
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.cpp6
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.h4
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp10
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h4
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/skeleton_ik_3d_editor_plugin.h4
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.cpp27
-rw-r--r--editor/plugins/sprite_2d_editor_plugin.h4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp25
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h4
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp4
-rw-r--r--editor/plugins/style_box_editor_plugin.h4
-rw-r--r--editor/plugins/text_editor.cpp12
-rw-r--r--editor/plugins/text_editor.h4
-rw-r--r--editor/plugins/texture_3d_editor_plugin.cpp27
-rw-r--r--editor/plugins/texture_3d_editor_plugin.h8
-rw-r--r--editor/plugins/texture_editor_plugin.cpp12
-rw-r--r--editor/plugins/texture_editor_plugin.h6
-rw-r--r--editor/plugins/texture_layered_editor_plugin.cpp28
-rw-r--r--editor/plugins/texture_layered_editor_plugin.h7
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp143
-rw-r--r--editor/plugins/texture_region_editor_plugin.h8
-rw-r--r--editor/plugins/theme_editor_plugin.cpp14
-rw-r--r--editor/plugins/theme_editor_plugin.h4
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp19
-rw-r--r--editor/plugins/tile_map_editor_plugin.h4
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp25
-rw-r--r--editor/plugins/tile_set_editor_plugin.h4
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp21
-rw-r--r--editor/plugins/version_control_editor_plugin.h5
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp749
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h25
130 files changed, 1912 insertions, 1126 deletions
diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp
index 0b61db6835..876b67fa77 100644
--- a/editor/plugins/abstract_polygon_2d_editor.cpp
+++ b/editor/plugins/abstract_polygon_2d_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -724,7 +724,7 @@ AbstractPolygon2DEditor::AbstractPolygon2DEditor(EditorNode *p_editor, bool p_wi
create_resource = memnew(ConfirmationDialog);
add_child(create_resource);
- create_resource->get_ok()->set_text(TTR("Create"));
+ create_resource->get_ok_button()->set_text(TTR("Create"));
mode = MODE_EDIT;
}
diff --git a/editor/plugins/abstract_polygon_2d_editor.h b/editor/plugins/abstract_polygon_2d_editor.h
index 527803150d..4f9adfff25 100644
--- a/editor/plugins/abstract_polygon_2d_editor.h
+++ b/editor/plugins/abstract_polygon_2d_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp
index 223484044a..d69913cc46 100644
--- a/editor/plugins/animation_blend_space_1d_editor.cpp
+++ b/editor/plugins/animation_blend_space_1d_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -106,7 +106,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
add_point_pos += blend_space->get_min_space();
if (snap->is_pressed()) {
- add_point_pos = Math::stepify(add_point_pos, blend_space->get_snap());
+ add_point_pos = Math::snapped(add_point_pos, blend_space->get_snap());
}
}
@@ -139,7 +139,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
point += drag_ofs.x;
if (snap->is_pressed()) {
- point = Math::stepify(point, blend_space->get_snap());
+ point = Math::snapped(point, blend_space->get_snap());
}
updating = true;
@@ -253,7 +253,7 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_draw() {
if (dragging_selected && selected_point == i) {
point += drag_ofs.x;
if (snap->is_pressed()) {
- point = Math::stepify(point, blend_space->get_snap());
+ point = Math::snapped(point, blend_space->get_snap());
}
}
@@ -454,7 +454,7 @@ void AnimationNodeBlendSpace1DEditor::_update_edited_point_pos() {
pos += drag_ofs.x;
if (snap->is_pressed()) {
- pos = Math::stepify(pos, blend_space->get_snap());
+ pos = Math::snapped(pos, blend_space->get_snap());
}
}
diff --git a/editor/plugins/animation_blend_space_1d_editor.h b/editor/plugins/animation_blend_space_1d_editor.h
index 5ff5da47c0..24c950fdee 100644
--- a/editor/plugins/animation_blend_space_1d_editor.h
+++ b/editor/plugins/animation_blend_space_1d_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp
index 94785a5422..6a57463dbc 100644
--- a/editor/plugins/animation_blend_space_2d_editor.cpp
+++ b/editor/plugins/animation_blend_space_2d_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -129,8 +129,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
add_point_pos += blend_space->get_min_space();
if (snap->is_pressed()) {
- add_point_pos.x = Math::stepify(add_point_pos.x, blend_space->get_snap().x);
- add_point_pos.y = Math::stepify(add_point_pos.y, blend_space->get_snap().y);
+ add_point_pos.x = Math::snapped(add_point_pos.x, blend_space->get_snap().x);
+ add_point_pos.y = Math::snapped(add_point_pos.y, blend_space->get_snap().y);
}
}
@@ -215,8 +215,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven
Vector2 point = blend_space->get_blend_point_position(selected_point);
point += drag_ofs;
if (snap->is_pressed()) {
- point.x = Math::stepify(point.x, blend_space->get_snap().x);
- point.y = Math::stepify(point.y, blend_space->get_snap().y);
+ point.x = Math::snapped(point.x, blend_space->get_snap().x);
+ point.y = Math::snapped(point.y, blend_space->get_snap().y);
}
updating = true;
@@ -467,8 +467,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (dragging_selected && selected_point == point_idx) {
point += drag_ofs;
if (snap->is_pressed()) {
- point.x = Math::stepify(point.x, blend_space->get_snap().x);
- point.y = Math::stepify(point.y, blend_space->get_snap().y);
+ point.x = Math::snapped(point.x, blend_space->get_snap().x);
+ point.y = Math::snapped(point.y, blend_space->get_snap().y);
}
}
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
@@ -503,8 +503,8 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_draw() {
if (dragging_selected && selected_point == i) {
point += drag_ofs;
if (snap->is_pressed()) {
- point.x = Math::stepify(point.x, blend_space->get_snap().x);
- point.y = Math::stepify(point.y, blend_space->get_snap().y);
+ point.x = Math::snapped(point.x, blend_space->get_snap().x);
+ point.y = Math::snapped(point.y, blend_space->get_snap().y);
}
}
point = (point - blend_space->get_min_space()) / (blend_space->get_max_space() - blend_space->get_min_space());
@@ -702,8 +702,8 @@ void AnimationNodeBlendSpace2DEditor::_update_edited_point_pos() {
if (dragging_selected) {
pos += drag_ofs;
if (snap->is_pressed()) {
- pos.x = Math::stepify(pos.x, blend_space->get_snap().x);
- pos.y = Math::stepify(pos.y, blend_space->get_snap().y);
+ pos.x = Math::snapped(pos.x, blend_space->get_snap().x);
+ pos.y = Math::snapped(pos.y, blend_space->get_snap().y);
}
}
updating = true;
diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h
index 64885aeaca..3b8b78b2b5 100644
--- a/editor/plugins/animation_blend_space_2d_editor.h
+++ b/editor/plugins/animation_blend_space_2d_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 38648b5f0a..e7e069e8b6 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -127,7 +127,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
Ref<AnimationNode> agnode = blend_tree->get_node(E->get());
- node->set_offset(blend_tree->get_node_position(E->get()) * EDSCALE);
+ node->set_position_offset(blend_tree->get_node_position(E->get()) * EDSCALE);
node->set_title(agnode->get_caption());
node->set_name(E->get());
@@ -255,6 +255,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
graph->connect_node(from, 0, to, to_idx);
}
+
+ float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
+ graph->set_minimap_opacity(graph_minimap_opacity);
}
void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) {
@@ -416,7 +419,7 @@ void AnimationNodeBlendTreeEditor::_delete_nodes_request() {
}
}
- if (to_erase.empty()) {
+ if (to_erase.is_empty()) {
return;
}
@@ -537,7 +540,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
default: {
} break;
}
- if (!track_type_name.empty()) {
+ if (!track_type_name.is_empty()) {
types[track_path].insert(track_type_name);
}
}
@@ -888,6 +891,8 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
graph->connect("scroll_offset_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_scroll_changed));
graph->connect("delete_nodes_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_nodes_request));
graph->connect("popup_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_popup_request));
+ float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
+ graph->set_minimap_opacity(graph_minimap_opacity);
VSeparator *vs = memnew(VSeparator);
graph->get_zoom_hbox()->add_child(vs);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.h b/editor/plugins/animation_blend_tree_editor_plugin.h
index 3ebf623eef..9f09069719 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.h
+++ b/editor/plugins/animation_blend_tree_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 17cfb5f5f3..cda88c00f3 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -78,7 +78,6 @@ void AnimationPlayerEditor::_notification(int p_what) {
}
frame->set_value(player->get_current_animation_position());
track_editor->set_anim_pos(player->get_current_animation_position());
- EditorNode::get_singleton()->get_inspector()->refresh();
} else if (!player->is_valid()) {
// Reset timeline when the player has been stopped externally
@@ -116,6 +115,19 @@ void AnimationPlayerEditor::_notification(int p_what) {
play_bw_from->set_icon(get_theme_icon("PlayBackwards", "EditorIcons"));
autoplay_icon = get_theme_icon("AutoPlay", "EditorIcons");
+ reset_icon = get_theme_icon("Reload", "EditorIcons");
+ {
+ Ref<Image> autoplay_img = autoplay_icon->get_data();
+ Ref<Image> reset_img = reset_icon->get_data();
+ Ref<Image> autoplay_reset_img;
+ Size2 icon_size = Size2(autoplay_img->get_width(), autoplay_img->get_height());
+ autoplay_reset_img.instance();
+ autoplay_reset_img->create(icon_size.x * 2, icon_size.y, false, autoplay_img->get_format());
+ autoplay_reset_img->blit_rect(autoplay_img, Rect2(Point2(), icon_size), Point2());
+ autoplay_reset_img->blit_rect(reset_img, Rect2(Point2(), icon_size), Point2(icon_size.x, 0));
+ autoplay_reset_icon.instance();
+ autoplay_reset_icon->create_from_image(autoplay_reset_img);
+ }
stop->set_icon(get_theme_icon("Stop", "EditorIcons"));
onion_toggle->set_icon(get_theme_icon("Onion", "EditorIcons"));
@@ -667,7 +679,7 @@ void AnimationPlayerEditor::set_state(const Dictionary &p_state) {
if (p_state.has("animation")) {
String anim = p_state["animation"];
- if (!anim.empty() && player->has_animation(anim)) {
+ if (!anim.is_empty() && player->has_animation(anim)) {
_select_anim_by_name(anim);
_animation_edit();
}
@@ -817,11 +829,17 @@ void AnimationPlayerEditor::_update_player() {
int active_idx = -1;
for (List<StringName>::Element *E = animlist.front(); E; E = E->next()) {
- if (player->get_autoplay() == E->get()) {
- animation->add_icon_item(autoplay_icon, E->get());
- } else {
- animation->add_item(E->get());
+ Ref<Texture2D> icon;
+ if (E->get() == player->get_autoplay()) {
+ if (E->get() == "RESET") {
+ icon = autoplay_reset_icon;
+ } else {
+ icon = autoplay_icon;
+ }
+ } else if (E->get() == "RESET") {
+ icon = reset_icon;
}
+ animation->add_icon_item(icon, E->get());
if (player->get_assigned_animation() == E->get()) {
active_idx = animation->get_item_count() - 1;
@@ -994,7 +1012,7 @@ void AnimationPlayerEditor::_seek_value_changed(float p_value, bool p_set) {
float pos = CLAMP(anim->get_length() * (p_value / frame->get_max()), 0, anim->get_length());
if (track_editor->is_snap_enabled()) {
- pos = Math::stepify(pos, _get_editor_step());
+ pos = Math::snapped(pos, _get_editor_step());
}
if (player->is_valid() && !p_set) {
@@ -1050,11 +1068,9 @@ void AnimationPlayerEditor::_animation_key_editor_seek(float p_pos, bool p_drag)
}
updating = true;
- frame->set_value(Math::stepify(p_pos, _get_editor_step()));
+ frame->set_value(Math::snapped(p_pos, _get_editor_step()));
updating = false;
_seek_value_changed(p_pos, !p_drag);
-
- EditorNode::get_singleton()->get_inspector()->refresh();
}
void AnimationPlayerEditor::_animation_tool_menu(int p_option) {
@@ -1375,7 +1391,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
}
// Backup current animation state.
- AnimatedValuesBackup values_backup = player->backup_animated_values();
+ Ref<AnimatedValuesBackup> values_backup = player->backup_animated_values();
float cpos = player->get_current_animation_position();
// Render every past/future step with the capture shader.
@@ -1405,7 +1421,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
if (valid) {
player->seek(pos, true);
get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds.
- values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D).
+ values_backup->update_skeletons(); // Needed for Skeletons (2D & 3D).
RS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
RS::get_singleton()->viewport_set_parent_viewport(root_vp, onion.captures[cidx]);
@@ -1425,7 +1441,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
// (Seeking with update=true wouldn't do the trick because the current value of the properties
// may not match their value for the current point in the animation).
player->seek(cpos, false);
- player->restore_animated_values(values_backup);
+ values_backup->restore();
// Restore state of main editors.
if (Node3DEditor::get_singleton()->is_visible()) {
@@ -1642,7 +1658,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
name_dialog->register_text_enter(name);
error_dialog = memnew(ConfirmationDialog);
- error_dialog->get_ok()->set_text(TTR("Close"));
+ error_dialog->get_ok_button()->set_text(TTR("Close"));
error_dialog->set_title(TTR("Error!"));
add_child(error_dialog);
@@ -1650,7 +1666,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
blend_editor.dialog = memnew(AcceptDialog);
add_child(blend_editor.dialog);
- blend_editor.dialog->get_ok()->set_text(TTR("Close"));
+ blend_editor.dialog->get_ok_button()->set_text(TTR("Close"));
blend_editor.dialog->set_hide_on_ok(true);
VBoxContainer *blend_vb = memnew(VBoxContainer);
blend_editor.dialog->add_child(blend_vb);
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 17e554ee0d..2f6bf55e4c 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -105,6 +105,8 @@ class AnimationPlayerEditor : public VBoxContainer {
Label *name_title;
UndoRedo *undo_redo;
Ref<Texture2D> autoplay_icon;
+ Ref<Texture2D> reset_icon;
+ Ref<ImageTexture> autoplay_reset_icon;
bool last_active;
float timeline_position;
diff --git a/editor/plugins/animation_state_machine_editor.cpp b/editor/plugins/animation_state_machine_editor.cpp
index c59e056f4f..c6d2faf849 100644
--- a/editor/plugins/animation_state_machine_editor.cpp
+++ b/editor/plugins/animation_state_machine_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -520,7 +520,7 @@ void AnimationNodeStateMachineEditor::_connection_draw(const Vector2 &p_from, co
Transform2D xf;
xf.elements[0] = (p_to - p_from).normalized();
- xf.elements[1] = xf.elements[0].tangent();
+ xf.elements[1] = xf.elements[0].orthogonal();
xf.elements[2] = (p_from + p_to) * 0.5 - xf.elements[1] * icon->get_height() * 0.5 - xf.elements[0] * icon->get_height() * 0.5;
state_machine_draw->draw_set_transform_matrix(xf);
@@ -690,7 +690,7 @@ void AnimationNodeStateMachineEditor::_state_machine_draw() {
tl.width = tr_bidi_offset;
if (state_machine->has_transition(tl.to_node, tl.from_node)) { //offset if same exists
- Vector2 offset = -(tl.from - tl.to).normalized().tangent() * tr_bidi_offset;
+ Vector2 offset = -(tl.from - tl.to).normalized().orthogonal() * tr_bidi_offset;
tl.from += offset;
tl.to += offset;
}
@@ -1291,18 +1291,18 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
state_machine_play_pos = memnew(Control);
state_machine_draw->add_child(state_machine_play_pos);
state_machine_play_pos->set_mouse_filter(MOUSE_FILTER_PASS); //pass all to parent
- state_machine_play_pos->set_anchors_and_margins_preset(PRESET_WIDE);
+ state_machine_play_pos->set_anchors_and_offsets_preset(PRESET_WIDE);
state_machine_play_pos->connect("draw", callable_mp(this, &AnimationNodeStateMachineEditor::_state_machine_pos_draw));
v_scroll = memnew(VScrollBar);
state_machine_draw->add_child(v_scroll);
- v_scroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
+ v_scroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE);
v_scroll->connect("value_changed", callable_mp(this, &AnimationNodeStateMachineEditor::_scroll_changed));
h_scroll = memnew(HScrollBar);
state_machine_draw->add_child(h_scroll);
- h_scroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
- h_scroll->set_margin(MARGIN_RIGHT, -v_scroll->get_size().x * EDSCALE);
+ h_scroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE);
+ h_scroll->set_offset(SIDE_RIGHT, -v_scroll->get_size().x * EDSCALE);
h_scroll->connect("value_changed", callable_mp(this, &AnimationNodeStateMachineEditor::_scroll_changed));
error_panel = memnew(PanelContainer);
@@ -1328,7 +1328,7 @@ AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {
add_child(name_edit_popup);
name_edit = memnew(LineEdit);
name_edit_popup->add_child(name_edit);
- name_edit->set_anchors_and_margins_preset(PRESET_WIDE);
+ name_edit->set_anchors_and_offsets_preset(PRESET_WIDE);
name_edit->connect("text_entered", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited));
name_edit->connect("focus_exited", callable_mp(this, &AnimationNodeStateMachineEditor::_name_edited_focus_out));
diff --git a/editor/plugins/animation_state_machine_editor.h b/editor/plugins/animation_state_machine_editor.h
index 119feb417d..a969ddd26b 100644
--- a/editor/plugins/animation_state_machine_editor.h
+++ b/editor/plugins/animation_state_machine_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 800df12199..c33b06ff32 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h
index fd3a449487..de3d89ae17 100644
--- a/editor/plugins/animation_tree_editor_plugin.h
+++ b/editor/plugins/animation_tree_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index f3aa11317e..d726cd031e 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -87,10 +87,10 @@ void EditorAssetLibraryItem::_bind_methods() {
EditorAssetLibraryItem::EditorAssetLibraryItem() {
Ref<StyleBoxEmpty> border;
border.instance();
- border->set_default_margin(MARGIN_LEFT, 5 * EDSCALE);
- border->set_default_margin(MARGIN_RIGHT, 5 * EDSCALE);
- border->set_default_margin(MARGIN_BOTTOM, 5 * EDSCALE);
- border->set_default_margin(MARGIN_TOP, 5 * EDSCALE);
+ border->set_default_margin(SIDE_LEFT, 5 * EDSCALE);
+ border->set_default_margin(SIDE_RIGHT, 5 * EDSCALE);
+ border->set_default_margin(SIDE_BOTTOM, 5 * EDSCALE);
+ border->set_default_margin(SIDE_TOP, 5 * EDSCALE);
add_theme_style_override("panel", border);
HBoxContainer *hb = memnew(HBoxContainer);
@@ -295,8 +295,8 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
previews->add_child(preview_hb);
- get_ok()->set_text(TTR("Download"));
- get_cancel()->set_text(TTR("Close"));
+ get_ok_button()->set_text(TTR("Download"));
+ get_cancel_button()->set_text(TTR("Close"));
}
///////////////////////////////////////////////////////////////////////////////////
@@ -702,7 +702,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PackedB
}
}
- if (!image->empty()) {
+ if (!image->is_empty()) {
switch (image_queue[p_queue_id].image_type) {
case IMAGE_QUEUE_ICON:
@@ -900,7 +900,7 @@ void EditorAssetLibrary::_search(int p_page) {
}
if (filter->get_text() != String()) {
- args += "&filter=" + filter->get_text().http_escape();
+ args += "&filter=" + filter->get_text().uri_encode();
}
if (p_page > 0) {
@@ -1151,7 +1151,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
asset_bottom_page = _make_pages(page, pages, page_len, total_items, result.size());
library_vb->add_child(asset_bottom_page);
- if (result.empty()) {
+ if (result.is_empty()) {
if (filter->get_text() != String()) {
library_error->set_text(
vformat(TTR("No results for \"%s\"."), filter->get_text()));
@@ -1188,7 +1188,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
}
}
- if (!result.empty()) {
+ if (!result.is_empty()) {
library_scroll->set_v_scroll(0);
}
} break;
@@ -1364,10 +1364,18 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
search_hb2->add_child(memnew(Label(TTR("Site:") + " ")));
repository = memnew(OptionButton);
- repository->add_item("godotengine.org");
- repository->set_item_metadata(0, "https://godotengine.org/asset-library/api");
- repository->add_item("localhost");
- repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api");
+ {
+ Dictionary default_urls;
+ default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api";
+ default_urls["localhost"] = "http://127.0.0.1/asset-library/api";
+ Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true);
+ Array keys = available_urls.keys();
+ for (int i = 0; i < available_urls.size(); i++) {
+ String key = keys[i];
+ repository->add_item(key);
+ repository->set_item_metadata(i, available_urls[key]);
+ }
+ }
repository->connect("item_selected", callable_mp(this, &EditorAssetLibrary::_repository_changed));
@@ -1400,10 +1408,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
Ref<StyleBoxEmpty> border2;
border2.instance();
- border2->set_default_margin(MARGIN_LEFT, 15 * EDSCALE);
- border2->set_default_margin(MARGIN_RIGHT, 35 * EDSCALE);
- border2->set_default_margin(MARGIN_BOTTOM, 15 * EDSCALE);
- border2->set_default_margin(MARGIN_TOP, 15 * EDSCALE);
+ border2->set_default_margin(SIDE_LEFT, 15 * EDSCALE);
+ border2->set_default_margin(SIDE_RIGHT, 35 * EDSCALE);
+ border2->set_default_margin(SIDE_BOTTOM, 15 * EDSCALE);
+ border2->set_default_margin(SIDE_TOP, 15 * EDSCALE);
PanelContainer *library_vb_border = memnew(PanelContainer);
library_scroll->add_child(library_vb_border);
@@ -1492,8 +1500,8 @@ AssetLibraryEditorPlugin::AssetLibraryEditorPlugin(EditorNode *p_node) {
editor = p_node;
addon_library = memnew(EditorAssetLibrary);
addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor->get_viewport()->add_child(addon_library);
- addon_library->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ editor->get_main_control()->add_child(addon_library);
+ addon_library->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
addon_library->hide();
}
diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h
index b69dfc208e..0509145673 100644
--- a/editor/plugins/asset_library_editor_plugin.h
+++ b/editor/plugins/asset_library_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp
index 998916349c..5963092860 100644
--- a/editor/plugins/audio_stream_editor_plugin.cpp
+++ b/editor/plugins/audio_stream_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,7 +96,7 @@ void AudioStreamEditor::_preview_changed(ObjectID p_which) {
}
}
-void AudioStreamEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+void AudioStreamEditor::_audio_changed() {
if (!is_visible()) {
return;
}
@@ -172,7 +172,7 @@ void AudioStreamEditor::_seek_to(real_t p_x) {
void AudioStreamEditor::edit(Ref<AudioStream> p_stream) {
if (!stream.is_null()) {
- stream->remove_change_receptor(this);
+ stream->disconnect("changed", callable_mp(this, &AudioStreamEditor::_audio_changed));
}
stream = p_stream;
@@ -182,7 +182,7 @@ void AudioStreamEditor::edit(Ref<AudioStream> p_stream) {
_duration_label->set_text(text);
if (!stream.is_null()) {
- stream->add_change_receptor(this);
+ stream->connect("changed", callable_mp(this, &AudioStreamEditor::_audio_changed));
update();
} else {
hide();
@@ -202,7 +202,7 @@ AudioStreamEditor::AudioStreamEditor() {
add_child(_player);
VBoxContainer *vbox = memnew(VBoxContainer);
- vbox->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_MINSIZE, 0);
+ vbox->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_MINSIZE, 0);
add_child(vbox);
_preview = memnew(ColorRect);
@@ -211,7 +211,7 @@ AudioStreamEditor::AudioStreamEditor() {
vbox->add_child(_preview);
_indicator = memnew(Control);
- _indicator->set_anchors_and_margins_preset(PRESET_WIDE);
+ _indicator->set_anchors_and_offsets_preset(PRESET_WIDE);
_indicator->connect("draw", callable_mp(this, &AudioStreamEditor::_draw_indicator));
_indicator->connect("gui_input", callable_mp(this, &AudioStreamEditor::_on_input_indicator));
_preview->add_child(_indicator);
diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h
index 5936b91fa1..aa906a6a05 100644
--- a/editor/plugins/audio_stream_editor_plugin.h
+++ b/editor/plugins/audio_stream_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,6 +53,8 @@ class AudioStreamEditor : public ColorRect {
float _current;
bool _dragging;
+ void _audio_changed();
+
protected:
void _notification(int p_what);
void _preview_changed(ObjectID p_which);
@@ -63,7 +65,6 @@ protected:
void _draw_indicator();
void _on_input_indicator(Ref<InputEvent> p_event);
void _seek_to(real_t p_x);
- void _changed_callback(Object *p_changed, const char *p_prop) override;
static void _bind_methods();
public:
diff --git a/editor/plugins/baked_lightmap_editor_plugin.cpp b/editor/plugins/baked_lightmap_editor_plugin.cpp
index e5d4e4a761..470b61bf40 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.cpp
+++ b/editor/plugins/baked_lightmap_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/baked_lightmap_editor_plugin.h b/editor/plugins/baked_lightmap_editor_plugin.h
index b4c7c07562..d291c377d9 100644
--- a/editor/plugins/baked_lightmap_editor_plugin.h
+++ b/editor/plugins/baked_lightmap_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/camera_3d_editor_plugin.cpp b/editor/plugins/camera_3d_editor_plugin.cpp
index 48f9f208a5..8583e95b25 100644
--- a/editor/plugins/camera_3d_editor_plugin.cpp
+++ b/editor/plugins/camera_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -69,12 +69,12 @@ Camera3DEditor::Camera3DEditor() {
preview->set_text(TTR("Preview"));
preview->set_toggle_mode(true);
- preview->set_anchor(MARGIN_LEFT, Control::ANCHOR_END);
- preview->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END);
- preview->set_margin(MARGIN_LEFT, -60);
- preview->set_margin(MARGIN_RIGHT, 0);
- preview->set_margin(MARGIN_TOP, 0);
- preview->set_margin(MARGIN_BOTTOM, 10);
+ preview->set_anchor(SIDE_LEFT, Control::ANCHOR_END);
+ preview->set_anchor(SIDE_RIGHT, Control::ANCHOR_END);
+ preview->set_offset(SIDE_LEFT, -60);
+ preview->set_offset(SIDE_RIGHT, 0);
+ preview->set_offset(SIDE_TOP, 0);
+ preview->set_offset(SIDE_BOTTOM, 10);
preview->connect("pressed", callable_mp(this, &Camera3DEditor::_pressed));
}
@@ -98,14 +98,14 @@ void Camera3DEditorPlugin::make_visible(bool p_visible) {
Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
/* camera_editor = memnew( CameraEditor );
- editor->get_viewport()->add_child(camera_editor);
-
- camera_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END);
- camera_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END);
- camera_editor->set_margin(MARGIN_LEFT,60);
- camera_editor->set_margin(MARGIN_RIGHT,0);
- camera_editor->set_margin(MARGIN_TOP,0);
- camera_editor->set_margin(MARGIN_BOTTOM,10);
+ editor->get_main_control()->add_child(camera_editor);
+
+ camera_editor->set_anchor(SIDE_LEFT,Control::ANCHOR_END);
+ camera_editor->set_anchor(SIDE_RIGHT,Control::ANCHOR_END);
+ camera_editor->set_offset(SIDE_LEFT,60);
+ camera_editor->set_offset(SIDE_RIGHT,0);
+ camera_editor->set_offset(SIDE_TOP,0);
+ camera_editor->set_offset(SIDE_BOTTOM,10);
camera_editor->hide();
diff --git a/editor/plugins/camera_3d_editor_plugin.h b/editor/plugins/camera_3d_editor_plugin.h
index 023f1866df..e087dd22a8 100644
--- a/editor/plugins/camera_3d_editor_plugin.h
+++ b/editor/plugins/camera_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 4227482ccc..d92837b68d 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -216,8 +216,8 @@ public:
grid_step_x->set_value(p_grid_step.x);
grid_step_y->set_value(p_grid_step.y);
primary_grid_steps->set_value(p_primary_grid_steps);
- rotation_offset->set_value(p_rotation_offset * (180 / Math_PI));
- rotation_step->set_value(p_rotation_step * (180 / Math_PI));
+ rotation_offset->set_value(Math::rad2deg(p_rotation_offset));
+ rotation_step->set_value(Math::rad2deg(p_rotation_step));
scale_step->set_value(p_scale_step);
}
@@ -225,8 +225,8 @@ public:
p_grid_offset = Point2(grid_offset_x->get_value(), grid_offset_y->get_value());
p_grid_step = Point2(grid_step_x->get_value(), grid_step_y->get_value());
p_primary_grid_steps = int(primary_grid_steps->get_value());
- p_rotation_offset = rotation_offset->get_value() / (180 / Math_PI);
- p_rotation_step = rotation_step->get_value() / (180 / Math_PI);
+ p_rotation_offset = Math::deg2rad(rotation_offset->get_value());
+ p_rotation_step = Math::deg2rad(rotation_step->get_value());
p_scale_step = scale_step->get_value();
}
};
@@ -366,8 +366,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
// Self anchors
if ((is_snap_active && snap_node_anchors && (p_modes & SNAP_NODE_ANCHORS)) || (p_forced_modes & SNAP_NODE_ANCHORS)) {
if (const Control *c = Object::cast_to<Control>(p_self_canvas_item)) {
- Point2 begin = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(MARGIN_LEFT), c->get_anchor(MARGIN_TOP))));
- Point2 end = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(MARGIN_RIGHT), c->get_anchor(MARGIN_BOTTOM))));
+ Point2 begin = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(SIDE_LEFT), c->get_anchor(SIDE_TOP))));
+ Point2 end = p_self_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(c->get_anchor(SIDE_RIGHT), c->get_anchor(SIDE_BOTTOM))));
_snap_if_closer_point(p_target, output, snap_target, begin, SNAP_TARGET_SELF_ANCHORS, rotation);
_snap_if_closer_point(p_target, output, snap_target, end, SNAP_TARGET_SELF_ANCHORS, rotation);
}
@@ -444,8 +444,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
}
}
Point2 grid_output;
- grid_output.x = Math::stepify(p_target.x - offset.x, grid_step.x * Math::pow(2.0, grid_step_multiplier)) + offset.x;
- grid_output.y = Math::stepify(p_target.y - offset.y, grid_step.y * Math::pow(2.0, grid_step_multiplier)) + offset.y;
+ grid_output.x = Math::snapped(p_target.x - offset.x, grid_step.x * Math::pow(2.0, grid_step_multiplier)) + offset.x;
+ grid_output.y = Math::snapped(p_target.y - offset.y, grid_step.y * Math::pow(2.0, grid_step_multiplier)) + offset.y;
_snap_if_closer_point(p_target, output, snap_target, grid_output, SNAP_TARGET_GRID, 0.0, -1.0);
}
@@ -462,9 +462,9 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig
float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
if (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) {
if (snap_relative) {
- return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step);
+ return Math::snapped(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step);
} else {
- return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset;
+ return Math::snapped(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset;
}
} else {
return p_target;
@@ -518,7 +518,7 @@ void CanvasItemEditor::_keying_changed() {
}
Rect2 CanvasItemEditor::_get_encompassing_rect_from_list(List<CanvasItem *> p_list) {
- ERR_FAIL_COND_V(p_list.empty(), Rect2());
+ ERR_FAIL_COND_V(p_list.is_empty(), Rect2());
// Handles the first element
CanvasItem *canvas_item = p_list.front()->get();
@@ -727,7 +727,7 @@ bool CanvasItemEditor::_get_bone_shape(Vector<Vector2> *shape, Vector<Vector2> *
}
Vector2 rel = to - from;
- Vector2 relt = rel.tangent().normalized() * bone_width;
+ Vector2 relt = rel.orthogonal().normalized() * bone_width;
Vector2 reln = rel.normalized();
Vector2 reltn = relt.normalized();
@@ -963,9 +963,24 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it
}
void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) {
- undo_redo->create_action(action_name);
+ List<CanvasItem *> modified_canvas_items;
for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get();
+ Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item)->undo_state;
+ Dictionary new_state = canvas_item->_edit_get_state();
+
+ if (old_state.hash() != new_state.hash()) {
+ modified_canvas_items.push_back(canvas_item);
+ }
+ }
+
+ if (modified_canvas_items.is_empty()) {
+ return;
+ }
+
+ undo_redo->create_action(action_name);
+ for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) {
+ CanvasItem *canvas_item = E->get();
CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item);
undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state());
undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state);
@@ -1147,7 +1162,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
if (dragged_guide_index >= 0) {
vguides.remove(dragged_guide_index);
undo_redo->create_action(TTR("Remove Vertical Guide"));
- if (vguides.empty()) {
+ if (vguides.is_empty()) {
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "remove_meta", "_edit_vertical_guides_");
} else {
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides);
@@ -1180,7 +1195,7 @@ bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_eve
if (dragged_guide_index >= 0) {
hguides.remove(dragged_guide_index);
undo_redo->create_action(TTR("Remove Horizontal Guide"));
- if (hguides.empty()) {
+ if (hguides.is_empty()) {
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "remove_meta", "_edit_horizontal_guides_");
} else {
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides);
@@ -1628,10 +1643,10 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
Control *control = Object::cast_to<Control>(selection[0]);
if (control && _is_node_movable(control)) {
Vector2 anchor_pos[4];
- anchor_pos[0] = Vector2(control->get_anchor(MARGIN_LEFT), control->get_anchor(MARGIN_TOP));
- anchor_pos[1] = Vector2(control->get_anchor(MARGIN_RIGHT), control->get_anchor(MARGIN_TOP));
- anchor_pos[2] = Vector2(control->get_anchor(MARGIN_RIGHT), control->get_anchor(MARGIN_BOTTOM));
- anchor_pos[3] = Vector2(control->get_anchor(MARGIN_LEFT), control->get_anchor(MARGIN_BOTTOM));
+ anchor_pos[0] = Vector2(control->get_anchor(SIDE_LEFT), control->get_anchor(SIDE_TOP));
+ anchor_pos[1] = Vector2(control->get_anchor(SIDE_RIGHT), control->get_anchor(SIDE_TOP));
+ anchor_pos[2] = Vector2(control->get_anchor(SIDE_RIGHT), control->get_anchor(SIDE_BOTTOM));
+ anchor_pos[3] = Vector2(control->get_anchor(SIDE_LEFT), control->get_anchor(SIDE_BOTTOM));
Rect2 anchor_rects[4];
for (int i = 0; i < 4; i++) {
@@ -1681,8 +1696,8 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
Transform2D xform = control->get_global_transform_with_canvas().affine_inverse();
Point2 previous_anchor;
- previous_anchor.x = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_BOTTOM_LEFT) ? control->get_anchor(MARGIN_LEFT) : control->get_anchor(MARGIN_RIGHT);
- previous_anchor.y = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_TOP_RIGHT) ? control->get_anchor(MARGIN_TOP) : control->get_anchor(MARGIN_BOTTOM);
+ previous_anchor.x = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_BOTTOM_LEFT) ? control->get_anchor(SIDE_LEFT) : control->get_anchor(SIDE_RIGHT);
+ previous_anchor.y = (drag_type == DRAG_ANCHOR_TOP_LEFT || drag_type == DRAG_ANCHOR_TOP_RIGHT) ? control->get_anchor(SIDE_TOP) : control->get_anchor(SIDE_BOTTOM);
previous_anchor = xform.affine_inverse().xform(_anchor_to_position(control, previous_anchor));
Vector2 new_anchor = xform.xform(snap_point(previous_anchor + (drag_to - drag_from), SNAP_GRID | SNAP_OTHER_NODES, SNAP_NODE_PARENT | SNAP_NODE_SIDES | SNAP_NODE_CENTER, control));
@@ -1695,44 +1710,44 @@ bool CanvasItemEditor::_gui_input_anchors(const Ref<InputEvent> &p_event) {
switch (drag_type) {
case DRAG_ANCHOR_TOP_LEFT:
if (!use_single_axis || !use_y) {
- control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false);
+ control->set_anchor(SIDE_LEFT, new_anchor.x, false, false);
}
if (!use_single_axis || use_y) {
- control->set_anchor(MARGIN_TOP, new_anchor.y, false, false);
+ control->set_anchor(SIDE_TOP, new_anchor.y, false, false);
}
break;
case DRAG_ANCHOR_TOP_RIGHT:
if (!use_single_axis || !use_y) {
- control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false);
+ control->set_anchor(SIDE_RIGHT, new_anchor.x, false, false);
}
if (!use_single_axis || use_y) {
- control->set_anchor(MARGIN_TOP, new_anchor.y, false, false);
+ control->set_anchor(SIDE_TOP, new_anchor.y, false, false);
}
break;
case DRAG_ANCHOR_BOTTOM_RIGHT:
if (!use_single_axis || !use_y) {
- control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, false);
+ control->set_anchor(SIDE_RIGHT, new_anchor.x, false, false);
}
if (!use_single_axis || use_y) {
- control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
+ control->set_anchor(SIDE_BOTTOM, new_anchor.y, false, false);
}
break;
case DRAG_ANCHOR_BOTTOM_LEFT:
if (!use_single_axis || !use_y) {
- control->set_anchor(MARGIN_LEFT, new_anchor.x, false, false);
+ control->set_anchor(SIDE_LEFT, new_anchor.x, false, false);
}
if (!use_single_axis || use_y) {
- control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, false);
+ control->set_anchor(SIDE_BOTTOM, new_anchor.y, false, false);
}
break;
case DRAG_ANCHOR_ALL:
if (!use_single_axis || !use_y) {
- control->set_anchor(MARGIN_LEFT, new_anchor.x, false, true);
- control->set_anchor(MARGIN_RIGHT, new_anchor.x, false, true);
+ control->set_anchor(SIDE_LEFT, new_anchor.x, false, true);
+ control->set_anchor(SIDE_RIGHT, new_anchor.x, false, true);
}
if (!use_single_axis || use_y) {
- control->set_anchor(MARGIN_TOP, new_anchor.y, false, true);
- control->set_anchor(MARGIN_BOTTOM, new_anchor.y, false, true);
+ control->set_anchor(SIDE_TOP, new_anchor.y, false, true);
+ control->set_anchor(SIDE_BOTTOM, new_anchor.y, false, true);
}
break;
default:
@@ -1808,7 +1823,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
}
ofs = (endpoints[i] + endpoints[next]) / 2;
- ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
+ ofs += (endpoints[next] - endpoints[i]).orthogonal().normalized() * (select_handle->get_size().width / 2);
if (ofs.distance_to(b->get_position()) < radius) {
resize_drag = dragger[i * 2 + 1];
}
@@ -1931,8 +1946,8 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
vformat(
TTR("Scale Node2D \"%s\" to (%s, %s)"),
drag_selection[0]->get_name(),
- Math::stepify(drag_selection[0]->_edit_get_scale().x, 0.01),
- Math::stepify(drag_selection[0]->_edit_get_scale().y, 0.01)),
+ Math::snapped(drag_selection[0]->_edit_get_scale().x, 0.01),
+ Math::snapped(drag_selection[0]->_edit_get_scale().y, 0.01)),
true);
} else {
// Extends from Control.
@@ -2083,8 +2098,8 @@ bool CanvasItemEditor::_gui_input_scale(const Ref<InputEvent> &p_event) {
drag_selection,
vformat(TTR("Scale CanvasItem \"%s\" to (%s, %s)"),
drag_selection[0]->get_name(),
- Math::stepify(drag_selection[0]->_edit_get_scale().x, 0.01),
- Math::stepify(drag_selection[0]->_edit_get_scale().y, 0.01)),
+ Math::snapped(drag_selection[0]->_edit_get_scale().x, 0.01),
+ Math::snapped(drag_selection[0]->_edit_get_scale().y, 0.01)),
true);
}
if (key_auto_insert_button->is_pressed()) {
@@ -2400,7 +2415,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
_select_click_on_item(item, click, b->get_shift());
return true;
- } else if (!selection_results.empty()) {
+ } else if (!selection_results.is_empty()) {
// Sorts items according the their z-index
selection_results.sort();
@@ -2463,13 +2478,13 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
// Retrieve the bones
Vector<_SelectResult> selection = Vector<_SelectResult>();
_get_bones_at_pos(click, selection);
- if (!selection.empty()) {
+ if (!selection.is_empty()) {
canvas_item = selection[0].item;
} else {
// Retrieve the canvas items
selection = Vector<_SelectResult>();
_get_canvas_items_at_pos(click, selection);
- if (!selection.empty()) {
+ if (!selection.is_empty()) {
canvas_item = selection[0].item;
}
}
@@ -2780,37 +2795,37 @@ void CanvasItemEditor::_update_cursor() {
viewport->set_default_cursor_shape(c);
}
-void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Margin p_side) {
+void CanvasItemEditor::_draw_text_at_position(Point2 p_position, String p_string, Side p_side) {
Color color = get_theme_color("font_color", "Editor");
color.a = 0.8;
Ref<Font> font = get_theme_font("font", "Label");
int font_size = get_theme_font_size("font_size", "Label");
Size2 text_size = font->get_string_size(p_string, font_size);
switch (p_side) {
- case MARGIN_LEFT:
+ case SIDE_LEFT:
p_position += Vector2(-text_size.x - 5, text_size.y / 2);
break;
- case MARGIN_TOP:
+ case SIDE_TOP:
p_position += Vector2(-text_size.x / 2, -5);
break;
- case MARGIN_RIGHT:
+ case SIDE_RIGHT:
p_position += Vector2(5, text_size.y / 2);
break;
- case MARGIN_BOTTOM:
+ case SIDE_BOTTOM:
p_position += Vector2(-text_size.x / 2, text_size.y + 5);
break;
}
viewport->draw_string(font, p_position, p_string, HALIGN_LEFT, -1, font_size, color);
}
-void CanvasItemEditor::_draw_margin_at_position(int p_value, Point2 p_position, Margin p_side) {
+void CanvasItemEditor::_draw_margin_at_position(int p_value, Point2 p_position, Side p_side) {
String str = TS->format_number(vformat("%d " + TTR("px"), p_value));
if (p_value != 0) {
_draw_text_at_position(p_position, str, p_side);
}
}
-void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_position, Margin p_side) {
+void CanvasItemEditor::_draw_percentage_at_position(float p_value, Point2 p_position, Side p_side) {
String str = TS->format_number(vformat("%.1f ", p_value * 100.0)) + TS->percent_sign();
if (p_value != 0) {
_draw_text_at_position(p_position, str, p_side);
@@ -2935,7 +2950,7 @@ void CanvasItemEditor::_draw_rulers() {
// Draw top ruler
viewport->draw_rect(Rect2(Point2(RULER_WIDTH, 0), Size2(viewport->get_size().x, RULER_WIDTH)), bg_color);
for (int i = Math::ceil(first.x); i < last.x; i++) {
- Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0));
+ Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0)).round();
if (i % (major_subdivision * minor_subdivision) == 0) {
viewport->draw_line(Point2(position.x, 0), Point2(position.x, RULER_WIDTH), graduation_color, Math::round(EDSCALE));
float val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(i, 0)).x;
@@ -2952,7 +2967,7 @@ void CanvasItemEditor::_draw_rulers() {
// Draw left ruler
viewport->draw_rect(Rect2(Point2(0, RULER_WIDTH), Size2(RULER_WIDTH, viewport->get_size().y)), bg_color);
for (int i = Math::ceil(first.y); i < last.y; i++) {
- Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i));
+ Point2 position = (transform * ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).round();
if (i % (major_subdivision * minor_subdivision) == 0) {
viewport->draw_line(Point2(0, position.y), Point2(RULER_WIDTH, position.y), graduation_color, Math::round(EDSCALE));
float val = (ruler_transform * major_subdivide * minor_subdivide).xform(Point2(0, i)).y;
@@ -3074,15 +3089,18 @@ void CanvasItemEditor::_draw_ruler_tool() {
int font_size = get_theme_font_size("bold_size", "EditorFonts");
Color font_color = get_theme_color("font_color", "Editor");
Color font_secondary_color = font_color;
- font_secondary_color.a = 0.5;
+ font_secondary_color.set_v(font_secondary_color.get_v() > 0.5 ? 0.7 : 0.3);
+ Color outline_color = font_color.inverted();
float text_height = font->get_height(font_size);
+
+ const float outline_size = 2;
const float text_width = 76;
const float angle_text_width = 54;
Point2 text_pos = (begin + end) / 2 - Vector2(text_width / 2, text_height / 2);
text_pos.x = CLAMP(text_pos.x, text_width / 2, viewport->get_rect().size.x - text_width * 1.5);
text_pos.y = CLAMP(text_pos.y, text_height * 1.5, viewport->get_rect().size.y - text_height * 1.5);
- viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.length())), HALIGN_LEFT, -1, font_size, font_color);
+ viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color);
if (draw_secondary_lines) {
const float horizontal_angle_rad = atan2(length_vector.y, length_vector.x);
@@ -3092,16 +3110,16 @@ void CanvasItemEditor::_draw_ruler_tool() {
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
- viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.y)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color);
Point2 v_angle_text_pos = Point2();
v_angle_text_pos.x = CLAMP(begin.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
v_angle_text_pos.y = begin.y < end.y ? MIN(text_pos2.y - 2 * text_height, begin.y - text_height * 0.5) : MAX(text_pos2.y + text_height * 3, begin.y + text_height * 1.5);
- viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color);
+ viewport->draw_string(font, v_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), vertical_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y - text_height / 2) : MAX(text_pos.y + text_height * 2, end.y - text_height / 2);
- viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%.2f " + TTR("px"), length_vector.x)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color);
Point2 h_angle_text_pos = Point2();
h_angle_text_pos.x = CLAMP(end.x - angle_text_width / 2, angle_text_width / 2, viewport->get_rect().size.x - angle_text_width);
@@ -3118,7 +3136,7 @@ void CanvasItemEditor::_draw_ruler_tool() {
h_angle_text_pos.y = MIN(text_pos.y - height_multiplier * text_height, MIN(end.y - text_height * 0.5, text_pos2.y - height_multiplier * text_height));
}
}
- viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color);
+ viewport->draw_string(font, h_angle_text_pos, TS->format_number(vformat("%d " + TTR("deg"), horizontal_angle)), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color);
// Angle arcs
int arc_point_count = 8;
@@ -3131,16 +3149,16 @@ void CanvasItemEditor::_draw_ruler_tool() {
float arc_1_start_angle =
end_to_begin.x < 0 ?
- (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0) :
- (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
+ (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0) :
+ (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
float arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
// Constrain arc to triangle height & max size
float arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.y)), arc_max_radius);
float arc_2_start_angle =
end_to_begin.x < 0 ?
- (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad) :
- (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
+ (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad) :
+ (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
float arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
// Constrain arc to triangle width & max size
float arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.x)), arc_max_radius);
@@ -3155,17 +3173,17 @@ void CanvasItemEditor::_draw_ruler_tool() {
text_pos.y = CLAMP(text_pos.y, text_height * 2.5, viewport->get_rect().size.y - text_height / 2);
if (draw_secondary_lines) {
- viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("units"), (length_vector / grid_step).length())), HALIGN_LEFT, -1, font_size, font_color);
+ viewport->draw_string(font, text_pos, TS->format_number(vformat("%.2f " + TTR("units"), (length_vector / grid_step).length())), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color);
Point2 text_pos2 = text_pos;
text_pos2.x = begin.x < text_pos.x ? MIN(text_pos.x - text_width, begin.x - text_width / 2) : MAX(text_pos.x + text_width, begin.x - text_width / 2);
- viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.y / grid_step.y))), HALIGN_LEFT, -1, font_size, font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.y / grid_step.y))), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color);
text_pos2 = text_pos;
text_pos2.y = end.y < text_pos.y ? MIN(text_pos.y - text_height * 2, end.y + text_height / 2) : MAX(text_pos.y + text_height * 2, end.y + text_height / 2);
- viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.x / grid_step.x))), HALIGN_LEFT, -1, font_size, font_secondary_color);
+ viewport->draw_string(font, text_pos2, TS->format_number(vformat("%d " + TTR("units"), roundf(length_vector.x / grid_step.x))), HALIGN_LEFT, -1, font_size, font_secondary_color, outline_size, outline_color);
} else {
- viewport->draw_string(font, text_pos, TS->format_number(vformat("%d " + TTR("units"), roundf((length_vector / grid_step).length()))), HALIGN_LEFT, -1, font_size, font_color);
+ viewport->draw_string(font, text_pos, TS->format_number(vformat("%d " + TTR("units"), roundf((length_vector / grid_step).length()))), HALIGN_LEFT, -1, font_size, font_color, outline_size, outline_color);
}
}
} else {
@@ -3182,10 +3200,10 @@ void CanvasItemEditor::_draw_control_anchors(Control *control) {
if (tool == TOOL_SELECT && !Object::cast_to<Container>(control->get_parent())) {
// Compute the anchors
float anchors_values[4];
- anchors_values[0] = control->get_anchor(MARGIN_LEFT);
- anchors_values[1] = control->get_anchor(MARGIN_TOP);
- anchors_values[2] = control->get_anchor(MARGIN_RIGHT);
- anchors_values[3] = control->get_anchor(MARGIN_BOTTOM);
+ anchors_values[0] = control->get_anchor(SIDE_LEFT);
+ anchors_values[1] = control->get_anchor(SIDE_TOP);
+ anchors_values[2] = control->get_anchor(SIDE_RIGHT);
+ anchors_values[3] = control->get_anchor(SIDE_BOTTOM);
Vector2 anchors_pos[4];
for (int i = 0; i < 4; i++) {
@@ -3221,10 +3239,10 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
// Compute the anchors
float anchors_values[4];
- anchors_values[0] = control->get_anchor(MARGIN_LEFT);
- anchors_values[1] = control->get_anchor(MARGIN_TOP);
- anchors_values[2] = control->get_anchor(MARGIN_RIGHT);
- anchors_values[3] = control->get_anchor(MARGIN_BOTTOM);
+ anchors_values[0] = control->get_anchor(SIDE_LEFT);
+ anchors_values[1] = control->get_anchor(SIDE_TOP);
+ anchors_values[2] = control->get_anchor(SIDE_RIGHT);
+ anchors_values[3] = control->get_anchor(SIDE_BOTTOM);
Vector2 anchors[4];
Vector2 anchors_pos[4];
@@ -3277,19 +3295,19 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
float percent_val;
percent_val = anchors_values[(dragged_anchor + 2) % 4] - anchors_values[dragged_anchor];
percent_val = (dragged_anchor >= 2) ? -percent_val : percent_val;
- _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 1) % 4]) / 2, (Margin)((dragged_anchor + 1) % 4));
+ _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 1) % 4]) / 2, (Side)((dragged_anchor + 1) % 4));
percent_val = anchors_values[(dragged_anchor + 3) % 4] - anchors_values[(dragged_anchor + 1) % 4];
percent_val = ((dragged_anchor + 1) % 4 >= 2) ? -percent_val : percent_val;
- _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 3) % 4]) / 2, (Margin)(dragged_anchor));
+ _draw_percentage_at_position(percent_val, (anchors_pos[dragged_anchor] + anchors_pos[(dragged_anchor + 3) % 4]) / 2, (Side)(dragged_anchor));
percent_val = anchors_values[(dragged_anchor + 1) % 4];
percent_val = ((dragged_anchor + 1) % 4 >= 2) ? ANCHOR_END - percent_val : percent_val;
- _draw_percentage_at_position(percent_val, (line_starts[dragged_anchor] + anchors_pos[dragged_anchor]) / 2, (Margin)(dragged_anchor));
+ _draw_percentage_at_position(percent_val, (line_starts[dragged_anchor] + anchors_pos[dragged_anchor]) / 2, (Side)(dragged_anchor));
percent_val = anchors_values[dragged_anchor];
percent_val = (dragged_anchor >= 2) ? ANCHOR_END - percent_val : percent_val;
- _draw_percentage_at_position(percent_val, (line_ends[(dragged_anchor + 1) % 4] + anchors_pos[dragged_anchor]) / 2, (Margin)((dragged_anchor + 1) % 4));
+ _draw_percentage_at_position(percent_val, (line_ends[(dragged_anchor + 1) % 4] + anchors_pos[dragged_anchor]) / 2, (Side)((dragged_anchor + 1) % 4));
}
// Draw the margin values and the node width/height when dragging control side
@@ -3299,22 +3317,22 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
Rect2 parent_rect = control->get_parent_anchorable_rect();
- node_pos_in_parent[0] = control->get_anchor(MARGIN_LEFT) * parent_rect.size.width + control->get_margin(MARGIN_LEFT) + parent_rect.position.x;
- node_pos_in_parent[1] = control->get_anchor(MARGIN_TOP) * parent_rect.size.height + control->get_margin(MARGIN_TOP) + parent_rect.position.y;
- node_pos_in_parent[2] = control->get_anchor(MARGIN_RIGHT) * parent_rect.size.width + control->get_margin(MARGIN_RIGHT) + parent_rect.position.x;
- node_pos_in_parent[3] = control->get_anchor(MARGIN_BOTTOM) * parent_rect.size.height + control->get_margin(MARGIN_BOTTOM) + parent_rect.position.y;
+ node_pos_in_parent[0] = control->get_anchor(SIDE_LEFT) * parent_rect.size.width + control->get_offset(SIDE_LEFT) + parent_rect.position.x;
+ node_pos_in_parent[1] = control->get_anchor(SIDE_TOP) * parent_rect.size.height + control->get_offset(SIDE_TOP) + parent_rect.position.y;
+ node_pos_in_parent[2] = control->get_anchor(SIDE_RIGHT) * parent_rect.size.width + control->get_offset(SIDE_RIGHT) + parent_rect.position.x;
+ node_pos_in_parent[3] = control->get_anchor(SIDE_BOTTOM) * parent_rect.size.height + control->get_offset(SIDE_BOTTOM) + parent_rect.position.y;
Point2 start, end;
switch (drag_type) {
case DRAG_LEFT:
case DRAG_TOP_LEFT:
case DRAG_BOTTOM_LEFT:
- _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM);
+ _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), SIDE_BOTTOM);
[[fallthrough]];
case DRAG_MOVE:
start = Vector2(node_pos_in_parent[0], Math::lerp(node_pos_in_parent[1], node_pos_in_parent[3], ratio));
- end = start - Vector2(control->get_margin(MARGIN_LEFT), 0);
- _draw_margin_at_position(control->get_margin(MARGIN_LEFT), parent_transform.xform((start + end) / 2), MARGIN_TOP);
+ end = start - Vector2(control->get_offset(SIDE_LEFT), 0);
+ _draw_margin_at_position(control->get_offset(SIDE_LEFT), parent_transform.xform((start + end) / 2), SIDE_TOP);
viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE));
break;
default:
@@ -3324,12 +3342,12 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_RIGHT:
case DRAG_TOP_RIGHT:
case DRAG_BOTTOM_RIGHT:
- _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), MARGIN_BOTTOM);
+ _draw_margin_at_position(control->get_size().width, parent_transform.xform(Vector2((node_pos_in_parent[0] + node_pos_in_parent[2]) / 2, node_pos_in_parent[3])) + Vector2(0, 5), SIDE_BOTTOM);
[[fallthrough]];
case DRAG_MOVE:
start = Vector2(node_pos_in_parent[2], Math::lerp(node_pos_in_parent[3], node_pos_in_parent[1], ratio));
- end = start - Vector2(control->get_margin(MARGIN_RIGHT), 0);
- _draw_margin_at_position(control->get_margin(MARGIN_RIGHT), parent_transform.xform((start + end) / 2), MARGIN_BOTTOM);
+ end = start - Vector2(control->get_offset(SIDE_RIGHT), 0);
+ _draw_margin_at_position(control->get_offset(SIDE_RIGHT), parent_transform.xform((start + end) / 2), SIDE_BOTTOM);
viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE));
break;
default:
@@ -3339,12 +3357,12 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_TOP:
case DRAG_TOP_LEFT:
case DRAG_TOP_RIGHT:
- _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), MARGIN_RIGHT);
+ _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2)) + Vector2(5, 0), SIDE_RIGHT);
[[fallthrough]];
case DRAG_MOVE:
start = Vector2(Math::lerp(node_pos_in_parent[0], node_pos_in_parent[2], ratio), node_pos_in_parent[1]);
- end = start - Vector2(0, control->get_margin(MARGIN_TOP));
- _draw_margin_at_position(control->get_margin(MARGIN_TOP), parent_transform.xform((start + end) / 2), MARGIN_LEFT);
+ end = start - Vector2(0, control->get_offset(SIDE_TOP));
+ _draw_margin_at_position(control->get_offset(SIDE_TOP), parent_transform.xform((start + end) / 2), SIDE_LEFT);
viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE));
break;
default:
@@ -3354,12 +3372,12 @@ void CanvasItemEditor::_draw_control_helpers(Control *control) {
case DRAG_BOTTOM:
case DRAG_BOTTOM_LEFT:
case DRAG_BOTTOM_RIGHT:
- _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), MARGIN_RIGHT);
+ _draw_margin_at_position(control->get_size().height, parent_transform.xform(Vector2(node_pos_in_parent[2], (node_pos_in_parent[1] + node_pos_in_parent[3]) / 2) + Vector2(5, 0)), SIDE_RIGHT);
[[fallthrough]];
case DRAG_MOVE:
start = Vector2(Math::lerp(node_pos_in_parent[2], node_pos_in_parent[0], ratio), node_pos_in_parent[3]);
- end = start - Vector2(0, control->get_margin(MARGIN_BOTTOM));
- _draw_margin_at_position(control->get_margin(MARGIN_BOTTOM), parent_transform.xform((start + end) / 2), MARGIN_RIGHT);
+ end = start - Vector2(0, control->get_offset(SIDE_BOTTOM));
+ _draw_margin_at_position(control->get_offset(SIDE_BOTTOM), parent_transform.xform((start + end) / 2), SIDE_RIGHT);
viewport->draw_line(parent_transform.xform(start), parent_transform.xform(end), color_base, Math::round(EDSCALE));
break;
default:
@@ -3495,7 +3513,7 @@ void CanvasItemEditor::_draw_selection() {
select_handle->draw(ci, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor());
ofs = (endpoints[i] + endpoints[next]) / 2;
- ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
+ ofs += (endpoints[next] - endpoints[i]).orthogonal().normalized() * (select_handle->get_size().width / 2);
select_handle->draw(ci, (ofs - (select_handle->get_size() / 2)).floor());
}
@@ -3913,7 +3931,7 @@ void CanvasItemEditor::_draw_viewport() {
bool all_locked = true;
bool all_group = true;
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.empty()) {
+ if (selection.is_empty()) {
all_locked = false;
all_group = false;
} else {
@@ -3932,13 +3950,13 @@ void CanvasItemEditor::_draw_viewport() {
}
lock_button->set_visible(!all_locked);
- lock_button->set_disabled(selection.empty());
+ lock_button->set_disabled(selection.is_empty());
unlock_button->set_visible(all_locked);
group_button->set_visible(!all_group);
- group_button->set_disabled(selection.empty());
+ group_button->set_disabled(selection.is_empty());
ungroup_button->set_visible(all_group);
- info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+ info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
_draw_grid();
_draw_ruler_tool();
@@ -3953,11 +3971,11 @@ void CanvasItemEditor::_draw_viewport() {
RenderingServer::get_singleton()->canvas_item_add_set_transform(ci, Transform2D());
EditorPluginList *over_plugin_list = editor->get_editor_plugins_over();
- if (!over_plugin_list->empty()) {
+ if (!over_plugin_list->is_empty()) {
over_plugin_list->forward_canvas_draw_over_viewport(viewport);
}
EditorPluginList *force_over_plugin_list = editor->get_editor_plugins_force_over();
- if (!force_over_plugin_list->empty()) {
+ if (!force_over_plugin_list->is_empty()) {
force_over_plugin_list->forward_canvas_force_draw_over_viewport(viewport);
}
@@ -4016,17 +4034,17 @@ void CanvasItemEditor::_notification(int p_what) {
Vector2 pivot;
pivot = control->get_pivot_offset();
- anchors[MARGIN_LEFT] = control->get_anchor(MARGIN_LEFT);
- anchors[MARGIN_RIGHT] = control->get_anchor(MARGIN_RIGHT);
- anchors[MARGIN_TOP] = control->get_anchor(MARGIN_TOP);
- anchors[MARGIN_BOTTOM] = control->get_anchor(MARGIN_BOTTOM);
+ anchors[SIDE_LEFT] = control->get_anchor(SIDE_LEFT);
+ anchors[SIDE_RIGHT] = control->get_anchor(SIDE_RIGHT);
+ anchors[SIDE_TOP] = control->get_anchor(SIDE_TOP);
+ anchors[SIDE_BOTTOM] = control->get_anchor(SIDE_BOTTOM);
- if (pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) {
+ if (pivot != se->prev_pivot || anchors[SIDE_LEFT] != se->prev_anchors[SIDE_LEFT] || anchors[SIDE_RIGHT] != se->prev_anchors[SIDE_RIGHT] || anchors[SIDE_TOP] != se->prev_anchors[SIDE_TOP] || anchors[SIDE_BOTTOM] != se->prev_anchors[SIDE_BOTTOM]) {
se->prev_pivot = pivot;
- se->prev_anchors[MARGIN_LEFT] = anchors[MARGIN_LEFT];
- se->prev_anchors[MARGIN_RIGHT] = anchors[MARGIN_RIGHT];
- se->prev_anchors[MARGIN_TOP] = anchors[MARGIN_TOP];
- se->prev_anchors[MARGIN_BOTTOM] = anchors[MARGIN_BOTTOM];
+ se->prev_anchors[SIDE_LEFT] = anchors[SIDE_LEFT];
+ se->prev_anchors[SIDE_RIGHT] = anchors[SIDE_RIGHT];
+ se->prev_anchors[SIDE_TOP] = anchors[SIDE_TOP];
+ se->prev_anchors[SIDE_BOTTOM] = anchors[SIDE_BOTTOM];
viewport->update();
}
nb_control++;
@@ -4097,8 +4115,8 @@ void CanvasItemEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
select_sb->set_texture(get_theme_icon("EditorRect2D", "EditorIcons"));
for (int i = 0; i < 4; i++) {
- select_sb->set_margin_size(Margin(i), 4);
- select_sb->set_default_margin(Margin(i), 4);
+ select_sb->set_margin_size(Side(i), 4);
+ select_sb->set_default_margin(Side(i), 4);
}
AnimationPlayerEditor::singleton->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed));
@@ -4145,7 +4163,7 @@ void CanvasItemEditor::_notification(int p_what) {
// the icon will be dark, so we need to lighten it before blending it
// with the red color.
const Color key_auto_color = EditorSettings::get_singleton()->is_dark_theme() ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25);
- key_auto_insert_button->add_theme_color_override("icon_color_pressed", key_auto_color.lerp(Color(1, 0, 0), 0.55));
+ key_auto_insert_button->add_theme_color_override("icon_pressed_color", key_auto_color.lerp(Color(1, 0, 0), 0.55));
animation_menu->set_icon(get_theme_icon("GuiTabMenuHl", "EditorIcons"));
zoom_minus->set_icon(get_theme_icon("ZoomLess", "EditorIcons"));
@@ -4155,26 +4173,26 @@ void CanvasItemEditor::_notification(int p_what) {
PopupMenu *p = presets_menu->get_popup();
p->clear();
- p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_MARGINS_PRESET_TOP_LEFT);
- p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT);
- p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT);
- p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT);
+ p->add_icon_item(get_theme_icon("ControlAlignTopLeft", "EditorIcons"), TTR("Top Left"), ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT);
+ p->add_icon_item(get_theme_icon("ControlAlignTopRight", "EditorIcons"), TTR("Top Right"), ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomRight", "EditorIcons"), TTR("Bottom Right"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomLeft", "EditorIcons"), TTR("Bottom Left"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT);
p->add_separator();
- p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT);
- p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_MARGINS_PRESET_CENTER_TOP);
- p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT);
- p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM);
- p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_MARGINS_PRESET_CENTER);
+ p->add_icon_item(get_theme_icon("ControlAlignLeftCenter", "EditorIcons"), TTR("Center Left"), ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT);
+ p->add_icon_item(get_theme_icon("ControlAlignTopCenter", "EditorIcons"), TTR("Center Top"), ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP);
+ p->add_icon_item(get_theme_icon("ControlAlignRightCenter", "EditorIcons"), TTR("Center Right"), ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomCenter", "EditorIcons"), TTR("Center Bottom"), ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM);
+ p->add_icon_item(get_theme_icon("ControlAlignCenter", "EditorIcons"), TTR("Center"), ANCHORS_AND_OFFSETS_PRESET_CENTER);
p->add_separator();
- p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE);
- p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_MARGINS_PRESET_TOP_WIDE);
- p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE);
- p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE);
- p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE);
- p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignLeftWide", "EditorIcons"), TTR("Left Wide"), ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignTopWide", "EditorIcons"), TTR("Top Wide"), ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignRightWide", "EditorIcons"), TTR("Right Wide"), ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE);
+ p->add_icon_item(get_theme_icon("ControlAlignBottomWide", "EditorIcons"), TTR("Bottom Wide"), ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE);
+ p->add_icon_item(get_theme_icon("ControlVcenterWide", "EditorIcons"), TTR("VCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE);
+ p->add_icon_item(get_theme_icon("ControlHcenterWide", "EditorIcons"), TTR("HCenter Wide"), ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE);
p->add_separator();
- p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_MARGINS_PRESET_WIDE);
- p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO);
+ p->add_icon_item(get_theme_icon("ControlAlignWide", "EditorIcons"), TTR("Full Rect"), ANCHORS_AND_OFFSETS_PRESET_WIDE);
+ p->add_icon_item(get_theme_icon("Anchor", "EditorIcons"), TTR("Keep Ratio"), ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO);
p->add_separator();
p->add_submenu_item(TTR("Anchors only"), "Anchors");
p->set_item_icon(21, get_theme_icon("Anchor", "EditorIcons"));
@@ -4393,7 +4411,7 @@ void CanvasItemEditor::_popup_warning_depop(Control *p_control) {
timer->queue_delete();
p_control->hide();
popup_temporarily_timers.erase(p_control);
- info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+ info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
}
void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const float p_duration) {
@@ -4411,7 +4429,7 @@ void CanvasItemEditor::_popup_warning_temporarily(Control *p_control, const floa
timer->start(p_duration);
p_control->show();
- info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+ info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
}
void CanvasItemEditor::_update_scroll(float) {
@@ -4424,10 +4442,10 @@ void CanvasItemEditor::_update_scroll(float) {
viewport->update();
}
-void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_preset) {
+void CanvasItemEditor::_set_anchors_and_offsets_preset(Control::LayoutPreset p_preset) {
List<Node *> selection = editor_selection->get_selected_node_list();
- undo_redo->create_action(TTR("Change Anchors and Margins"));
+ undo_redo->create_action(TTR("Change Anchors and Offsets"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Control *control = Object::cast_to<Control>(E->get());
@@ -4443,7 +4461,7 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
case PRESET_CENTER_RIGHT:
case PRESET_CENTER_BOTTOM:
case PRESET_CENTER:
- undo_redo->add_do_method(control, "set_margins_preset", p_preset, Control::PRESET_MODE_KEEP_SIZE);
+ undo_redo->add_do_method(control, "set_offsets_preset", p_preset, Control::PRESET_MODE_KEEP_SIZE);
break;
case PRESET_LEFT_WIDE:
case PRESET_TOP_WIDE:
@@ -4452,7 +4470,7 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
case PRESET_VCENTER_WIDE:
case PRESET_HCENTER_WIDE:
case PRESET_WIDE:
- undo_redo->add_do_method(control, "set_margins_preset", p_preset, Control::PRESET_MODE_MINSIZE);
+ undo_redo->add_do_method(control, "set_offsets_preset", p_preset, Control::PRESET_MODE_MINSIZE);
break;
}
undo_redo->add_undo_method(control, "_edit_set_state", control->_edit_get_state());
@@ -4465,20 +4483,20 @@ void CanvasItemEditor::_set_anchors_and_margins_preset(Control::LayoutPreset p_p
anchor_mode_button->set_pressed(anchors_mode);
}
-void CanvasItemEditor::_set_anchors_and_margins_to_keep_ratio() {
+void CanvasItemEditor::_set_anchors_and_offsets_to_keep_ratio() {
List<Node *> selection = editor_selection->get_selected_node_list();
- undo_redo->create_action(TTR("Change Anchors and Margins"));
+ undo_redo->create_action(TTR("Change Anchors and Offsets"));
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
Control *control = Object::cast_to<Control>(E->get());
if (control) {
Point2 top_left_anchor = _position_to_anchor(control, Point2());
Point2 bottom_right_anchor = _position_to_anchor(control, control->get_size());
- undo_redo->add_do_method(control, "set_anchor", MARGIN_LEFT, top_left_anchor.x, false, true);
- undo_redo->add_do_method(control, "set_anchor", MARGIN_RIGHT, bottom_right_anchor.x, false, true);
- undo_redo->add_do_method(control, "set_anchor", MARGIN_TOP, top_left_anchor.y, false, true);
- undo_redo->add_do_method(control, "set_anchor", MARGIN_BOTTOM, bottom_right_anchor.y, false, true);
+ undo_redo->add_do_method(control, "set_anchor", SIDE_LEFT, top_left_anchor.x, false, true);
+ undo_redo->add_do_method(control, "set_anchor", SIDE_RIGHT, bottom_right_anchor.x, false, true);
+ undo_redo->add_do_method(control, "set_anchor", SIDE_TOP, top_left_anchor.y, false, true);
+ undo_redo->add_do_method(control, "set_anchor", SIDE_BOTTOM, bottom_right_anchor.y, false, true);
undo_redo->add_do_method(control, "set_meta", "_edit_use_anchors_", true);
bool use_anchors = control->has_meta("_edit_use_anchors_") && control->get_meta("_edit_use_anchors_");
@@ -4573,7 +4591,7 @@ void CanvasItemEditor::_update_zoom_label() {
// Don't show a decimal when the zoom level is higher than 1000 %.
zoom_text = TS->format_number(rtos(Math::round((zoom / MAX(1, EDSCALE)) * 100))) + " " + TS->percent_sign();
} else {
- zoom_text = TS->format_number(rtos(Math::stepify((zoom / MAX(1, EDSCALE)) * 100, 0.1))) + " " + TS->percent_sign();
+ zoom_text = TS->format_number(rtos(Math::snapped((zoom / MAX(1, EDSCALE)) * 100, 0.1))) + " " + TS->percent_sign();
}
zoom_reset->set_text(zoom_text);
@@ -4931,56 +4949,56 @@ void CanvasItemEditor::_popup_callback(int p_op) {
undo_redo->add_undo_method(viewport, "update", Variant());
undo_redo->commit_action();
} break;
- case ANCHORS_AND_MARGINS_PRESET_TOP_LEFT: {
- _set_anchors_and_margins_preset(PRESET_TOP_LEFT);
+ case ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT: {
+ _set_anchors_and_offsets_preset(PRESET_TOP_LEFT);
} break;
- case ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT: {
- _set_anchors_and_margins_preset(PRESET_TOP_RIGHT);
+ case ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT: {
+ _set_anchors_and_offsets_preset(PRESET_TOP_RIGHT);
} break;
- case ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT: {
- _set_anchors_and_margins_preset(PRESET_BOTTOM_LEFT);
+ case ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT: {
+ _set_anchors_and_offsets_preset(PRESET_BOTTOM_LEFT);
} break;
- case ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT: {
- _set_anchors_and_margins_preset(PRESET_BOTTOM_RIGHT);
+ case ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT: {
+ _set_anchors_and_offsets_preset(PRESET_BOTTOM_RIGHT);
} break;
- case ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT: {
- _set_anchors_and_margins_preset(PRESET_CENTER_LEFT);
+ case ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT: {
+ _set_anchors_and_offsets_preset(PRESET_CENTER_LEFT);
} break;
- case ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT: {
- _set_anchors_and_margins_preset(PRESET_CENTER_RIGHT);
+ case ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT: {
+ _set_anchors_and_offsets_preset(PRESET_CENTER_RIGHT);
} break;
- case ANCHORS_AND_MARGINS_PRESET_CENTER_TOP: {
- _set_anchors_and_margins_preset(PRESET_CENTER_TOP);
+ case ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP: {
+ _set_anchors_and_offsets_preset(PRESET_CENTER_TOP);
} break;
- case ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM: {
- _set_anchors_and_margins_preset(PRESET_CENTER_BOTTOM);
+ case ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM: {
+ _set_anchors_and_offsets_preset(PRESET_CENTER_BOTTOM);
} break;
- case ANCHORS_AND_MARGINS_PRESET_CENTER: {
- _set_anchors_and_margins_preset(PRESET_CENTER);
+ case ANCHORS_AND_OFFSETS_PRESET_CENTER: {
+ _set_anchors_and_offsets_preset(PRESET_CENTER);
} break;
- case ANCHORS_AND_MARGINS_PRESET_TOP_WIDE: {
- _set_anchors_and_margins_preset(PRESET_TOP_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE: {
+ _set_anchors_and_offsets_preset(PRESET_TOP_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE: {
- _set_anchors_and_margins_preset(PRESET_LEFT_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE: {
+ _set_anchors_and_offsets_preset(PRESET_LEFT_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE: {
- _set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE: {
+ _set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE: {
- _set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE: {
+ _set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE: {
- _set_anchors_and_margins_preset(PRESET_VCENTER_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE: {
+ _set_anchors_and_offsets_preset(PRESET_VCENTER_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE: {
- _set_anchors_and_margins_preset(PRESET_HCENTER_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE: {
+ _set_anchors_and_offsets_preset(PRESET_HCENTER_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_WIDE: {
- _set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ case ANCHORS_AND_OFFSETS_PRESET_WIDE: {
+ _set_anchors_and_offsets_preset(Control::PRESET_WIDE);
} break;
- case ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO: {
- _set_anchors_and_margins_to_keep_ratio();
+ case ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO: {
+ _set_anchors_and_offsets_to_keep_ratio();
} break;
case ANCHORS_PRESET_TOP_LEFT: {
@@ -5569,12 +5587,12 @@ void CanvasItemEditor::add_control_to_info_overlay(Control *p_control) {
p_control->set_h_size_flags(p_control->get_h_size_flags() & ~Control::SIZE_EXPAND_FILL);
info_overlay->add_child(p_control);
- info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+ info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
}
void CanvasItemEditor::remove_control_from_info_overlay(Control *p_control) {
info_overlay->remove_child(p_control);
- info_overlay->set_margin(MARGIN_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
+ info_overlay->set_offset(SIDE_LEFT, (show_rulers ? RULER_WIDTH : 0) + 10);
}
void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) {
@@ -5620,7 +5638,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
primary_grid_steps = 8; // A power-of-two value works better as a default
grid_step_multiplier = 0;
snap_rotation_offset = 0;
- snap_rotation_step = 15 / (180 / Math_PI);
+ snap_rotation_step = Math::deg2rad(15.0);
snap_scale_step = 0.1f;
smart_snap_active = false;
grid_snap_active = false;
@@ -5671,7 +5689,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb = memnew(HBoxContainer);
add_child(hb);
- hb->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ hb->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
bottom_split = memnew(VSplitContainer);
add_child(bottom_split);
@@ -5692,7 +5710,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
SubViewportContainer *scene_tree = memnew(SubViewportContainer);
viewport_scrollable->add_child(scene_tree);
scene_tree->set_stretch(true);
- scene_tree->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ scene_tree->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
scene_tree->add_child(p_editor->get_scene_root());
controls_vb = memnew(VBoxContainer);
@@ -5706,16 +5724,16 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
viewport = memnew(CanvasItemEditorViewport(p_editor, this));
viewport_scrollable->add_child(viewport);
viewport->set_mouse_filter(MOUSE_FILTER_PASS);
- viewport->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ viewport->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
viewport->set_clip_contents(true);
viewport->set_focus_mode(FOCUS_ALL);
viewport->connect("draw", callable_mp(this, &CanvasItemEditor::_draw_viewport));
viewport->connect("gui_input", callable_mp(this, &CanvasItemEditor::_gui_input_viewport));
info_overlay = memnew(VBoxContainer);
- info_overlay->set_anchors_and_margins_preset(Control::PRESET_BOTTOM_LEFT);
- info_overlay->set_margin(MARGIN_LEFT, 10);
- info_overlay->set_margin(MARGIN_BOTTOM, -15);
+ info_overlay->set_anchors_and_offsets_preset(Control::PRESET_BOTTOM_LEFT);
+ info_overlay->set_offset(SIDE_LEFT, 10);
+ info_overlay->set_offset(SIDE_BOTTOM, -15);
info_overlay->set_v_grow_direction(Control::GROW_DIRECTION_BEGIN);
info_overlay->add_theme_constant_override("separation", 10);
viewport_scrollable->add_child(info_overlay);
@@ -5761,7 +5779,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_reset->set_flat(true);
zoom_hb->add_child(zoom_reset);
zoom_reset->add_theme_constant_override("outline_size", 1);
- zoom_reset->add_theme_color_override("font_outline_modulate", Color(0, 0, 0));
+ zoom_reset->add_theme_color_override("font_outline_color", Color(0, 0, 0));
zoom_reset->add_theme_color_override("font_color", Color(1, 1, 1));
zoom_reset->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_reset));
zoom_reset->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset"), KEY_MASK_CMD | KEY_0));
@@ -6136,8 +6154,8 @@ CanvasItemEditorPlugin::CanvasItemEditorPlugin(EditorNode *p_node) {
editor = p_node;
canvas_item_editor = memnew(CanvasItemEditor(editor));
canvas_item_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor->get_viewport()->add_child(canvas_item_editor);
- canvas_item_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ editor->get_main_control()->add_child(canvas_item_editor);
+ canvas_item_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
canvas_item_editor->hide();
}
@@ -6595,7 +6613,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
}
label = memnew(Label);
- label->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 1));
+ label->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 1));
label->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE);
label->hide();
canvas_item_editor->get_controls_container()->add_child(label);
@@ -6603,7 +6621,7 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte
label_desc = memnew(Label);
label_desc->set_text(TTR("Drag & drop + Shift : Add node as sibling\nDrag & drop + Alt : Change node type"));
label_desc->add_theme_color_override("font_color", Color(0.6f, 0.6f, 0.6f, 1));
- label_desc->add_theme_color_override("font_color_shadow", Color(0.2f, 0.2f, 0.2f, 1));
+ label_desc->add_theme_color_override("font_shadow_color", Color(0.2f, 0.2f, 0.2f, 1));
label_desc->add_theme_constant_override("shadow_as_outline", 1 * EDSCALE);
label_desc->add_theme_constant_override("line_spacing", 0);
label_desc->hide();
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index c4a1dca593..24149a57b0 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -119,23 +119,23 @@ private:
UNLOCK_SELECTED,
GROUP_SELECTED,
UNGROUP_SELECTED,
- ANCHORS_AND_MARGINS_PRESET_TOP_LEFT,
- ANCHORS_AND_MARGINS_PRESET_TOP_RIGHT,
- ANCHORS_AND_MARGINS_PRESET_BOTTOM_LEFT,
- ANCHORS_AND_MARGINS_PRESET_BOTTOM_RIGHT,
- ANCHORS_AND_MARGINS_PRESET_CENTER_LEFT,
- ANCHORS_AND_MARGINS_PRESET_CENTER_RIGHT,
- ANCHORS_AND_MARGINS_PRESET_CENTER_TOP,
- ANCHORS_AND_MARGINS_PRESET_CENTER_BOTTOM,
- ANCHORS_AND_MARGINS_PRESET_CENTER,
- ANCHORS_AND_MARGINS_PRESET_TOP_WIDE,
- ANCHORS_AND_MARGINS_PRESET_LEFT_WIDE,
- ANCHORS_AND_MARGINS_PRESET_RIGHT_WIDE,
- ANCHORS_AND_MARGINS_PRESET_BOTTOM_WIDE,
- ANCHORS_AND_MARGINS_PRESET_VCENTER_WIDE,
- ANCHORS_AND_MARGINS_PRESET_HCENTER_WIDE,
- ANCHORS_AND_MARGINS_PRESET_WIDE,
- ANCHORS_AND_MARGINS_PRESET_KEEP_RATIO,
+ ANCHORS_AND_OFFSETS_PRESET_TOP_LEFT,
+ ANCHORS_AND_OFFSETS_PRESET_TOP_RIGHT,
+ ANCHORS_AND_OFFSETS_PRESET_BOTTOM_LEFT,
+ ANCHORS_AND_OFFSETS_PRESET_BOTTOM_RIGHT,
+ ANCHORS_AND_OFFSETS_PRESET_CENTER_LEFT,
+ ANCHORS_AND_OFFSETS_PRESET_CENTER_RIGHT,
+ ANCHORS_AND_OFFSETS_PRESET_CENTER_TOP,
+ ANCHORS_AND_OFFSETS_PRESET_CENTER_BOTTOM,
+ ANCHORS_AND_OFFSETS_PRESET_CENTER,
+ ANCHORS_AND_OFFSETS_PRESET_TOP_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_LEFT_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_RIGHT_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_BOTTOM_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_VCENTER_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_HCENTER_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_WIDE,
+ ANCHORS_AND_OFFSETS_PRESET_KEEP_RATIO,
ANCHORS_PRESET_TOP_LEFT,
ANCHORS_PRESET_TOP_RIGHT,
ANCHORS_PRESET_BOTTOM_LEFT,
@@ -152,22 +152,22 @@ private:
ANCHORS_PRESET_VCENTER_WIDE,
ANCHORS_PRESET_HCENTER_WIDE,
ANCHORS_PRESET_WIDE,
- MARGINS_PRESET_TOP_LEFT,
- MARGINS_PRESET_TOP_RIGHT,
- MARGINS_PRESET_BOTTOM_LEFT,
- MARGINS_PRESET_BOTTOM_RIGHT,
- MARGINS_PRESET_CENTER_LEFT,
- MARGINS_PRESET_CENTER_RIGHT,
- MARGINS_PRESET_CENTER_TOP,
- MARGINS_PRESET_CENTER_BOTTOM,
- MARGINS_PRESET_CENTER,
- MARGINS_PRESET_TOP_WIDE,
- MARGINS_PRESET_LEFT_WIDE,
- MARGINS_PRESET_RIGHT_WIDE,
- MARGINS_PRESET_BOTTOM_WIDE,
- MARGINS_PRESET_VCENTER_WIDE,
- MARGINS_PRESET_HCENTER_WIDE,
- MARGINS_PRESET_WIDE,
+ OFFSETS_PRESET_TOP_LEFT,
+ OFFSETS_PRESET_TOP_RIGHT,
+ OFFSETS_PRESET_BOTTOM_LEFT,
+ OFFSETS_PRESET_BOTTOM_RIGHT,
+ OFFSETS_PRESET_CENTER_LEFT,
+ OFFSETS_PRESET_CENTER_RIGHT,
+ OFFSETS_PRESET_CENTER_TOP,
+ OFFSETS_PRESET_CENTER_BOTTOM,
+ OFFSETS_PRESET_CENTER,
+ OFFSETS_PRESET_TOP_WIDE,
+ OFFSETS_PRESET_LEFT_WIDE,
+ OFFSETS_PRESET_RIGHT_WIDE,
+ OFFSETS_PRESET_BOTTOM_WIDE,
+ OFFSETS_PRESET_VCENTER_WIDE,
+ OFFSETS_PRESET_HCENTER_WIDE,
+ OFFSETS_PRESET_WIDE,
ANIM_INSERT_KEY,
ANIM_INSERT_KEY_EXISTING,
ANIM_INSERT_POS,
@@ -454,9 +454,9 @@ private:
void _unhandled_key_input(const Ref<InputEvent> &p_ev);
- void _draw_text_at_position(Point2 p_position, String p_string, Margin p_side);
- void _draw_margin_at_position(int p_value, Point2 p_position, Margin p_side);
- void _draw_percentage_at_position(float p_value, Point2 p_position, Margin p_side);
+ void _draw_text_at_position(Point2 p_position, String p_string, Side p_side);
+ void _draw_margin_at_position(int p_value, Point2 p_position, Side p_side);
+ void _draw_percentage_at_position(float p_value, Point2 p_position, Side p_side);
void _draw_straight_line(Point2 p_from, Point2 p_to, Color p_color);
void _draw_smart_snapping();
@@ -519,9 +519,9 @@ private:
const Node *p_current);
void _set_anchors_preset(Control::LayoutPreset p_preset);
- void _set_margins_preset(Control::LayoutPreset p_preset);
- void _set_anchors_and_margins_preset(Control::LayoutPreset p_preset);
- void _set_anchors_and_margins_to_keep_ratio();
+ void _set_offsets_preset(Control::LayoutPreset p_preset);
+ void _set_anchors_and_offsets_preset(Control::LayoutPreset p_preset);
+ void _set_anchors_and_offsets_to_keep_ratio();
void _button_toggle_anchor_mode(bool p_status);
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
index 08d6fc966d..8e340b28ef 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h
index 482f00a7f7..e78c486a39 100644
--- a/editor/plugins/collision_polygon_2d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
index 6eb17685f6..0c18975258 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.h b/editor/plugins/collision_polygon_3d_editor_plugin.h
index bb4ee2185e..c66518e3e5 100644
--- a/editor/plugins/collision_polygon_3d_editor_plugin.h
+++ b/editor/plugins/collision_polygon_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 23ab6a9de2..141ee35cdb 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -98,7 +98,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
Ref<RectangleShape2D> rect = node->get_shape();
if (idx < 3) {
- return rect->get_extents().abs();
+ return rect->get_size().abs();
}
} break;
@@ -179,13 +179,13 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
if (idx < 3) {
Ref<RectangleShape2D> rect = node->get_shape();
- Vector2 extents = rect->get_extents();
+ Vector2 size = rect->get_size();
if (idx == 2) {
- extents = p_point;
+ size = p_point * 2;
} else {
- extents[idx] = p_point[idx];
+ size[idx] = p_point[idx] * 2;
}
- rect->set_extents(extents.abs());
+ rect->set_size(size.abs());
canvas_item_editor->update_viewport();
}
@@ -207,7 +207,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
} break;
}
- node->get_shape()->_change_notify();
+ node->get_shape()->notify_property_list_changed();
}
void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
@@ -279,9 +279,9 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
case RECTANGLE_SHAPE: {
Ref<RectangleShape2D> rect = node->get_shape();
- undo_redo->add_do_method(rect.ptr(), "set_extents", rect->get_extents());
+ undo_redo->add_do_method(rect.ptr(), "set_size", rect->get_size());
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
- undo_redo->add_undo_method(rect.ptr(), "set_extents", p_org);
+ undo_redo->add_undo_method(rect.ptr(), "set_size", p_org);
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -493,7 +493,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
Ref<RectangleShape2D> shape = node->get_shape();
handles.resize(3);
- Vector2 ext = shape->get_extents();
+ Vector2 ext = shape->get_size() / 2;
handles.write[0] = Point2(ext.x, 0);
handles.write[1] = Point2(0, ext.y);
handles.write[2] = Point2(ext.x, ext.y);
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index 083ceb4b38..054db1a61b 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.cpp b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
index 32f7d02af2..3403aeceba 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/cpu_particles_2d_editor_plugin.h b/editor/plugins/cpu_particles_2d_editor_plugin.h
index 58984d6d16..b188df8e96 100644
--- a/editor/plugins/cpu_particles_2d_editor_plugin.h
+++ b/editor/plugins/cpu_particles_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.cpp b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
index d44e487ae4..f41ccfa86b 100644
--- a/editor/plugins/cpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -122,7 +122,7 @@ void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {
CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
particles_editor = memnew(CPUParticles3DEditor);
- editor->get_viewport()->add_child(particles_editor);
+ editor->get_main_control()->add_child(particles_editor);
particles_editor->hide();
}
diff --git a/editor/plugins/cpu_particles_3d_editor_plugin.h b/editor/plugins/cpu_particles_3d_editor_plugin.h
index d6886a24dc..9dced3ea86 100644
--- a/editor/plugins/cpu_particles_3d_editor_plugin.h
+++ b/editor/plugins/cpu_particles_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index 4768cac217..bff5cb8d2a 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -353,8 +353,8 @@ void CurveEditor::open_context_menu(Vector2 pos) {
_context_menu->add_check_item(TTR("Linear"), CONTEXT_LINEAR);
bool is_linear = _selected_tangent == TANGENT_LEFT ?
- _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR :
- _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
+ _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR :
+ _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
_context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_LINEAR), is_linear);
diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h
index 2872f65730..2e8dd43d7e 100644
--- a/editor/plugins/curve_editor_plugin.h
+++ b/editor/plugins/curve_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index 0747e42045..1512e1817a 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h
index c5ae4cd8a9..a6fab01c29 100644
--- a/editor/plugins/debugger_editor_plugin.h
+++ b/editor/plugins/debugger_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/editor_debugger_plugin.cpp b/editor/plugins/editor_debugger_plugin.cpp
index b775e871e2..85114d88ae 100644
--- a/editor/plugins/editor_debugger_plugin.cpp
+++ b/editor/plugins/editor_debugger_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/editor_debugger_plugin.h b/editor/plugins/editor_debugger_plugin.h
index 10fd1151de..b33a8ed925 100644
--- a/editor/plugins/editor_debugger_plugin.h
+++ b/editor/plugins/editor_debugger_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 2fc0e35f82..63bb785c5e 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -106,7 +106,7 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const RES &p_from, const Siz
}
}
- if (img.is_null() || img->empty()) {
+ if (img.is_null() || img->is_empty()) {
return Ref<Texture2D>();
}
@@ -150,7 +150,7 @@ bool EditorImagePreviewPlugin::handles(const String &p_type) const {
Ref<Texture2D> EditorImagePreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const {
Ref<Image> img = p_from;
- if (img.is_null() || img->empty()) {
+ if (img.is_null() || img->is_empty()) {
return Ref<Image>();
}
@@ -382,7 +382,9 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
int lats = 32;
int lons = 32;
- float radius = 1.0;
+ const double lat_step = Math_TAU / lats;
+ const double lon_step = Math_TAU / lons;
+ real_t radius = 1.0;
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -391,20 +393,20 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
Basis tt = Basis(Vector3(0, 1, 0), Math_PI * 0.5);
for (int i = 1; i <= lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double)(i - 1) / lats);
+ double lat0 = lat_step * (i - 1) - Math_TAU / 4;
double z0 = Math::sin(lat0);
double zr0 = Math::cos(lat0);
- double lat1 = Math_PI * (-0.5 + (double)i / lats);
+ double lat1 = lat_step * i - Math_TAU / 4;
double z1 = Math::sin(lat1);
double zr1 = Math::cos(lat1);
for (int j = lons; j >= 1; j--) {
- double lng0 = 2 * Math_PI * (double)(j - 1) / lons;
+ double lng0 = lon_step * (j - 1);
double x0 = Math::cos(lng0);
double y0 = Math::sin(lng0);
- double lng1 = 2 * Math_PI * (double)(j) / lons;
+ double lng1 = lon_step * j;
double x1 = Math::cos(lng1);
double y1 = Math::sin(lng1);
diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h
index 04e6be2354..57e2911c89 100644
--- a/editor/plugins/editor_preview_plugins.h
+++ b/editor/plugins/editor_preview_plugins.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/font_editor_plugin.cpp b/editor/plugins/font_editor_plugin.cpp
index a82547182c..fa58eb5480 100644
--- a/editor/plugins/font_editor_plugin.cpp
+++ b/editor/plugins/font_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -216,7 +216,7 @@ void FontDataEditor::init_script_edit() {
void FontDataEditor::add_lang() {
FontData *fd = Object::cast_to<FontData>(get_edited_object());
- if (fd != nullptr && !le->get_text().empty()) {
+ if (fd != nullptr && !le->get_text().is_empty()) {
fd->set_language_support_override(le->get_text(), chk->is_pressed());
le->set_text("");
chk->set_pressed(false);
diff --git a/editor/plugins/font_editor_plugin.h b/editor/plugins/font_editor_plugin.h
index 1d3ffc8857..04e6c1dac7 100644
--- a/editor/plugins/font_editor_plugin.h
+++ b/editor/plugins/font_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp
index 2f5dd36ef1..f309c5da01 100644
--- a/editor/plugins/gi_probe_editor_plugin.cpp
+++ b/editor/plugins/gi_probe_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h
index 85d2b6f449..fdf0623561 100644
--- a/editor/plugins/gi_probe_editor_plugin.h
+++ b/editor/plugins/gi_probe_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.cpp b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
index d27df1d063..1aaa98d02e 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gpu_particles_2d_editor_plugin.h b/editor/plugins/gpu_particles_2d_editor_plugin.h
index f3ca20b71a..0b2028b745 100644
--- a/editor/plugins/gpu_particles_2d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
index c98ba25db5..5b840ddbcf 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -213,7 +213,7 @@ GPUParticles3DEditorBase::GPUParticles3DEditorBase() {
emission_fill->add_item(TTR("Volume"));
emd_vb->add_margin_child(TTR("Emission Source: "), emission_fill);
- emission_dialog->get_ok()->set_text(TTR("Create"));
+ emission_dialog->get_ok_button()->set_text(TTR("Create"));
emission_dialog->connect("confirmed", callable_mp(this, &GPUParticles3DEditorBase::_generate_emission_points));
emission_tree_dialog = memnew(SceneTreeDialog);
@@ -454,7 +454,7 @@ void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {
GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
particles_editor = memnew(GPUParticles3DEditor);
- editor->get_viewport()->add_child(particles_editor);
+ editor->get_main_control()->add_child(particles_editor);
particles_editor->hide();
}
diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.h b/editor/plugins/gpu_particles_3d_editor_plugin.h
index ce376e4386..bd10895459 100644
--- a/editor/plugins/gpu_particles_3d_editor_plugin.h
+++ b/editor/plugins/gpu_particles_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
index 0288645f91..8c4928b7cb 100644
--- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
+++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h
index 0cdc70a62b..5a71fc44ef 100644
--- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h
+++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp
index 13b5c8cef5..46fa00f730 100644
--- a/editor/plugins/gradient_editor_plugin.cpp
+++ b/editor/plugins/gradient_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h
index 4d3fc0d8a9..bcbb86e422 100644
--- a/editor/plugins/gradient_editor_plugin.h
+++ b/editor/plugins/gradient_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp
index b4dcbdfe20..1ea6630622 100644
--- a/editor/plugins/item_list_editor_plugin.cpp
+++ b/editor/plugins/item_list_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -145,7 +145,7 @@ int ItemListOptionButtonPlugin::get_flags() const {
void ItemListOptionButtonPlugin::add_item() {
ob->add_item(vformat(TTR("Item %d"), ob->get_item_count()));
- _change_notify();
+ notify_property_list_changed();
}
int ItemListOptionButtonPlugin::get_item_count() const {
@@ -154,7 +154,7 @@ int ItemListOptionButtonPlugin::get_item_count() const {
void ItemListOptionButtonPlugin::erase(int p_idx) {
ob->remove_item(p_idx);
- _change_notify();
+ notify_property_list_changed();
}
ItemListOptionButtonPlugin::ItemListOptionButtonPlugin() {
@@ -181,7 +181,7 @@ int ItemListPopupMenuPlugin::get_flags() const {
void ItemListPopupMenuPlugin::add_item() {
pp->add_item(vformat(TTR("Item %d"), pp->get_item_count()));
- _change_notify();
+ notify_property_list_changed();
}
int ItemListPopupMenuPlugin::get_item_count() const {
@@ -190,7 +190,7 @@ int ItemListPopupMenuPlugin::get_item_count() const {
void ItemListPopupMenuPlugin::erase(int p_idx) {
pp->remove_item(p_idx);
- _change_notify();
+ notify_property_list_changed();
}
ItemListPopupMenuPlugin::ItemListPopupMenuPlugin() {
@@ -213,7 +213,7 @@ int ItemListItemListPlugin::get_flags() const {
void ItemListItemListPlugin::add_item() {
pp->add_item(vformat(TTR("Item %d"), pp->get_item_count()));
- _change_notify();
+ notify_property_list_changed();
}
int ItemListItemListPlugin::get_item_count() const {
@@ -222,7 +222,7 @@ int ItemListItemListPlugin::get_item_count() const {
void ItemListItemListPlugin::erase(int p_idx) {
pp->remove_item(p_idx);
- _change_notify();
+ notify_property_list_changed();
}
ItemListItemListPlugin::ItemListItemListPlugin() {
diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h
index fa5e802869..8c77f3d952 100644
--- a/editor/plugins/item_list_editor_plugin.h
+++ b/editor/plugins/item_list_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index e422140efa..3d555d7eba 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h
index e034a41ddc..eb1ce04788 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.h
+++ b/editor/plugins/light_occluder_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp
index 77eeb19d26..08c5ef02a4 100644
--- a/editor/plugins/line_2d_editor_plugin.cpp
+++ b/editor/plugins/line_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h
index b3bc9df3a5..769109583a 100644
--- a/editor/plugins/line_2d_editor_plugin.h
+++ b/editor/plugins/line_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp
index e49cfd51f7..ad99ad7808 100644
--- a/editor/plugins/material_editor_plugin.cpp
+++ b/editor/plugins/material_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -108,7 +108,7 @@ MaterialEditor::MaterialEditor() {
vc = memnew(SubViewportContainer);
vc->set_stretch(true);
add_child(vc);
- vc->set_anchors_and_margins_preset(PRESET_WIDE);
+ vc->set_anchors_and_offsets_preset(PRESET_WIDE);
viewport = memnew(SubViewport);
Ref<World3D> world_3d;
world_3d.instance();
@@ -155,7 +155,7 @@ MaterialEditor::MaterialEditor() {
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
- hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
+ hb->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
VBoxContainer *vb_shape = memnew(VBoxContainer);
hb->add_child(vb_shape);
diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h
index 570ba9ae03..a4532b58b3 100644
--- a/editor/plugins/material_editor_plugin.h
+++ b/editor/plugins/material_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 9d396467c3..1e4553a967 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -137,7 +137,7 @@ MeshEditor::MeshEditor() {
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
- hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
+ hb->set_anchors_and_offsets_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
hb->add_spacer();
diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h
index 1fb0babb10..455fcb5fe9 100644
--- a/editor/plugins/mesh_editor_plugin.h
+++ b/editor/plugins/mesh_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index 5b241deab0..0d2b2ea2f5 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -63,7 +63,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
List<Node *> selection = editor_selection->get_selected_node_list();
- if (selection.empty()) {
+ if (selection.is_empty()) {
Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
@@ -457,7 +457,7 @@ MeshInstance3DEditor::MeshInstance3DEditor() {
outline_dialog = memnew(ConfirmationDialog);
outline_dialog->set_title(TTR("Create Outline Mesh"));
- outline_dialog->get_ok()->set_text(TTR("Create"));
+ outline_dialog->get_ok_button()->set_text(TTR("Create"));
VBoxContainer *outline_dialog_vbc = memnew(VBoxContainer);
outline_dialog->add_child(outline_dialog_vbc);
@@ -505,7 +505,7 @@ void MeshInstance3DEditorPlugin::make_visible(bool p_visible) {
MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
mesh_editor = memnew(MeshInstance3DEditor);
- editor->get_viewport()->add_child(mesh_editor);
+ editor->get_main_control()->add_child(mesh_editor);
mesh_editor->options->hide();
}
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.h b/editor/plugins/mesh_instance_3d_editor_plugin.h
index f42136942b..69f494de7f 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.h
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp
index 9d3498efa1..f8932cd534 100644
--- a/editor/plugins/mesh_library_editor_plugin.cpp
+++ b/editor/plugins/mesh_library_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -267,7 +267,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
editor = p_editor;
cd = memnew(ConfirmationDialog);
add_child(cd);
- cd->get_ok()->connect("pressed", callable_mp(this, &MeshLibraryEditor::_menu_confirm));
+ cd->get_ok_button()->connect("pressed", callable_mp(this, &MeshLibraryEditor::_menu_confirm));
}
void MeshLibraryEditorPlugin::edit(Object *p_node) {
@@ -297,8 +297,8 @@ MeshLibraryEditorPlugin::MeshLibraryEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("editors/grid_map/preview_size", 64);
mesh_library_editor = memnew(MeshLibraryEditor(p_node));
- p_node->get_viewport()->add_child(mesh_library_editor);
- mesh_library_editor->set_anchors_and_margins_preset(Control::PRESET_TOP_WIDE);
+ p_node->get_main_control()->add_child(mesh_library_editor);
+ mesh_library_editor->set_anchors_and_offsets_preset(Control::PRESET_TOP_WIDE);
mesh_library_editor->set_end(Point2(0, 22));
mesh_library_editor->hide();
diff --git a/editor/plugins/mesh_library_editor_plugin.h b/editor/plugins/mesh_library_editor_plugin.h
index fafbce9243..6c33c8bb9e 100644
--- a/editor/plugins/mesh_library_editor_plugin.h
+++ b/editor/plugins/mesh_library_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp
index bd1384967f..19c6dcf402 100644
--- a/editor/plugins/multimesh_editor_plugin.cpp
+++ b/editor/plugins/multimesh_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -337,7 +337,7 @@ MultiMeshEditor::MultiMeshEditor() {
vbc->add_margin_child(TTR("Scale:"), populate_scale);
populate_amount = memnew(SpinBox);
- populate_amount->set_anchor(MARGIN_RIGHT, ANCHOR_END);
+ populate_amount->set_anchor(SIDE_RIGHT, ANCHOR_END);
populate_amount->set_begin(Point2(20, 232));
populate_amount->set_end(Point2(-5, 237));
populate_amount->set_min(1);
@@ -345,9 +345,9 @@ MultiMeshEditor::MultiMeshEditor() {
populate_amount->set_value(128);
vbc->add_margin_child(TTR("Amount:"), populate_amount);
- populate_dialog->get_ok()->set_text(TTR("Populate"));
+ populate_dialog->get_ok_button()->set_text(TTR("Populate"));
- populate_dialog->get_ok()->connect("pressed", callable_mp(this, &MultiMeshEditor::_populate));
+ populate_dialog->get_ok_button()->connect("pressed", callable_mp(this, &MultiMeshEditor::_populate));
std = memnew(SceneTreeDialog);
populate_dialog->add_child(std);
std->connect("selected", callable_mp(this, &MultiMeshEditor::_browsed));
@@ -378,7 +378,7 @@ void MultiMeshEditorPlugin::make_visible(bool p_visible) {
MultiMeshEditorPlugin::MultiMeshEditorPlugin(EditorNode *p_node) {
editor = p_node;
multimesh_editor = memnew(MultiMeshEditor);
- editor->get_viewport()->add_child(multimesh_editor);
+ editor->get_main_control()->add_child(multimesh_editor);
multimesh_editor->options->hide();
}
diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h
index 6a80fd4d16..2cdd7cf504 100644
--- a/editor/plugins/multimesh_editor_plugin.h
+++ b/editor/plugins/multimesh_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 8cf9f01fa0..9971d3111d 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h
index 3c5a7c2829..0f5928d416 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.h
+++ b/editor/plugins/navigation_polygon_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 6493e0f953..c591e7f42d 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -612,7 +612,7 @@ void Node3DEditorViewport::_find_items_at_pos(const Point2 &p_pos, bool &r_inclu
results.push_back(res);
}
- if (results.empty()) {
+ if (results.is_empty()) {
return;
}
@@ -1045,7 +1045,7 @@ void Node3DEditorViewport::_list_select(Ref<InputEventMouseButton> b) {
clicked = ObjectID();
}
- } else if (!selection_results.empty()) {
+ } else if (!selection_results.is_empty()) {
NodePath root_path = get_tree()->get_edited_scene_root()->get_path();
StringName root_name = root_path.get_name(root_path.get_name_count() - 1);
@@ -1097,7 +1097,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
{
EditorNode *en = editor;
EditorPluginList *force_input_forwarding_list = en->get_editor_plugins_force_input_forwarding();
- if (!force_input_forwarding_list->empty()) {
+ if (!force_input_forwarding_list->is_empty()) {
bool discard = force_input_forwarding_list->forward_spatial_gui_input(camera, p_event, true);
if (discard) {
return;
@@ -1107,7 +1107,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
{
EditorNode *en = editor;
EditorPluginList *over_plugin_list = en->get_editor_plugins_over();
- if (!over_plugin_list->empty()) {
+ if (!over_plugin_list->is_empty()) {
bool discard = over_plugin_list->forward_spatial_gui_input(camera, p_event, false);
if (discard) {
return;
@@ -2210,8 +2210,8 @@ void Node3DEditorViewport::set_freelook_active(bool active_now) {
}
void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
- real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
- real_t max_distance = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
+ real_t min_distance = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_distance = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
if (unlikely(min_distance > max_distance)) {
cursor.distance = (min_distance + max_distance) / 2;
} else {
@@ -2223,8 +2223,8 @@ void Node3DEditorViewport::scale_cursor_distance(real_t scale) {
}
void Node3DEditorViewport::scale_freelook_speed(real_t scale) {
- real_t min_speed = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
- real_t max_speed = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
+ real_t min_speed = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_speed = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
if (unlikely(min_speed > max_speed)) {
freelook_speed = (min_speed + max_speed) / 2;
} else {
@@ -2335,7 +2335,43 @@ void Node3DEditorPlugin::edited_scene_changed() {
}
}
+void Node3DEditorViewport::_project_settings_changed() {
+ //update shadow atlas if changed
+ int shadowmap_size = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/size");
+ bool shadowmap_16_bits = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/16_bits");
+ int atlas_q0 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_0_subdiv");
+ int atlas_q1 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_1_subdiv");
+ int atlas_q2 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_2_subdiv");
+ int atlas_q3 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_3_subdiv");
+
+ viewport->set_shadow_atlas_size(shadowmap_size);
+ viewport->set_shadow_atlas_16_bits(shadowmap_16_bits);
+ viewport->set_shadow_atlas_quadrant_subdiv(0, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0));
+ viewport->set_shadow_atlas_quadrant_subdiv(1, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q1));
+ viewport->set_shadow_atlas_quadrant_subdiv(2, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q2));
+ viewport->set_shadow_atlas_quadrant_subdiv(3, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q3));
+
+ bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
+
+ if (shrink != (subviewport_container->get_stretch_shrink() > 1)) {
+ subviewport_container->set_stretch_shrink(shrink ? 2 : 1);
+ }
+
+ // Update MSAA, screen-space AA and debanding if changed
+
+ const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/screen_filters/msaa");
+ viewport->set_msaa(Viewport::MSAA(msaa_mode));
+ const int ssaa_mode = GLOBAL_GET("rendering/quality/screen_filters/screen_space_aa");
+ viewport->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode));
+ const bool use_debanding = GLOBAL_GET("rendering/quality/screen_filters/use_debanding");
+ viewport->set_use_debanding(use_debanding);
+}
+
void Node3DEditorViewport::_notification(int p_what) {
+ if (p_what == NOTIFICATION_READY) {
+ EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &Node3DEditorViewport::_project_settings_changed));
+ }
+
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
bool visible = is_visible_in_tree();
@@ -2442,35 +2478,6 @@ void Node3DEditorViewport::_notification(int p_what) {
}
}
- //update shadow atlas if changed
-
- int shadowmap_size = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/size");
- int atlas_q0 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_0_subdiv");
- int atlas_q1 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_1_subdiv");
- int atlas_q2 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_2_subdiv");
- int atlas_q3 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_3_subdiv");
-
- viewport->set_shadow_atlas_size(shadowmap_size);
- viewport->set_shadow_atlas_quadrant_subdiv(0, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0));
- viewport->set_shadow_atlas_quadrant_subdiv(1, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q1));
- viewport->set_shadow_atlas_quadrant_subdiv(2, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q2));
- viewport->set_shadow_atlas_quadrant_subdiv(3, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q3));
-
- bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
-
- if (shrink != (subviewport_container->get_stretch_shrink() > 1)) {
- subviewport_container->set_stretch_shrink(shrink ? 2 : 1);
- }
-
- // Update MSAA, screen-space AA and debanding if changed
-
- const int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/screen_filters/msaa");
- viewport->set_msaa(Viewport::MSAA(msaa_mode));
- const int ssaa_mode = GLOBAL_GET("rendering/quality/screen_filters/screen_space_aa");
- viewport->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode));
- const bool use_debanding = GLOBAL_GET("rendering/quality/screen_filters/use_debanding");
- viewport->set_use_debanding(use_debanding);
-
bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
if (show_info != info_label->is_visible()) {
info_label->set_visible(show_info);
@@ -2491,6 +2498,13 @@ void Node3DEditorViewport::_notification(int p_what) {
text += "Z: " + rtos(current_camera->get_translation().z).pad_decimals(1) + "\n";
text += TTR("Pitch") + ": " + itos(Math::round(current_camera->get_rotation_degrees().x)) + "\n";
text += TTR("Yaw") + ": " + itos(Math::round(current_camera->get_rotation_degrees().y)) + "\n\n";
+
+ text += TTR("Size") +
+ vformat(
+ ": %dx%d (%.1fMP)\n",
+ viewport->get_size().x,
+ viewport->get_size().y,
+ viewport->get_size().x * viewport->get_size().y * 0.000'001);
text += TTR("Objects Drawn") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_OBJECTS_IN_FRAME)) + "\n";
text += TTR("Material Changes") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_MATERIAL_CHANGES_IN_FRAME)) + "\n";
text += TTR("Shader Changes") + ": " + itos(viewport->get_render_info(Viewport::RENDER_INFO_SHADER_CHANGES_IN_FRAME)) + "\n";
@@ -2505,6 +2519,8 @@ void Node3DEditorViewport::_notification(int p_what) {
bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FRAME_TIME));
if (show_fps != fps_label->is_visible()) {
+ cpu_time_label->set_visible(show_fps);
+ gpu_time_label->set_visible(show_fps);
fps_label->set_visible(show_fps);
RS::get_singleton()->viewport_set_measure_render_time(viewport->get_viewport_rid(), show_fps);
for (int i = 0; i < FRAME_TIME_HISTORY; i++) {
@@ -2531,24 +2547,40 @@ void Node3DEditorViewport::_notification(int p_what) {
}
gpu_time /= FRAME_TIME_HISTORY;
- String text;
- text += TTR("CPU Time") + ": " + String::num(cpu_time, 1) + " ms\n";
- text += TTR("GPU Time") + ": " + String::num(gpu_time, 1) + " ms\n";
- text += TTR("FPS") + ": " + itos(1000.0 / gpu_time);
-
- fps_label->set_text(text);
+ // Color labels depending on performance level ("good" = green, "OK" = yellow, "bad" = red).
+ // Middle point is at 15 ms.
+ cpu_time_label->set_text(vformat(TTR("CPU Time: %s ms"), String::num(cpu_time, 1)));
+ cpu_time_label->add_theme_color_override(
+ "font_color",
+ frame_time_gradient->get_color_at_offset(
+ Math::range_lerp(cpu_time, 0, 30, 0, 1)));
+
+ gpu_time_label->set_text(vformat(TTR("GPU Time: %s ms"), String::num(gpu_time, 1)));
+ // Middle point is at 15 ms.
+ gpu_time_label->add_theme_color_override(
+ "font_color",
+ frame_time_gradient->get_color_at_offset(
+ Math::range_lerp(gpu_time, 0, 30, 0, 1)));
+
+ const float fps = 1000.0 / gpu_time;
+ fps_label->set_text(vformat(TTR("FPS: %d"), fps));
+ // Middle point is at 60 FPS.
+ fps_label->add_theme_color_override(
+ "font_color",
+ frame_time_gradient->get_color_at_offset(
+ Math::range_lerp(fps, 110, 10, 0, 1)));
}
bool show_cinema = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_CINEMATIC_PREVIEW));
cinema_label->set_visible(show_cinema);
if (show_cinema) {
float cinema_half_width = cinema_label->get_size().width / 2.0f;
- cinema_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -cinema_half_width);
+ cinema_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -cinema_half_width);
}
if (lock_rotation) {
float locked_half_width = locked_label->get_size().width / 2.0f;
- locked_label->set_anchor_and_margin(MARGIN_LEFT, 0.5f, -locked_half_width);
+ locked_label->set_anchor_and_offset(SIDE_LEFT, 0.5f, -locked_half_width);
}
}
@@ -2583,7 +2615,13 @@ void Node3DEditorViewport::_notification(int p_what) {
preview_camera->add_theme_style_override("focus", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
preview_camera->add_theme_style_override("disabled", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ frame_time_gradient->set_color(0, get_theme_color("success_color", "Editor"));
+ frame_time_gradient->set_color(1, get_theme_color("warning_color", "Editor"));
+ frame_time_gradient->set_color(2, get_theme_color("error_color", "Editor"));
+
info_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ cpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
+ gpu_time_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
fps_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
cinema_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
locked_label->add_theme_style_override("normal", editor->get_gui_base()->get_theme_stylebox("Information3dViewport", "EditorStyles"));
@@ -2615,12 +2653,12 @@ static void draw_indicator_bar(Control &surface, real_t fill, const Ref<Texture2
void Node3DEditorViewport::_draw() {
EditorPluginList *over_plugin_list = EditorNode::get_singleton()->get_editor_plugins_over();
- if (!over_plugin_list->empty()) {
+ if (!over_plugin_list->is_empty()) {
over_plugin_list->forward_spatial_draw_over_viewport(surface);
}
EditorPluginList *force_over_plugin_list = editor->get_editor_plugins_force_over();
- if (!force_over_plugin_list->empty()) {
+ if (!force_over_plugin_list->is_empty()) {
force_over_plugin_list->forward_spatial_force_draw_over_viewport(surface);
}
@@ -2657,11 +2695,31 @@ void Node3DEditorViewport::_draw() {
if (_edit.mode == TRANSFORM_ROTATE) {
Point2 center = _point_to_screen(_edit.center);
+
+ Color handle_color;
+ switch (_edit.plane) {
+ case TRANSFORM_X_AXIS:
+ handle_color = get_theme_color("axis_x_color", "Editor");
+ break;
+ case TRANSFORM_Y_AXIS:
+ handle_color = get_theme_color("axis_y_color", "Editor");
+ break;
+ case TRANSFORM_Z_AXIS:
+ handle_color = get_theme_color("axis_z_color", "Editor");
+ break;
+ default:
+ handle_color = get_theme_color("accent_color", "Editor");
+ break;
+ }
+ handle_color.a = 1.0;
+ const float brightness = 1.3;
+ handle_color *= Color(brightness, brightness, brightness);
+
RenderingServer::get_singleton()->canvas_item_add_line(
ci,
_edit.mouse_pos,
center,
- get_theme_color("accent_color", "Editor") * Color(1, 1, 1, 0.6),
+ handle_color,
Math::round(2 * EDSCALE));
}
if (previewing) {
@@ -2686,7 +2744,7 @@ void Node3DEditorViewport::_draw() {
} break;
}
- draw_rect = Rect2(Vector2(), s).clip(draw_rect);
+ draw_rect = Rect2(Vector2(), s).intersection(draw_rect);
surface->draw_rect(draw_rect, Color(0.6, 0.6, 0.1, 0.5), false, Math::round(2 * EDSCALE));
@@ -2695,8 +2753,8 @@ void Node3DEditorViewport::_draw() {
if (is_freelook_active()) {
// Show speed
- real_t min_speed = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
- real_t max_speed = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
+ real_t min_speed = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_speed = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
real_t scale_length = (max_speed - min_speed);
if (!Math::is_zero_approx(scale_length)) {
@@ -2716,8 +2774,8 @@ void Node3DEditorViewport::_draw() {
} else {
// Show zoom
- real_t min_distance = MAX(camera->get_znear() * 4, ZOOM_FREELOOK_MIN);
- real_t max_distance = MIN(camera->get_zfar() / 4, ZOOM_FREELOOK_MAX);
+ real_t min_distance = MAX(camera->get_near() * 4, ZOOM_FREELOOK_MIN);
+ real_t max_distance = MIN(camera->get_far() / 4, ZOOM_FREELOOK_MAX);
real_t scale_length = (max_distance - min_distance);
if (!Math::is_zero_approx(scale_length)) {
@@ -2778,7 +2836,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_FRONT: {
cursor.x_rot = 0;
- cursor.y_rot = 0;
+ cursor.y_rot = Math_PI;
set_message(TTR("Front View."), 2);
name = TTR("Front");
_set_auto_orthogonal();
@@ -2787,7 +2845,7 @@ void Node3DEditorViewport::_menu_option(int p_option) {
} break;
case VIEW_REAR: {
cursor.x_rot = 0;
- cursor.y_rot = Math_PI;
+ cursor.y_rot = 0;
set_message(TTR("Rear View."), 2);
name = TTR("Rear");
_set_auto_orthogonal();
@@ -2998,7 +3056,12 @@ void Node3DEditorViewport::_menu_option(int p_option) {
case VIEW_DISPLAY_DEBUG_DECAL_ATLAS:
case VIEW_DISPLAY_DEBUG_SDFGI:
case VIEW_DISPLAY_DEBUG_SDFGI_PROBES:
- case VIEW_DISPLAY_DEBUG_GI_BUFFER: {
+ case VIEW_DISPLAY_DEBUG_GI_BUFFER:
+ case VIEW_DISPLAY_DEBUG_DISABLE_LOD:
+ case VIEW_DISPLAY_DEBUG_CLUSTER_OMNI_LIGHTS:
+ case VIEW_DISPLAY_DEBUG_CLUSTER_SPOT_LIGHTS:
+ case VIEW_DISPLAY_DEBUG_CLUSTER_DECALS:
+ case VIEW_DISPLAY_DEBUG_CLUSTER_REFLECTION_PROBES: {
static const int display_options[] = {
VIEW_DISPLAY_NORMAL,
VIEW_DISPLAY_WIREFRAME,
@@ -3015,10 +3078,15 @@ void Node3DEditorViewport::_menu_option(int p_option) {
VIEW_DISPLAY_DEBUG_SCENE_LUMINANCE,
VIEW_DISPLAY_DEBUG_SSAO,
VIEW_DISPLAY_DEBUG_GI_BUFFER,
+ VIEW_DISPLAY_DEBUG_DISABLE_LOD,
VIEW_DISPLAY_DEBUG_PSSM_SPLITS,
VIEW_DISPLAY_DEBUG_DECAL_ATLAS,
VIEW_DISPLAY_DEBUG_SDFGI,
VIEW_DISPLAY_DEBUG_SDFGI_PROBES,
+ VIEW_DISPLAY_DEBUG_CLUSTER_OMNI_LIGHTS,
+ VIEW_DISPLAY_DEBUG_CLUSTER_SPOT_LIGHTS,
+ VIEW_DISPLAY_DEBUG_CLUSTER_DECALS,
+ VIEW_DISPLAY_DEBUG_CLUSTER_REFLECTION_PROBES,
VIEW_MAX
};
static const Viewport::DebugDraw debug_draw_modes[] = {
@@ -3037,10 +3105,15 @@ void Node3DEditorViewport::_menu_option(int p_option) {
Viewport::DEBUG_DRAW_SCENE_LUMINANCE,
Viewport::DEBUG_DRAW_SSAO,
Viewport::DEBUG_DRAW_GI_BUFFER,
+ Viewport::DEBUG_DRAW_DISABLE_LOD,
Viewport::DEBUG_DRAW_PSSM_SPLITS,
Viewport::DEBUG_DRAW_DECAL_ATLAS,
Viewport::DEBUG_DRAW_SDFGI,
Viewport::DEBUG_DRAW_SDFGI_PROBES,
+ Viewport::DEBUG_DRAW_CLUSTER_OMNI_LIGHTS,
+ Viewport::DEBUG_DRAW_CLUSTER_SPOT_LIGHTS,
+ Viewport::DEBUG_DRAW_CLUSTER_DECALS,
+ Viewport::DEBUG_DRAW_CLUSTER_REFLECTION_PROBES,
};
int idx = 0;
@@ -3168,6 +3241,8 @@ void Node3DEditorViewport::_toggle_camera_preview(bool p_activate) {
void Node3DEditorViewport::_toggle_cinema_preview(bool p_activate) {
previewing_cinema = p_activate;
+ rotation_control->set_visible(!p_activate);
+
if (!previewing_cinema) {
if (previewing != nullptr) {
previewing->disconnect("tree_exited", callable_mp(this, &Node3DEditorViewport::_preview_exited_scene));
@@ -3258,6 +3333,21 @@ void Node3DEditorViewport::update_transform_gizmo_view() {
xform.basis.scale(scale);
+ // if the determinant is zero, we should disable the gizmo from being rendered
+ // this prevents supplying bad values to the renderer and then having to filter it out again
+ if (xform.basis.determinant() == 0) {
+ for (int i = 0; i < 3; i++) {
+ RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(move_plane_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], false);
+ RenderingServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false);
+ }
+ // Rotation white outline
+ RenderingServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[3], false);
+ return;
+ }
+
for (int i = 0; i < 3; i++) {
RenderingServer::get_singleton()->instance_set_transform(move_gizmo_instance[i], xform);
RenderingServer::get_singleton()->instance_set_visible(move_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE));
@@ -3868,7 +3958,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
subviewport_container = c;
c->set_stretch(true);
add_child(c);
- c->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ c->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
viewport = memnew(SubViewport);
viewport->set_disable_input(true);
@@ -3876,7 +3966,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
surface = memnew(Control);
surface->set_drag_forwarding(this);
add_child(surface);
- surface->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ surface->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
surface->set_clip_contents(true);
camera = memnew(Camera3D);
camera->set_disable_gizmo(true);
@@ -3940,6 +4030,14 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
display_submenu->add_radio_check_item(TTR("SSAO"), VIEW_DISPLAY_DEBUG_SSAO);
display_submenu->add_separator();
display_submenu->add_radio_check_item(TTR("GI Buffer"), VIEW_DISPLAY_DEBUG_GI_BUFFER);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Disable LOD"), VIEW_DISPLAY_DEBUG_DISABLE_LOD);
+ display_submenu->add_separator();
+ display_submenu->add_radio_check_item(TTR("Omni Light Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_OMNI_LIGHTS);
+ display_submenu->add_radio_check_item(TTR("Spot Light Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_SPOT_LIGHTS);
+ display_submenu->add_radio_check_item(TTR("Decal Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_DECALS);
+ display_submenu->add_radio_check_item(TTR("Reflection Probe Cluster"), VIEW_DISPLAY_DEBUG_CLUSTER_REFLECTION_PROBES);
+
display_submenu->set_name("display_advanced");
view_menu->get_popup()->add_submenu_item(TTR("Display Advanced..."), "display_advanced", VIEW_DISPLAY_ADVANCED);
view_menu->get_popup()->add_separator();
@@ -4009,27 +4107,17 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
preview_node = nullptr;
info_label = memnew(Label);
- info_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE);
- info_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -90 * EDSCALE);
- info_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE);
- info_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE);
+ info_label->set_anchor_and_offset(SIDE_LEFT, ANCHOR_END, -90 * EDSCALE);
+ info_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -90 * EDSCALE);
+ info_label->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, -10 * EDSCALE);
+ info_label->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -10 * EDSCALE);
info_label->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info_label->set_v_grow_direction(GROW_DIRECTION_BEGIN);
surface->add_child(info_label);
info_label->hide();
- fps_label = memnew(Label);
- fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE);
- fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
- fps_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE);
- fps_label->set_h_grow_direction(GROW_DIRECTION_BEGIN);
- fps_label->set_tooltip(TTR("Note: The FPS is estimated on a 60hz refresh rate."));
- fps_label->set_mouse_filter(MOUSE_FILTER_PASS); // Otherwise tooltip doesn't show.
- surface->add_child(fps_label);
- fps_label->hide();
-
cinema_label = memnew(Label);
- cinema_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
+ cinema_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
cinema_label->set_h_grow_direction(GROW_DIRECTION_END);
cinema_label->set_align(Label::ALIGN_CENTER);
surface->add_child(cinema_label);
@@ -4038,8 +4126,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
previewing_cinema = false;
locked_label = memnew(Label);
- locked_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -20 * EDSCALE);
- locked_label->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -10 * EDSCALE);
+ locked_label->set_anchor_and_offset(SIDE_TOP, ANCHOR_END, -20 * EDSCALE);
+ locked_label->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, -10 * EDSCALE);
locked_label->set_h_grow_direction(GROW_DIRECTION_END);
locked_label->set_v_grow_direction(GROW_DIRECTION_BEGIN);
locked_label->set_align(Label::ALIGN_CENTER);
@@ -4047,9 +4135,17 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
locked_label->set_text(TTR("View Rotation Locked"));
locked_label->hide();
+ frame_time_gradient = memnew(Gradient);
+ // The color is set when the theme changes.
+ frame_time_gradient->add_point(0.5, Color());
+
top_right_vbox = memnew(VBoxContainer);
- top_right_vbox->set_anchors_and_margins_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE);
+ top_right_vbox->set_anchors_and_offsets_preset(PRESET_TOP_RIGHT, PRESET_MODE_MINSIZE, 2.0 * EDSCALE);
top_right_vbox->set_h_grow_direction(GROW_DIRECTION_BEGIN);
+ // Make sure frame time labels don't touch the viewport's edge.
+ top_right_vbox->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
+ // Prevent visible spacing between frame time labels.
+ top_right_vbox->add_theme_constant_override("separation", 0);
rotation_control = memnew(ViewportRotationControl);
rotation_control->set_custom_minimum_size(Size2(80, 80) * EDSCALE);
@@ -4057,13 +4153,16 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
rotation_control->set_viewport(this);
top_right_vbox->add_child(rotation_control);
+ // Individual Labels are used to allow coloring each label with its own color.
+ cpu_time_label = memnew(Label);
+ top_right_vbox->add_child(cpu_time_label);
+ cpu_time_label->hide();
+
+ gpu_time_label = memnew(Label);
+ top_right_vbox->add_child(gpu_time_label);
+ gpu_time_label->hide();
+
fps_label = memnew(Label);
- fps_label->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_END, -90 * EDSCALE);
- fps_label->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 10 * EDSCALE);
- fps_label->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -10 * EDSCALE);
- fps_label->set_h_grow_direction(GROW_DIRECTION_BEGIN);
- fps_label->set_tooltip(TTR("Note: The FPS value displayed is the editor's framerate.\nIt cannot be used as a reliable indication of in-game performance."));
- fps_label->set_mouse_filter(MOUSE_FILTER_PASS); // Otherwise tooltip doesn't show.
top_right_vbox->add_child(fps_label);
fps_label->hide();
@@ -4091,6 +4190,10 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Node3DEditorViewport::update_transform_gizmo_view));
}
+Node3DEditorViewport::~Node3DEditorViewport() {
+ memdelete(frame_time_gradient);
+}
+
//////////////////////////////////////////////////////////////
void Node3DEditorViewportContainer::_gui_input(const Ref<InputEvent> &p_event) {
@@ -4549,8 +4652,8 @@ void Node3DEditor::_generate_selection_boxes() {
Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
- // Use a similar color to the 2D editor selection.
- mat->set_albedo(Color(1, 0.5, 0));
+ const Color selection_box_color = EDITOR_GET("editors/3d/selection_box_color");
+ mat->set_albedo(selection_box_color);
mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
st->set_material(mat);
selection_box = st->commit();
@@ -4558,7 +4661,7 @@ void Node3DEditor::_generate_selection_boxes() {
Ref<StandardMaterial3D> mat_xray = memnew(StandardMaterial3D);
mat_xray->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
mat_xray->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
- mat_xray->set_albedo(Color(1, 0.5, 0, 0.15));
+ mat_xray->set_albedo(selection_box_color * Color(1, 1, 1, 0.15));
mat_xray->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
st_xray->set_material(mat_xray);
selection_box_xray = st_xray->commit();
@@ -5168,6 +5271,42 @@ void Node3DEditor::_init_indicators() {
origin_points.push_back(axis * -1048576);
}
+ Ref<Shader> grid_shader = memnew(Shader);
+ grid_shader->set_code(
+ "\n"
+ "shader_type spatial; \n"
+ "render_mode unshaded; \n"
+ "uniform bool orthogonal; \n"
+ "uniform float grid_size; \n"
+ "\n"
+ "void vertex() { \n"
+ " // From FLAG_SRGB_VERTEX_COLOR \n"
+ " if (!OUTPUT_IS_SRGB) { \n"
+ " COLOR.rgb = mix(pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb * (1.0 / 12.92), lessThan(COLOR.rgb, vec3(0.04045))); \n"
+ " } \n"
+ "} \n"
+ "\n"
+ "void fragment() { \n"
+ " ALBEDO = COLOR.rgb; \n"
+ " vec3 dir = orthogonal ? -vec3(0, 0, 1) : VIEW; \n"
+ " float angle_fade = abs(dot(dir, NORMAL)); \n"
+ " angle_fade = smoothstep(0.05, 0.2, angle_fade); \n"
+ " \n"
+ " vec3 world_pos = (CAMERA_MATRIX * vec4(VERTEX, 1.0)).xyz; \n"
+ " vec3 world_normal = (CAMERA_MATRIX * vec4(NORMAL, 0.0)).xyz; \n"
+ " vec3 camera_world_pos = CAMERA_MATRIX[3].xyz; \n"
+ " vec3 camera_world_pos_on_plane = camera_world_pos * (1.0 - world_normal); \n"
+ " float dist_fade = 1.0 - (distance(world_pos, camera_world_pos_on_plane) / grid_size); \n"
+ " dist_fade = smoothstep(0.02, 0.3, dist_fade); \n"
+ " \n"
+ " ALPHA = COLOR.a * dist_fade * angle_fade; \n"
+ "}");
+
+ for (int i = 0; i < 3; i++) {
+ grid_mat[i].instance();
+ grid_mat[i]->set_shader(grid_shader);
+ }
+
grid_enable[0] = EditorSettings::get_singleton()->get("editors/3d/grid_xy_plane");
grid_enable[1] = EditorSettings::get_singleton()->get("editors/3d/grid_yz_plane");
grid_enable[2] = EditorSettings::get_singleton()->get("editors/3d/grid_xz_plane");
@@ -5228,7 +5367,9 @@ void Node3DEditor::_init_indicators() {
gizmo_color[i] = mat;
Ref<StandardMaterial3D> mat_hl = mat->duplicate();
- mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
+ const float brightness = 1.3;
+ const Color albedo = Color(col.r * brightness, col.g * brightness, col.b * brightness);
+ mat_hl->set_albedo(albedo);
gizmo_color_hl[i] = mat_hl;
Vector3 ivec;
@@ -5258,9 +5399,10 @@ void Node3DEditor::_init_indicators() {
int arrow_sides = 16;
+ const real_t arrow_sides_step = Math_TAU / arrow_sides;
for (int k = 0; k < arrow_sides; k++) {
- Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
- Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
+ Basis ma(ivec, k * arrow_sides_step);
+ Basis mb(ivec, (k + 1) * arrow_sides_step);
for (int j = 0; j < arrow_points - 1; j++) {
Vector3 points[4] = {
@@ -5323,7 +5465,7 @@ void Node3DEditor::_init_indicators() {
surftool->commit(move_plane_gizmo[i]);
Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate();
- plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
+ plane_mat_hl->set_albedo(albedo);
plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides
}
@@ -5335,13 +5477,14 @@ void Node3DEditor::_init_indicators() {
int n = 128; // number of circle segments
int m = 6; // number of thickness segments
+ real_t step = Math_TAU / n;
for (int j = 0; j < n; ++j) {
- Basis basis = Basis(ivec, (Math_PI * 2.0f * j) / n);
+ Basis basis = Basis(ivec, j * step);
Vector3 vertex = basis.xform(ivec2 * GIZMO_CIRCLE_SIZE);
for (int k = 0; k < m; ++k) {
- Vector2 ofs = Vector2(Math::cos((Math_PI * 2.0 * k) / m), Math::sin((Math_PI * 2.0 * k) / m));
+ Vector2 ofs = Vector2(Math::cos((Math_TAU * k) / m), Math::sin((Math_TAU * k) / m));
Vector3 normal = ivec * ofs.x + ivec2 * ofs.y;
surftool->set_normal(basis.xform(normal));
@@ -5368,32 +5511,33 @@ void Node3DEditor::_init_indicators() {
Ref<Shader> rotate_shader = memnew(Shader);
- rotate_shader->set_code("\n"
- "shader_type spatial; \n"
- "render_mode unshaded, depth_test_disabled; \n"
- "uniform vec4 albedo; \n"
- "\n"
- "mat3 orthonormalize(mat3 m) { \n"
- " vec3 x = normalize(m[0]); \n"
- " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n"
- " vec3 z = m[2] - x * dot(x, m[2]); \n"
- " z = normalize(z - y * (dot(y,m[2]))); \n"
- " return mat3(x,y,z); \n"
- "} \n"
- "\n"
- "void vertex() { \n"
- " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n"
- " vec3 n = mv * VERTEX; \n"
- " float orientation = dot(vec3(0,0,-1),n); \n"
- " if (orientation <= 0.005) { \n"
- " VERTEX += NORMAL*0.02; \n"
- " } \n"
- "} \n"
- "\n"
- "void fragment() { \n"
- " ALBEDO = albedo.rgb; \n"
- " ALPHA = albedo.a; \n"
- "}");
+ rotate_shader->set_code(
+ "\n"
+ "shader_type spatial; \n"
+ "render_mode unshaded, depth_test_disabled; \n"
+ "uniform vec4 albedo; \n"
+ "\n"
+ "mat3 orthonormalize(mat3 m) { \n"
+ " vec3 x = normalize(m[0]); \n"
+ " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n"
+ " vec3 z = m[2] - x * dot(x, m[2]); \n"
+ " z = normalize(z - y * (dot(y,m[2]))); \n"
+ " return mat3(x,y,z); \n"
+ "} \n"
+ "\n"
+ "void vertex() { \n"
+ " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n"
+ " vec3 n = mv * VERTEX; \n"
+ " float orientation = dot(vec3(0,0,-1),n); \n"
+ " if (orientation <= 0.005) { \n"
+ " VERTEX += NORMAL*0.02; \n"
+ " } \n"
+ "} \n"
+ "\n"
+ "void fragment() { \n"
+ " ALBEDO = albedo.rgb; \n"
+ " ALPHA = albedo.a; \n"
+ "}");
Ref<ShaderMaterial> rotate_mat = memnew(ShaderMaterial);
rotate_mat->set_render_priority(Material::RENDER_PRIORITY_MAX);
@@ -5406,40 +5550,41 @@ void Node3DEditor::_init_indicators() {
rotate_gizmo[i]->surface_set_material(0, rotate_mat);
Ref<ShaderMaterial> rotate_mat_hl = rotate_mat->duplicate();
- rotate_mat_hl->set_shader_param("albedo", Color(col.r, col.g, col.b, 1.0));
+ rotate_mat_hl->set_shader_param("albedo", albedo);
rotate_gizmo_color_hl[i] = rotate_mat_hl;
if (i == 2) { // Rotation white outline
Ref<ShaderMaterial> border_mat = rotate_mat->duplicate();
Ref<Shader> border_shader = memnew(Shader);
- border_shader->set_code("\n"
- "shader_type spatial; \n"
- "render_mode unshaded, depth_test_disabled; \n"
- "uniform vec4 albedo; \n"
- "\n"
- "mat3 orthonormalize(mat3 m) { \n"
- " vec3 x = normalize(m[0]); \n"
- " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n"
- " vec3 z = m[2] - x * dot(x, m[2]); \n"
- " z = normalize(z - y * (dot(y,m[2]))); \n"
- " return mat3(x,y,z); \n"
- "} \n"
- "\n"
- "void vertex() { \n"
- " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n"
- " mv = inverse(mv); \n"
- " VERTEX += NORMAL*0.008; \n"
- " vec3 camera_dir_local = mv * vec3(0,0,1); \n"
- " vec3 camera_up_local = mv * vec3(0,1,0); \n"
- " mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); \n"
- " VERTEX = rotation_matrix * VERTEX; \n"
- "} \n"
- "\n"
- "void fragment() { \n"
- " ALBEDO = albedo.rgb; \n"
- " ALPHA = albedo.a; \n"
- "}");
+ border_shader->set_code(
+ "\n"
+ "shader_type spatial; \n"
+ "render_mode unshaded, depth_test_disabled; \n"
+ "uniform vec4 albedo; \n"
+ "\n"
+ "mat3 orthonormalize(mat3 m) { \n"
+ " vec3 x = normalize(m[0]); \n"
+ " vec3 y = normalize(m[1] - x * dot(x, m[1])); \n"
+ " vec3 z = m[2] - x * dot(x, m[2]); \n"
+ " z = normalize(z - y * (dot(y,m[2]))); \n"
+ " return mat3(x,y,z); \n"
+ "} \n"
+ "\n"
+ "void vertex() { \n"
+ " mat3 mv = orthonormalize(mat3(MODELVIEW_MATRIX)); \n"
+ " mv = inverse(mv); \n"
+ " VERTEX += NORMAL*0.008; \n"
+ " vec3 camera_dir_local = mv * vec3(0,0,1); \n"
+ " vec3 camera_up_local = mv * vec3(0,1,0); \n"
+ " mat3 rotation_matrix = mat3(cross(camera_dir_local, camera_up_local), camera_up_local, camera_dir_local); \n"
+ " VERTEX = rotation_matrix * VERTEX; \n"
+ "} \n"
+ "\n"
+ "void fragment() { \n"
+ " ALBEDO = albedo.rgb; \n"
+ " ALPHA = albedo.a; \n"
+ "}");
border_mat->set_shader(border_shader);
border_mat->set_shader_param("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0));
@@ -5468,9 +5613,10 @@ void Node3DEditor::_init_indicators() {
int arrow_sides = 4;
+ const real_t arrow_sides_step = Math_TAU / arrow_sides;
for (int k = 0; k < 4; k++) {
- Basis ma(ivec, Math_PI * 2 * float(k) / arrow_sides);
- Basis mb(ivec, Math_PI * 2 * float(k + 1) / arrow_sides);
+ Basis ma(ivec, k * arrow_sides_step);
+ Basis mb(ivec, (k + 1) * arrow_sides_step);
for (int j = 0; j < arrow_points - 1; j++) {
Vector3 points[4] = {
@@ -5533,7 +5679,7 @@ void Node3DEditor::_init_indicators() {
surftool->commit(scale_plane_gizmo[i]);
Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate();
- plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0));
+ plane_mat_hl->set_albedo(Color(col.r * 1.3, col.g * 1.3, col.b * 1.3));
plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides
}
}
@@ -5601,8 +5747,11 @@ void Node3DEditor::_init_grid() {
return; // Camera3D is invalid, don't draw the grid.
}
+ bool orthogonal = camera->get_projection() == Camera3D::PROJECTION_ORTHOGONAL;
+
Vector<Color> grid_colors[3];
Vector<Vector3> grid_points[3];
+ Vector<Vector3> grid_normals[3];
Color primary_grid_color = EditorSettings::get_singleton()->get("editors/3d/primary_grid_color");
Color secondary_grid_color = EditorSettings::get_singleton()->get("editors/3d/secondary_grid_color");
@@ -5638,10 +5787,26 @@ void Node3DEditor::_init_grid() {
int b = (a + 1) % 3;
int c = (a + 2) % 3;
- real_t division_level = Math::log(Math::abs(camera_position[c])) / Math::log((double)primary_grid_steps) + division_level_bias;
- division_level = CLAMP(division_level, division_level_min, division_level_max);
- real_t division_level_floored = Math::floor(division_level);
- real_t division_level_decimals = division_level - division_level_floored;
+ Vector3 normal;
+ normal[c] = 1.0;
+
+ real_t camera_distance = Math::abs(camera_position[c]);
+
+ if (orthogonal) {
+ camera_distance = camera->get_size() / 2.0;
+ Vector3 camera_direction = -camera->get_global_transform().get_basis().get_axis(2);
+ Plane grid_plane = Plane(Vector3(), normal);
+ Vector3 intersection;
+ if (grid_plane.intersects_ray(camera_position, camera_direction, &intersection)) {
+ camera_position = intersection;
+ }
+ }
+
+ real_t division_level = Math::log(Math::abs(camera_distance)) / Math::log((double)primary_grid_steps) + division_level_bias;
+
+ real_t clamped_division_level = CLAMP(division_level, division_level_min, division_level_max);
+ real_t division_level_floored = Math::floor(clamped_division_level);
+ real_t division_level_decimals = clamped_division_level - division_level_floored;
real_t small_step_size = Math::pow(primary_grid_steps, division_level_floored);
real_t large_step_size = small_step_size * primary_grid_steps;
@@ -5653,6 +5818,15 @@ void Node3DEditor::_init_grid() {
real_t bgn_b = center_b - grid_size * small_step_size;
real_t end_b = center_b + grid_size * small_step_size;
+ real_t fade_size = Math::pow(primary_grid_steps, division_level - 1.0);
+ real_t min_fade_size = Math::pow(primary_grid_steps, float(division_level_min));
+ real_t max_fade_size = Math::pow(primary_grid_steps, float(division_level_max));
+ fade_size = CLAMP(fade_size, min_fade_size, max_fade_size);
+
+ real_t grid_fade_size = (grid_size - primary_grid_steps) * fade_size;
+ grid_mat[c]->set_shader_param("grid_size", grid_fade_size);
+ grid_mat[c]->set_shader_param("orthogonal", orthogonal);
+
// In each iteration of this loop, draw one line in each direction (so two lines per loop, in each if statement).
for (int i = -grid_size; i <= grid_size; i++) {
Color line_color;
@@ -5663,11 +5837,6 @@ void Node3DEditor::_init_grid() {
line_color = secondary_grid_color;
line_color.a = line_color.a * (1 - division_level_decimals);
}
- // Makes lines farther from the center fade out.
- // Due to limitations of lines, any that come near the camera have full opacity always.
- // This should eventually be replaced by some kind of "distance fade" system, outside of this function.
- // But the effect is still somewhat convincing...
- line_color.a *= 1 - (1 - division_level_decimals * 0.9) * (Math::abs(i / (float)grid_size));
real_t position_a = center_a + i * small_step_size;
real_t position_b = center_b + i * small_step_size;
@@ -5684,6 +5853,8 @@ void Node3DEditor::_init_grid() {
grid_points[c].push_back(line_end);
grid_colors[c].push_back(line_color);
grid_colors[c].push_back(line_color);
+ grid_normals[c].push_back(normal);
+ grid_normals[c].push_back(normal);
}
if (!(origin_enabled && Math::is_zero_approx(position_b))) {
@@ -5697,6 +5868,8 @@ void Node3DEditor::_init_grid() {
grid_points[c].push_back(line_end);
grid_colors[c].push_back(line_color);
grid_colors[c].push_back(line_color);
+ grid_normals[c].push_back(normal);
+ grid_normals[c].push_back(normal);
}
}
@@ -5706,8 +5879,9 @@ void Node3DEditor::_init_grid() {
d.resize(RS::ARRAY_MAX);
d[RenderingServer::ARRAY_VERTEX] = grid_points[c];
d[RenderingServer::ARRAY_COLOR] = grid_colors[c];
+ d[RenderingServer::ARRAY_NORMAL] = grid_normals[c];
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(grid[c], RenderingServer::PRIMITIVE_LINES, d);
- RenderingServer::get_singleton()->mesh_surface_set_material(grid[c], 0, indicator_mat->get_rid());
+ RenderingServer::get_singleton()->mesh_surface_set_material(grid[c], 0, grid_mat[c]->get_rid());
grid_instance[c] = RenderingServer::get_singleton()->instance_create2(grid[c], get_tree()->get_root()->get_world_3d()->get_scenario());
// Yes, the end of this line is supposed to be a.
@@ -5751,7 +5925,7 @@ void Node3DEditor::_refresh_menu_icons() {
List<Node *> &selection = editor_selection->get_selected_node_list();
- if (selection.empty()) {
+ if (selection.is_empty()) {
all_locked = false;
all_grouped = false;
} else {
@@ -5770,11 +5944,11 @@ void Node3DEditor::_refresh_menu_icons() {
}
tool_button[TOOL_LOCK_SELECTED]->set_visible(!all_locked);
- tool_button[TOOL_LOCK_SELECTED]->set_disabled(selection.empty());
+ tool_button[TOOL_LOCK_SELECTED]->set_disabled(selection.is_empty());
tool_button[TOOL_UNLOCK_SELECTED]->set_visible(all_locked);
tool_button[TOOL_GROUP_SELECTED]->set_visible(!all_grouped);
- tool_button[TOOL_GROUP_SELECTED]->set_disabled(selection.empty());
+ tool_button[TOOL_GROUP_SELECTED]->set_disabled(selection.is_empty());
tool_button[TOOL_UNGROUP_SELECTED]->set_visible(all_grouped);
}
@@ -5824,17 +5998,20 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
// Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin
Set<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp);
Set<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp);
+ bool found_valid_shape = false;
if (cs.size()) {
AABB aabb;
- bool found_valid_shape = false;
- if (cs.front()->get()->get_shape().is_valid()) {
- aabb = sp->get_global_transform().xform(cs.front()->get()->get_shape()->get_debug_mesh()->get_aabb());
+ Set<CollisionShape3D *>::Element *I = cs.front();
+ if (I->get()->get_shape().is_valid()) {
+ CollisionShape3D *collision_shape = cs.front()->get();
+ aabb = collision_shape->get_global_transform().xform(collision_shape->get_shape()->get_debug_mesh()->get_aabb());
found_valid_shape = true;
}
- for (Set<CollisionShape3D *>::Element *I = cs.front(); I; I = I->next()) {
- if (I->get()->get_shape().is_valid()) {
- aabb.merge_with(sp->get_global_transform().xform(I->get()->get_shape()->get_debug_mesh()->get_aabb()));
+ for (I = I->next(); I; I = I->next()) {
+ CollisionShape3D *col_shape = I->get();
+ if (col_shape->get_shape().is_valid()) {
+ aabb.merge_with(col_shape->get_global_transform().xform(col_shape->get_shape()->get_debug_mesh()->get_aabb()));
found_valid_shape = true;
}
}
@@ -5842,10 +6019,9 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
from = aabb.position + size;
position_offset.y = from.y - sp->get_global_transform().origin.y;
- } else {
- from = sp->get_global_transform().origin;
}
- } else if (vi.size()) {
+ }
+ if (!found_valid_shape && vi.size()) {
AABB aabb = vi.front()->get()->get_transformed_aabb();
for (Set<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) {
aabb.merge_with(I->get()->get_transformed_aabb());
@@ -5853,7 +6029,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
from = aabb.position + size;
position_offset.y = from.y - sp->get_global_transform().origin.y;
- } else {
+ } else if (!found_valid_shape) {
from = sp->get_global_transform().origin;
}
@@ -6085,7 +6261,7 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) {
if (!maximized) {
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
if (i == (uint32_t)index) {
- viewports[i]->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ viewports[i]->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
} else {
viewports[i]->hide();
}
@@ -6157,9 +6333,9 @@ void Node3DEditor::_bind_methods() {
}
void Node3DEditor::clear() {
- settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0));
- settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05));
- settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0));
+ settings_fov->set_value(EDITOR_GET("editors/3d/default_fov"));
+ settings_znear->set_value(EDITOR_GET("editors/3d/default_z_near"));
+ settings_zfar->set_value(EDITOR_GET("editors/3d/default_z_far"));
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->reset();
@@ -6423,7 +6599,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
snap_dialog->set_title(TTR("Snap Settings"));
add_child(snap_dialog);
snap_dialog->connect("confirmed", callable_mp(this, &Node3DEditor::_snap_changed));
- snap_dialog->get_cancel()->connect("pressed", callable_mp(this, &Node3DEditor::_snap_update));
+ snap_dialog->get_cancel_button()->connect("pressed", callable_mp(this, &Node3DEditor::_snap_update));
VBoxContainer *snap_dialog_vbc = memnew(VBoxContainer);
snap_dialog->add_child(snap_dialog_vbc);
@@ -6451,22 +6627,22 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
settings_fov = memnew(SpinBox);
settings_fov->set_max(MAX_FOV);
settings_fov->set_min(MIN_FOV);
- settings_fov->set_step(0.01);
- settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0));
+ settings_fov->set_step(0.1);
+ settings_fov->set_value(EDITOR_GET("editors/3d/default_fov"));
settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"), settings_fov);
settings_znear = memnew(SpinBox);
settings_znear->set_max(MAX_Z);
settings_znear->set_min(MIN_Z);
settings_znear->set_step(0.01);
- settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05));
+ settings_znear->set_value(EDITOR_GET("editors/3d/default_z_near"));
settings_vbc->add_margin_child(TTR("View Z-Near:"), settings_znear);
settings_zfar = memnew(SpinBox);
settings_zfar->set_max(MAX_Z);
settings_zfar->set_min(MIN_Z);
- settings_zfar->set_step(0.01);
- settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500));
+ settings_zfar->set_step(0.1);
+ settings_zfar->set_value(EDITOR_GET("editors/3d/default_z_far"));
settings_vbc->add_margin_child(TTR("View Z-Far:"), settings_zfar);
for (uint32_t i = 0; i < VIEWPORTS_COUNT; ++i) {
@@ -6541,8 +6717,8 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) {
add_to_group("_spatial_editor_group");
EDITOR_DEF("editors/3d/manipulator_gizmo_size", 80);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/3d/manipulator_gizmo_size", PROPERTY_HINT_RANGE, "16,1024,1"));
- EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.4);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/3d/manipulator_gizmo_size", PROPERTY_HINT_RANGE, "16,160,1"));
+ EDITOR_DEF("editors/3d/manipulator_gizmo_opacity", 0.9);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "editors/3d/manipulator_gizmo_opacity", PROPERTY_HINT_RANGE, "0,1,0.01"));
EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true);
@@ -6672,7 +6848,7 @@ Node3DEditorPlugin::Node3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
spatial_editor = memnew(Node3DEditor(p_node));
spatial_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
- editor->get_viewport()->add_child(spatial_editor);
+ editor->get_main_control()->add_child(spatial_editor);
spatial_editor->hide();
spatial_editor->connect("transform_key_request", Callable(editor->get_inspector_dock(), "_transform_keyed"));
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 66ee678154..bf478f850e 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -212,6 +212,12 @@ class Node3DEditorViewport : public Control {
VIEW_DISPLAY_DEBUG_SDFGI,
VIEW_DISPLAY_DEBUG_SDFGI_PROBES,
VIEW_DISPLAY_DEBUG_GI_BUFFER,
+ VIEW_DISPLAY_DEBUG_DISABLE_LOD,
+ VIEW_DISPLAY_DEBUG_CLUSTER_OMNI_LIGHTS,
+ VIEW_DISPLAY_DEBUG_CLUSTER_SPOT_LIGHTS,
+ VIEW_DISPLAY_DEBUG_CLUSTER_DECALS,
+ VIEW_DISPLAY_DEBUG_CLUSTER_REFLECTION_PROBES,
+
VIEW_LOCK_ROTATION,
VIEW_CINEMATIC_PREVIEW,
VIEW_AUTO_ORTHOGONAL,
@@ -288,6 +294,9 @@ private:
VBoxContainer *top_right_vbox;
ViewportRotationControl *rotation_control;
+ Gradient *frame_time_gradient;
+ Label *cpu_time_label;
+ Label *gpu_time_label;
Label *fps_label;
struct _RayResult {
@@ -454,6 +463,8 @@ private:
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
+ void _project_settings_changed();
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -479,6 +490,7 @@ public:
Camera3D *get_camera() { return camera; } // return the default camera object.
Node3DEditorViewport(Node3DEditor *p_spatial_editor, EditorNode *p_editor, int p_index);
+ ~Node3DEditorViewport();
};
class Node3DEditorSelectedItem : public Object {
@@ -580,7 +592,6 @@ private:
/////
ToolMode tool_mode;
- bool orthogonal;
RenderingServer::ScenarioDebugMode scenario_debug;
@@ -613,6 +624,7 @@ private:
RID cursor_mesh;
RID cursor_instance;
Ref<StandardMaterial3D> indicator_mat;
+ Ref<ShaderMaterial> grid_mat[3];
Ref<StandardMaterial3D> cursor_material;
// Scene drag and drop support
diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp
index 3478148521..ebfdf2c7cd 100644
--- a/editor/plugins/ot_features_plugin.cpp
+++ b/editor/plugins/ot_features_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/ot_features_plugin.h b/editor/plugins/ot_features_plugin.h
index 5b5f367b24..9559a6c0c3 100644
--- a/editor/plugins/ot_features_plugin.h
+++ b/editor/plugins/ot_features_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp
index 608b5c3104..0a949c8610 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.cpp
+++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,7 +42,7 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
// These properties are translated with the tr() function in the C++ code when being set or updated.
Error err;
- RES loaded_res = ResourceLoader::load(p_path, "PackedScene", false, &err);
+ RES loaded_res = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
if (err) {
ERR_PRINT("Failed to load " + p_path);
return err;
@@ -81,14 +81,14 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
Vector<String> str_values = property_value;
for (int k = 0; k < str_values.size(); k++) {
String desc = str_values[k].get_slice(";", 1).strip_edges();
- if (!desc.empty()) {
+ if (!desc.is_empty()) {
parsed_strings.push_back(desc);
}
}
} else if (property_value.get_type() == Variant::STRING) {
String str_value = String(property_value);
// Prevent reading text containing only spaces.
- if (!str_value.strip_edges().empty()) {
+ if (!str_value.strip_edges().is_empty()) {
parsed_strings.push_back(str_value);
}
}
diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h
index a0ffdf692c..e51d65414e 100644
--- a/editor/plugins/packed_scene_translation_parser_plugin.h
+++ b/editor/plugins/packed_scene_translation_parser_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp
index f79098ce5d..908235f89f 100644
--- a/editor/plugins/path_2d_editor_plugin.cpp
+++ b/editor/plugins/path_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h
index 8a420d7c8d..867e0ce74f 100644
--- a/editor/plugins/path_2d_editor_plugin.h
+++ b/editor/plugins/path_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index 043693801e..3783af8fc6 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -609,7 +609,7 @@ Path3DEditorPlugin::Path3DEditorPlugin(EditorNode *p_node) {
curve_edit->set_pressed(true);
/*
collision_polygon_editor = memnew( PathEditor(p_node) );
- editor->get_viewport()->add_child(collision_polygon_editor);
+ editor->get_main_control()->add_child(collision_polygon_editor);
collision_polygon_editor->set_margin(MARGIN_LEFT,200);
collision_polygon_editor->set_margin(MARGIN_RIGHT,230);
collision_polygon_editor->set_margin(MARGIN_TOP,0);
diff --git a/editor/plugins/path_3d_editor_plugin.h b/editor/plugins/path_3d_editor_plugin.h
index 3b92a59143..13870d7591 100644
--- a/editor/plugins/path_3d_editor_plugin.h
+++ b/editor/plugins/path_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp
index 30bf827b3c..4b52512933 100644
--- a/editor/plugins/physical_bone_3d_editor_plugin.cpp
+++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/physical_bone_3d_editor_plugin.h b/editor/plugins/physical_bone_3d_editor_plugin.h
index bdfcca8878..248aad9298 100644
--- a/editor/plugins/physical_bone_3d_editor_plugin.h
+++ b/editor/plugins/physical_bone_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index 0ccca7e06c..3d7b01c149 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -86,8 +86,8 @@ void Polygon2DEditor::_notification(int p_what) {
b_snap_enable->set_icon(get_theme_icon("SnapGrid", "EditorIcons"));
uv_icon_zoom->set_texture(get_theme_icon("Zoom", "EditorIcons"));
- uv_vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
- uv_hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
+ uv_vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE);
+ uv_hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (!is_visible()) {
@@ -1052,8 +1052,6 @@ void Polygon2DEditor::_uv_draw() {
if (i < uv_draw_max /*&& polygons.size() == 0 && polygon_create.size() == 0*/) { //if using or creating polygons, do not show outline (will show polygons instead)
uv_edit_draw->draw_line(mtx.xform(uvs[i]), mtx.xform(next_point), poly_line_color, Math::round(EDSCALE));
}
-
- rect.expand_to(mtx.basis_xform(uvs[i]));
}
for (int i = 0; i < polygons.size(); i++) {
@@ -1160,8 +1158,8 @@ void Polygon2DEditor::_uv_draw() {
uv_edit_draw->draw_circle(bone_paint_pos, bone_paint_radius->get_value() * EDSCALE, Color(1, 1, 1, 0.1));
}
- rect.position -= uv_edit_draw->get_size();
- rect.size += uv_edit_draw->get_size() * 2.0;
+ rect.position = -uv_edit_draw->get_size();
+ rect.size = uv_edit_draw->get_size() * 2.0 + base_tex->get_size() * uv_draw_zoom;
updating_uv_scroll = true;
@@ -1189,8 +1187,8 @@ void Polygon2DEditor::_uv_draw() {
Size2 vmin = uv_vscroll->get_combined_minimum_size();
// Avoid scrollbar overlapping.
- uv_hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, uv_vscroll->is_visible() ? -vmin.width : 0);
- uv_vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, uv_hscroll->is_visible() ? -hmin.height : 0);
+ uv_hscroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, uv_vscroll->is_visible() ? -vmin.width : 0);
+ uv_vscroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, uv_hscroll->is_visible() ? -hmin.height : 0);
updating_uv_scroll = false;
}
diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h
index 77580a5604..af3b2f5aef 100644
--- a/editor/plugins/polygon_2d_editor_plugin.h
+++ b/editor/plugins/polygon_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index f317aebe74..b4b8e82124 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -62,7 +62,7 @@ void ResourcePreloaderEditor::_files_load_request(const Vector<String> &p_paths)
dialog->set_text(TTR("ERROR: Couldn't load resource!"));
dialog->set_title(TTR("Error!"));
//dialog->get_cancel()->set_text("Close");
- dialog->get_ok()->set_text(TTR("Close"));
+ dialog->get_ok_button()->set_text(TTR("Close"));
dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -144,7 +144,7 @@ void ResourcePreloaderEditor::_paste_pressed() {
if (!r.is_valid()) {
dialog->set_text(TTR("Resource clipboard is empty!"));
dialog->set_title(TTR("Error!"));
- dialog->get_ok()->set_text(TTR("Close"));
+ dialog->get_ok_button()->set_text(TTR("Close"));
dialog->popup_centered();
return; ///beh should show an error i guess
}
diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h
index ddfb54c40b..bc10b48a16 100644
--- a/editor/plugins/resource_preloader_editor_plugin.h
+++ b/editor/plugins/resource_preloader_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index e107435373..50f4d8493f 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/root_motion_editor_plugin.h b/editor/plugins/root_motion_editor_plugin.h
index cc19228470..c70fff7db7 100644
--- a/editor/plugins/root_motion_editor_plugin.h
+++ b/editor/plugins/root_motion_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 5982074750..a6afd45686 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -338,7 +338,7 @@ void ScriptEditorQuickOpen::_update_search() {
}
}
- get_ok()->set_disabled(root->get_children() == nullptr);
+ get_ok_button()->set_disabled(root->get_children() == nullptr);
}
void ScriptEditorQuickOpen::_confirmed() {
@@ -382,8 +382,8 @@ ScriptEditorQuickOpen::ScriptEditorQuickOpen() {
search_box->connect("gui_input", callable_mp(this, &ScriptEditorQuickOpen::_sbox_input));
search_options = memnew(Tree);
vbc->add_margin_child(TTR("Matches:"), search_options, true);
- get_ok()->set_text(TTR("Open"));
- get_ok()->set_disabled(true);
+ get_ok_button()->set_text(TTR("Open"));
+ get_ok_button()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
search_options->connect("item_activated", callable_mp(this, &ScriptEditorQuickOpen::_confirmed));
@@ -587,7 +587,7 @@ void ScriptEditor::_go_to_tab(int p_idx) {
}
void ScriptEditor::_add_recent_script(String p_path) {
- if (p_path.empty()) {
+ if (p_path.is_empty()) {
return;
}
@@ -702,7 +702,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
}
}
if (script.is_valid()) {
- if (!script->get_path().empty()) {
+ if (!script->get_path().is_empty()) {
// Only saved scripts can be restored.
previous_scripts.push_back(script->get_path());
}
@@ -894,7 +894,7 @@ void ScriptEditor::_reload_scripts() {
Ref<Script> script = edited_res;
if (script != nullptr) {
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
+ Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
ERR_CONTINUE(!rel_script.is_valid());
script->set_source_code(rel_script->get_source_code());
script->set_last_modified_time(rel_script->get_last_modified_time());
@@ -1129,7 +1129,7 @@ void ScriptEditor::_menu_option(int p_option) {
return;
} break;
case FILE_REOPEN_CLOSED: {
- if (previous_scripts.empty()) {
+ if (previous_scripts.is_empty()) {
return;
}
@@ -1381,7 +1381,7 @@ void ScriptEditor::_menu_option(int p_option) {
case SHOW_IN_FILE_SYSTEM: {
const RES script = current->get_edited_resource();
const String path = script->get_path();
- if (!path.empty()) {
+ if (!path.is_empty()) {
FileSystemDock *file_system_dock = EditorNode::get_singleton()->get_filesystem_dock();
file_system_dock->navigate_to_path(path);
// Ensure that the FileSystem dock is visible.
@@ -1887,7 +1887,7 @@ void ScriptEditor::_update_script_names() {
if (se) {
Ref<Texture2D> icon = se->get_theme_icon();
String path = se->get_edited_resource()->get_path();
- bool saved = !path.empty();
+ bool saved = !path.is_empty();
if (saved) {
// The script might be deleted, moved, or renamed, so make sure
// to update original path to previously edited resource.
@@ -1934,7 +1934,7 @@ void ScriptEditor::_update_script_names() {
sd.name = name;
} break;
case DISPLAY_DIR_AND_NAME: {
- if (!path.get_base_dir().get_file().empty()) {
+ if (!path.get_base_dir().get_file().is_empty()) {
sd.name = path.get_base_dir().get_file().plus_file(name);
} else {
sd.name = name;
@@ -1954,7 +1954,20 @@ void ScriptEditor::_update_script_names() {
Vector<String> disambiguated_script_names;
Vector<String> full_script_paths;
for (int j = 0; j < sedata.size(); j++) {
- disambiguated_script_names.append(sedata[j].name.replace("(*)", ""));
+ String name = sedata[j].name.replace("(*)", "");
+ ScriptListName script_display = (ScriptListName)(int)EditorSettings::get_singleton()->get("text_editor/script_list/list_script_names_as");
+ switch (script_display) {
+ case DISPLAY_NAME: {
+ name = name.get_file();
+ } break;
+ case DISPLAY_DIR_AND_NAME: {
+ name = name.get_base_dir().get_file().plus_file(name.get_file());
+ } break;
+ default:
+ break;
+ }
+
+ disambiguated_script_names.append(name);
full_script_paths.append(sedata[j].tooltip);
}
@@ -1988,7 +2001,7 @@ void ScriptEditor::_update_script_names() {
}
}
- if (_sort_list_on_update && !sedata.empty()) {
+ if (_sort_list_on_update && !sedata.is_empty()) {
sedata.sort();
// change actual order of tab_container so that the order can be rearranged by user
@@ -2052,7 +2065,7 @@ void ScriptEditor::_update_script_names() {
_update_help_overview_visibility();
_update_script_colors();
- file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(FILE_REOPEN_CLOSED), previous_scripts.empty());
+ file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(FILE_REOPEN_CLOSED), previous_scripts.is_empty());
}
void ScriptEditor::_update_script_connections() {
@@ -2198,7 +2211,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
args.push_back(script_path);
}
- Error err = OS::get_singleton()->execute(path, args, false);
+ Error err = OS::get_singleton()->create_process(path, args);
if (err == OK) {
return false;
}
@@ -2806,7 +2819,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
String path = scripts[i];
Dictionary script_info = scripts[i];
- if (!script_info.empty()) {
+ if (!script_info.is_empty()) {
path = script_info["path"];
}
@@ -2833,7 +2846,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
}
}
- if (!script_info.empty()) {
+ if (!script_info.is_empty()) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(tab_container->get_tab_count() - 1));
if (se) {
se->set_edit_state(script_info["state"]);
@@ -3482,7 +3495,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
tab_container->connect("tab_changed", callable_mp(this, &ScriptEditor::_tab_changed));
erase_tab_confirm = memnew(ConfirmationDialog);
- erase_tab_confirm->get_ok()->set_text(TTR("Save"));
+ erase_tab_confirm->get_ok_button()->set_text(TTR("Save"));
erase_tab_confirm->add_button(TTR("Discard"), DisplayServer::get_singleton()->get_swap_cancel_ok(), "discard");
erase_tab_confirm->connect("confirmed", callable_mp(this, &ScriptEditor::_close_current_tab));
erase_tab_confirm->connect("custom_action", callable_mp(this, &ScriptEditor::_close_discard_current_tab));
@@ -3515,7 +3528,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL);
disk_changed->connect("confirmed", callable_mp(this, &ScriptEditor::_reload_scripts));
- disk_changed->get_ok()->set_text(TTR("Reload"));
+ disk_changed->get_ok_button()->set_text(TTR("Reload"));
disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->connect("custom_action", callable_mp(this, &ScriptEditor::_resave_scripts));
@@ -3646,7 +3659,7 @@ void ScriptEditorPlugin::edited_scene_changed() {
ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
editor = p_node;
script_editor = memnew(ScriptEditor(p_node));
- editor->get_viewport()->add_child(script_editor);
+ editor->get_main_control()->add_child(script_editor);
script_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
script_editor->hide();
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index aafd8cba18..09ed3854ea 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index e854ed4fb3..71b18497b0 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -84,10 +84,10 @@ ConnectionInfoDialog::ConnectionInfoDialog() {
set_title(TTR("Connections to method:"));
VBoxContainer *vbc = memnew(VBoxContainer);
- vbc->set_anchor_and_margin(MARGIN_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_RIGHT, Control::ANCHOR_END, -8 * EDSCALE);
- vbc->set_anchor_and_margin(MARGIN_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_offset(SIDE_LEFT, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_offset(SIDE_TOP, Control::ANCHOR_BEGIN, 8 * EDSCALE);
+ vbc->set_anchor_and_offset(SIDE_RIGHT, Control::ANCHOR_END, -8 * EDSCALE);
+ vbc->set_anchor_and_offset(SIDE_BOTTOM, Control::ANCHOR_END, -8 * EDSCALE);
add_child(vbc);
method = memnew(Label);
@@ -214,7 +214,7 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->add_theme_color_override("line_number_color", line_number_color);
text_edit->add_theme_color_override("caret_color", caret_color);
text_edit->add_theme_color_override("caret_background_color", caret_background_color);
- text_edit->add_theme_color_override("font_color_selected", text_selected_color);
+ text_edit->add_theme_color_override("font_selected_color", text_selected_color);
text_edit->add_theme_color_override("selection_color", selection_color);
text_edit->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
text_edit->add_theme_color_override("current_line_color", current_line_color);
@@ -349,7 +349,7 @@ void ScriptTextEditor::update_settings() {
bool ScriptTextEditor::is_unsaved() {
const bool unsaved =
code_editor->get_text_editor()->get_version() != code_editor->get_text_editor()->get_saved_version() ||
- script->get_path().empty(); // In memory.
+ script->get_path().is_empty(); // In memory.
return unsaved;
}
@@ -427,7 +427,7 @@ String ScriptTextEditor::get_name() {
if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
name = script->get_path().get_file();
if (is_unsaved()) {
- if (script->get_path().empty()) {
+ if (script->get_path().is_empty()) {
name = TTR("[unsaved]");
}
name += "(*)";
@@ -551,7 +551,7 @@ void ScriptTextEditor::_validate_script() {
if (safe_lines.has(i + 1)) {
te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
last_is_safe = true;
- } else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().empty())) {
+ } else if (last_is_safe && (te->is_line_comment(i) || te->get_line(i).strip_edges().is_empty())) {
te->set_line_gutter_item_color(i, line_number_gutter, safe_line_number_color);
} else {
te->set_line_gutter_item_color(i, line_number_gutter, default_line_number_color);
@@ -688,7 +688,7 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo
uint64_t date = FileAccess::get_modified_time(script->get_path());
if (last_date != date) {
- Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), true);
+ Ref<Script> rel_script = ResourceLoader::load(script->get_path(), script->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
ERR_CONTINUE(!rel_script.is_valid());
script->set_source_code(rel_script->get_source_code());
script->set_last_modified_time(rel_script->get_last_modified_time());
@@ -1679,7 +1679,7 @@ void ScriptTextEditor::_enable_code_editor() {
VSplitContainer *editor_box = memnew(VSplitContainer);
add_child(editor_box);
- editor_box->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ editor_box->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
editor_box->set_v_size_flags(SIZE_EXPAND_FILL);
editor_box->add_child(code_editor);
@@ -1809,7 +1809,7 @@ void ScriptTextEditor::_enable_code_editor() {
ScriptTextEditor::ScriptTextEditor() {
code_editor = memnew(CodeTextEditor);
code_editor->add_theme_constant_override("separation", 2);
- code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ code_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
code_editor->set_code_complete_func(_code_complete_scripts, this);
code_editor->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 1e436fbe65..17abfcf4cc 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 6e174653f6..8be82628cb 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -117,7 +117,7 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_editor()->add_theme_color_override("line_number_color", line_number_color);
get_text_editor()->add_theme_color_override("caret_color", caret_color);
get_text_editor()->add_theme_color_override("caret_background_color", caret_background_color);
- get_text_editor()->add_theme_color_override("font_color_selected", text_selected_color);
+ get_text_editor()->add_theme_color_override("font_selected_color", text_selected_color);
get_text_editor()->add_theme_color_override("selection_color", selection_color);
get_text_editor()->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
get_text_editor()->add_theme_color_override("current_line_color", current_line_color);
@@ -339,7 +339,7 @@ void ShaderEditor::_menu_option(int p_option) {
shader_editor->remove_all_bookmarks();
} break;
case HELP_DOCS: {
- OS::get_singleton()->shell_open("https://docs.godotengine.org/en/stable/tutorials/shading/shading_reference/index.html");
+ OS::get_singleton()->shell_open("https://docs.godotengine.org/en/latest/tutorials/shaders/shader_reference/index.html");
} break;
}
if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) {
@@ -405,7 +405,7 @@ void ShaderEditor::_check_for_external_edit() {
}
void ShaderEditor::_reload_shader_from_disk() {
- Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), true);
+ Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
ERR_FAIL_COND(!rel_shader.is_valid());
shader->set_code(rel_shader->get_code());
@@ -558,7 +558,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
shader_editor = memnew(ShaderTextEditor);
shader_editor->set_v_size_flags(SIZE_EXPAND_FILL);
shader_editor->add_theme_constant_override("separation", 0);
- shader_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ shader_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
shader_editor->connect("script_changed", callable_mp(this, &ShaderEditor::apply_shaders));
EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ShaderEditor::_editor_settings_changed));
@@ -661,7 +661,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
vbc->add_child(dl);
disk_changed->connect("confirmed", callable_mp(this, &ShaderEditor::_reload_shader_from_disk));
- disk_changed->get_ok()->set_text(TTR("Reload"));
+ disk_changed->get_ok_button()->set_text(TTR("Reload"));
disk_changed->add_button(TTR("Resave"), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "resave");
disk_changed->connect("custom_action", callable_mp(this, &ShaderEditor::save_external_data));
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index e81a782ac8..731c0a5b7e 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp
index f15a801530..47d7f8204b 100644
--- a/editor/plugins/shader_file_editor_plugin.cpp
+++ b/editor/plugins/shader_file_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -59,7 +59,7 @@ void ShaderFileEditor::_version_selected(int p_option) {
ERR_FAIL_COND(bytecode.is_null());
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
- if (bytecode->get_stage_bytecode(RD::ShaderStage(i)).empty() && bytecode->get_stage_compile_error(RD::ShaderStage(i)) == String()) {
+ if (bytecode->get_stage_bytecode(RD::ShaderStage(i)).is_empty() && bytecode->get_stage_compile_error(RD::ShaderStage(i)) == String()) {
stages[i]->set_icon(Ref<Texture2D>());
continue;
}
@@ -182,7 +182,7 @@ void ShaderFileEditor::_update_options() {
for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
Vector<uint8_t> bc = bytecode->get_stage_bytecode(RD::ShaderStage(i));
String error = bytecode->get_stage_compile_error(RD::ShaderStage(i));
- bool disable = error == String() && bc.empty();
+ bool disable = error == String() && bc.is_empty();
stages[i]->set_disabled(disable);
if (!disable) {
if (stages[i]->is_pressed()) {
diff --git a/editor/plugins/shader_file_editor_plugin.h b/editor/plugins/shader_file_editor_plugin.h
index 6858f7d933..7d6e503b6c 100644
--- a/editor/plugins/shader_file_editor_plugin.h
+++ b/editor/plugins/shader_file_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp
index a198e4ff8f..44916e1d46 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -129,7 +129,7 @@ void Skeleton2DEditorPlugin::make_visible(bool p_visible) {
Skeleton2DEditorPlugin::Skeleton2DEditorPlugin(EditorNode *p_node) {
editor = p_node;
sprite_editor = memnew(Skeleton2DEditor);
- editor->get_viewport()->add_child(sprite_editor);
+ editor->get_main_control()->add_child(sprite_editor);
make_visible(false);
//sprite_editor->options->hide();
diff --git a/editor/plugins/skeleton_2d_editor_plugin.h b/editor/plugins/skeleton_2d_editor_plugin.h
index b8377fc914..dacd8fe43f 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.h
+++ b/editor/plugins/skeleton_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 22f50c0689..e160e6ca0d 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -293,7 +293,7 @@ void BoneTransformEditor::_key_button_pressed() {
const BoneId bone_id = property.get_slicec('/', 1).to_int();
const String name = skeleton->get_bone_name(bone_id);
- if (name.empty())
+ if (name.is_empty())
return;
// Need to normalize the basis before you key it
@@ -383,6 +383,10 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi
CollisionShape3D *bone_shape = memnew(CollisionShape3D);
bone_shape->set_shape(bone_shape_capsule);
+ Transform capsule_transform;
+ capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0));
+ bone_shape->set_transform(capsule_transform);
+
Transform body_transform;
body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin, Vector3(0, 1, 0));
body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height));
diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h
index 44dc1bc36e..14c213f7b2 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
index 8fc789b94a..2da49c1c0b 100644
--- a/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_ik_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/skeleton_ik_3d_editor_plugin.h b/editor/plugins/skeleton_ik_3d_editor_plugin.h
index c1585ea670..b0d2138115 100644
--- a/editor/plugins/skeleton_ik_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_ik_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/sprite_2d_editor_plugin.cpp b/editor/plugins/sprite_2d_editor_plugin.cpp
index f5fafb68a5..4949d2b9b7 100644
--- a/editor/plugins/sprite_2d_editor_plugin.cpp
+++ b/editor/plugins/sprite_2d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -120,7 +120,7 @@ void Sprite2DEditor::_menu_option(int p_option) {
switch (p_option) {
case MENU_OPTION_CONVERT_TO_MESH_2D: {
- debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D"));
+ debug_uv_dialog->get_ok_button()->set_text(TTR("Create Mesh2D"));
debug_uv_dialog->set_title(TTR("Mesh2D Preview"));
_update_mesh_data();
@@ -129,7 +129,7 @@ void Sprite2DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CONVERT_TO_POLYGON_2D: {
- debug_uv_dialog->get_ok()->set_text(TTR("Create Polygon2D"));
+ debug_uv_dialog->get_ok_button()->set_text(TTR("Create Polygon2D"));
debug_uv_dialog->set_title(TTR("Polygon2D Preview"));
_update_mesh_data();
@@ -137,7 +137,7 @@ void Sprite2DEditor::_menu_option(int p_option) {
debug_uv->update();
} break;
case MENU_OPTION_CREATE_COLLISION_POLY_2D: {
- debug_uv_dialog->get_ok()->set_text(TTR("Create CollisionPolygon2D"));
+ debug_uv_dialog->get_ok_button()->set_text(TTR("Create CollisionPolygon2D"));
debug_uv_dialog->set_title(TTR("CollisionPolygon2D Preview"));
_update_mesh_data();
@@ -146,7 +146,7 @@ void Sprite2DEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D: {
- debug_uv_dialog->get_ok()->set_text(TTR("Create LightOccluder2D"));
+ debug_uv_dialog->get_ok_button()->set_text(TTR("Create LightOccluder2D"));
debug_uv_dialog->set_title(TTR("LightOccluder2D Preview"));
_update_mesh_data();
@@ -173,6 +173,11 @@ void Sprite2DEditor::_update_mesh_data() {
Ref<Image> image = texture->get_data();
ERR_FAIL_COND(image.is_null());
+
+ if (image->is_compressed()) {
+ image->decompress();
+ }
+
Rect2 rect;
if (node->is_region()) {
rect = node->get_region_rect();
@@ -340,7 +345,7 @@ void Sprite2DEditor::_convert_to_mesh_2d_node() {
}
void Sprite2DEditor::_convert_to_polygon_2d_node() {
- if (computed_outline_lines.empty()) {
+ if (computed_outline_lines.is_empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create polygon."));
err_dialog->popup_centered();
return;
@@ -398,7 +403,7 @@ void Sprite2DEditor::_convert_to_polygon_2d_node() {
}
void Sprite2DEditor::_create_collision_polygon_2d_node() {
- if (computed_outline_lines.empty()) {
+ if (computed_outline_lines.is_empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create collision polygon."));
err_dialog->popup_centered();
return;
@@ -420,7 +425,7 @@ void Sprite2DEditor::_create_collision_polygon_2d_node() {
}
void Sprite2DEditor::_create_light_occluder_2d_node() {
- if (computed_outline_lines.empty()) {
+ if (computed_outline_lines.is_empty()) {
err_dialog->set_text(TTR("Invalid geometry, can't create light occluder."));
err_dialog->popup_centered();
return;
@@ -515,7 +520,7 @@ Sprite2DEditor::Sprite2DEditor() {
add_child(err_dialog);
debug_uv_dialog = memnew(ConfirmationDialog);
- debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D"));
+ debug_uv_dialog->get_ok_button()->set_text(TTR("Create Mesh2D"));
debug_uv_dialog->set_title("Mesh 2D Preview");
VBoxContainer *vb = memnew(VBoxContainer);
debug_uv_dialog->add_child(vb);
@@ -583,7 +588,7 @@ void Sprite2DEditorPlugin::make_visible(bool p_visible) {
Sprite2DEditorPlugin::Sprite2DEditorPlugin(EditorNode *p_node) {
editor = p_node;
sprite_editor = memnew(Sprite2DEditor);
- editor->get_viewport()->add_child(sprite_editor);
+ editor->get_main_control()->add_child(sprite_editor);
make_visible(false);
//sprite_editor->options->hide();
diff --git a/editor/plugins/sprite_2d_editor_plugin.h b/editor/plugins/sprite_2d_editor_plugin.h
index 8769f19b5c..d4a1ef4312 100644
--- a/editor/plugins/sprite_2d_editor_plugin.h
+++ b/editor/plugins/sprite_2d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 69a8a8d92c..0547f99079 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
+#include "core/os/keyboard.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "scene/3d/sprite_3d.h"
@@ -74,8 +75,8 @@ void SpriteFramesEditor::_sheet_preview_draw() {
}
if (frames_selected.size() == 0) {
- split_sheet_dialog->get_ok()->set_disabled(true);
- split_sheet_dialog->get_ok()->set_text(TTR("No Frames Selected"));
+ split_sheet_dialog->get_ok_button()->set_disabled(true);
+ split_sheet_dialog->get_ok_button()->set_text(TTR("No Frames Selected"));
return;
}
@@ -97,8 +98,8 @@ void SpriteFramesEditor::_sheet_preview_draw() {
split_sheet_preview->draw_rect(Rect2(x + 5, y + 5, width - 10, height - 10), Color(0, 0, 0, 1), false);
}
- split_sheet_dialog->get_ok()->set_disabled(false);
- split_sheet_dialog->get_ok()->set_text(vformat(TTR("Add %d Frame(s)"), frames_selected.size()));
+ split_sheet_dialog->get_ok_button()->set_disabled(false);
+ split_sheet_dialog->get_ok_button()->set_text(vformat(TTR("Add %d Frame(s)"), frames_selected.size()));
}
void SpriteFramesEditor::_sheet_preview_input(const Ref<InputEvent> &p_event) {
@@ -310,7 +311,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_
dialog->set_title(TTR("Error!"));
//dialog->get_cancel()->set_text("Close");
- dialog->get_ok()->set_text(TTR("Close"));
+ dialog->get_ok_button()->set_text(TTR("Close"));
dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -318,7 +319,7 @@ void SpriteFramesEditor::_file_load_request(const Vector<String> &p_path, int p_
resources.push_back(resource);
}
- if (resources.empty()) {
+ if (resources.is_empty()) {
return;
}
@@ -361,7 +362,7 @@ void SpriteFramesEditor::_paste_pressed() {
dialog->set_text(TTR("Resource clipboard is empty or not a texture!"));
dialog->set_title(TTR("Error!"));
//dialog->get_cancel()->set_text("Close");
- dialog->get_ok()->set_text(TTR("Close"));
+ dialog->get_ok_button()->set_text(TTR("Close"));
dialog->popup_centered();
return; ///beh should show an error i guess
}
@@ -952,7 +953,11 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (String(d["type"]) == "files") {
Vector<String> files = d["files"];
- _file_load_request(files, at_pos);
+ if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ _prepare_sprite_sheet(files[0]);
+ } else {
+ _file_load_request(files, at_pos);
+ }
}
}
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 0dce93f55a..bbc26ca726 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index 3641052a4e..64df982d5d 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index 41daa662db..d4a235cd10 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index 9894d0e1b0..d45011c8aa 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,7 +96,7 @@ void TextEditor::_load_theme_settings() {
text_edit->add_theme_color_override("line_number_color", line_number_color);
text_edit->add_theme_color_override("caret_color", caret_color);
text_edit->add_theme_color_override("caret_background_color", caret_background_color);
- text_edit->add_theme_color_override("font_color_selected", text_selected_color);
+ text_edit->add_theme_color_override("font_selected_color", text_selected_color);
text_edit->add_theme_color_override("selection_color", selection_color);
text_edit->add_theme_color_override("brace_mismatch_color", brace_mismatch_color);
text_edit->add_theme_color_override("current_line_color", current_line_color);
@@ -119,7 +119,7 @@ String TextEditor::get_name() {
if (text_file->get_path().find("local://") == -1 && text_file->get_path().find("::") == -1) {
name = text_file->get_path().get_file();
if (is_unsaved()) {
- if (text_file->get_path().empty()) {
+ if (text_file->get_path().is_empty()) {
name = TTR("[unsaved]");
}
name += "(*)";
@@ -242,7 +242,7 @@ void TextEditor::apply_code() {
bool TextEditor::is_unsaved() {
const bool unsaved =
code_editor->get_text_editor()->get_version() != code_editor->get_text_editor()->get_saved_version() ||
- text_file->get_path().empty(); // In memory.
+ text_file->get_path().is_empty(); // In memory.
return unsaved;
}
@@ -548,7 +548,7 @@ TextEditor::TextEditor() {
code_editor->add_theme_constant_override("separation", 0);
code_editor->connect("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings));
code_editor->connect("validate_script", callable_mp(this, &TextEditor::_validate_script));
- code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE);
+ code_editor->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
update_settings();
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index ea425bd033..c066d51b18 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/texture_3d_editor_plugin.cpp b/editor/plugins/texture_3d_editor_plugin.cpp
index 8447a2346f..36297c8a4a 100644
--- a/editor/plugins/texture_3d_editor_plugin.cpp
+++ b/editor/plugins/texture_3d_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -57,7 +57,7 @@ void Texture3DEditor::_notification(int p_what) {
}
}
-void Texture3DEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+void Texture3DEditor::_texture_changed() {
if (!is_visible()) {
return;
}
@@ -118,7 +118,7 @@ void Texture3DEditor::_texture_rect_update_area() {
void Texture3DEditor::edit(Ref<Texture3D> p_texture) {
if (!texture.is_null()) {
- texture->remove_change_receptor(this);
+ texture->disconnect("changed", callable_mp(this, &Texture3DEditor::_texture_changed));
}
texture = p_texture;
@@ -128,7 +128,7 @@ void Texture3DEditor::edit(Ref<Texture3D> p_texture) {
_make_shaders();
}
- texture->add_change_receptor(this);
+ texture->connect("changed", callable_mp(this, &Texture3DEditor::_texture_changed));
update();
texture_rect->set_material(material);
setting = true;
@@ -160,21 +160,20 @@ Texture3DEditor::Texture3DEditor() {
layer->set_step(1);
layer->set_max(100);
add_child(layer);
- layer->set_anchor(MARGIN_RIGHT, 1);
- layer->set_anchor(MARGIN_LEFT, 1);
+ layer->set_anchor(SIDE_RIGHT, 1);
+ layer->set_anchor(SIDE_LEFT, 1);
layer->set_h_grow_direction(GROW_DIRECTION_BEGIN);
layer->set_modulate(Color(1, 1, 1, 0.8));
info = memnew(Label);
add_child(info);
- info->set_anchor(MARGIN_RIGHT, 1);
- info->set_anchor(MARGIN_LEFT, 1);
- info->set_anchor(MARGIN_BOTTOM, 1);
- info->set_anchor(MARGIN_TOP, 1);
+ info->set_anchor(SIDE_RIGHT, 1);
+ info->set_anchor(SIDE_LEFT, 1);
+ info->set_anchor(SIDE_BOTTOM, 1);
+ info->set_anchor(SIDE_TOP, 1);
info->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info->set_v_grow_direction(GROW_DIRECTION_BEGIN);
info->add_theme_color_override("font_color", Color(1, 1, 1, 1));
- info->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 0.5));
- info->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 0.5));
+ info->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5));
info->add_theme_constant_override("shadow_as_outline", 1);
info->add_theme_constant_override("shadow_offset_x", 2);
info->add_theme_constant_override("shadow_offset_y", 2);
@@ -185,7 +184,7 @@ Texture3DEditor::Texture3DEditor() {
Texture3DEditor::~Texture3DEditor() {
if (!texture.is_null()) {
- texture->remove_change_receptor(this);
+ texture->disconnect("changed", callable_mp(this, &Texture3DEditor::_texture_changed));
}
}
diff --git a/editor/plugins/texture_3d_editor_plugin.h b/editor/plugins/texture_3d_editor_plugin.h
index 4fbf47ecfe..9d90d3653f 100644
--- a/editor/plugins/texture_3d_editor_plugin.h
+++ b/editor/plugins/texture_3d_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -61,10 +61,12 @@ class Texture3DEditor : public Control {
void _texture_rect_update_area();
void _texture_rect_draw();
+ void _texture_changed();
+
protected:
void _notification(int p_what);
void _gui_input(Ref<InputEvent> p_event);
- void _changed_callback(Object *p_changed, const char *p_prop) override;
+
static void _bind_methods();
public:
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 9b760c0e50..253f8878d2 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -104,7 +104,7 @@ void TextureEditor::_notification(int p_what) {
}
}
-void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+void TextureEditor::_texture_changed() {
if (!is_visible()) {
return;
}
@@ -113,13 +113,13 @@ void TextureEditor::_changed_callback(Object *p_changed, const char *p_prop) {
void TextureEditor::edit(Ref<Texture2D> p_texture) {
if (!texture.is_null()) {
- texture->remove_change_receptor(this);
+ texture->disconnect("changed", callable_mp(this, &TextureEditor::_texture_changed));
}
texture = p_texture;
if (!texture.is_null()) {
- texture->add_change_receptor(this);
+ texture->connect("changed", callable_mp(this, &TextureEditor::_texture_changed));
update();
} else {
hide();
@@ -137,7 +137,7 @@ TextureEditor::TextureEditor() {
TextureEditor::~TextureEditor() {
if (!texture.is_null()) {
- texture->remove_change_receptor(this);
+ texture->disconnect("changed", callable_mp(this, &TextureEditor::_texture_changed));
}
}
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index 0d4452c662..ebe8882194 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,7 +43,7 @@ class TextureEditor : public Control {
protected:
void _notification(int p_what);
void _gui_input(Ref<InputEvent> p_event);
- void _changed_callback(Object *p_changed, const char *p_prop) override;
+ void _texture_changed();
static void _bind_methods();
public:
diff --git a/editor/plugins/texture_layered_editor_plugin.cpp b/editor/plugins/texture_layered_editor_plugin.cpp
index eafe4d546b..254ad3d56e 100644
--- a/editor/plugins/texture_layered_editor_plugin.cpp
+++ b/editor/plugins/texture_layered_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -63,7 +63,7 @@ void TextureLayeredEditor::_notification(int p_what) {
}
}
-void TextureLayeredEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+void TextureLayeredEditor::_texture_changed() {
if (!is_visible()) {
return;
}
@@ -173,7 +173,7 @@ void TextureLayeredEditor::_texture_rect_update_area() {
void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) {
if (!texture.is_null()) {
- texture->remove_change_receptor(this);
+ texture->disconnect("changed", callable_mp(this, &TextureLayeredEditor::_texture_changed));
}
texture = p_texture;
@@ -183,7 +183,7 @@ void TextureLayeredEditor::edit(Ref<TextureLayered> p_texture) {
_make_shaders();
}
- texture->add_change_receptor(this);
+ texture->connect("changed", callable_mp(this, &TextureLayeredEditor::_texture_changed));
update();
texture_rect->set_material(materials[texture->get_layered_type()]);
setting = true;
@@ -225,21 +225,20 @@ TextureLayeredEditor::TextureLayeredEditor() {
layer->set_step(1);
layer->set_max(100);
add_child(layer);
- layer->set_anchor(MARGIN_RIGHT, 1);
- layer->set_anchor(MARGIN_LEFT, 1);
+ layer->set_anchor(SIDE_RIGHT, 1);
+ layer->set_anchor(SIDE_LEFT, 1);
layer->set_h_grow_direction(GROW_DIRECTION_BEGIN);
layer->set_modulate(Color(1, 1, 1, 0.8));
info = memnew(Label);
add_child(info);
- info->set_anchor(MARGIN_RIGHT, 1);
- info->set_anchor(MARGIN_LEFT, 1);
- info->set_anchor(MARGIN_BOTTOM, 1);
- info->set_anchor(MARGIN_TOP, 1);
+ info->set_anchor(SIDE_RIGHT, 1);
+ info->set_anchor(SIDE_LEFT, 1);
+ info->set_anchor(SIDE_BOTTOM, 1);
+ info->set_anchor(SIDE_TOP, 1);
info->set_h_grow_direction(GROW_DIRECTION_BEGIN);
info->set_v_grow_direction(GROW_DIRECTION_BEGIN);
info->add_theme_color_override("font_color", Color(1, 1, 1, 1));
- info->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 0.5));
- info->add_theme_color_override("font_color_shadow", Color(0, 0, 0, 0.5));
+ info->add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.5));
info->add_theme_constant_override("shadow_as_outline", 1);
info->add_theme_constant_override("shadow_offset_x", 2);
info->add_theme_constant_override("shadow_offset_y", 2);
@@ -249,9 +248,6 @@ TextureLayeredEditor::TextureLayeredEditor() {
}
TextureLayeredEditor::~TextureLayeredEditor() {
- if (!texture.is_null()) {
- texture->remove_change_receptor(this);
- }
}
//
diff --git a/editor/plugins/texture_layered_editor_plugin.h b/editor/plugins/texture_layered_editor_plugin.h
index 9a28d2dff8..c4ced62fb9 100644
--- a/editor/plugins/texture_layered_editor_plugin.h
+++ b/editor/plugins/texture_layered_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -63,10 +63,11 @@ class TextureLayeredEditor : public Control {
void _texture_rect_update_area();
void _texture_rect_draw();
+ void _texture_changed();
+
protected:
void _notification(int p_what);
void _gui_input(Ref<InputEvent> p_event);
- void _changed_callback(Object *p_changed, const char *p_prop) override;
static void _bind_methods();
public:
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index f599b94428..63255e6547 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,8 +42,21 @@
void draw_margin_line(Control *edit_draw, Vector2 from, Vector2 to) {
Vector2 line = (to - from).normalized() * 10;
+
+ // Draw a translucent background line to make the foreground line visible on any background.
+ edit_draw->draw_line(
+ from,
+ to,
+ EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor").inverted() * Color(1, 1, 1, 0.5),
+ Math::round(2 * EDSCALE));
+
while ((to - from).length_squared() > 200) {
- edit_draw->draw_line(from, from + line, EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"), 2);
+ edit_draw->draw_line(
+ from,
+ from + line,
+ EditorNode::get_singleton()->get_theme_base()->get_theme_color("mono_color", "Editor"),
+ Math::round(2 * EDSCALE));
+
from += line * 2;
}
}
@@ -177,7 +190,7 @@ void TextureRegionEditor::_region_draw() {
}
ofs = (endpoints[next] - endpoints[i]) / 2;
- ofs += (endpoints[next] - endpoints[i]).tangent().normalized() * (select_handle->get_size().width / 2);
+ ofs += (endpoints[next] - endpoints[i]).orthogonal().normalized() * (select_handle->get_size().width / 2);
if (snap_mode != SNAP_AUTOSLICE) {
edit_draw->draw_texture(select_handle, (endpoints[i] + ofs - (select_handle->get_size() / 2)).floor() - draw_ofs * draw_zoom);
@@ -217,23 +230,23 @@ void TextureRegionEditor::_region_draw() {
Size2 vmin = vscroll->get_combined_minimum_size();
// Avoid scrollbar overlapping.
- hscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, vscroll->is_visible() ? -vmin.width : 0);
- vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, hscroll->is_visible() ? -hmin.height : 0);
+ hscroll->set_anchor_and_offset(SIDE_RIGHT, ANCHOR_END, vscroll->is_visible() ? -vmin.width : 0);
+ vscroll->set_anchor_and_offset(SIDE_BOTTOM, ANCHOR_END, hscroll->is_visible() ? -hmin.height : 0);
updating_scroll = false;
if (node_ninepatch || obj_styleBox.is_valid()) {
float margins[4] = { 0 };
if (node_ninepatch) {
- margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP);
- margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM);
- margins[2] = node_ninepatch->get_patch_margin(MARGIN_LEFT);
- margins[3] = node_ninepatch->get_patch_margin(MARGIN_RIGHT);
+ margins[0] = node_ninepatch->get_patch_margin(SIDE_TOP);
+ margins[1] = node_ninepatch->get_patch_margin(SIDE_BOTTOM);
+ margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT);
+ margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT);
} else if (obj_styleBox.is_valid()) {
- margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP);
- margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM);
- margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT);
- margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT);
+ margins[0] = obj_styleBox->get_margin_size(SIDE_TOP);
+ margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM);
+ margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT);
+ margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT);
}
Vector2 pos[4] = {
@@ -278,15 +291,15 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
edited_margin = -1;
float margins[4] = { 0 };
if (node_ninepatch) {
- margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP);
- margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM);
- margins[2] = node_ninepatch->get_patch_margin(MARGIN_LEFT);
- margins[3] = node_ninepatch->get_patch_margin(MARGIN_RIGHT);
+ margins[0] = node_ninepatch->get_patch_margin(SIDE_TOP);
+ margins[1] = node_ninepatch->get_patch_margin(SIDE_BOTTOM);
+ margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT);
+ margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT);
} else if (obj_styleBox.is_valid()) {
- margins[0] = obj_styleBox->get_margin_size(MARGIN_TOP);
- margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM);
- margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT);
- margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT);
+ margins[0] = obj_styleBox->get_margin_size(SIDE_TOP);
+ margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM);
+ margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT);
+ margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT);
}
Vector2 pos[4] = {
@@ -395,13 +408,13 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
} else if (drag) {
if (edited_margin >= 0) {
undo_redo->create_action(TTR("Set Margin"));
- static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
+ static Side side[4] = { SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT };
if (node_ninepatch) {
- undo_redo->add_do_method(node_ninepatch, "set_patch_margin", m[edited_margin], node_ninepatch->get_patch_margin(m[edited_margin]));
- undo_redo->add_undo_method(node_ninepatch, "set_patch_margin", m[edited_margin], prev_margin);
+ undo_redo->add_do_method(node_ninepatch, "set_patch_margin", side[edited_margin], node_ninepatch->get_patch_margin(side[edited_margin]));
+ undo_redo->add_undo_method(node_ninepatch, "set_patch_margin", side[edited_margin], prev_margin);
} else if (obj_styleBox.is_valid()) {
- undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], obj_styleBox->get_margin_size(m[edited_margin]));
- undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", m[edited_margin], prev_margin);
+ undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", side[edited_margin], obj_styleBox->get_margin_size(side[edited_margin]));
+ undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", side[edited_margin], prev_margin);
obj_styleBox->emit_signal(CoreStringNames::get_singleton()->changed);
}
edited_margin = -1;
@@ -438,12 +451,12 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
if (drag) {
drag = false;
if (edited_margin >= 0) {
- static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
+ static Side side[4] = { SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT };
if (node_ninepatch) {
- node_ninepatch->set_patch_margin(m[edited_margin], prev_margin);
+ node_ninepatch->set_patch_margin(side[edited_margin], prev_margin);
}
if (obj_styleBox.is_valid()) {
- obj_styleBox->set_margin_size(m[edited_margin], prev_margin);
+ obj_styleBox->set_margin_size(side[edited_margin], prev_margin);
}
edited_margin = -1;
} else {
@@ -467,31 +480,52 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
Vector2 dragged(mm->get_relative().x / draw_zoom, mm->get_relative().y / draw_zoom);
hscroll->set_value(hscroll->get_value() - dragged.x);
vscroll->set_value(vscroll->get_value() - dragged.y);
-
} else if (drag) {
if (edited_margin >= 0) {
float new_margin = 0;
- if (edited_margin == 0) {
- new_margin = prev_margin + (mm->get_position().y - drag_from.y) / draw_zoom;
- } else if (edited_margin == 1) {
- new_margin = prev_margin - (mm->get_position().y - drag_from.y) / draw_zoom;
- } else if (edited_margin == 2) {
- new_margin = prev_margin + (mm->get_position().x - drag_from.x) / draw_zoom;
- } else if (edited_margin == 3) {
- new_margin = prev_margin - (mm->get_position().x - drag_from.x) / draw_zoom;
+
+ if (snap_mode != SNAP_GRID) {
+ if (edited_margin == 0) {
+ new_margin = prev_margin + (mm->get_position().y - drag_from.y) / draw_zoom;
+ } else if (edited_margin == 1) {
+ new_margin = prev_margin - (mm->get_position().y - drag_from.y) / draw_zoom;
+ } else if (edited_margin == 2) {
+ new_margin = prev_margin + (mm->get_position().x - drag_from.x) / draw_zoom;
+ } else if (edited_margin == 3) {
+ new_margin = prev_margin - (mm->get_position().x - drag_from.x) / draw_zoom;
+ } else {
+ ERR_PRINT("Unexpected edited_margin");
+ }
+
+ if (snap_mode == SNAP_PIXEL) {
+ new_margin = Math::round(new_margin);
+ }
} else {
- ERR_PRINT("Unexpected edited_margin");
+ Vector2 pos_snapped = snap_point(mtx.affine_inverse().xform(mm->get_position()));
+ Rect2 rect_rounded = Rect2(rect.position.round(), rect.size.round());
+
+ if (edited_margin == 0) {
+ new_margin = pos_snapped.y - rect_rounded.position.y;
+ } else if (edited_margin == 1) {
+ new_margin = rect_rounded.size.y + rect_rounded.position.y - pos_snapped.y;
+ } else if (edited_margin == 2) {
+ new_margin = pos_snapped.x - rect_rounded.position.x;
+ } else if (edited_margin == 3) {
+ new_margin = rect_rounded.size.x + rect_rounded.position.x - pos_snapped.x;
+ } else {
+ ERR_PRINT("Unexpected edited_margin");
+ }
}
if (new_margin < 0) {
new_margin = 0;
}
- static Margin m[4] = { MARGIN_TOP, MARGIN_BOTTOM, MARGIN_LEFT, MARGIN_RIGHT };
+ static Side side[4] = { SIDE_TOP, SIDE_BOTTOM, SIDE_LEFT, SIDE_RIGHT };
if (node_ninepatch) {
- node_ninepatch->set_patch_margin(m[edited_margin], new_margin);
+ node_ninepatch->set_patch_margin(side[edited_margin], new_margin);
}
if (obj_styleBox.is_valid()) {
- obj_styleBox->set_margin_size(m[edited_margin], new_margin);
+ obj_styleBox->set_margin_size(side[edited_margin], new_margin);
}
} else {
Vector2 new_pos = mtx.affine_inverse().xform(mm->get_position());
@@ -772,8 +806,8 @@ void TextureRegionEditor::_notification(int p_what) {
zoom_reset->set_icon(get_theme_icon("ZoomReset", "EditorIcons"));
zoom_in->set_icon(get_theme_icon("ZoomMore", "EditorIcons"));
- vscroll->set_anchors_and_margins_preset(PRESET_RIGHT_WIDE);
- hscroll->set_anchors_and_margins_preset(PRESET_BOTTOM_WIDE);
+ vscroll->set_anchors_and_offsets_preset(PRESET_RIGHT_WIDE);
+ hscroll->set_anchors_and_offsets_preset(PRESET_BOTTOM_WIDE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
if (snap_mode == SNAP_AUTOSLICE && is_visible() && autoslice_is_dirty) {
@@ -829,19 +863,19 @@ Sprite2D *TextureRegionEditor::get_sprite() {
void TextureRegionEditor::edit(Object *p_obj) {
if (node_sprite) {
- node_sprite->remove_change_receptor(this);
+ node_sprite->disconnect("changed", callable_mp(this, &TextureRegionEditor::_texture_changed));
}
if (node_sprite_3d) {
- node_sprite_3d->remove_change_receptor(this);
+ node_sprite_3d->disconnect("changed", callable_mp(this, &TextureRegionEditor::_texture_changed));
}
if (node_ninepatch) {
- node_ninepatch->remove_change_receptor(this);
+ node_ninepatch->disconnect("changed", callable_mp(this, &TextureRegionEditor::_texture_changed));
}
if (obj_styleBox.is_valid()) {
- obj_styleBox->remove_change_receptor(this);
+ obj_styleBox->disconnect("changed", callable_mp(this, &TextureRegionEditor::_texture_changed));
}
if (atlas_tex.is_valid()) {
- atlas_tex->remove_change_receptor(this);
+ atlas_tex->disconnect("changed", callable_mp(this, &TextureRegionEditor::_texture_changed));
}
if (p_obj) {
node_sprite = Object::cast_to<Sprite2D>(p_obj);
@@ -853,7 +887,7 @@ void TextureRegionEditor::edit(Object *p_obj) {
if (Object::cast_to<AtlasTexture>(p_obj)) {
atlas_tex = Ref<AtlasTexture>(Object::cast_to<AtlasTexture>(p_obj));
}
- p_obj->add_change_receptor(this);
+ p_obj->connect("changed", callable_mp(this, &TextureRegionEditor::_texture_changed));
_edit_region();
} else {
node_sprite = nullptr;
@@ -871,14 +905,11 @@ void TextureRegionEditor::edit(Object *p_obj) {
}
}
-void TextureRegionEditor::_changed_callback(Object *p_changed, const char *p_prop) {
+void TextureRegionEditor::_texture_changed() {
if (!is_visible()) {
return;
}
- String prop = p_prop;
- if (prop == "atlas" || prop == "texture" || prop == "region") {
- _edit_region();
- }
+ _edit_region();
}
void TextureRegionEditor::_edit_region() {
diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h
index e9f58006a4..d3db0a08a9 100644
--- a/editor/plugins/texture_region_editor_plugin.h
+++ b/editor/plugins/texture_region_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -117,6 +117,8 @@ class TextureRegionEditor : public VBoxContainer {
void _update_rect();
void _update_autoslice();
+ void _texture_changed();
+
protected:
void _notification(int p_what);
void _node_removed(Object *p_obj);
@@ -124,8 +126,6 @@ protected:
Vector2 snap_point(Vector2 p_target) const;
- virtual void _changed_callback(Object *p_changed, const char *p_prop) override;
-
public:
void _edit_region();
void _region_draw();
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index dd53f60014..dfa8c04145 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -556,7 +556,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
if (p_option == POPUP_ADD) { // Add.
add_del_dialog->set_title(TTR("Add Item"));
- add_del_dialog->get_ok()->set_text(TTR("Add"));
+ add_del_dialog->get_ok_button()->set_text(TTR("Add"));
add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
base_theme = Theme::get_default();
@@ -564,7 +564,7 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
} else if (p_option == POPUP_CLASS_ADD) { // Add.
add_del_dialog->set_title(TTR("Add All Items"));
- add_del_dialog->get_ok()->set_text(TTR("Add All"));
+ add_del_dialog->get_ok_button()->set_text(TTR("Add All"));
add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
base_theme = Theme::get_default();
@@ -576,14 +576,14 @@ void ThemeEditor::_theme_menu_cbk(int p_option) {
} else if (p_option == POPUP_REMOVE) {
add_del_dialog->set_title(TTR("Remove Item"));
- add_del_dialog->get_ok()->set_text(TTR("Remove"));
+ add_del_dialog->get_ok_button()->set_text(TTR("Remove"));
add_del_dialog->popup_centered(Size2(490, 85) * EDSCALE);
base_theme = theme;
} else if (p_option == POPUP_CLASS_REMOVE) {
add_del_dialog->set_title(TTR("Remove All Items"));
- add_del_dialog->get_ok()->set_text(TTR("Remove All"));
+ add_del_dialog->get_ok_button()->set_text(TTR("Remove All"));
add_del_dialog->popup_centered(Size2(240, 85) * EDSCALE);
base_theme = Theme::get_default();
@@ -908,7 +908,7 @@ ThemeEditor::ThemeEditor() {
dialog_vbc->add_child(type_select);
- add_del_dialog->get_ok()->connect("pressed", callable_mp(this, &ThemeEditor::_dialog_cbk));
+ add_del_dialog->get_ok_button()->connect("pressed", callable_mp(this, &ThemeEditor::_dialog_cbk));
file_dialog = memnew(EditorFileDialog);
file_dialog->add_filter("*.theme ; " + TTR("Theme File"));
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index e374dd8714..ab199f8e51 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 189e5ec442..6a16aa28a9 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,10 @@
#include "scene/gui/split_container.h"
void TileMapEditor::_node_removed(Node *p_node) {
- if (p_node == node) {
+ if (p_node == node && node) {
+ // Fixes #44824, which describes a situation where you can reselect a TileMap node without first de-selecting it when switching scenes.
+ node->disconnect("settings_changed", callable_mp(this, &TileMapEditor::_tileset_settings_changed));
+
node = nullptr;
}
}
@@ -262,7 +265,7 @@ Vector<int> TileMapEditor::get_selected_tiles() const {
}
void TileMapEditor::set_selected_tiles(Vector<int> p_tiles) {
- palette->unselect_all();
+ palette->deselect_all();
for (int i = p_tiles.size() - 1; i >= 0; i--) {
int idx = palette->find_metadata(p_tiles[i]);
@@ -449,7 +452,7 @@ void TileMapEditor::_update_palette() {
List<int> tiles;
tileset->get_tile_list(&tiles);
- if (tiles.empty()) {
+ if (tiles.is_empty()) {
return;
}
@@ -1779,7 +1782,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
return;
}
- if (paint_undo.empty()) {
+ if (paint_undo.is_empty()) {
return;
}
@@ -1810,7 +1813,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
}
}
} else if (tool == TOOL_PASTING) {
- if (copydata.empty()) {
+ if (copydata.is_empty()) {
return;
}
@@ -2085,7 +2088,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
info_message->set_align(Label::ALIGN_CENTER);
info_message->set_autowrap(true);
info_message->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
- info_message->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
+ info_message->set_anchors_and_offsets_preset(PRESET_WIDE, PRESET_MODE_KEEP_SIZE, 8 * EDSCALE);
palette->add_child(info_message);
// Add autotile override palette.
diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h
index 3a4cb22ac1..421a3b3f68 100644
--- a/editor/plugins/tile_map_editor_plugin.h
+++ b/editor/plugins/tile_map_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 900a2c75a0..c628fe8367 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,6 @@
void TileSetEditor::edit(const Ref<TileSet> &p_tileset) {
tileset = p_tileset;
- tileset->add_change_receptor(this);
texture_list->clear();
texture_map.clear();
@@ -1859,7 +1858,7 @@ void TileSetEditor::_on_tool_clicked(int p_tool) {
_update_toggle_shape_button();
workspace->update();
workspace_container->update();
- helper->_change_notify("");
+ helper->notify_property_list_changed();
}
} else if (p_tool == SELECT_NEXT) {
_select_next_shape();
@@ -2173,7 +2172,7 @@ Array TileSetEditor::_get_tiles_in_current_texture(bool sorted) {
}
}
if (sorted) {
- a.sort_custom(this, "_sort_tiles");
+ a.sort_custom(callable_mp(this, &TileSetEditor::_sort_tiles));
}
return a;
}
@@ -2287,7 +2286,7 @@ void TileSetEditor::_select_next_shape() {
}
workspace->update();
workspace_container->update();
- helper->_change_notify("");
+ helper->notify_property_list_changed();
}
}
@@ -2349,7 +2348,7 @@ void TileSetEditor::_select_previous_shape() {
}
workspace->update();
workspace_container->update();
- helper->_change_notify("");
+ helper->notify_property_list_changed();
}
}
@@ -3012,7 +3011,7 @@ void TileSetEditor::close_shape(const Vector2 &shape_anchor) {
undo_redo->add_undo_method(this, "_select_edited_shape_coord");
undo_redo->commit_action();
}
- tileset->_change_notify("");
+ tileset->notify_property_list_changed();
}
void TileSetEditor::select_coord(const Vector2 &coord) {
@@ -3115,7 +3114,7 @@ void TileSetEditor::select_coord(const Vector2 &coord) {
}
workspace->update();
workspace_container->update();
- helper->_change_notify("");
+ helper->notify_property_list_changed();
}
Vector2 TileSetEditor::snap_point(const Vector2 &point) {
@@ -3225,7 +3224,7 @@ void TileSetEditor::update_texture_list() {
workspace_overlay->update();
}
update_texture_list_icon();
- helper->_change_notify("");
+ helper->notify_property_list_changed();
}
void TileSetEditor::update_texture_list_icon() {
@@ -3389,7 +3388,7 @@ int TileSetEditor::get_current_tile() const {
void TileSetEditor::set_current_tile(int p_id) {
if (current_tile != p_id) {
current_tile = p_id;
- helper->_change_notify("");
+ helper->notify_property_list_changed();
select_coord(Vector2(0, 0));
update_workspace_tile_mode();
if (p_id == -1) {
@@ -3414,7 +3413,7 @@ void TilesetEditorContext::set_tileset(const Ref<TileSet> &p_tileset) {
void TilesetEditorContext::set_snap_options_visible(bool p_visible) {
snap_options_visible = p_visible;
- _change_notify("");
+ notify_property_list_changed();
}
bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value) {
@@ -3450,7 +3449,7 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value
tileset->set(String::num(tileset_editor->get_current_tile(), 0) + "/" + name2, p_value, &v);
}
if (v) {
- tileset->_change_notify("");
+ tileset->notify_property_list_changed();
tileset_editor->workspace->update();
tileset_editor->workspace_overlay->update();
}
diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h
index 72eb14941c..e778c18f44 100644
--- a/editor/plugins/tile_set_editor_plugin.h
+++ b/editor/plugins/tile_set_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index 5e98b2d98b..0af3b936cb 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -119,19 +119,13 @@ void VersionControlEditorPlugin::_initialize_vcs() {
}
void VersionControlEditorPlugin::_send_commit_msg() {
- String msg = commit_message->get_text();
- if (msg == "") {
- commit_status->set_text(TTR("No commit message was provided"));
- return;
- }
-
if (EditorVCSInterface::get_singleton()) {
if (staged_files_count == 0) {
commit_status->set_text(TTR("No files added to stage"));
return;
}
- EditorVCSInterface::get_singleton()->commit(msg);
+ EditorVCSInterface::get_singleton()->commit(commit_message->get_text());
commit_message->set_text("");
version_control_dock_button->set_pressed(false);
@@ -294,6 +288,10 @@ void VersionControlEditorPlugin::_update_commit_status() {
staged_files_count = 0;
}
+void VersionControlEditorPlugin::_update_commit_button() {
+ commit_button->set_disabled(commit_message->get_text().strip_edges() == "");
+}
+
void VersionControlEditorPlugin::register_editor() {
if (!EditorVCSInterface::get_singleton()) {
EditorNode::get_singleton()->add_control_to_dock(EditorNode::DOCK_SLOT_RIGHT_UL, version_commit_dock);
@@ -357,7 +355,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_dialog->set_min_size(Size2(400, 100));
version_control_actions->add_child(set_up_dialog);
- set_up_ok_button = set_up_dialog->get_ok();
+ set_up_ok_button = set_up_dialog->get_ok_button();
set_up_ok_button->set_text(TTR("Close"));
set_up_vbc = memnew(VBoxContainer);
@@ -463,11 +461,12 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
commit_message->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END);
commit_message->set_custom_minimum_size(Size2(200, 100));
commit_message->set_wrap_enabled(true);
- commit_message->set_text(TTR("Add a commit message"));
+ commit_message->connect("text_changed", callable_mp(this, &VersionControlEditorPlugin::_update_commit_button));
commit_box_vbc->add_child(commit_message);
commit_button = memnew(Button);
commit_button->set_text(TTR("Commit Changes"));
+ commit_button->set_disabled(true);
commit_button->connect("pressed", callable_mp(this, &VersionControlEditorPlugin::_send_commit_msg));
commit_box_vbc->add_child(commit_button);
diff --git a/editor/plugins/version_control_editor_plugin.h b/editor/plugins/version_control_editor_plugin.h
index 34643e85e4..7d7c66a7ee 100644
--- a/editor/plugins/version_control_editor_plugin.h
+++ b/editor/plugins/version_control_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -110,6 +110,7 @@ private:
void _clear_file_diff();
void _update_stage_status();
void _update_commit_status();
+ void _update_commit_button();
friend class EditorVCSInterface;
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 07061a4bc5..5061067ded 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -44,6 +44,7 @@
#include "scene/gui/panel.h"
#include "scene/main/window.h"
#include "scene/resources/visual_shader_nodes.h"
+#include "scene/resources/visual_shader_sdf_nodes.h"
#include "servers/display_server.h"
#include "servers/rendering/shader_types.h"
@@ -83,10 +84,10 @@ void VisualShaderNodePlugin::_bind_methods() {
static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
- style->set_default_margin(MARGIN_LEFT, p_margin_left * EDSCALE);
- style->set_default_margin(MARGIN_RIGHT, p_margin_right * EDSCALE);
- style->set_default_margin(MARGIN_BOTTOM, p_margin_bottom * EDSCALE);
- style->set_default_margin(MARGIN_TOP, p_margin_top * EDSCALE);
+ style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE);
+ style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE);
+ style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE);
+ style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE);
return style;
}
@@ -283,7 +284,7 @@ VisualShader::Type VisualShaderGraphPlugin::get_shader_type() const {
void VisualShaderGraphPlugin::set_node_position(VisualShader::Type p_type, int p_id, const Vector2 &p_position) {
if (visual_shader->get_shader_type() == p_type && links.has(p_id)) {
- links[p_id].graph_node->set_offset(p_position);
+ links[p_id].graph_node->set_position_offset(p_position);
}
}
@@ -365,7 +366,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
expression = expression_node->get_expression();
}
- node->set_offset(visual_shader->get_node_position(p_type, p_id));
+ node->set_position_offset(visual_shader->get_node_position(p_type, p_id));
node->set_title(vsnode->get_caption());
node->set_name(itos(p_id));
@@ -618,7 +619,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) {
if (vsnode->get_input_port_default_hint(i) != "" && !port_left_used) {
Label *hint_label = memnew(Label);
hint_label->set_text("[" + vsnode->get_input_port_default_hint(i) + "]");
- hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("font_color_readonly", "TextEdit"));
+ hint_label->add_theme_color_override("font_color", VisualShaderEditor::get_singleton()->get_theme_color("font_readonly_color", "TextEdit"));
hint_label->add_theme_style_override("normal", label_style);
hb->add_child(hint_label);
}
@@ -1009,13 +1010,13 @@ String VisualShaderEditor::_get_description(int p_idx) {
void VisualShaderEditor::_update_options_menu() {
node_desc->set_text("");
- members_dialog->get_ok()->set_disabled(true);
+ members_dialog->get_ok_button()->set_disabled(true);
members->clear();
TreeItem *root = members->create_item();
String filter = node_filter->get_text().strip_edges();
- bool use_filter = !filter.empty();
+ bool use_filter = !filter.is_empty();
bool is_first_item = true;
@@ -1281,6 +1282,9 @@ void VisualShaderEditor::_update_graph() {
graph->connect_node(itos(from), from_idx, itos(to), to_idx);
}
+
+ float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
+ graph->set_minimap_opacity(graph_minimap_opacity);
}
VisualShader::Type VisualShaderEditor::get_current_shader_type() const {
@@ -1580,9 +1584,9 @@ void VisualShaderEditor::_set_node_size(int p_type, int p_node, const Vector2 &p
box_size.x = gn->get_size().x;
}
}
- box_size.x -= text_box->get_margin(MARGIN_LEFT);
+ box_size.x -= text_box->get_offset(SIDE_LEFT);
box_size.x -= 28 * EDSCALE;
- box_size.y -= text_box->get_margin(MARGIN_TOP);
+ box_size.y -= text_box->get_offset(SIDE_TOP);
box_size.y -= 28 * EDSCALE;
text_box->set_custom_minimum_size(Size2(box_size.x, box_size.y));
text_box->set_size(Size2(1, 1));
@@ -1733,114 +1737,220 @@ void VisualShaderEditor::_add_curve_node(const String &p_path) {
curve->set_texture(ResourceLoader::load(p_path));
}
-VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
- ERR_FAIL_INDEX_V(p_idx, add_options.size(), nullptr);
+void VisualShaderEditor::_setup_node(VisualShaderNode *p_node, int p_op_idx) {
+ // FLOAT_OP
+ {
+ VisualShaderNodeFloatOp *floatOp = Object::cast_to<VisualShaderNodeFloatOp>(p_node);
- Ref<VisualShaderNode> vsnode;
+ if (floatOp) {
+ floatOp->set_operator((VisualShaderNodeFloatOp::Operator)p_op_idx);
+ return;
+ }
+ }
- bool is_custom = add_options[p_idx].is_custom;
+ // FLOAT_FUNC
+ {
+ VisualShaderNodeFloatFunc *floatFunc = Object::cast_to<VisualShaderNodeFloatFunc>(p_node);
- if (!is_custom && add_options[p_idx].type != String()) {
- VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type));
- ERR_FAIL_COND_V(!vsn, nullptr);
+ if (floatFunc) {
+ floatFunc->set_function((VisualShaderNodeFloatFunc::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn);
+ // VECTOR_OP
+ {
+ VisualShaderNodeVectorOp *vecOp = Object::cast_to<VisualShaderNodeVectorOp>(p_node);
- if (constant) {
- if ((int)add_options[p_idx].value != -1) {
- constant->set_constant(add_options[p_idx].value);
- }
+ if (vecOp) {
+ vecOp->set_operator((VisualShaderNodeVectorOp::Operator)p_op_idx);
+ return;
}
+ }
- if (p_op_idx != -1) {
- VisualShaderNodeInput *input = Object::cast_to<VisualShaderNodeInput>(vsn);
+ // VECTOR_FUNC
+ {
+ VisualShaderNodeVectorFunc *vecFunc = Object::cast_to<VisualShaderNodeVectorFunc>(p_node);
- if (input) {
- input->set_input_name(add_options[p_idx].sub_func_str);
- }
+ if (vecFunc) {
+ vecFunc->set_function((VisualShaderNodeVectorFunc::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeIs *is = Object::cast_to<VisualShaderNodeIs>(vsn);
+ // COLOR_OP
+ {
+ VisualShaderNodeColorOp *colorOp = Object::cast_to<VisualShaderNodeColorOp>(p_node);
- if (is) {
- is->set_function((VisualShaderNodeIs::Function)p_op_idx);
- }
+ if (colorOp) {
+ colorOp->set_operator((VisualShaderNodeColorOp::Operator)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeCompare *cmp = Object::cast_to<VisualShaderNodeCompare>(vsn);
+ // COLOR_FUNC
+ {
+ VisualShaderNodeColorFunc *colorFunc = Object::cast_to<VisualShaderNodeColorFunc>(p_node);
- if (cmp) {
- cmp->set_function((VisualShaderNodeCompare::Function)p_op_idx);
- }
+ if (colorFunc) {
+ colorFunc->set_function((VisualShaderNodeColorFunc::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeColorOp *colorOp = Object::cast_to<VisualShaderNodeColorOp>(vsn);
+ // INT_OP
+ {
+ VisualShaderNodeIntOp *intOp = Object::cast_to<VisualShaderNodeIntOp>(p_node);
- if (colorOp) {
- colorOp->set_operator((VisualShaderNodeColorOp::Operator)p_op_idx);
- }
+ if (intOp) {
+ intOp->set_operator((VisualShaderNodeIntOp::Operator)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeColorFunc *colorFunc = Object::cast_to<VisualShaderNodeColorFunc>(vsn);
+ // INT_FUNC
+ {
+ VisualShaderNodeIntFunc *intFunc = Object::cast_to<VisualShaderNodeIntFunc>(p_node);
- if (colorFunc) {
- colorFunc->set_function((VisualShaderNodeColorFunc::Function)p_op_idx);
- }
+ if (intFunc) {
+ intFunc->set_function((VisualShaderNodeIntFunc::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeFloatOp *floatOp = Object::cast_to<VisualShaderNodeFloatOp>(vsn);
+ // TRANSFORM_FUNC
+ {
+ VisualShaderNodeTransformFunc *matFunc = Object::cast_to<VisualShaderNodeTransformFunc>(p_node);
- if (floatOp) {
- floatOp->set_operator((VisualShaderNodeFloatOp::Operator)p_op_idx);
- }
+ if (matFunc) {
+ matFunc->set_function((VisualShaderNodeTransformFunc::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeIntOp *intOp = Object::cast_to<VisualShaderNodeIntOp>(vsn);
+ // IS
+ {
+ VisualShaderNodeIs *is = Object::cast_to<VisualShaderNodeIs>(p_node);
- if (intOp) {
- intOp->set_operator((VisualShaderNodeIntOp::Operator)p_op_idx);
- }
+ if (is) {
+ is->set_function((VisualShaderNodeIs::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeFloatFunc *floatFunc = Object::cast_to<VisualShaderNodeFloatFunc>(vsn);
+ // COMPARE
+ {
+ VisualShaderNodeCompare *cmp = Object::cast_to<VisualShaderNodeCompare>(p_node);
- if (floatFunc) {
- floatFunc->set_function((VisualShaderNodeFloatFunc::Function)p_op_idx);
- }
+ if (cmp) {
+ cmp->set_function((VisualShaderNodeCompare::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeIntFunc *intFunc = Object::cast_to<VisualShaderNodeIntFunc>(vsn);
+ // DERIVATIVE
+ {
+ VisualShaderNodeScalarDerivativeFunc *sderFunc = Object::cast_to<VisualShaderNodeScalarDerivativeFunc>(p_node);
- if (intFunc) {
- intFunc->set_function((VisualShaderNodeIntFunc::Function)p_op_idx);
- }
+ if (sderFunc) {
+ sderFunc->set_function((VisualShaderNodeScalarDerivativeFunc::Function)p_op_idx);
+ return;
+ }
- VisualShaderNodeVectorOp *vecOp = Object::cast_to<VisualShaderNodeVectorOp>(vsn);
+ VisualShaderNodeVectorDerivativeFunc *vderFunc = Object::cast_to<VisualShaderNodeVectorDerivativeFunc>(p_node);
- if (vecOp) {
- vecOp->set_operator((VisualShaderNodeVectorOp::Operator)p_op_idx);
- }
+ if (vderFunc) {
+ vderFunc->set_function((VisualShaderNodeVectorDerivativeFunc::Function)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeVectorFunc *vecFunc = Object::cast_to<VisualShaderNodeVectorFunc>(vsn);
+ // MIX
+ {
+ VisualShaderNodeMix *mix = Object::cast_to<VisualShaderNodeMix>(p_node);
- if (vecFunc) {
- vecFunc->set_function((VisualShaderNodeVectorFunc::Function)p_op_idx);
- }
+ if (mix) {
+ mix->set_op_type((VisualShaderNodeMix::OpType)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeTransformFunc *matFunc = Object::cast_to<VisualShaderNodeTransformFunc>(vsn);
+ // CLAMP
+ {
+ VisualShaderNodeClamp *clampFunc = Object::cast_to<VisualShaderNodeClamp>(p_node);
- if (matFunc) {
- matFunc->set_function((VisualShaderNodeTransformFunc::Function)p_op_idx);
- }
+ if (clampFunc) {
+ clampFunc->set_op_type((VisualShaderNodeClamp::OpType)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeScalarDerivativeFunc *sderFunc = Object::cast_to<VisualShaderNodeScalarDerivativeFunc>(vsn);
+ // SWITCH
+ {
+ VisualShaderNodeSwitch *switchFunc = Object::cast_to<VisualShaderNodeSwitch>(p_node);
- if (sderFunc) {
- sderFunc->set_function((VisualShaderNodeScalarDerivativeFunc::Function)p_op_idx);
- }
+ if (switchFunc) {
+ switchFunc->set_op_type((VisualShaderNodeSwitch::OpType)p_op_idx);
+ return;
+ }
+ }
- VisualShaderNodeVectorDerivativeFunc *vderFunc = Object::cast_to<VisualShaderNodeVectorDerivativeFunc>(vsn);
+ // SMOOTHSTEP
+ {
+ VisualShaderNodeSmoothStep *smoothStepFunc = Object::cast_to<VisualShaderNodeSmoothStep>(p_node);
- if (vderFunc) {
- vderFunc->set_function((VisualShaderNodeVectorDerivativeFunc::Function)p_op_idx);
- }
+ if (smoothStepFunc) {
+ smoothStepFunc->set_op_type((VisualShaderNodeSmoothStep::OpType)p_op_idx);
+ return;
+ }
+ }
+
+ // STEP
+ {
+ VisualShaderNodeStep *stepFunc = Object::cast_to<VisualShaderNodeStep>(p_node);
+
+ if (stepFunc) {
+ stepFunc->set_op_type((VisualShaderNodeStep::OpType)p_op_idx);
+ return;
+ }
+ }
+
+ // MULTIPLY_ADD
+ {
+ VisualShaderNodeMultiplyAdd *fmaFunc = Object::cast_to<VisualShaderNodeMultiplyAdd>(p_node);
+
+ if (fmaFunc) {
+ fmaFunc->set_op_type((VisualShaderNodeMultiplyAdd::OpType)p_op_idx);
+ }
+ }
+}
+
+VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
+ ERR_FAIL_INDEX_V(p_idx, add_options.size(), nullptr);
+
+ Ref<VisualShaderNode> vsnode;
- VisualShaderNodeMultiplyAdd *fmaFunc = Object::cast_to<VisualShaderNodeMultiplyAdd>(vsn);
+ bool is_custom = add_options[p_idx].is_custom;
- if (fmaFunc) {
- fmaFunc->set_op_type((VisualShaderNodeMultiplyAdd::OpType)p_op_idx);
+ if (!is_custom && add_options[p_idx].type != String()) {
+ VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instance(add_options[p_idx].type));
+ ERR_FAIL_COND_V(!vsn, nullptr);
+
+ VisualShaderNodeFloatConstant *constant = Object::cast_to<VisualShaderNodeFloatConstant>(vsn);
+
+ if (constant) {
+ if ((int)add_options[p_idx].value != -1) {
+ constant->set_constant(add_options[p_idx].value);
+ }
+ } else {
+ if (p_op_idx != -1) {
+ VisualShaderNodeInput *input = Object::cast_to<VisualShaderNodeInput>(vsn);
+
+ if (input) {
+ input->set_input_name(add_options[p_idx].sub_func_str);
+ } else {
+ _setup_node(vsn, p_op_idx);
+ }
}
}
@@ -1879,28 +1989,95 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
undo_redo->add_do_method(expr, "set_size", Size2(250 * EDSCALE, 150 * EDSCALE));
}
+ bool created_expression_port = false;
+
if (to_node != -1 && to_slot != -1) {
- if (vsnode->get_output_port_count() > 0) {
+ VisualShaderNode::PortType input_port_type = visual_shader->get_node(type, to_node)->get_input_port_type(to_slot);
+
+ if (expr && expr->is_editable() && input_port_type != VisualShaderNode::PORT_TYPE_SAMPLER) {
+ undo_redo->add_do_method(expr, "add_output_port", 0, input_port_type, "output0");
+ undo_redo->add_undo_method(expr, "remove_output_port", 0);
+
+ String initial_expression_code;
+
+ switch (input_port_type) {
+ case VisualShaderNode::PORT_TYPE_SCALAR:
+ initial_expression_code = "output0 = 1.0;";
+ break;
+ case VisualShaderNode::PORT_TYPE_SCALAR_INT:
+ initial_expression_code = "output0 = 1;";
+ break;
+ case VisualShaderNode::PORT_TYPE_VECTOR:
+ initial_expression_code = "output0 = vec3(1.0, 1.0, 1.0);";
+ break;
+ case VisualShaderNode::PORT_TYPE_BOOLEAN:
+ initial_expression_code = "output0 = true;";
+ break;
+ case VisualShaderNode::PORT_TYPE_TRANSFORM:
+ initial_expression_code = "output0 = mat4(1.0);";
+ break;
+ default:
+ break;
+ }
+
+ undo_redo->add_do_method(expr, "set_expression", initial_expression_code);
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, id_to_use);
+
+ created_expression_port = true;
+ }
+ if (vsnode->get_output_port_count() > 0 || created_expression_port) {
int _from_node = id_to_use;
int _from_slot = 0;
- if (visual_shader->is_port_types_compatible(vsnode->get_output_port_type(_from_slot), visual_shader->get_node(type, to_node)->get_input_port_type(to_slot))) {
+ if (created_expression_port) {
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot);
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot);
undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, _from_node, _from_slot, to_node, to_slot);
undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, _from_node, _from_slot, to_node, to_slot);
+ } else {
+ // Attempting to connect to the first correct port.
+ for (int i = 0; i < vsnode->get_output_port_count(); i++) {
+ if (visual_shader->is_port_types_compatible(vsnode->get_output_port_type(i), input_port_type)) {
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, _from_node, i, to_node, to_slot);
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, _from_node, i, to_node, to_slot);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, _from_node, i, to_node, to_slot);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, _from_node, i, to_node, to_slot);
+ break;
+ }
+ }
}
}
} else if (from_node != -1 && from_slot != -1) {
- if (vsnode->get_input_port_count() > 0) {
+ VisualShaderNode::PortType output_port_type = visual_shader->get_node(type, from_node)->get_output_port_type(from_slot);
+
+ if (expr && expr->is_editable()) {
+ undo_redo->add_do_method(expr, "add_input_port", 0, output_port_type, "input0");
+ undo_redo->add_undo_method(expr, "remove_input_port", 0);
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, id_to_use);
+
+ created_expression_port = true;
+ }
+
+ if (vsnode->get_input_port_count() > 0 || created_expression_port) {
int _to_node = id_to_use;
int _to_slot = 0;
- if (visual_shader->is_port_types_compatible(visual_shader->get_node(type, from_node)->get_output_port_type(from_slot), vsnode->get_input_port_type(_to_slot))) {
+ if (created_expression_port) {
undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, _to_slot);
undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, _to_slot);
+ } else {
+ // Attempting to connect to the first correct port.
+ for (int i = 0; i < vsnode->get_input_port_count(); i++) {
+ if (visual_shader->is_port_types_compatible(output_port_type, vsnode->get_input_port_type(i))) {
+ undo_redo->add_undo_method(visual_shader.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, i);
+ undo_redo->add_do_method(visual_shader.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, i);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "disconnect_nodes", type, from_node, from_slot, _to_node, i);
+ undo_redo->add_do_method(graph_plugin.ptr(), "connect_nodes", type, from_node, from_slot, _to_node, i);
+ break;
+ }
+ }
}
}
}
@@ -2087,6 +2264,197 @@ void VisualShaderEditor::_delete_nodes(int p_type, const List<int> &p_nodes) {
}
}
+void VisualShaderEditor::_replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to) {
+ undo_redo->add_do_method(visual_shader.ptr(), "replace_node", p_type_id, p_node_id, p_to);
+ undo_redo->add_undo_method(visual_shader.ptr(), "replace_node", p_type_id, p_node_id, p_from);
+}
+
+void VisualShaderEditor::_update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) {
+ Ref<VisualShaderNode> node = visual_shader->get_node(p_type_id, p_node_id);
+ ERR_FAIL_COND(!node.is_valid());
+ ERR_FAIL_COND(!node->has_method("set_constant"));
+ node->call("set_constant", p_var);
+ if (p_preview_port != -1) {
+ node->set_output_port_for_preview(p_preview_port);
+ }
+}
+
+void VisualShaderEditor::_update_uniform(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port) {
+ Ref<VisualShaderNodeUniform> uniform = visual_shader->get_node(p_type_id, p_node_id);
+ ERR_FAIL_COND(!uniform.is_valid());
+
+ String valid_name = visual_shader->validate_uniform_name(uniform->get_uniform_name(), uniform);
+ uniform->set_uniform_name(valid_name);
+ graph_plugin->set_uniform_name(p_type_id, p_node_id, valid_name);
+
+ if (uniform->has_method("set_default_value_enabled")) {
+ uniform->call("set_default_value_enabled", true);
+ uniform->call("set_default_value", p_var);
+ }
+ if (p_preview_port != -1) {
+ uniform->set_output_port_for_preview(p_preview_port);
+ }
+}
+
+void VisualShaderEditor::_convert_constants_to_uniforms(bool p_vice_versa) {
+ VisualShader::Type type_id = get_current_shader_type();
+
+ if (!p_vice_versa) {
+ undo_redo->create_action(TTR("Convert Constant Node(s) To Uniform(s)"));
+ } else {
+ undo_redo->create_action(TTR("Convert Uniform Node(s) To Constant(s)"));
+ }
+
+ const Set<int> &current_set = p_vice_versa ? selected_uniforms : selected_constants;
+ Set<String> deleted_names;
+
+ for (Set<int>::Element *E = current_set.front(); E; E = E->next()) {
+ int node_id = E->get();
+ Ref<VisualShaderNode> node = visual_shader->get_node(type_id, node_id);
+ bool catched = false;
+ Variant var;
+
+ // float
+ if (!p_vice_versa) {
+ Ref<VisualShaderNodeFloatConstant> float_const = Object::cast_to<VisualShaderNodeFloatConstant>(node.ptr());
+ if (float_const.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeFloatConstant", "VisualShaderNodeFloatUniform");
+ var = float_const->get_constant();
+ catched = true;
+ }
+ } else {
+ Ref<VisualShaderNodeFloatUniform> float_uniform = Object::cast_to<VisualShaderNodeFloatUniform>(node.ptr());
+ if (float_uniform.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeFloatUniform", "VisualShaderNodeFloatConstant");
+ var = float_uniform->get_default_value();
+ catched = true;
+ }
+ }
+
+ // int
+ if (!catched) {
+ if (!p_vice_versa) {
+ Ref<VisualShaderNodeIntConstant> int_const = Object::cast_to<VisualShaderNodeIntConstant>(node.ptr());
+ if (int_const.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeIntConstant", "VisualShaderNodeIntUniform");
+ var = int_const->get_constant();
+ catched = true;
+ }
+ } else {
+ Ref<VisualShaderNodeIntUniform> int_uniform = Object::cast_to<VisualShaderNodeIntUniform>(node.ptr());
+ if (int_uniform.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeIntUniform", "VisualShaderNodeIntConstant");
+ var = int_uniform->get_default_value();
+ catched = true;
+ }
+ }
+ }
+
+ // boolean
+ if (!catched) {
+ if (!p_vice_versa) {
+ Ref<VisualShaderNodeBooleanConstant> boolean_const = Object::cast_to<VisualShaderNodeBooleanConstant>(node.ptr());
+ if (boolean_const.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeBooleanConstant", "VisualShaderNodeBooleanUniform");
+ var = boolean_const->get_constant();
+ catched = true;
+ }
+ } else {
+ Ref<VisualShaderNodeBooleanUniform> boolean_uniform = Object::cast_to<VisualShaderNodeBooleanUniform>(node.ptr());
+ if (boolean_uniform.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeBooleanUniform", "VisualShaderNodeBooleanConstant");
+ var = boolean_uniform->get_default_value();
+ catched = true;
+ }
+ }
+ }
+
+ // vec3
+ if (!catched) {
+ if (!p_vice_versa) {
+ Ref<VisualShaderNodeVec3Constant> vec3_const = Object::cast_to<VisualShaderNodeVec3Constant>(node.ptr());
+ if (vec3_const.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeVec3Constant", "VisualShaderNodeVec3Uniform");
+ var = vec3_const->get_constant();
+ catched = true;
+ }
+ } else {
+ Ref<VisualShaderNodeVec3Uniform> vec3_uniform = Object::cast_to<VisualShaderNodeVec3Uniform>(node.ptr());
+ if (vec3_uniform.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeVec3Uniform", "VisualShaderNodeVec3Constant");
+ var = vec3_uniform->get_default_value();
+ catched = true;
+ }
+ }
+ }
+
+ // color
+ if (!catched) {
+ if (!p_vice_versa) {
+ Ref<VisualShaderNodeColorConstant> color_const = Object::cast_to<VisualShaderNodeColorConstant>(node.ptr());
+ if (color_const.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeColorConstant", "VisualShaderNodeColorUniform");
+ var = color_const->get_constant();
+ catched = true;
+ }
+ } else {
+ Ref<VisualShaderNodeColorUniform> color_uniform = Object::cast_to<VisualShaderNodeColorUniform>(node.ptr());
+ if (color_uniform.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeColorUniform", "VisualShaderNodeColorConstant");
+ var = color_uniform->get_default_value();
+ catched = true;
+ }
+ }
+ }
+
+ // transform
+ if (!catched) {
+ if (!p_vice_versa) {
+ Ref<VisualShaderNodeTransformConstant> transform_const = Object::cast_to<VisualShaderNodeTransformConstant>(node.ptr());
+ if (transform_const.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeTransformConstant", "VisualShaderNodeTransformUniform");
+ var = transform_const->get_constant();
+ catched = true;
+ }
+ } else {
+ Ref<VisualShaderNodeTransformUniform> transform_uniform = Object::cast_to<VisualShaderNodeTransformUniform>(node.ptr());
+ if (transform_uniform.is_valid()) {
+ _replace_node(type_id, node_id, "VisualShaderNodeTransformUniform", "VisualShaderNodeTransformConstant");
+ var = transform_uniform->get_default_value();
+ catched = true;
+ }
+ }
+ }
+ ERR_CONTINUE(!catched);
+ int preview_port = node->get_output_port_for_preview();
+
+ if (!p_vice_versa) {
+ undo_redo->add_do_method(this, "_update_uniform", type_id, node_id, var, preview_port);
+ undo_redo->add_undo_method(this, "_update_constant", type_id, node_id, var, preview_port);
+ } else {
+ undo_redo->add_do_method(this, "_update_constant", type_id, node_id, var, preview_port);
+ undo_redo->add_undo_method(this, "_update_uniform", type_id, node_id, var, preview_port);
+
+ Ref<VisualShaderNodeUniform> uniform = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
+ ERR_CONTINUE(!uniform.is_valid());
+
+ deleted_names.insert(uniform->get_uniform_name());
+ }
+
+ undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, node_id);
+ undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, node_id);
+ }
+
+ undo_redo->add_do_method(this, "_update_uniforms", true);
+ undo_redo->add_undo_method(this, "_update_uniforms", true);
+
+ if (deleted_names.size() > 0) {
+ _update_uniform_refs(deleted_names);
+ }
+
+ undo_redo->commit_action();
+}
+
void VisualShaderEditor::_delete_node_request(int p_type, int p_node) {
List<int> to_erase;
to_erase.push_back(p_node);
@@ -2108,7 +2476,7 @@ void VisualShaderEditor::_delete_nodes_request() {
}
}
- if (to_erase.empty()) {
+ if (to_erase.is_empty()) {
return;
}
@@ -2134,27 +2502,69 @@ void VisualShaderEditor::_node_selected(Object *p_node) {
void VisualShaderEditor::_graph_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
+ VisualShader::Type type = get_current_shader_type();
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) {
+ selected_constants.clear();
+ selected_uniforms.clear();
+
List<int> to_change;
for (int i = 0; i < graph->get_child_count(); i++) {
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected() && gn->is_close_button_visible()) {
- to_change.push_back(gn->get_name().operator String().to_int());
+ int id = gn->get_name().operator String().to_int();
+ to_change.push_back(id);
+
+ Ref<VisualShaderNode> node = visual_shader->get_node(type, id);
+ VisualShaderNodeConstant *cnode = Object::cast_to<VisualShaderNodeConstant>(node.ptr());
+ if (cnode != nullptr) {
+ selected_constants.insert(id);
+ }
+ VisualShaderNodeUniform *unode = Object::cast_to<VisualShaderNodeUniform>(node.ptr());
+ if (unode != nullptr) {
+ selected_uniforms.insert(id);
+ }
}
}
}
- if (to_change.empty() && copy_nodes_buffer.empty()) {
+ if (to_change.is_empty() && copy_nodes_buffer.is_empty()) {
_show_members_dialog(true);
} else {
- popup_menu->set_item_disabled(NodeMenuOptions::COPY, to_change.empty());
- popup_menu->set_item_disabled(NodeMenuOptions::PASTE, copy_nodes_buffer.empty());
- popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.empty());
- popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::COPY, to_change.is_empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::PASTE, copy_nodes_buffer.is_empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::DELETE, to_change.is_empty());
+ popup_menu->set_item_disabled(NodeMenuOptions::DUPLICATE, to_change.is_empty());
+
+ int temp = popup_menu->get_item_index(NodeMenuOptions::SEPARATOR2);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+ temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+ temp = popup_menu->get_item_index(NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
+ if (temp != -1) {
+ popup_menu->remove_item(temp);
+ }
+
+ if (selected_constants.size() > 0 || selected_uniforms.size() > 0) {
+ popup_menu->add_separator("", NodeMenuOptions::SEPARATOR2);
+
+ if (selected_constants.size() > 0) {
+ popup_menu->add_item(TTR("Convert Constant(s) to Uniform(s)"), NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS);
+ }
+
+ if (selected_uniforms.size() > 0) {
+ popup_menu->add_item(TTR("Convert Uniforms(s) to Constant(s)"), NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS);
+ }
+ }
+
menu_point = graph->get_local_mouse_position();
Point2 gpos = Input::get_singleton()->get_mouse_position();
popup_menu->set_position(gpos);
+ popup_menu->set_size(Size2(-1, -1));
popup_menu->popup();
}
}
@@ -2445,7 +2855,7 @@ void VisualShaderEditor::_duplicate_nodes() {
_dup_copy_nodes(type, nodes, excluded);
- if (nodes.empty()) {
+ if (nodes.is_empty()) {
return;
}
@@ -2463,7 +2873,7 @@ void VisualShaderEditor::_copy_nodes() {
}
void VisualShaderEditor::_paste_nodes(bool p_use_custom_position, const Vector2 &p_custom_position) {
- if (copy_nodes_buffer.empty()) {
+ if (copy_nodes_buffer.is_empty()) {
return;
}
@@ -2613,12 +3023,12 @@ void VisualShaderEditor::_member_selected() {
TreeItem *item = members->get_selected();
if (item != nullptr && item->has_meta("id")) {
- members_dialog->get_ok()->set_disabled(false);
+ members_dialog->get_ok_button()->set_disabled(false);
highend_label->set_visible(add_options[item->get_meta("id")].highend);
node_desc->set_text(_get_description(item->get_meta("id")));
} else {
highend_label->set_visible(false);
- members_dialog->get_ok()->set_disabled(true);
+ members_dialog->get_ok_button()->set_disabled(true);
node_desc->set_text("");
}
}
@@ -2695,6 +3105,14 @@ void VisualShaderEditor::_node_menu_id_pressed(int p_idx) {
case NodeMenuOptions::DUPLICATE:
_duplicate_nodes();
break;
+ case NodeMenuOptions::CONVERT_CONSTANTS_TO_UNIFORMS:
+ _convert_constants_to_uniforms(false);
+ break;
+ case NodeMenuOptions::CONVERT_UNIFORMS_TO_CONSTANTS:
+ _convert_constants_to_uniforms(true);
+ break;
+ default:
+ break;
}
}
@@ -2799,15 +3217,35 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
void VisualShaderEditor::_show_preview_text() {
preview_showed = !preview_showed;
- preview_vbox->set_visible(preview_showed);
if (preview_showed) {
+ if (preview_first) {
+ preview_window->set_size(Size2(400 * EDSCALE, 600 * EDSCALE));
+ preview_window->popup_centered();
+ preview_first = false;
+ } else {
+ preview_window->popup();
+ }
+ _preview_size_changed();
+
if (pending_update_preview) {
_update_preview();
pending_update_preview = false;
}
+ } else {
+ preview_window->hide();
}
}
+void VisualShaderEditor::_preview_close_requested() {
+ preview_showed = false;
+ preview_window->hide();
+ preview_shader->set_pressed(false);
+}
+
+void VisualShaderEditor::_preview_size_changed() {
+ preview_vbox->set_custom_minimum_size(preview_window->get_size());
+}
+
static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
return RS::global_variable_type_get_shader_datatype(gvt);
@@ -2843,6 +3281,16 @@ void VisualShaderEditor::_update_preview() {
}
}
+void VisualShaderEditor::_visibility_changed() {
+ if (!is_visible()) {
+ if (preview_window->is_visible()) {
+ preview_shader->set_pressed(false);
+ preview_window->hide();
+ preview_showed = false;
+ }
+ }
+}
+
void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_update_graph", &VisualShaderEditor::_update_graph);
ClassDB::bind_method("_update_options_menu", &VisualShaderEditor::_update_options_menu);
@@ -2856,6 +3304,8 @@ void VisualShaderEditor::_bind_methods() {
ClassDB::bind_method("_set_mode", &VisualShaderEditor::_set_mode);
ClassDB::bind_method("_nodes_dragged", &VisualShaderEditor::_nodes_dragged);
ClassDB::bind_method("_float_constant_selected", &VisualShaderEditor::_float_constant_selected);
+ ClassDB::bind_method("_update_constant", &VisualShaderEditor::_update_constant);
+ ClassDB::bind_method("_update_uniform", &VisualShaderEditor::_update_uniform);
ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &VisualShaderEditor::get_drag_data_fw);
ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &VisualShaderEditor::can_drop_data_fw);
@@ -2873,7 +3323,6 @@ VisualShaderEditor::VisualShaderEditor() {
saved_node_pos = Point2(0, 0);
ShaderLanguage::get_keyword_list(&keyword_list);
- preview_showed = false;
pending_update_preview = false;
shader_error = false;
@@ -2882,17 +3331,14 @@ VisualShaderEditor::VisualShaderEditor() {
from_node = -1;
from_slot = -1;
- main_box = memnew(HSplitContainer);
- main_box->set_v_size_flags(SIZE_EXPAND_FILL);
- main_box->set_h_size_flags(SIZE_EXPAND_FILL);
- add_child(main_box);
-
graph = memnew(GraphEdit);
graph->get_zoom_hbox()->set_h_size_flags(SIZE_EXPAND_FILL);
graph->set_v_size_flags(SIZE_EXPAND_FILL);
graph->set_h_size_flags(SIZE_EXPAND_FILL);
- main_box->add_child(graph);
+ add_child(graph);
graph->set_drag_forwarding(this);
+ float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
+ graph->set_minimap_opacity(graph_minimap_opacity);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR_INT);
graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_BOOLEAN);
@@ -2912,6 +3358,7 @@ VisualShaderEditor::VisualShaderEditor() {
graph->connect("gui_input", callable_mp(this, &VisualShaderEditor::_graph_gui_input));
graph->connect("connection_to_empty", callable_mp(this, &VisualShaderEditor::_connection_to_empty));
graph->connect("connection_from_empty", callable_mp(this, &VisualShaderEditor::_connection_from_empty));
+ graph->connect("visibility_changed", callable_mp(this, &VisualShaderEditor::_visibility_changed));
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR_INT);
graph->add_valid_connection_type(VisualShaderNode::PORT_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR);
@@ -2966,29 +3413,35 @@ VisualShaderEditor::VisualShaderEditor() {
preview_shader = memnew(Button);
preview_shader->set_flat(true);
preview_shader->set_toggle_mode(true);
- preview_shader->set_tooltip(TTR("Show resulted shader code."));
+ preview_shader->set_tooltip(TTR("Show generated shader code."));
graph->get_zoom_hbox()->add_child(preview_shader);
preview_shader->connect("pressed", callable_mp(this, &VisualShaderEditor::_show_preview_text));
///////////////////////////////////////
- // PREVIEW PANEL
+ // PREVIEW WINDOW
///////////////////////////////////////
+ preview_window = memnew(Window);
+ preview_window->set_title(TTR("Generated shader code"));
+ preview_window->set_visible(preview_showed);
+ preview_window->connect("close_requested", callable_mp(this, &VisualShaderEditor::_preview_close_requested));
+ preview_window->connect("size_changed", callable_mp(this, &VisualShaderEditor::_preview_size_changed));
+ add_child(preview_window);
+
preview_vbox = memnew(VBoxContainer);
- preview_vbox->set_visible(preview_showed);
- main_box->add_child(preview_vbox);
+ preview_window->add_child(preview_vbox);
+
preview_text = memnew(CodeEdit);
syntax_highlighter.instance();
preview_vbox->add_child(preview_text);
- preview_text->set_h_size_flags(SIZE_EXPAND_FILL);
- preview_text->set_v_size_flags(SIZE_EXPAND_FILL);
- preview_text->set_custom_minimum_size(Size2(400 * EDSCALE, 0));
+ preview_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
preview_text->set_syntax_highlighter(syntax_highlighter);
preview_text->set_draw_line_numbers(true);
preview_text->set_readonly(true);
error_text = memnew(Label);
preview_vbox->add_child(error_text);
+ error_text->set_autowrap(true);
error_text->set_visible(false);
///////////////////////////////////////
@@ -2997,12 +3450,12 @@ VisualShaderEditor::VisualShaderEditor() {
popup_menu = memnew(PopupMenu);
add_child(popup_menu);
- popup_menu->add_item("Add Node", NodeMenuOptions::ADD);
+ popup_menu->add_item(TTR("Add Node"), NodeMenuOptions::ADD);
popup_menu->add_separator();
- popup_menu->add_item("Copy", NodeMenuOptions::COPY);
- popup_menu->add_item("Paste", NodeMenuOptions::PASTE);
- popup_menu->add_item("Delete", NodeMenuOptions::DELETE);
- popup_menu->add_item("Duplicate", NodeMenuOptions::DUPLICATE);
+ popup_menu->add_item(TTR("Copy"), NodeMenuOptions::COPY);
+ popup_menu->add_item(TTR("Paste"), NodeMenuOptions::PASTE);
+ popup_menu->add_item(TTR("Delete"), NodeMenuOptions::DELETE);
+ popup_menu->add_item(TTR("Duplicate"), NodeMenuOptions::DUPLICATE);
popup_menu->connect("id_pressed", callable_mp(this, &VisualShaderEditor::_node_menu_id_pressed));
///////////////////////////////////////
@@ -3068,9 +3521,9 @@ VisualShaderEditor::VisualShaderEditor() {
members_dialog->set_title(TTR("Create Shader Node"));
members_dialog->set_exclusive(false);
members_dialog->add_child(members_vb);
- members_dialog->get_ok()->set_text(TTR("Create"));
- members_dialog->get_ok()->connect("pressed", callable_mp(this, &VisualShaderEditor::_member_create));
- members_dialog->get_ok()->set_disabled(true);
+ members_dialog->get_ok_button()->set_text(TTR("Create"));
+ members_dialog->get_ok_button()->connect("pressed", callable_mp(this, &VisualShaderEditor::_member_create));
+ members_dialog->get_ok_button()->set_disabled(true);
members_dialog->connect("cancelled", callable_mp(this, &VisualShaderEditor::_member_cancel));
add_child(members_dialog);
@@ -3121,8 +3574,11 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("LessThan", "Conditional", "Functions", "VisualShaderNodeCompare", vformat(compare_func_desc, TTR("Less Than (<)")), VisualShaderNodeCompare::FUNC_LESS_THAN, VisualShaderNode::PORT_TYPE_BOOLEAN));
add_options.push_back(AddOption("LessThanEqual", "Conditional", "Functions", "VisualShaderNodeCompare", vformat(compare_func_desc, TTR("Less Than or Equal (<=)")), VisualShaderNodeCompare::FUNC_LESS_THAN_EQUAL, VisualShaderNode::PORT_TYPE_BOOLEAN));
add_options.push_back(AddOption("NotEqual", "Conditional", "Functions", "VisualShaderNodeCompare", vformat(compare_func_desc, TTR("Not Equal (!=)")), VisualShaderNodeCompare::FUNC_NOT_EQUAL, VisualShaderNode::PORT_TYPE_BOOLEAN));
- add_options.push_back(AddOption("Switch", "Conditional", "Functions", "VisualShaderNodeSwitch", TTR("Returns an associated vector if the provided boolean value is true or false."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("SwitchS", "Conditional", "Functions", "VisualShaderNodeScalarSwitch", TTR("Returns an associated scalar if the provided boolean value is true or false."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Switch", "Conditional", "Functions", "VisualShaderNodeSwitch", TTR("Returns an associated vector if the provided boolean value is true or false."), VisualShaderNodeSwitch::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("SwitchBool", "Conditional", "Functions", "VisualShaderNodeSwitch", TTR("Returns an associated boolean if the provided boolean value is true or false."), VisualShaderNodeSwitch::OP_TYPE_BOOLEAN, VisualShaderNode::PORT_TYPE_BOOLEAN));
+ add_options.push_back(AddOption("SwitchFloat", "Conditional", "Functions", "VisualShaderNodeSwitch", TTR("Returns an associated floating-point scalar if the provided boolean value is true or false."), VisualShaderNodeSwitch::OP_TYPE_FLOAT, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("SwitchInt", "Conditional", "Functions", "VisualShaderNodeSwitch", TTR("Returns an associated integer scalar if the provided boolean value is true or false."), VisualShaderNodeSwitch::OP_TYPE_INT, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("SwitchTransform", "Conditional", "Functions", "VisualShaderNodeSwitch", TTR("Returns an associated transform if the provided boolean value is true or false."), VisualShaderNodeSwitch::OP_TYPE_TRANSFORM, VisualShaderNode::PORT_TYPE_TRANSFORM));
add_options.push_back(AddOption("Compare", "Conditional", "Common", "VisualShaderNodeCompare", TTR("Returns the boolean result of the comparison between two parameters."), -1, VisualShaderNode::PORT_TYPE_BOOLEAN));
add_options.push_back(AddOption("Is", "Conditional", "Common", "VisualShaderNodeIs", TTR("Returns the boolean result of the comparison between INF (or NaN) and a scalar parameter."), -1, VisualShaderNode::PORT_TYPE_BOOLEAN));
@@ -3345,8 +3801,8 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("ATan2", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the arc-tangent of the parameters."), VisualShaderNodeFloatOp::OP_ATAN2, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("ATanH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the inverse hyperbolic tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_ATANH, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Ceil", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the nearest integer that is greater than or equal to the parameter."), VisualShaderNodeFloatFunc::FUNC_CEIL, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeScalarClamp", TTR("Constrains a value to lie between two further values."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Constrains a value to lie between two further values."), VisualShaderNodeIntFunc::FUNC_CLAMP, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeClamp", TTR("Constrains a value to lie between two further values."), VisualShaderNodeClamp::OP_TYPE_FLOAT, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Clamp", "Scalar", "Functions", "VisualShaderNodeClamp", TTR("Constrains a value to lie between two further values."), VisualShaderNodeClamp::OP_TYPE_INT, VisualShaderNode::PORT_TYPE_SCALAR_INT));
add_options.push_back(AddOption("Cos", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the cosine of the parameter."), VisualShaderNodeFloatFunc::FUNC_COS, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("CosH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the hyperbolic cosine of the parameter."), VisualShaderNodeFloatFunc::FUNC_COSH, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Degrees", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Converts a quantity in radians to degrees."), VisualShaderNodeFloatFunc::FUNC_DEGREES, VisualShaderNode::PORT_TYPE_SCALAR));
@@ -3359,7 +3815,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Log2", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Base-2 logarithm."), VisualShaderNodeFloatFunc::FUNC_LOG2, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Max", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the greater of two values."), VisualShaderNodeFloatOp::OP_MAX, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Min", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the lesser of two values."), VisualShaderNodeFloatOp::OP_MIN, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Mix", "Scalar", "Functions", "VisualShaderNodeScalarInterp", TTR("Linear interpolation between two scalars."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Mix", "Scalar", "Functions", "VisualShaderNodeMix", TTR("Linear interpolation between two scalars."), VisualShaderNodeMix::OP_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("MultiplyAdd", "Scalar", "Functions", "VisualShaderNodeMultiplyAdd", TTR("Performs a fused multiply-add operation (a * b + c) on scalars."), VisualShaderNodeMultiplyAdd::OP_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeFloatFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeIntFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR_INT));
@@ -3375,8 +3831,8 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Sin", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the sine of the parameter."), VisualShaderNodeFloatFunc::FUNC_SIN, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("SinH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the hyperbolic sine of the parameter."), VisualShaderNodeFloatFunc::FUNC_SINH, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Sqrt", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the square root of the parameter."), VisualShaderNodeFloatFunc::FUNC_SQRT, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("SmoothStep", "Scalar", "Functions", "VisualShaderNodeScalarSmoothStep", TTR("SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if x is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
- add_options.push_back(AddOption("Step", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Step function( scalar(edge), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeFloatOp::OP_STEP, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("SmoothStep", "Scalar", "Functions", "VisualShaderNodeSmoothStep", TTR("SmoothStep function( scalar(edge0), scalar(edge1), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if x is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), VisualShaderNodeSmoothStep::OP_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR));
+ add_options.push_back(AddOption("Step", "Scalar", "Functions", "VisualShaderNodeStep", TTR("Step function( scalar(edge), scalar(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeStep::OP_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Tan", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_TAN, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("TanH", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the hyperbolic tangent of the parameter."), VisualShaderNodeFloatFunc::FUNC_TANH, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Trunc", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Finds the truncated value of the parameter."), VisualShaderNodeFloatFunc::FUNC_TRUNC, VisualShaderNode::PORT_TYPE_SCALAR));
@@ -3397,7 +3853,17 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("FloatUniform", "Scalar", "Variables", "VisualShaderNodeFloatUniform", TTR("Scalar floating-point uniform."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("IntUniform", "Scalar", "Variables", "VisualShaderNodeIntUniform", TTR("Scalar integer uniform."), -1, VisualShaderNode::PORT_TYPE_SCALAR_INT));
+ // SDF
+ {
+ add_options.push_back(AddOption("ScreenUVToSDF", "SDF", "", "VisualShaderNodeScreenUVToSDF", TTR("Converts screen UV to a SDF."), -1, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SDFRaymarch", "SDF", "", "VisualShaderNodeSDFRaymarch", TTR("Casts a ray against the screen SDF and returns the distance travelled."), -1, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("SDFToScreenUV", "SDF", "", "VisualShaderNodeSDFToScreenUV", TTR("Converts a SDF to screen UV."), -1, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("TextureSDF", "SDF", "", "VisualShaderNodeTextureSDF", TTR("Performs a SDF texture lookup."), -1, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ add_options.push_back(AddOption("TextureSDFNormal", "SDF", "", "VisualShaderNodeTextureSDFNormal", TTR("Performs a SDF normal texture lookup."), -1, VisualShaderNode::PORT_TYPE_VECTOR, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM));
+ }
+
// TEXTURES
+
cubemap_node_option_idx = add_options.size();
add_options.push_back(AddOption("CubeMap", "Textures", "Functions", "VisualShaderNodeCubemap", TTR("Perform the cubic texture lookup."), -1, -1));
curve_node_option_idx = add_options.size();
@@ -3450,7 +3916,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("ATan2", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Returns the arc-tangent of the parameters."), VisualShaderNodeVectorOp::OP_ATAN2, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("ATanH", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the inverse hyperbolic tangent of the parameter."), VisualShaderNodeVectorFunc::FUNC_ATANH, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Ceil", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Finds the nearest integer that is greater than or equal to the parameter."), VisualShaderNodeVectorFunc::FUNC_CEIL, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("Clamp", "Vector", "Functions", "VisualShaderNodeVectorClamp", TTR("Constrains a value to lie between two further values."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("Clamp", "Vector", "Functions", "VisualShaderNodeClamp", TTR("Constrains a value to lie between two further values."), VisualShaderNodeClamp::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Cos", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the cosine of the parameter."), VisualShaderNodeVectorFunc::FUNC_COS, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("CosH", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the hyperbolic cosine of the parameter."), VisualShaderNodeVectorFunc::FUNC_COSH, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Cross", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Calculates the cross product of two vectors."), VisualShaderNodeVectorOp::OP_CROSS, VisualShaderNode::PORT_TYPE_VECTOR));
@@ -3468,8 +3934,8 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Log2", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Base-2 logarithm."), VisualShaderNodeVectorFunc::FUNC_LOG2, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Max", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Returns the greater of two values."), VisualShaderNodeVectorOp::OP_MAX, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Min", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Returns the lesser of two values."), VisualShaderNodeVectorOp::OP_MIN, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("Mix", "Vector", "Functions", "VisualShaderNodeVectorInterp", TTR("Linear interpolation between two vectors."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("MixS", "Vector", "Functions", "VisualShaderNodeVectorScalarMix", TTR("Linear interpolation between two vectors using scalar."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("Mix", "Vector", "Functions", "VisualShaderNodeMix", TTR("Linear interpolation between two vectors."), VisualShaderNodeMix::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("MixS", "Vector", "Functions", "VisualShaderNodeMix", TTR("Linear interpolation between two vectors using scalar."), VisualShaderNodeMix::OP_TYPE_VECTOR_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("MultiplyAdd", "Vector", "Functions", "VisualShaderNodeMultiplyAdd", TTR("Performs a fused multiply-add operation (a * b + c) on vectors."), VisualShaderNodeMultiplyAdd::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Negate", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeVectorFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Normalize", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Calculates the normalize product of vector."), VisualShaderNodeVectorFunc::FUNC_NORMALIZE, VisualShaderNode::PORT_TYPE_VECTOR));
@@ -3486,10 +3952,10 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Sin", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the sine of the parameter."), VisualShaderNodeVectorFunc::FUNC_SIN, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("SinH", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the hyperbolic sine of the parameter."), VisualShaderNodeVectorFunc::FUNC_SINH, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Sqrt", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the square root of the parameter."), VisualShaderNodeVectorFunc::FUNC_SQRT, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("SmoothStep", "Vector", "Functions", "VisualShaderNodeVectorSmoothStep", TTR("SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if 'x' is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("SmoothStepS", "Vector", "Functions", "VisualShaderNodeVectorScalarSmoothStep", TTR("SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if 'x' is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("Step", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Step function( vector(edge), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeVectorOp::OP_STEP, VisualShaderNode::PORT_TYPE_VECTOR));
- add_options.push_back(AddOption("StepS", "Vector", "Functions", "VisualShaderNodeVectorScalarStep", TTR("Step function( scalar(edge), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("SmoothStep", "Vector", "Functions", "VisualShaderNodeSmoothStep", TTR("SmoothStep function( vector(edge0), vector(edge1), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if 'x' is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), VisualShaderNodeSmoothStep::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("SmoothStepS", "Vector", "Functions", "VisualShaderNodeSmoothStep", TTR("SmoothStep function( scalar(edge0), scalar(edge1), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge0' and 1.0 if 'x' is larger than 'edge1'. Otherwise the return value is interpolated between 0.0 and 1.0 using Hermite polynomials."), VisualShaderNodeSmoothStep::OP_TYPE_VECTOR_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("Step", "Vector", "Functions", "VisualShaderNodeStep", TTR("Step function( vector(edge), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeStep::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
+ add_options.push_back(AddOption("StepS", "Vector", "Functions", "VisualShaderNodeStep", TTR("Step function( scalar(edge), vector(x) ).\n\nReturns 0.0 if 'x' is smaller than 'edge' and otherwise 1.0."), VisualShaderNodeStep::OP_TYPE_VECTOR_SCALAR, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Tan", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the tangent of the parameter."), VisualShaderNodeVectorFunc::FUNC_TAN, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("TanH", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the hyperbolic tangent of the parameter."), VisualShaderNodeVectorFunc::FUNC_TANH, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Trunc", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Finds the truncated value of the parameter."), VisualShaderNodeVectorFunc::FUNC_TRUNC, VisualShaderNode::PORT_TYPE_VECTOR));
@@ -4007,10 +4473,17 @@ void VisualShaderNodePortPreview::_shader_changed() {
for (int i = EditorNode::get_singleton()->get_editor_history()->get_path_size() - 1; i >= 0; i--) {
Object *object = ObjectDB::get_instance(EditorNode::get_singleton()->get_editor_history()->get_path_object(i));
+ ShaderMaterial *src_mat;
if (!object) {
continue;
}
- ShaderMaterial *src_mat = Object::cast_to<ShaderMaterial>(object);
+ if (object->has_method("get_material_override")) { // trying getting material from MeshInstance
+ src_mat = Object::cast_to<ShaderMaterial>(object->call("get_material_override"));
+ } else if (object->has_method("get_material")) { // from CanvasItem/Node2D
+ src_mat = Object::cast_to<ShaderMaterial>(object->call("get_material"));
+ } else {
+ src_mat = Object::cast_to<ShaderMaterial>(object);
+ }
if (src_mat && src_mat->get_shader().is_valid()) {
List<PropertyInfo> params;
src_mat->get_shader()->get_param_list(&params);
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index a5983410f9..182bed6ba6 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -134,7 +134,6 @@ class VisualShaderEditor : public VBoxContainer {
int editing_port;
Ref<VisualShader> visual_shader;
- HSplitContainer *main_box;
GraphEdit *graph;
Button *add_node;
Button *preview_shader;
@@ -148,6 +147,7 @@ class VisualShaderEditor : public VBoxContainer {
bool pending_update_preview;
bool shader_error;
+ Window *preview_window;
VBoxContainer *preview_vbox;
CodeEdit *preview_text;
Ref<CodeHighlighter> syntax_highlighter;
@@ -161,7 +161,8 @@ class VisualShaderEditor : public VBoxContainer {
PopupMenu *popup_menu;
MenuButton *tools;
- bool preview_showed;
+ bool preview_first = true;
+ bool preview_showed = false;
bool particles_mode;
enum TypeFlags {
@@ -188,6 +189,9 @@ class VisualShaderEditor : public VBoxContainer {
PASTE,
DELETE,
DUPLICATE,
+ SEPARATOR2, // ignore
+ CONVERT_CONSTANTS_TO_UNIFORMS,
+ CONVERT_UNIFORMS_TO_CONSTANTS,
};
Tree *members;
@@ -272,11 +276,14 @@ class VisualShaderEditor : public VBoxContainer {
void _add_texture3d_node(const String &p_path);
void _add_curve_node(const String &p_path);
+ void _setup_node(VisualShaderNode *p_node, int p_op_idx);
VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1);
void _update_options_menu();
void _set_mode(int p_which);
void _show_preview_text();
+ void _preview_close_requested();
+ void _preview_size_changed();
void _update_preview();
String _get_description(int p_idx);
@@ -316,6 +323,14 @@ class VisualShaderEditor : public VBoxContainer {
int from_node;
int from_slot;
+ Set<int> selected_constants;
+ Set<int> selected_uniforms;
+
+ void _convert_constants_to_uniforms(bool p_vice_versa);
+ void _replace_node(VisualShader::Type p_type_id, int p_node_id, const StringName &p_from, const StringName &p_to);
+ void _update_constant(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port);
+ void _update_uniform(VisualShader::Type p_type_id, int p_node_id, Variant p_var, int p_preview_port);
+
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
@@ -388,6 +403,8 @@ class VisualShaderEditor : public VBoxContainer {
void _update_uniforms(bool p_update_refs);
void _update_uniform_refs(Set<String> &p_names);
+ void _visibility_changed();
+
protected:
void _notification(int p_what);
static void _bind_methods();