summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp102
-rw-r--r--editor/plugins/canvas_item_editor_plugin.h13
-rw-r--r--editor/plugins/gdextension_export_plugin.h138
-rw-r--r--editor/plugins/gradient_texture_2d_editor_plugin.cpp284
-rw-r--r--editor/plugins/gradient_texture_2d_editor_plugin.h112
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp36
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp3
-rw-r--r--editor/plugins/shader_editor_plugin.cpp14
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp47
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h1
-rw-r--r--editor/plugins/theme_editor_plugin.cpp4
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp1
-rw-r--r--editor/plugins/tiles/tile_set_editor.cpp1
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp4
15 files changed, 691 insertions, 71 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index fd9b665b20..1468d63daf 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -577,6 +577,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
void EditorAssetLibrary::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
+ add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("AssetLib")));
error_label->raise();
} break;
@@ -1377,7 +1378,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
initial_loading = true;
VBoxContainer *library_main = memnew(VBoxContainer);
-
add_child(library_main);
HBoxContainer *search_hb = memnew(HBoxContainer);
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index 4ee4eb86af..d713e70251 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -60,12 +60,12 @@
// Min and Max are power of two in order to play nicely with successive increment.
// That way, we can naturally reach a 100% zoom from boundaries.
-#define MIN_ZOOM 1. / 128
-#define MAX_ZOOM 128
+constexpr real_t MIN_ZOOM = 1. / 128;
+constexpr real_t MAX_ZOOM = 128;
#define RULER_WIDTH (15 * EDSCALE)
-#define SCALE_HANDLE_DISTANCE 25
-#define MOVE_HANDLE_DISTANCE 25
+constexpr real_t SCALE_HANDLE_DISTANCE = 25;
+constexpr real_t MOVE_HANDLE_DISTANCE = 25;
class SnapDialog : public ConfirmationDialog {
GDCLASS(SnapDialog, ConfirmationDialog);
@@ -489,12 +489,12 @@ void CanvasItemEditor::unhandled_key_input(const Ref<InputEvent> &p_ev) {
viewport->update();
}
- if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo()) {
- if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) {
+ if (k->is_pressed() && !k->is_ctrl_pressed() && !k->is_echo() && (grid_snap_active || _is_grid_visible())) {
+ if (multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->matches_event(p_ev)) {
// Multiply the grid size
grid_step_multiplier = MIN(grid_step_multiplier + 1, 12);
viewport->update();
- } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) {
+ } else if (divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->matches_event(p_ev)) {
// Divide the grid size
Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1);
if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) {
@@ -938,6 +938,60 @@ void CanvasItemEditor::_reset_create_position() {
node_create_position = Point2();
}
+bool CanvasItemEditor::_is_grid_visible() const {
+ switch (grid_visibility) {
+ case GRID_VISIBILITY_SHOW:
+ return true;
+ case GRID_VISIBILITY_SHOW_WHEN_SNAPPING:
+ return grid_snap_active;
+ case GRID_VISIBILITY_HIDE:
+ return false;
+ }
+ ERR_FAIL_V_MSG(true, "Unexpected grid_visibility value");
+}
+
+void CanvasItemEditor::_prepare_grid_menu() {
+ for (int i = GRID_VISIBILITY_SHOW; i <= GRID_VISIBILITY_HIDE; i++) {
+ grid_menu->set_item_checked(i, i == grid_visibility);
+ }
+}
+
+void CanvasItemEditor::_on_grid_menu_id_pressed(int p_id) {
+ switch (p_id) {
+ case GRID_VISIBILITY_SHOW:
+ case GRID_VISIBILITY_SHOW_WHEN_SNAPPING:
+ case GRID_VISIBILITY_HIDE:
+ grid_visibility = (GridVisibility)p_id;
+ viewport->update();
+ view_menu->get_popup()->hide();
+ return;
+ }
+
+ // Toggle grid: go to the least restrictive option possible.
+ if (grid_snap_active) {
+ switch (grid_visibility) {
+ case GRID_VISIBILITY_SHOW:
+ case GRID_VISIBILITY_SHOW_WHEN_SNAPPING:
+ grid_visibility = GRID_VISIBILITY_HIDE;
+ break;
+ case GRID_VISIBILITY_HIDE:
+ grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING;
+ break;
+ }
+ } else {
+ switch (grid_visibility) {
+ case GRID_VISIBILITY_SHOW:
+ grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING;
+ break;
+ case GRID_VISIBILITY_SHOW_WHEN_SNAPPING:
+ case GRID_VISIBILITY_HIDE:
+ grid_visibility = GRID_VISIBILITY_SHOW;
+ break;
+ }
+ }
+ viewport->update();
+}
+
bool CanvasItemEditor::_gui_input_rulers_and_guides(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> b = p_event;
Ref<InputEventMouseMotion> m = p_event;
@@ -2162,7 +2216,7 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
if (drag_type == DRAG_NONE) {
- if (b.is_valid() &&
+ if (b.is_valid() && b->is_pressed() &&
((b->get_button_index() == MouseButton::RIGHT && b->is_alt_pressed() && tool == TOOL_SELECT) ||
(b->get_button_index() == MouseButton::LEFT && tool == TOOL_LIST_SELECT))) {
// Popup the selection menu list
@@ -2728,7 +2782,7 @@ void CanvasItemEditor::_draw_rulers() {
// The rule transform
Transform2D ruler_transform = Transform2D();
- if (show_grid || grid_snap_active) {
+ if (grid_snap_active || _is_grid_visible()) {
List<CanvasItem *> selection = _get_edited_canvas_items();
if (snap_relative && selection.size() > 0) {
ruler_transform.translate(_get_encompassing_rect_from_list(selection).position);
@@ -2808,7 +2862,7 @@ void CanvasItemEditor::_draw_rulers() {
}
void CanvasItemEditor::_draw_grid() {
- if (show_grid || grid_snap_active) {
+ if (_is_grid_visible()) {
// Draw the grid
Vector2 real_grid_offset;
const List<CanvasItem *> selection = _get_edited_canvas_items();
@@ -4139,12 +4193,6 @@ void CanvasItemEditor::_update_override_camera_button(bool p_game_running) {
void CanvasItemEditor::_popup_callback(int p_op) {
last_option = MenuOption(p_op);
switch (p_op) {
- case SHOW_GRID: {
- show_grid = !show_grid;
- int idx = view_menu->get_popup()->get_item_index(SHOW_GRID);
- view_menu->get_popup()->set_item_checked(idx, show_grid);
- viewport->update();
- } break;
case SHOW_ORIGIN: {
show_origin = !show_origin;
int idx = view_menu->get_popup()->get_item_index(SHOW_ORIGIN);
@@ -4617,7 +4665,7 @@ Dictionary CanvasItemEditor::get_state() const {
state["snap_node_center"] = snap_node_center;
state["snap_other_nodes"] = snap_other_nodes;
state["snap_guides"] = snap_guides;
- state["show_grid"] = show_grid;
+ state["grid_visibility"] = grid_visibility;
state["show_origin"] = show_origin;
state["show_viewport"] = show_viewport;
state["show_rulers"] = show_rulers;
@@ -4719,10 +4767,8 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
smartsnap_config_popup->set_item_checked(idx, snap_guides);
}
- if (state.has("show_grid")) {
- show_grid = state["show_grid"];
- int idx = view_menu->get_popup()->get_item_index(SHOW_GRID);
- view_menu->get_popup()->set_item_checked(idx, show_grid);
+ if (state.has("grid_visibility")) {
+ grid_visibility = (GridVisibility)(int)(state["grid_visibility"]);
}
if (state.has("show_origin")) {
@@ -5132,7 +5178,19 @@ CanvasItemEditor::CanvasItemEditor() {
p = view_menu->get_popup();
p->set_hide_on_checkable_item_selection(false);
- p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_grid", TTR("Always Show Grid"), Key::NUMBERSIGN), SHOW_GRID);
+
+ grid_menu = memnew(PopupMenu);
+ grid_menu->connect("about_to_popup", callable_mp(this, &CanvasItemEditor::_prepare_grid_menu));
+ grid_menu->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_on_grid_menu_id_pressed));
+ grid_menu->set_name("GridMenu");
+ grid_menu->add_radio_check_item(TTR("Show"), GRID_VISIBILITY_SHOW);
+ grid_menu->add_radio_check_item(TTR("Show When Snapping"), GRID_VISIBILITY_SHOW_WHEN_SNAPPING);
+ grid_menu->add_radio_check_item(TTR("Hide"), GRID_VISIBILITY_HIDE);
+ grid_menu->add_separator();
+ grid_menu->add_shortcut(ED_SHORTCUT("canvas_item_editor/toggle_grid", TTR("Toggle Grid"), KeyModifierMask::CMD | Key::APOSTROPHE));
+ p->add_child(grid_menu);
+ p->add_submenu_item(TTR("Grid"), "GridMenu");
+
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_helpers", TTR("Show Helpers"), Key::H), SHOW_HELPERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_rulers", TTR("Show Rulers")), SHOW_RULERS);
p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/show_guides", TTR("Show Guides"), Key::Y), SHOW_GUIDES);
diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h
index e7c265ee02..1a9d49a4a8 100644
--- a/editor/plugins/canvas_item_editor_plugin.h
+++ b/editor/plugins/canvas_item_editor_plugin.h
@@ -116,7 +116,6 @@ private:
SNAP_RELATIVE,
SNAP_CONFIGURE,
SNAP_USE_PIXEL,
- SHOW_GRID,
SHOW_HELPERS,
SHOW_RULERS,
SHOW_GUIDES,
@@ -175,6 +174,12 @@ private:
DRAG_KEY_MOVE
};
+ enum GridVisibility {
+ GRID_VISIBILITY_SHOW,
+ GRID_VISIBILITY_SHOW_WHEN_SNAPPING,
+ GRID_VISIBILITY_HIDE,
+ };
+
bool selection_menu_additive_selection;
Tool tool = TOOL_SELECT;
@@ -190,7 +195,7 @@ private:
HBoxContainer *hbc_context_menu;
Transform2D transform;
- bool show_grid = false;
+ GridVisibility grid_visibility = GRID_VISIBILITY_SHOW_WHEN_SNAPPING;
bool show_rulers = true;
bool show_guides = true;
bool show_origin = true;
@@ -314,6 +319,7 @@ private:
MenuButton *skeleton_menu;
Button *override_camera_button;
MenuButton *view_menu;
+ PopupMenu *grid_menu;
HBoxContainer *animation_hb;
MenuButton *animation_menu;
@@ -390,6 +396,9 @@ private:
void _node_created(Node *p_node);
void _reset_create_position();
void _update_editor_settings();
+ bool _is_grid_visible() const;
+ void _prepare_grid_menu();
+ void _on_grid_menu_id_pressed(int p_id);
UndoRedo *undo_redo;
diff --git a/editor/plugins/gdextension_export_plugin.h b/editor/plugins/gdextension_export_plugin.h
new file mode 100644
index 0000000000..8ed72b1c42
--- /dev/null
+++ b/editor/plugins/gdextension_export_plugin.h
@@ -0,0 +1,138 @@
+/*************************************************************************/
+/* gdextension_export_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef GDEXTENSION_EXPORT_PLUGIN_H
+#define GDEXTENSION_EXPORT_PLUGIN_H
+
+#include "editor/editor_export.h"
+
+class GDExtensionExportPlugin : public EditorExportPlugin {
+protected:
+ virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
+};
+
+void GDExtensionExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
+ if (p_type != "NativeExtension") {
+ return;
+ }
+
+ Ref<ConfigFile> config;
+ config.instantiate();
+
+ Error err = config->load(p_path);
+
+ if (err != OK) {
+ return;
+ }
+
+ if (!config->has_section_key("configuration", "entry_symbol")) {
+ return;
+ }
+
+ String entry_symbol = config->get_value("configuration", "entry_symbol");
+
+ List<String> libraries;
+
+ config->get_section_keys("libraries", &libraries);
+
+ for (const String &E : libraries) {
+ Vector<String> tags = E.split(".");
+ bool all_tags_met = true;
+ for (int i = 0; i < tags.size(); i++) {
+ String tag = tags[i].strip_edges();
+ if (!p_features.has(tag)) {
+ all_tags_met = false;
+ break;
+ }
+ }
+
+ if (all_tags_met) {
+ String library_path = config->get_value("libraries", E);
+ if (!library_path.begins_with("res://")) {
+ print_line("Skipping export of out-of-project library " + library_path);
+ continue;
+ }
+ add_shared_object(library_path, tags);
+
+ if (p_features.has("iOS") && (library_path.ends_with(".a") || library_path.ends_with(".xcframework"))) {
+ String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n"
+ "extern void add_ios_init_callback(void (*cb)());\n"
+ "\n"
+ "extern \"C\" void $ENTRY();\n"
+ "void $ENTRY_init() {\n"
+ " if (&$ENTRY) register_dynamic_symbol((char *)\"$ENTRY\", (void *)$ENTRY);\n"
+ "}\n"
+ "struct $ENTRY_struct {\n"
+ " $ENTRY_struct() {\n"
+ " add_ios_init_callback($ENTRY_init);\n"
+ " }\n"
+ "};\n"
+ "$ENTRY_struct $ENTRY_struct_instance;\n\n";
+ additional_code = additional_code.replace("$ENTRY", entry_symbol);
+ add_ios_cpp_code(additional_code);
+
+ String linker_flags = "-Wl,-U,_" + entry_symbol;
+ add_ios_linker_flags(linker_flags);
+ }
+ break;
+ }
+ }
+
+ List<String> dependencies;
+
+ config->get_section_keys("dependencies", &dependencies);
+ for (const String &E : libraries) {
+ Vector<String> tags = E.split(".");
+ bool all_tags_met = true;
+ for (int i = 0; i < tags.size(); i++) {
+ String tag = tags[i].strip_edges();
+ if (!p_features.has(tag)) {
+ all_tags_met = false;
+ break;
+ }
+ }
+
+ if (all_tags_met) {
+ Dictionary dependency = config->get_value("dependencies", E);
+ for (const Variant *key = dependency.next(nullptr); key; key = dependency.next(key)) {
+ String library_path = *key;
+ String target_path = dependency[*key];
+ if (!library_path.begins_with("res://")) {
+ print_line("Skipping export of out-of-project library " + library_path);
+ continue;
+ }
+ add_shared_object(library_path, tags, target_path);
+ }
+ break;
+ }
+ }
+}
+
+#endif // GDEXTENSION_EXPORT_PLUGIN_H
diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp
new file mode 100644
index 0000000000..e97c611e96
--- /dev/null
+++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp
@@ -0,0 +1,284 @@
+/*************************************************************************/
+/* gradient_texture_2d_editor_plugin.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "gradient_texture_2d_editor_plugin.h"
+
+#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
+#include "scene/gui/box_container.h"
+#include "scene/gui/flow_container.h"
+#include "scene/gui/separator.h"
+
+Point2 GradientTexture2DEditorRect::_get_handle_position(const Handle p_handle) {
+ // Get the handle's mouse position in pixels relative to offset.
+ return (p_handle == HANDLE_FILL_FROM ? texture->get_fill_from() : texture->get_fill_to()).clamp(Vector2(), Vector2(1, 1)) * size;
+}
+
+void GradientTexture2DEditorRect::_update_fill_position() {
+ if (handle == HANDLE_NONE) {
+ return;
+ }
+
+ // Update the texture's fill_from/fill_to property based on mouse input.
+ Vector2 percent = ((get_local_mouse_position() - offset) / size).clamp(Vector2(), Vector2(1, 1));
+ if (snap_enabled) {
+ percent = (percent - Vector2(0.5, 0.5)).snapped(Vector2(snap_size, snap_size)) + Vector2(0.5, 0.5);
+ }
+
+ String property_name = handle == HANDLE_FILL_FROM ? "fill_from" : "fill_to";
+
+ undo_redo->create_action(vformat(TTR("Set %s"), property_name), UndoRedo::MERGE_ENDS);
+ undo_redo->add_do_property(texture.ptr(), property_name, percent);
+ undo_redo->add_undo_property(texture.ptr(), property_name, handle == HANDLE_FILL_FROM ? texture->get_fill_from() : texture->get_fill_to());
+ undo_redo->commit_action();
+}
+
+void GradientTexture2DEditorRect::gui_input(const Ref<InputEvent> &p_event) {
+ // Grab/release handle.
+ const Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT) {
+ if (mb->is_pressed()) {
+ Point2 mouse_position = mb->get_position() - offset;
+ if (Rect2(_get_handle_position(HANDLE_FILL_FROM).round() - handle_size / 2, handle_size).has_point(mouse_position)) {
+ handle = HANDLE_FILL_FROM;
+ } else if (Rect2(_get_handle_position(HANDLE_FILL_TO).round() - handle_size / 2, handle_size).has_point(mouse_position)) {
+ handle = HANDLE_FILL_TO;
+ } else {
+ handle = HANDLE_NONE;
+ }
+ } else {
+ _update_fill_position();
+ handle = HANDLE_NONE;
+ }
+ }
+
+ // Move handle.
+ const Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid()) {
+ _update_fill_position();
+ }
+}
+
+void GradientTexture2DEditorRect::set_texture(Ref<GradientTexture2D> &p_texture) {
+ texture = p_texture;
+ texture->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update));
+}
+
+void GradientTexture2DEditorRect::set_snap_enabled(bool p_snap_enabled) {
+ snap_enabled = p_snap_enabled;
+ update();
+}
+
+void GradientTexture2DEditorRect::set_snap_size(float p_snap_size) {
+ snap_size = p_snap_size;
+ update();
+}
+
+void GradientTexture2DEditorRect::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ checkerboard->set_texture(get_theme_icon(SNAME("GuiMiniCheckerboard"), SNAME("EditorIcons")));
+ } break;
+
+ case NOTIFICATION_DRAW: {
+ if (texture.is_null()) {
+ return;
+ }
+
+ const Ref<Texture2D> fill_from_icon = get_theme_icon(SNAME("EditorPathSmoothHandle"), SNAME("EditorIcons"));
+ const Ref<Texture2D> fill_to_icon = get_theme_icon(SNAME("EditorPathSharpHandle"), SNAME("EditorIcons"));
+ handle_size = fill_from_icon->get_size();
+
+ const int MAX_HEIGHT = 250 * EDSCALE;
+ Size2 rect_size = get_size();
+
+ // Get the size and position to draw the texture and handles at.
+ size = Size2(texture->get_width() * MAX_HEIGHT / texture->get_height(), MAX_HEIGHT);
+ if (size.width > rect_size.width) {
+ size.width = rect_size.width;
+ size.height = texture->get_height() * rect_size.width / texture->get_width();
+ }
+ offset = Point2(Math::round((rect_size.width - size.width) / 2), 0) + handle_size / 2;
+ set_custom_minimum_size(Size2(0, size.height));
+ size -= handle_size;
+ checkerboard->set_rect(Rect2(offset, size));
+
+ draw_set_transform(offset);
+ draw_texture_rect(texture, Rect2(Point2(), size));
+
+ // Draw grid snap lines.
+ if (snap_enabled) {
+ const Color primary_line_color = Color(0.5, 0.5, 0.5, 0.9);
+ const Color line_color = Color(0.5, 0.5, 0.5, 0.5);
+
+ // Draw border and centered axis lines.
+ draw_rect(Rect2(Point2(), size), primary_line_color, false);
+ draw_line(Point2(size.width / 2, 0), Point2(size.width / 2, size.height), primary_line_color);
+ draw_line(Point2(0, size.height / 2), Point2(size.width, size.height / 2), primary_line_color);
+
+ // Draw vertical lines.
+ int prev_idx = 0;
+ for (int x = 0; x < size.width; x++) {
+ int idx = int((x / size.width - 0.5) / snap_size);
+
+ if (x > 0 && prev_idx != idx) {
+ draw_line(Point2(x, 0), Point2(x, size.height), line_color);
+ }
+
+ prev_idx = idx;
+ }
+
+ // Draw horizontal lines.
+ prev_idx = 0;
+ for (int y = 0; y < size.height; y++) {
+ int idx = int((y / size.height - 0.5) / snap_size);
+
+ if (y > 0 && prev_idx != idx) {
+ draw_line(Point2(0, y), Point2(size.width, y), line_color);
+ }
+
+ prev_idx = idx;
+ }
+ }
+
+ // Draw handles.
+ draw_texture(fill_from_icon, (_get_handle_position(HANDLE_FILL_FROM) - handle_size / 2).round());
+ draw_texture(fill_to_icon, (_get_handle_position(HANDLE_FILL_TO) - handle_size / 2).round());
+ } break;
+ }
+}
+
+GradientTexture2DEditorRect::GradientTexture2DEditorRect() {
+ undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ checkerboard = memnew(TextureRect);
+ checkerboard->set_stretch_mode(TextureRect::STRETCH_TILE);
+ checkerboard->set_draw_behind_parent(true);
+ add_child(checkerboard);
+}
+
+///////////////////////
+
+void GradientTexture2DEditor::_reverse_button_pressed() {
+ undo_redo->create_action(TTR("Swap GradientTexture2D Fill Points"));
+ undo_redo->add_do_property(texture.ptr(), "fill_from", texture->get_fill_to());
+ undo_redo->add_do_property(texture.ptr(), "fill_to", texture->get_fill_from());
+ undo_redo->add_undo_property(texture.ptr(), "fill_from", texture->get_fill_from());
+ undo_redo->add_undo_property(texture.ptr(), "fill_to", texture->get_fill_to());
+ undo_redo->commit_action();
+}
+
+void GradientTexture2DEditor::_set_snap_enabled(bool p_enabled) {
+ texture_editor_rect->set_snap_enabled(p_enabled);
+
+ snap_size_edit->set_visible(p_enabled);
+}
+
+void GradientTexture2DEditor::_set_snap_size(float p_snap_size) {
+ texture_editor_rect->set_snap_size(MAX(p_snap_size, 0.01));
+}
+
+void GradientTexture2DEditor::set_texture(Ref<GradientTexture2D> &p_texture) {
+ texture = p_texture;
+ texture_editor_rect->set_texture(p_texture);
+}
+
+void GradientTexture2DEditor::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ reverse_button->set_icon(get_theme_icon(SNAME("ReverseGradient"), SNAME("EditorIcons")));
+ snap_button->set_icon(get_theme_icon(SNAME("SnapGrid"), SNAME("EditorIcons")));
+ } break;
+ }
+}
+
+GradientTexture2DEditor::GradientTexture2DEditor() {
+ undo_redo = EditorNode::get_singleton()->get_undo_redo();
+
+ HFlowContainer *toolbar = memnew(HFlowContainer);
+ add_child(toolbar);
+
+ reverse_button = memnew(Button);
+ reverse_button->set_tooltip(TTR("Swap Gradient Fill Points"));
+ toolbar->add_child(reverse_button);
+ reverse_button->connect("pressed", callable_mp(this, &GradientTexture2DEditor::_reverse_button_pressed));
+
+ toolbar->add_child(memnew(VSeparator));
+
+ snap_button = memnew(Button);
+ snap_button->set_tooltip(TTR("Toggle Grid Snap"));
+ snap_button->set_toggle_mode(true);
+ toolbar->add_child(snap_button);
+ snap_button->connect("toggled", callable_mp(this, &GradientTexture2DEditor::_set_snap_enabled));
+
+ snap_size_edit = memnew(EditorSpinSlider);
+ snap_size_edit->set_min(0.01);
+ snap_size_edit->set_max(0.5);
+ snap_size_edit->set_step(0.01);
+ snap_size_edit->set_value(0.1);
+ snap_size_edit->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
+ toolbar->add_child(snap_size_edit);
+ snap_size_edit->connect("value_changed", callable_mp(this, &GradientTexture2DEditor::_set_snap_size));
+
+ texture_editor_rect = memnew(GradientTexture2DEditorRect);
+ add_child(texture_editor_rect);
+
+ set_mouse_filter(MOUSE_FILTER_STOP);
+ _set_snap_enabled(snap_button->is_pressed());
+ _set_snap_size(snap_size_edit->get_value());
+}
+
+///////////////////////
+
+bool EditorInspectorPluginGradientTexture2D::can_handle(Object *p_object) {
+ return Object::cast_to<GradientTexture2D>(p_object) != nullptr;
+}
+
+void EditorInspectorPluginGradientTexture2D::parse_begin(Object *p_object) {
+ GradientTexture2D *texture = Object::cast_to<GradientTexture2D>(p_object);
+ if (!texture) {
+ return;
+ }
+ Ref<GradientTexture2D> t(texture);
+
+ GradientTexture2DEditor *editor = memnew(GradientTexture2DEditor);
+ editor->set_texture(t);
+ add_custom_control(editor);
+}
+
+///////////////////////
+
+GradientTexture2DEditorPlugin::GradientTexture2DEditorPlugin() {
+ Ref<EditorInspectorPluginGradientTexture2D> plugin;
+ plugin.instantiate();
+ add_inspector_plugin(plugin);
+}
diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.h b/editor/plugins/gradient_texture_2d_editor_plugin.h
new file mode 100644
index 0000000000..4ce64ce1dc
--- /dev/null
+++ b/editor/plugins/gradient_texture_2d_editor_plugin.h
@@ -0,0 +1,112 @@
+/*************************************************************************/
+/* gradient_texture_2d_editor_plugin.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef GRADIENT_TEXTURE_2D_EDITOR
+#define GRADIENT_TEXTURE_2D_EDITOR
+
+#include "editor/editor_plugin.h"
+#include "editor/editor_spin_slider.h"
+
+class GradientTexture2DEditorRect : public Control {
+ GDCLASS(GradientTexture2DEditorRect, Control);
+
+ enum Handle {
+ HANDLE_NONE,
+ HANDLE_FILL_FROM,
+ HANDLE_FILL_TO
+ };
+
+ Ref<GradientTexture2D> texture;
+ UndoRedo *undo_redo = nullptr;
+ bool snap_enabled = false;
+ float snap_size = 0;
+
+ TextureRect *checkerboard = nullptr;
+
+ Handle handle = HANDLE_NONE;
+ Size2 handle_size;
+ Point2 offset;
+ Size2 size;
+
+ Point2 _get_handle_position(const Handle p_handle);
+ void _update_fill_position();
+ virtual void gui_input(const Ref<InputEvent> &p_event) override;
+
+protected:
+ void _notification(int p_what);
+
+public:
+ void set_texture(Ref<GradientTexture2D> &p_texture);
+ void set_snap_enabled(bool p_snap_enabled);
+ void set_snap_size(float p_snap_size);
+
+ GradientTexture2DEditorRect();
+};
+
+class GradientTexture2DEditor : public VBoxContainer {
+ GDCLASS(GradientTexture2DEditor, VBoxContainer);
+
+ Ref<GradientTexture2D> texture;
+ UndoRedo *undo_redo = nullptr;
+
+ Button *reverse_button = nullptr;
+ Button *snap_button = nullptr;
+ EditorSpinSlider *snap_size_edit = nullptr;
+ GradientTexture2DEditorRect *texture_editor_rect = nullptr;
+
+ void _reverse_button_pressed();
+ void _set_snap_enabled(bool p_enabled);
+ void _set_snap_size(float p_snap_size);
+
+protected:
+ void _notification(int p_what);
+
+public:
+ void set_texture(Ref<GradientTexture2D> &p_texture);
+
+ GradientTexture2DEditor();
+};
+
+class EditorInspectorPluginGradientTexture2D : public EditorInspectorPlugin {
+ GDCLASS(EditorInspectorPluginGradientTexture2D, EditorInspectorPlugin);
+
+public:
+ virtual bool can_handle(Object *p_object) override;
+ virtual void parse_begin(Object *p_object) override;
+};
+
+class GradientTexture2DEditorPlugin : public EditorPlugin {
+ GDCLASS(GradientTexture2DEditorPlugin, EditorPlugin);
+
+public:
+ GradientTexture2DEditorPlugin();
+};
+
+#endif
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index a857a7509e..39e2e0bc9b 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -56,31 +56,31 @@
#include "scene/resources/packed_scene.h"
#include "scene/resources/surface_tool.h"
-#define DISTANCE_DEFAULT 4
+constexpr real_t DISTANCE_DEFAULT = 4;
-#define GIZMO_ARROW_SIZE 0.35
-#define GIZMO_RING_HALF_WIDTH 0.1
-#define GIZMO_PLANE_SIZE 0.2
-#define GIZMO_PLANE_DST 0.3
-#define GIZMO_CIRCLE_SIZE 1.1
-#define GIZMO_SCALE_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)
-#define GIZMO_ARROW_OFFSET (GIZMO_CIRCLE_SIZE + 0.3)
+constexpr real_t GIZMO_ARROW_SIZE = 0.35;
+constexpr real_t GIZMO_RING_HALF_WIDTH = 0.1;
+constexpr real_t GIZMO_PLANE_SIZE = 0.2;
+constexpr real_t GIZMO_PLANE_DST = 0.3;
+constexpr real_t GIZMO_CIRCLE_SIZE = 1.1;
+constexpr real_t GIZMO_SCALE_OFFSET = GIZMO_CIRCLE_SIZE + 0.3;
+constexpr real_t GIZMO_ARROW_OFFSET = GIZMO_CIRCLE_SIZE + 0.3;
-#define ZOOM_FREELOOK_MIN 0.01
-#define ZOOM_FREELOOK_MULTIPLIER 1.08
-#define ZOOM_FREELOOK_INDICATOR_DELAY_S 1.5
+constexpr real_t ZOOM_FREELOOK_MIN = 0.01;
+constexpr real_t ZOOM_FREELOOK_MULTIPLIER = 1.08;
+constexpr real_t ZOOM_FREELOOK_INDICATOR_DELAY_S = 1.5;
#ifdef REAL_T_IS_DOUBLE
-#define ZOOM_FREELOOK_MAX 1'000'000'000'000
+constexpr double ZOOM_FREELOOK_MAX = 1'000'000'000'000;
#else
-#define ZOOM_FREELOOK_MAX 10'000
+constexpr float ZOOM_FREELOOK_MAX = 10'000;
#endif
-#define MIN_Z 0.01
-#define MAX_Z 1000000.0
+constexpr real_t MIN_Z = 0.01;
+constexpr real_t MAX_Z = 1000000.0;
-#define MIN_FOV 0.01
-#define MAX_FOV 179
+constexpr real_t MIN_FOV = 0.01;
+constexpr real_t MAX_FOV = 179;
void ViewportRotationControl::_notification(int p_what) {
switch (p_what) {
@@ -145,7 +145,7 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {
// Draw the axis letter for the positive axes.
const String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z");
- draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.0, 0.0, 0.0, alpha));
+ draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(Math::round(-4.0 * EDSCALE), Math::round(5.0 * EDSCALE)), axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.0, 0.0, 0.0, alpha));
} else {
// Draw an outline around the negative axes.
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c);
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index b7aef7f1bb..eafc53c72b 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -39,7 +39,8 @@
void ResourcePreloaderEditor::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
load->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
} break;
}
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 02f11bb82f..dbe6ca192c 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -435,8 +435,16 @@ void ShaderEditor::_menu_option(int p_option) {
}
void ShaderEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_WM_WINDOW_FOCUS_IN) {
- _check_for_external_edit();
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
+ PopupMenu *popup = help_menu->get_popup();
+ popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")));
+ } break;
+
+ case NOTIFICATION_WM_WINDOW_FOCUS_IN: {
+ _check_for_external_edit();
+ } break;
}
}
@@ -772,7 +780,7 @@ ShaderEditor::ShaderEditor() {
help_menu = memnew(MenuButton);
help_menu->set_text(TTR("Help"));
help_menu->set_switch_on_hover(true);
- help_menu->get_popup()->add_icon_item(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Instance"), SNAME("EditorIcons")), TTR("Online Docs"), HELP_DOCS);
+ help_menu->get_popup()->add_item(TTR("Online Docs"), HELP_DOCS);
help_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option));
add_child(main_container);
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 4a63080747..87b5b829e0 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -204,15 +204,22 @@ void SpriteFramesEditor::_sheet_scroll_input(const Ref<InputEvent> &p_event) {
// to allow performing this action anywhere, even if the cursor isn't
// hovering the texture in the workspace.
if (mb->get_button_index() == MouseButton::WHEEL_UP && mb->is_pressed() && mb->is_ctrl_pressed()) {
- _sheet_zoom_in();
+ _sheet_zoom_on_position(scale_ratio, mb->get_position());
// Don't scroll up after zooming in.
- accept_event();
+ split_sheet_scroll->accept_event();
} else if (mb->get_button_index() == MouseButton::WHEEL_DOWN && mb->is_pressed() && mb->is_ctrl_pressed()) {
- _sheet_zoom_out();
+ _sheet_zoom_on_position(1 / scale_ratio, mb->get_position());
// Don't scroll down after zooming out.
- accept_event();
+ split_sheet_scroll->accept_event();
}
}
+
+ const Ref<InputEventMouseMotion> mm = p_event;
+ if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_MIDDLE) != MouseButton::NONE) {
+ const Vector2 dragged = Input::get_singleton()->warp_mouse_motion(mm, split_sheet_scroll->get_global_rect());
+ split_sheet_scroll->set_h_scroll(split_sheet_scroll->get_h_scroll() - dragged.x);
+ split_sheet_scroll->set_v_scroll(split_sheet_scroll->get_v_scroll() - dragged.y);
+ }
}
void SpriteFramesEditor::_sheet_add_frames() {
@@ -243,20 +250,25 @@ void SpriteFramesEditor::_sheet_add_frames() {
undo_redo->commit_action();
}
+void SpriteFramesEditor::_sheet_zoom_on_position(float p_zoom, const Vector2 &p_position) {
+ const float old_zoom = sheet_zoom;
+ sheet_zoom = CLAMP(sheet_zoom * p_zoom, min_sheet_zoom, max_sheet_zoom);
+
+ const Size2 texture_size = split_sheet_preview->get_texture()->get_size();
+ split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);
+
+ Vector2 offset = Vector2(split_sheet_scroll->get_h_scroll(), split_sheet_scroll->get_v_scroll());
+ offset = (offset + p_position) / old_zoom * sheet_zoom - p_position;
+ split_sheet_scroll->set_h_scroll(offset.x);
+ split_sheet_scroll->set_v_scroll(offset.y);
+}
+
void SpriteFramesEditor::_sheet_zoom_in() {
- if (sheet_zoom < max_sheet_zoom) {
- sheet_zoom *= scale_ratio;
- Size2 texture_size = split_sheet_preview->get_texture()->get_size();
- split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);
- }
+ _sheet_zoom_on_position(scale_ratio, Vector2());
}
void SpriteFramesEditor::_sheet_zoom_out() {
- if (sheet_zoom > min_sheet_zoom) {
- sheet_zoom /= scale_ratio;
- Size2 texture_size = split_sheet_preview->get_texture()->get_size();
- split_sheet_preview->set_custom_minimum_size(texture_size * sheet_zoom);
- }
+ _sheet_zoom_on_position(1 / scale_ratio, Vector2());
}
void SpriteFramesEditor::_sheet_zoom_reset() {
@@ -310,7 +322,8 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
void SpriteFramesEditor::_notification(int p_what) {
switch (p_what) {
- case NOTIFICATION_ENTER_TREE: {
+ case NOTIFICATION_ENTER_TREE:
+ case NOTIFICATION_THEME_CHANGED: {
load->set_icon(get_theme_icon(SNAME("Load"), SNAME("EditorIcons")));
load_sheet->set_icon(get_theme_icon(SNAME("SpriteSheet"), SNAME("EditorIcons")));
copy->set_icon(get_theme_icon(SNAME("ActionCopy"), SNAME("EditorIcons")));
@@ -328,11 +341,9 @@ void SpriteFramesEditor::_notification(int p_what) {
split_sheet_zoom_out->set_icon(get_theme_icon(SNAME("ZoomLess"), SNAME("EditorIcons")));
split_sheet_zoom_reset->set_icon(get_theme_icon(SNAME("ZoomReset"), SNAME("EditorIcons")));
split_sheet_zoom_in->set_icon(get_theme_icon(SNAME("ZoomMore"), SNAME("EditorIcons")));
- [[fallthrough]];
- }
- case NOTIFICATION_THEME_CHANGED: {
split_sheet_scroll->add_theme_style_override("bg", get_theme_stylebox(SNAME("bg"), SNAME("Tree")));
} break;
+
case NOTIFICATION_READY: {
add_theme_constant_override("autohide", 1); // Fixes the dragger always showing up.
} break;
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 461c8dd41a..872a88e262 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -143,6 +143,7 @@ class SpriteFramesEditor : public HSplitContainer {
void _sheet_preview_input(const Ref<InputEvent> &p_event);
void _sheet_scroll_input(const Ref<InputEvent> &p_event);
void _sheet_add_frames();
+ void _sheet_zoom_on_position(float p_zoom, const Vector2 &p_position);
void _sheet_zoom_in();
void _sheet_zoom_out();
void _sheet_zoom_reset();
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index d313b98a7f..e17bea0f2a 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -1887,7 +1887,6 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito
theme_type_editor = p_theme_type_editor;
tc = memnew(TabContainer);
- tc->set_tab_alignment(TabBar::ALIGNMENT_LEFT);
add_child(tc);
// Edit Items tab.
@@ -2046,6 +2045,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito
// Import Items tab.
TabContainer *import_tc = memnew(TabContainer);
+ import_tc->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
tc->add_child(import_tc);
tc->set_tab_title(1, TTR("Import Items"));
@@ -3393,6 +3393,7 @@ ThemeTypeEditor::ThemeTypeEditor() {
add_default_items_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_add_default_type_items));
data_type_tabs = memnew(TabContainer);
+ data_type_tabs->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
main_vb->add_child(data_type_tabs);
data_type_tabs->set_v_size_flags(SIZE_EXPAND_FILL);
data_type_tabs->set_use_hidden_tabs_for_min_size(true);
@@ -3640,7 +3641,6 @@ ThemeEditor::ThemeEditor() {
preview_tabs_vb->add_child(preview_tabs_content);
preview_tabs = memnew(TabBar);
- preview_tabs->set_tab_alignment(TabBar::ALIGNMENT_LEFT);
preview_tabs->set_h_size_flags(SIZE_EXPAND_FILL);
preview_tabbar_hb->add_child(preview_tabs);
preview_tabs->connect("tab_changed", callable_mp(this, &ThemeEditor::_change_preview_tab));
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index 8d8c65f2c4..c1a95c11f6 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -3989,6 +3989,7 @@ TileMapEditor::TileMapEditor() {
// TabBar.
tabs_bar = memnew(TabBar);
+ tabs_bar->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
tabs_bar->set_clip_tabs(false);
for (int plugin_index = 0; plugin_index < tile_map_editor_plugins.size(); plugin_index++) {
Vector<TileMapEditorPlugin::TabData> tabs_vector = tile_map_editor_plugins[plugin_index]->get_tabs();
diff --git a/editor/plugins/tiles/tile_set_editor.cpp b/editor/plugins/tiles/tile_set_editor.cpp
index 8b0b184f54..fb4a563992 100644
--- a/editor/plugins/tiles/tile_set_editor.cpp
+++ b/editor/plugins/tiles/tile_set_editor.cpp
@@ -664,6 +664,7 @@ TileSetEditor::TileSetEditor() {
// TabBar.
tabs_bar = memnew(TabBar);
+ tabs_bar->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
tabs_bar->set_clip_tabs(false);
tabs_bar->add_tab(TTR("Tiles"));
tabs_bar->add_tab(TTR("Patterns"));
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 7f30dd91e5..d83cf17048 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -1773,8 +1773,6 @@ void VisualShaderEditor::_change_input_port_name(const String &p_text, Object *p
undo_redo->create_action(TTR("Change Input Port Name"));
undo_redo->add_do_method(node.ptr(), "set_input_port_name", p_port_id, validated_name);
undo_redo->add_undo_method(node.ptr(), "set_input_port_name", p_port_id, node->get_input_port_name(p_port_id));
- undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id);
- undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->commit_action();
}
@@ -1801,8 +1799,6 @@ void VisualShaderEditor::_change_output_port_name(const String &p_text, Object *
undo_redo->create_action(TTR("Change Output Port Name"));
undo_redo->add_do_method(node.ptr(), "set_output_port_name", p_port_id, validated_name);
undo_redo->add_undo_method(node.ptr(), "set_output_port_name", p_port_id, prev_name);
- undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, p_node_id);
- undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, p_node_id);
undo_redo->commit_action();
}