summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/string/ustring.cpp6
-rw-r--r--doc/classes/EditorPlugin.xml7
-rw-r--r--doc/classes/FileAccess.xml2
-rw-r--r--doc/classes/TreeItem.xml6
-rw-r--r--editor/editor_audio_buses.cpp3
-rw-r--r--editor/editor_dock_manager.cpp14
-rw-r--r--editor/editor_dock_manager.h2
-rw-r--r--editor/editor_node.cpp7
-rw-r--r--editor/editor_plugin.compat.inc46
-rw-r--r--editor/editor_plugin.cpp13
-rw-r--r--editor/editor_plugin.h77
-rw-r--r--editor/gui/editor_bottom_panel.cpp16
-rw-r--r--editor/gui/editor_bottom_panel.h4
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp3
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp3
-rw-r--r--editor/plugins/debugger_editor_plugin.cpp3
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp3
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp2
-rw-r--r--editor/plugins/shader_file_editor_plugin.cpp4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp30
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp3
-rw-r--r--editor/plugins/tiles/tiles_editor_plugin.cpp5
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp3
-rw-r--r--editor/shader_globals_editor.cpp3
-rw-r--r--misc/extension_api_validation/4.2-stable.expected9
-rw-r--r--modules/multiplayer/editor/multiplayer_editor_plugin.cpp3
-rw-r--r--modules/openxr/editor/openxr_editor_plugin.cpp3
-rw-r--r--platform/windows/display_server_windows.cpp15
-rw-r--r--scene/gui/tree.cpp45
-rw-r--r--scene/gui/tree.h4
-rw-r--r--tests/core/string/test_string.h63
33 files changed, 286 insertions, 125 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index f4b00255a1..1d27933016 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -3329,10 +3329,14 @@ bool String::begins_with(const String &p_string) const {
bool String::begins_with(const char *p_string) const {
int l = length();
- if (l == 0 || !p_string) {
+ if (!p_string) {
return false;
}
+ if (l == 0) {
+ return *p_string == 0;
+ }
+
const char32_t *str = &operator[](0);
int i = 0;
diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml
index 0092c445c1..e874b44cfc 100644
--- a/doc/classes/EditorPlugin.xml
+++ b/doc/classes/EditorPlugin.xml
@@ -409,9 +409,10 @@
<return type="Button" />
<param index="0" name="control" type="Control" />
<param index="1" name="title" type="String" />
+ <param index="2" name="shortcut" type="Shortcut" default="null" />
<description>
- Adds a control to the bottom panel (together with [b]Output[/b], [b]Debug[/b], [b]Animation[/b], etc.). Returns the button added to the tab bar. It's up to you to manage the button's visibility as needed.
- When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_bottom_panel] and free it with [method Node.queue_free].
+ Adds a control to the bottom panel (together with Output, Debug, Animation, etc). Returns a reference to the button added. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_bottom_panel] and free it with [method Node.queue_free].
+ Optionally, you can specify a shortcut parameter. When pressed, this shortcut will toggle the bottom panel's visibility. See the default editor bottom panel shortcuts in the Editor Settings for inspiration. Per convention, they all use [kbd]Alt[/kbd] modifier.
</description>
</method>
<method name="add_control_to_container">
@@ -428,10 +429,12 @@
<return type="void" />
<param index="0" name="slot" type="int" enum="EditorPlugin.DockSlot" />
<param index="1" name="control" type="Control" />
+ <param index="2" name="shortcut" type="Shortcut" default="null" />
<description>
Adds the control to a specific dock slot (see [enum DockSlot] for options).
If the dock is repositioned and as long as the plugin is active, the editor will save the dock position on further sessions.
When your plugin is deactivated, make sure to remove your custom control with [method remove_control_from_docks] and free it with [method Node.queue_free].
+ Optionally, you can specify a shortcut parameter. When pressed, this shortcut will toggle the dock's visibility once it's moved to the bottom panel (this shortcut does not affect the dock otherwise). See the default editor bottom panel shortcuts in the Editor Settings for inspiration. Per convention, they all use [kbd]Alt[/kbd] modifier.
</description>
</method>
<method name="add_custom_type">
diff --git a/doc/classes/FileAccess.xml b/doc/classes/FileAccess.xml
index df8ebc12fa..2abd9974ca 100644
--- a/doc/classes/FileAccess.xml
+++ b/doc/classes/FileAccess.xml
@@ -517,12 +517,14 @@
</constant>
<constant name="WRITE" value="2" enum="ModeFlags">
Opens the file for write operations. The file is created if it does not exist, and truncated if it does.
+ [b]Note:[/b] When creating a file it must be in an already existing directory. To recursively create directories for a file path, see [method DirAccess.make_dir_recursive]).
</constant>
<constant name="READ_WRITE" value="3" enum="ModeFlags">
Opens the file for read and write operations. Does not truncate the file. The cursor is positioned at the beginning of the file.
</constant>
<constant name="WRITE_READ" value="7" enum="ModeFlags">
Opens the file for read and write operations. The file is created if it does not exist, and truncated if it does. The cursor is positioned at the beginning of the file.
+ [b]Note:[/b] When creating a file it must be in an already existing directory. To recursively create directories for a file path, see [method DirAccess.make_dir_recursive]).
</constant>
<constant name="COMPRESSION_FASTLZ" value="0" enum="CompressionMode">
Uses the [url=https://fastlz.org/]FastLZ[/url] compression method.
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index a1173d4628..c679838ec5 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -438,6 +438,12 @@
Returns [code]true[/code] if the given [param column] is selected.
</description>
</method>
+ <method name="is_visible_in_tree" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if [member visible] is [code]true[/code] and all its ancestors are also visible.
+ </description>
+ </method>
<method name="move_after">
<return type="void" />
<param index="0" name="item" type="TreeItem" />
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index ee8b66cddf..dd5dc14136 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -34,6 +34,7 @@
#include "core/input/input.h"
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
@@ -1041,7 +1042,7 @@ void EditorAudioBuses::_rebuild_buses() {
EditorAudioBuses *EditorAudioBuses::register_editor() {
EditorAudioBuses *audio_buses = memnew(EditorAudioBuses);
- EditorNode::get_bottom_panel()->add_item(TTR("Audio"), audio_buses);
+ EditorNode::get_bottom_panel()->add_item(TTR("Audio"), audio_buses, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_audio_bottom_panel", TTR("Toggle Audio Bottom Panel"), KeyModifierMask::ALT | Key::A));
return audio_buses;
}
diff --git a/editor/editor_dock_manager.cpp b/editor/editor_dock_manager.cpp
index a6b16a245d..08719d6bf0 100644
--- a/editor/editor_dock_manager.cpp
+++ b/editor/editor_dock_manager.cpp
@@ -38,6 +38,7 @@
#include "scene/gui/tab_container.h"
#include "scene/main/window.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
@@ -48,6 +49,8 @@
EditorDockManager *EditorDockManager::singleton = nullptr;
+static const char *META_TOGGLE_SHORTCUT = "_toggle_shortcut";
+
void DockSplitContainer::_update_visibility() {
if (is_updating) {
return;
@@ -392,7 +395,10 @@ void EditorDockManager::_dock_move_selected_to_bottom() {
dock->call("_set_dock_horizontal", true);
bottom_docks.push_back(dock);
- EditorNode::get_bottom_panel()->add_item(dock->get_name(), dock, true);
+
+ // Force docks moved to the bottom to appear first in the list, and give them their associated shortcut to toggle their bottom panel.
+ EditorNode::get_bottom_panel()->add_item(dock->get_name(), dock, dock->get_meta(META_TOGGLE_SHORTCUT), true);
+
dock_select_popup->hide();
update_dock_slots_visibility(true);
_edit_current();
@@ -663,7 +669,8 @@ void EditorDockManager::load_docks_from_config(Ref<ConfigFile> p_layout, const S
node->call("_set_dock_horizontal", true);
bottom_docks.push_back(node);
- EditorNode::get_bottom_panel()->add_item(node->get_name(), node, true);
+ // Force docks moved to the bottom to appear first in the list, and give them their associated shortcut to toggle their bottom panel.
+ EditorNode::get_bottom_panel()->add_item(node->get_name(), node, node->get_meta(META_TOGGLE_SHORTCUT), true);
}
}
@@ -730,8 +737,9 @@ void EditorDockManager::close_all_floating_docks() {
}
}
-void EditorDockManager::add_control_to_dock(DockSlot p_slot, Control *p_control, const String &p_name) {
+void EditorDockManager::add_control_to_dock(DockSlot p_slot, Control *p_control, const String &p_name, const Ref<Shortcut> &p_shortcut) {
ERR_FAIL_INDEX(p_slot, DOCK_SLOT_MAX);
+ p_control->set_meta(META_TOGGLE_SHORTCUT, p_shortcut);
dock_slot[p_slot]->add_child(p_control);
if (!p_name.is_empty()) {
dock_slot[p_slot]->set_tab_title(dock_slot[p_slot]->get_tab_idx_from_control(p_control), p_name);
diff --git a/editor/editor_dock_manager.h b/editor/editor_dock_manager.h
index cc1a6634bc..193ccd6541 100644
--- a/editor/editor_dock_manager.h
+++ b/editor/editor_dock_manager.h
@@ -133,7 +133,7 @@ public:
void set_docks_visible(bool p_show);
bool are_docks_visible() const;
- void add_control_to_dock(DockSlot p_slot, Control *p_control, const String &p_name = "");
+ void add_control_to_dock(DockSlot p_slot, Control *p_control, const String &p_name = "", const Ref<Shortcut> &p_shortcut = nullptr);
void remove_control_from_dock(Control *p_control);
EditorDockManager();
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 7de3f58997..041784d7da 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -338,6 +338,8 @@ void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) {
_editor_select_prev();
} else if (ED_IS_SHORTCUT("editor/command_palette", p_event)) {
_open_command_palette();
+ } else if (ED_IS_SHORTCUT("editor/toggle_last_opened_bottom_panel", p_event)) {
+ bottom_panel->toggle_last_opened_bottom_panel();
} else {
}
@@ -6582,6 +6584,7 @@ EditorNode::EditorNode() {
distraction_free->set_theme_type_variation("FlatMenuButton");
ED_SHORTCUT_AND_COMMAND("editor/distraction_free_mode", TTR("Distraction Free Mode"), KeyModifierMask::CTRL | KeyModifierMask::SHIFT | Key::F11);
ED_SHORTCUT_OVERRIDE("editor/distraction_free_mode", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::D);
+ ED_SHORTCUT_AND_COMMAND("editor/toggle_last_opened_bottom_panel", TTR("Toggle Last Opened Bottom Panel"), KeyModifierMask::CMD_OR_CTRL | Key::J);
distraction_free->set_shortcut(ED_GET_SHORTCUT("editor/distraction_free_mode"));
distraction_free->set_tooltip_text(TTR("Toggle distraction-free mode."));
distraction_free->set_toggle_mode(true);
@@ -6993,7 +6996,7 @@ EditorNode::EditorNode() {
editor_dock_manager->add_control_to_dock(EditorDockManager::DOCK_SLOT_LEFT_UR, ImportDock::get_singleton(), TTR("Import"));
// FileSystem: Bottom left.
- editor_dock_manager->add_control_to_dock(EditorDockManager::DOCK_SLOT_LEFT_BR, FileSystemDock::get_singleton(), TTR("FileSystem"));
+ editor_dock_manager->add_control_to_dock(EditorDockManager::DOCK_SLOT_LEFT_BR, FileSystemDock::get_singleton(), TTR("FileSystem"), ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_filesystem_bottom_panel", TTR("Toggle FileSystem Bottom Panel"), KeyModifierMask::ALT | Key::F));
// Inspector: Full height right.
editor_dock_manager->add_control_to_dock(EditorDockManager::DOCK_SLOT_RIGHT_UL, InspectorDock::get_singleton(), TTR("Inspector"));
@@ -7035,7 +7038,7 @@ EditorNode::EditorNode() {
center_split->set_dragger_visibility(SplitContainer::DRAGGER_HIDDEN);
log = memnew(EditorLog);
- Button *output_button = bottom_panel->add_item(TTR("Output"), log);
+ Button *output_button = bottom_panel->add_item(TTR("Output"), log, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_output_bottom_panel", TTR("Toggle Output Bottom Panel"), KeyModifierMask::ALT | Key::O));
log->set_tool_button(output_button);
center_split->connect("resized", callable_mp(this, &EditorNode::_vp_resized));
diff --git a/editor/editor_plugin.compat.inc b/editor/editor_plugin.compat.inc
new file mode 100644
index 0000000000..7edf938604
--- /dev/null
+++ b/editor/editor_plugin.compat.inc
@@ -0,0 +1,46 @@
+/**************************************************************************/
+/* editor_plugin.compat.inc */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef DISABLE_DEPRECATED
+
+Button *EditorPlugin::_add_control_to_bottom_panel_compat_88081(Control *p_control, const String &p_title) {
+ return add_control_to_bottom_panel(p_control, p_title, nullptr);
+}
+
+void EditorPlugin::_add_control_to_dock_compat_88081(DockSlot p_slot, Control *p_control) {
+ return add_control_to_dock(p_slot, p_control, nullptr);
+}
+
+void EditorPlugin::_bind_compatibility_methods() {
+ ClassDB::bind_compatibility_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::_add_control_to_bottom_panel_compat_88081);
+ ClassDB::bind_compatibility_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::_add_control_to_dock_compat_88081);
+}
+
+#endif
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 7b5b084f09..67fe0c2e28 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -29,6 +29,7 @@
/**************************************************************************/
#include "editor_plugin.h"
+#include "editor_plugin.compat.inc"
#include "editor/debugger/editor_debugger_node.h"
#include "editor/editor_dock_manager.h"
@@ -79,14 +80,14 @@ void EditorPlugin::remove_autoload_singleton(const String &p_name) {
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
}
-Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
+Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title, const Ref<Shortcut> &p_shortcut) {
ERR_FAIL_NULL_V(p_control, nullptr);
- return EditorNode::get_bottom_panel()->add_item(p_title, p_control);
+ return EditorNode::get_bottom_panel()->add_item(p_title, p_control, p_shortcut);
}
-void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
+void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control, const Ref<Shortcut> &p_shortcut) {
ERR_FAIL_NULL(p_control);
- EditorDockManager::get_singleton()->add_control_to_dock(EditorDockManager::DockSlot(p_slot), p_control);
+ EditorDockManager::get_singleton()->add_control_to_dock(EditorDockManager::DockSlot(p_slot), p_control, String(), p_shortcut);
}
void EditorPlugin::remove_control_from_docks(Control *p_control) {
@@ -559,8 +560,8 @@ void EditorPlugin::_notification(int p_what) {
void EditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container);
- ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel);
- ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock);
+ ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title", "shortcut"), &EditorPlugin::add_control_to_bottom_panel, DEFVAL(Ref<Shortcut>()));
+ ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control", "shortcut"), &EditorPlugin::add_control_to_dock, DEFVAL(Ref<Shortcut>()));
ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h
index a93955046a..7c28818b2f 100644
--- a/editor/editor_plugin.h
+++ b/editor/editor_plugin.h
@@ -67,6 +67,40 @@ class EditorPlugin : public Node {
void _editor_project_settings_changed();
#endif
+public:
+ enum CustomControlContainer {
+ CONTAINER_TOOLBAR,
+ CONTAINER_SPATIAL_EDITOR_MENU,
+ CONTAINER_SPATIAL_EDITOR_SIDE_LEFT,
+ CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT,
+ CONTAINER_SPATIAL_EDITOR_BOTTOM,
+ CONTAINER_CANVAS_EDITOR_MENU,
+ CONTAINER_CANVAS_EDITOR_SIDE_LEFT,
+ CONTAINER_CANVAS_EDITOR_SIDE_RIGHT,
+ CONTAINER_CANVAS_EDITOR_BOTTOM,
+ CONTAINER_INSPECTOR_BOTTOM,
+ CONTAINER_PROJECT_SETTING_TAB_LEFT,
+ CONTAINER_PROJECT_SETTING_TAB_RIGHT,
+ };
+
+ enum DockSlot {
+ DOCK_SLOT_LEFT_UL,
+ DOCK_SLOT_LEFT_BL,
+ DOCK_SLOT_LEFT_UR,
+ DOCK_SLOT_LEFT_BR,
+ DOCK_SLOT_RIGHT_UL,
+ DOCK_SLOT_RIGHT_BL,
+ DOCK_SLOT_RIGHT_UR,
+ DOCK_SLOT_RIGHT_BR,
+ DOCK_SLOT_MAX
+ };
+
+ enum AfterGUIInput {
+ AFTER_GUI_INPUT_PASS,
+ AFTER_GUI_INPUT_STOP,
+ AFTER_GUI_INPUT_CUSTOM,
+ };
+
protected:
void _notification(int p_what);
@@ -101,46 +135,19 @@ protected:
GDVIRTUAL0(_enable_plugin)
GDVIRTUAL0(_disable_plugin)
-public:
- enum CustomControlContainer {
- CONTAINER_TOOLBAR,
- CONTAINER_SPATIAL_EDITOR_MENU,
- CONTAINER_SPATIAL_EDITOR_SIDE_LEFT,
- CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT,
- CONTAINER_SPATIAL_EDITOR_BOTTOM,
- CONTAINER_CANVAS_EDITOR_MENU,
- CONTAINER_CANVAS_EDITOR_SIDE_LEFT,
- CONTAINER_CANVAS_EDITOR_SIDE_RIGHT,
- CONTAINER_CANVAS_EDITOR_BOTTOM,
- CONTAINER_INSPECTOR_BOTTOM,
- CONTAINER_PROJECT_SETTING_TAB_LEFT,
- CONTAINER_PROJECT_SETTING_TAB_RIGHT,
- };
-
- enum DockSlot {
- DOCK_SLOT_LEFT_UL,
- DOCK_SLOT_LEFT_BL,
- DOCK_SLOT_LEFT_UR,
- DOCK_SLOT_LEFT_BR,
- DOCK_SLOT_RIGHT_UL,
- DOCK_SLOT_RIGHT_BL,
- DOCK_SLOT_RIGHT_UR,
- DOCK_SLOT_RIGHT_BR,
- DOCK_SLOT_MAX
- };
-
- enum AfterGUIInput {
- AFTER_GUI_INPUT_PASS,
- AFTER_GUI_INPUT_STOP,
- AFTER_GUI_INPUT_CUSTOM
- };
+#ifndef DISABLE_DEPRECATED
+ Button *_add_control_to_bottom_panel_compat_88081(Control *p_control, const String &p_title);
+ void _add_control_to_dock_compat_88081(DockSlot p_slot, Control *p_control);
+ static void _bind_compatibility_methods();
+#endif
+public:
//TODO: send a resource for editing to the editor node?
void add_control_to_container(CustomControlContainer p_location, Control *p_control);
void remove_control_from_container(CustomControlContainer p_location, Control *p_control);
- Button *add_control_to_bottom_panel(Control *p_control, const String &p_title);
- void add_control_to_dock(DockSlot p_slot, Control *p_control);
+ Button *add_control_to_bottom_panel(Control *p_control, const String &p_title, const Ref<Shortcut> &p_shortcut = nullptr);
+ void add_control_to_dock(DockSlot p_slot, Control *p_control, const Ref<Shortcut> &p_shortcut = nullptr);
void remove_control_from_docks(Control *p_control);
void remove_control_from_bottom_panel(Control *p_control);
diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp
index ab7e05b915..6a59d7a3a7 100644
--- a/editor/gui/editor_bottom_panel.cpp
+++ b/editor/gui/editor_bottom_panel.cpp
@@ -105,6 +105,8 @@ void EditorBottomPanel::_switch_to_item(bool p_visible, int p_idx) {
EditorNode::get_top_split()->show();
}
}
+
+ last_opened_control = items[p_idx].control;
}
void EditorBottomPanel::_expand_button_toggled(bool p_pressed) {
@@ -156,12 +158,13 @@ void EditorBottomPanel::load_layout_from_config(Ref<ConfigFile> p_config_file, c
}
}
-Button *EditorBottomPanel::add_item(String p_text, Control *p_item, bool p_at_front) {
+Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Ref<Shortcut> &p_shortcut, bool p_at_front) {
Button *tb = memnew(Button);
tb->set_theme_type_variation("FlatMenuButton");
tb->connect("toggled", callable_mp(this, &EditorBottomPanel::_switch_by_control).bind(p_item));
tb->set_drag_forwarding(Callable(), callable_mp(this, &EditorBottomPanel::_button_drag_hover).bind(tb, p_item), Callable());
tb->set_text(p_text);
+ tb->set_shortcut(p_shortcut);
tb->set_toggle_mode(true);
tb->set_focus_mode(Control::FOCUS_NONE);
item_vbox->add_child(p_item);
@@ -221,6 +224,17 @@ void EditorBottomPanel::hide_bottom_panel() {
}
}
+void EditorBottomPanel::toggle_last_opened_bottom_panel() {
+ // Select by control instead of index, so that the last bottom panel is opened correctly
+ // if it's been reordered since.
+ if (last_opened_control) {
+ _switch_by_control(!last_opened_control->is_visible(), last_opened_control);
+ } else {
+ // Open the first panel in the list if no panel was opened this session.
+ _switch_to_item(true, 0);
+ }
+}
+
EditorBottomPanel::EditorBottomPanel() {
item_vbox = memnew(VBoxContainer);
add_child(item_vbox);
diff --git a/editor/gui/editor_bottom_panel.h b/editor/gui/editor_bottom_panel.h
index 54b3a1319d..95c767dae5 100644
--- a/editor/gui/editor_bottom_panel.h
+++ b/editor/gui/editor_bottom_panel.h
@@ -57,6 +57,7 @@ class EditorBottomPanel : public PanelContainer {
EditorToaster *editor_toaster = nullptr;
LinkButton *version_btn = nullptr;
Button *expand_button = nullptr;
+ Control *last_opened_control = nullptr;
void _switch_by_control(bool p_visible, Control *p_control);
void _switch_to_item(bool p_visible, int p_idx);
@@ -72,11 +73,12 @@ public:
void save_layout_to_config(Ref<ConfigFile> p_config_file, const String &p_section) const;
void load_layout_from_config(Ref<ConfigFile> p_config_file, const String &p_section);
- Button *add_item(String p_text, Control *p_item, bool p_at_front = false);
+ Button *add_item(String p_text, Control *p_item, const Ref<Shortcut> &p_shortcut = nullptr, bool p_at_front = false);
void remove_item(Control *p_item);
void make_item_visible(Control *p_item, bool p_visible = true);
void move_item_to_end(Control *p_item);
void hide_bottom_panel();
+ void toggle_last_opened_bottom_panel();
EditorBottomPanel();
};
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 7ee155b478..c03dc7efde 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -35,6 +35,7 @@
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
@@ -2275,7 +2276,7 @@ void AnimationPlayerEditorPlugin::make_visible(bool p_visible) {
AnimationPlayerEditorPlugin::AnimationPlayerEditorPlugin() {
anim_editor = memnew(AnimationPlayerEditor(this));
- EditorNode::get_bottom_panel()->add_item(TTR("Animation"), anim_editor);
+ EditorNode::get_bottom_panel()->add_item(TTR("Animation"), anim_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_bottom_panel", TTR("Toggle Animation Bottom Panel"), KeyModifierMask::ALT | Key::N));
}
AnimationPlayerEditorPlugin::~AnimationPlayerEditorPlugin() {
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index 3e9eebdeab..074fea49bd 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -39,6 +39,7 @@
#include "core/io/resource_loader.h"
#include "core/math/delaunay_2d.h"
#include "core/os/keyboard.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/gui/editor_file_dialog.h"
@@ -316,7 +317,7 @@ AnimationTreeEditorPlugin::AnimationTreeEditorPlugin() {
anim_tree_editor = memnew(AnimationTreeEditor);
anim_tree_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
- button = EditorNode::get_bottom_panel()->add_item(TTR("AnimationTree"), anim_tree_editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("AnimationTree"), anim_tree_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_animation_tree_bottom_panel", TTR("Toggle AnimationTree Bottom Panel")));
button->hide();
}
diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp
index da7b256572..2dc43098f7 100644
--- a/editor/plugins/debugger_editor_plugin.cpp
+++ b/editor/plugins/debugger_editor_plugin.cpp
@@ -34,6 +34,7 @@
#include "editor/debugger/editor_debugger_node.h"
#include "editor/debugger/editor_debugger_server.h"
#include "editor/debugger/editor_file_server.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/gui/editor_bottom_panel.h"
@@ -55,7 +56,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) {
file_server = memnew(EditorFileServer);
EditorDebuggerNode *debugger = memnew(EditorDebuggerNode);
- Button *db = EditorNode::get_bottom_panel()->add_item(TTR("Debugger"), debugger);
+ Button *db = EditorNode::get_bottom_panel()->add_item(TTR("Debugger"), debugger, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_debugger_bottom_panel", TTR("Toggle Debugger Bottom Panel"), KeyModifierMask::ALT | Key::D));
debugger->set_tool_button(db);
// Main editor debug menu.
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index 9aac87da35..a624c47e3e 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -32,6 +32,7 @@
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_interface.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
@@ -423,7 +424,7 @@ ResourcePreloaderEditorPlugin::ResourcePreloaderEditorPlugin() {
preloader_editor = memnew(ResourcePreloaderEditor);
preloader_editor->set_custom_minimum_size(Size2(0, 250) * EDSCALE);
- button = EditorNode::get_bottom_panel()->add_item("ResourcePreloader", preloader_editor);
+ button = EditorNode::get_bottom_panel()->add_item("ResourcePreloader", preloader_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_resource_preloader_bottom_panel", TTR("Toggle ResourcePreloader Bottom Panel")));
button->hide();
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index e986510895..edec4af094 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -4197,7 +4197,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
find_in_files_dialog->connect(FindInFilesDialog::SIGNAL_REPLACE_REQUESTED, callable_mp(this, &ScriptEditor::_start_find_in_files).bind(true));
add_child(find_in_files_dialog);
find_in_files = memnew(FindInFilesPanel);
- find_in_files_button = EditorNode::get_bottom_panel()->add_item(TTR("Search Results"), find_in_files);
+ find_in_files_button = EditorNode::get_bottom_panel()->add_item(TTR("Search Results"), find_in_files, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_search_results_bottom_panel", TTR("Toggle Search Results Bottom Panel")));
find_in_files->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
find_in_files->connect(FindInFilesPanel::SIGNAL_RESULT_SELECTED, callable_mp(this, &ScriptEditor::_on_find_in_files_result_selected));
find_in_files->connect(FindInFilesPanel::SIGNAL_FILES_MODIFIED, callable_mp(this, &ScriptEditor::_on_find_in_files_modified_files));
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 213a332bab..222d010a7a 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -728,7 +728,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
empty.instantiate();
shader_tabs->add_theme_style_override("panel", empty);
- button = EditorNode::get_bottom_panel()->add_item(TTR("Shader Editor"), window_wrapper);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("Shader Editor"), window_wrapper, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_shader_editor_bottom_panel", TTR("Toggle Shader Editor Bottom Panel"), KeyModifierMask::ALT | Key::S));
shader_create_dialog = memnew(ShaderCreateDialog);
vb->add_child(shader_create_dialog);
diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp
index e127007d0c..3e025f8ba0 100644
--- a/editor/plugins/shader_file_editor_plugin.cpp
+++ b/editor/plugins/shader_file_editor_plugin.cpp
@@ -34,8 +34,8 @@
#include "core/io/resource_saver.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
-#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/gui/editor_bottom_panel.h"
#include "editor/themes/editor_scale.h"
@@ -323,7 +323,7 @@ ShaderFileEditorPlugin::ShaderFileEditorPlugin() {
shader_editor = memnew(ShaderFileEditor);
shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
- button = EditorNode::get_bottom_panel()->add_item(TTR("ShaderFile"), shader_editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("ShaderFile"), shader_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_shader_file_bottom_panel", TTR("Toggle ShaderFile Bottom Panel")));
button->hide();
}
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 9c1170492b..3055e178ba 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "core/os/keyboard.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
@@ -525,18 +526,21 @@ void SpriteFramesEditor::_prepare_sprite_sheet(const String &p_file) {
split_sheet_offset_x->set_max(size.x);
split_sheet_offset_y->set_max(size.y);
- // Different texture, reset to 4x4.
- dominant_param = PARAM_FRAME_COUNT;
- updating_split_settings = true;
- split_sheet_h->set_value(4);
- split_sheet_v->set_value(4);
- split_sheet_size_x->set_value(size.x / 4);
- split_sheet_size_y->set_value(size.y / 4);
- split_sheet_sep_x->set_value(0);
- split_sheet_sep_y->set_value(0);
- split_sheet_offset_x->set_value(0);
- split_sheet_offset_y->set_value(0);
- updating_split_settings = false;
+ if (size != previous_texture_size) {
+ // Different texture, reset to 4x4.
+ dominant_param = PARAM_FRAME_COUNT;
+ updating_split_settings = true;
+ split_sheet_h->set_value(4);
+ split_sheet_v->set_value(4);
+ split_sheet_size_x->set_value(size.x / 4);
+ split_sheet_size_y->set_value(size.y / 4);
+ split_sheet_sep_x->set_value(0);
+ split_sheet_sep_y->set_value(0);
+ split_sheet_offset_x->set_value(0);
+ split_sheet_offset_y->set_value(0);
+ updating_split_settings = false;
+ }
+ previous_texture_size = size;
// Reset zoom.
_sheet_zoom_reset();
@@ -2337,7 +2341,7 @@ void SpriteFramesEditorPlugin::make_visible(bool p_visible) {
SpriteFramesEditorPlugin::SpriteFramesEditorPlugin() {
frames_editor = memnew(SpriteFramesEditor);
frames_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
- button = EditorNode::get_bottom_panel()->add_item(TTR("SpriteFrames"), frames_editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("SpriteFrames"), frames_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_sprite_frames_bottom_panel", TTR("Toggle SpriteFrames Bottom Panel")));
button->hide();
}
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index 730dddade1..2d0e43be1e 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -167,6 +167,8 @@ class SpriteFramesEditor : public HSplitContainer {
bool frames_need_sort = false;
int last_frame_selected = 0;
+ Size2i previous_texture_size;
+
float scale_ratio;
int thumbnail_default_size;
float thumbnail_zoom;
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 92f107f369..8ed00cf542 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -31,6 +31,7 @@
#include "theme_editor_plugin.h"
#include "core/os/keyboard.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_help.h"
#include "editor/editor_node.h"
#include "editor/editor_resource_picker.h"
@@ -3844,6 +3845,6 @@ ThemeEditorPlugin::ThemeEditorPlugin() {
theme_editor->plugin = this;
theme_editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
- button = EditorNode::get_bottom_panel()->add_item(TTR("Theme"), theme_editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("Theme"), theme_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_theme_bottom_panel", TTR("Toggle Theme Bottom Panel")));
button->hide();
}
diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp
index fb31ace2e0..ed21a29487 100644
--- a/editor/plugins/tiles/tiles_editor_plugin.cpp
+++ b/editor/plugins/tiles/tiles_editor_plugin.cpp
@@ -34,6 +34,7 @@
#include "core/os/mutex.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_interface.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
@@ -511,7 +512,7 @@ TileMapEditorPlugin::TileMapEditorPlugin() {
editor->connect("change_selected_layer_request", callable_mp(this, &TileMapEditorPlugin::_select_layer));
editor->hide();
- button = EditorNode::get_bottom_panel()->add_item(TTR("TileMap"), editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("TileMap"), editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_tile_map_bottom_panel", TTR("Toggle TileMap Bottom Panel")));
button->hide();
}
@@ -562,7 +563,7 @@ TileSetEditorPlugin::TileSetEditorPlugin() {
editor->set_custom_minimum_size(Size2(0, 200) * EDSCALE);
editor->hide();
- button = EditorNode::get_bottom_panel()->add_item(TTR("TileSet"), editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("TileSet"), editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_tile_set_bottom_panel", TTR("Toggle TileSet Bottom Panel")));
button->hide();
}
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index 86c7e31740..a54ffd4ee8 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -33,6 +33,7 @@
#include "core/config/project_settings.h"
#include "core/os/keyboard.h"
#include "core/os/time.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_dock_manager.h"
#include "editor/editor_file_system.h"
#include "editor/editor_interface.h"
@@ -913,7 +914,7 @@ void VersionControlEditorPlugin::fetch_available_vcs_plugin_names() {
void VersionControlEditorPlugin::register_editor() {
EditorDockManager::get_singleton()->add_control_to_dock(EditorDockManager::DOCK_SLOT_RIGHT_UL, version_commit_dock);
- version_control_dock_button = EditorNode::get_bottom_panel()->add_item(TTR("Version Control"), version_control_dock);
+ version_control_dock_button = EditorNode::get_bottom_panel()->add_item(TTR("Version Control"), version_control_dock, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_version_control_bottom_panel", TTR("Toggle Version Control Bottom Panel")));
_set_vcs_ui_state(true);
}
diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp
index 97f6ce2215..86a78d813e 100644
--- a/editor/shader_globals_editor.cpp
+++ b/editor/shader_globals_editor.cpp
@@ -398,6 +398,8 @@ void ShaderGlobalsEditor::_variable_added() {
undo_redo->add_do_method(this, "_changed");
undo_redo->add_undo_method(this, "_changed");
undo_redo->commit_action();
+
+ variable_name->clear();
}
void ShaderGlobalsEditor::_variable_deleted(const String &p_variable) {
@@ -455,6 +457,7 @@ ShaderGlobalsEditor::ShaderGlobalsEditor() {
variable_name->set_h_size_flags(SIZE_EXPAND_FILL);
variable_name->set_clear_button_enabled(true);
variable_name->connect("text_changed", callable_mp(this, &ShaderGlobalsEditor::_variable_name_text_changed));
+ variable_name->connect("text_submitted", callable_mp(this, &ShaderGlobalsEditor::_variable_added).unbind(1));
add_menu_hb->add_child(variable_name);
diff --git a/misc/extension_api_validation/4.2-stable.expected b/misc/extension_api_validation/4.2-stable.expected
index 1c36c47246..49e871e203 100644
--- a/misc/extension_api_validation/4.2-stable.expected
+++ b/misc/extension_api_validation/4.2-stable.expected
@@ -231,3 +231,12 @@ GH-89024
Validate extension JSON: Error: Field 'classes/RichTextLabel/methods/push_meta/arguments': size changed value in new API, from 1 to 2.
Added optional argument. Compatibility method registered.
+
+
+GH-88081
+--------
+Validate extension JSON: Error: Field 'classes/EditorPlugin/methods/add_control_to_bottom_panel/arguments': size changed value in new API, from 2 to 3.
+Validate extension JSON: Error: Field 'classes/EditorPlugin/methods/add_control_to_dock/arguments': size changed value in new API, from 2 to 3.
+
+Added optional argument to add_control_to_bottom_panel and add_control_to_dock to specify a shortcut that toggles the bottom panel/dock's visibility.
+Compatibility method registered.
diff --git a/modules/multiplayer/editor/multiplayer_editor_plugin.cpp b/modules/multiplayer/editor/multiplayer_editor_plugin.cpp
index e8dfc3379c..599926ec99 100644
--- a/modules/multiplayer/editor/multiplayer_editor_plugin.cpp
+++ b/modules/multiplayer/editor/multiplayer_editor_plugin.cpp
@@ -34,6 +34,7 @@
#include "editor_network_profiler.h"
#include "replication_editor.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_interface.h"
#include "editor/editor_node.h"
#include "editor/gui/editor_bottom_panel.h"
@@ -113,7 +114,7 @@ void MultiplayerEditorDebugger::setup_session(int p_session_id) {
MultiplayerEditorPlugin::MultiplayerEditorPlugin() {
repl_editor = memnew(ReplicationEditor);
- button = EditorNode::get_bottom_panel()->add_item(TTR("Replication"), repl_editor);
+ button = EditorNode::get_bottom_panel()->add_item(TTR("Replication"), repl_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_replication_bottom_panel", TTR("Toggle Replication Bottom Panel")));
button->hide();
repl_editor->get_pin()->connect("pressed", callable_mp(this, &MultiplayerEditorPlugin::_pinned));
debugger.instantiate();
diff --git a/modules/openxr/editor/openxr_editor_plugin.cpp b/modules/openxr/editor/openxr_editor_plugin.cpp
index f545e31073..f6b7f2dd0c 100644
--- a/modules/openxr/editor/openxr_editor_plugin.cpp
+++ b/modules/openxr/editor/openxr_editor_plugin.cpp
@@ -32,6 +32,7 @@
#include "../action_map/openxr_action_map.h"
+#include "editor/editor_command_palette.h"
#include "editor/editor_node.h"
#include "editor/gui/editor_bottom_panel.h"
@@ -53,7 +54,7 @@ void OpenXREditorPlugin::make_visible(bool p_visible) {
OpenXREditorPlugin::OpenXREditorPlugin() {
action_map_editor = memnew(OpenXRActionMapEditor);
- EditorNode::get_bottom_panel()->add_item(TTR("OpenXR Action Map"), action_map_editor);
+ EditorNode::get_bottom_panel()->add_item(TTR("OpenXR Action Map"), action_map_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_openxr_action_map_bottom_panel", TTR("Toggle OpenXR Action Map Bottom Panel")));
#ifndef ANDROID_ENABLED
select_runtime = memnew(OpenXRSelectRuntime);
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index ada9202207..99b18759f3 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -2531,17 +2531,15 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
config.pButtons = tbuttons;
config.pfCallback = win32_task_dialog_callback;
+ Error result = FAILED;
HMODULE comctl = LoadLibraryW(L"comctl32.dll");
if (comctl) {
typedef HRESULT(WINAPI * TaskDialogIndirectPtr)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked);
TaskDialogIndirectPtr task_dialog_indirect = (TaskDialogIndirectPtr)GetProcAddress(comctl, "TaskDialogIndirect");
- if (task_dialog_indirect) {
- int button_pressed;
- if (FAILED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
- return FAILED;
- }
+ int button_pressed;
+ if (task_dialog_indirect && SUCCEEDED(task_dialog_indirect(&config, &button_pressed, nullptr, nullptr))) {
if (!p_callback.is_null()) {
Variant button = button_pressed;
const Variant *args[1] = { &button };
@@ -2553,13 +2551,14 @@ Error DisplayServerWindows::dialog_show(String p_title, String p_description, Ve
}
}
- return OK;
+ result = OK;
}
FreeLibrary(comctl);
+ } else {
+ ERR_PRINT("Unable to create native dialog.");
}
- ERR_PRINT("Unable to create native dialog.");
- return FAILED;
+ return result;
}
struct Win32InputTextDialogInit {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 30a5433e45..7842fc5fc0 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -691,7 +691,7 @@ bool TreeItem::_is_any_collapsed(bool p_only_visible) {
}
bool TreeItem::is_any_collapsed(bool p_only_visible) {
- if (p_only_visible && !is_visible()) {
+ if (p_only_visible && !is_visible_in_tree()) {
return false;
}
@@ -712,12 +712,31 @@ void TreeItem::set_visible(bool p_visible) {
tree->queue_redraw();
_changed_notify();
}
+
+ _handle_visibility_changed(p_visible);
}
bool TreeItem::is_visible() {
return visible;
}
+bool TreeItem::is_visible_in_tree() const {
+ return visible && parent_visible_in_tree;
+}
+
+void TreeItem::_handle_visibility_changed(bool p_visible) {
+ TreeItem *child = get_first_child();
+ while (child) {
+ child->_propagate_visibility_changed(p_visible);
+ child = child->get_next();
+ }
+}
+
+void TreeItem::_propagate_visibility_changed(bool p_parent_visible_in_tree) {
+ parent_visible_in_tree = p_parent_visible_in_tree;
+ _handle_visibility_changed(p_parent_visible_in_tree);
+}
+
void TreeItem::uncollapse_tree() {
TreeItem *t = this;
while (t) {
@@ -788,6 +807,7 @@ TreeItem *TreeItem::create_child(int p_index) {
}
ti->parent = this;
+ ti->parent_visible_in_tree = is_visible_in_tree();
return ti;
}
@@ -799,6 +819,8 @@ void TreeItem::add_child(TreeItem *p_item) {
p_item->_change_tree(tree);
p_item->parent = this;
+ p_item->parent_visible_in_tree = is_visible_in_tree();
+ p_item->_handle_visibility_changed(p_item->parent_visible_in_tree);
TreeItem *item_prev = first_child;
while (item_prev && item_prev->next) {
@@ -906,7 +928,7 @@ TreeItem *TreeItem::_get_prev_in_tree(bool p_wrap, bool p_include_invisible) {
TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
TreeItem *loop = this;
TreeItem *prev_item = _get_prev_in_tree(p_wrap);
- while (prev_item && !prev_item->is_visible()) {
+ while (prev_item && !prev_item->is_visible_in_tree()) {
prev_item = prev_item->_get_prev_in_tree(p_wrap);
if (prev_item == loop) {
// Check that we haven't looped all the way around to the start.
@@ -947,7 +969,7 @@ TreeItem *TreeItem::_get_next_in_tree(bool p_wrap, bool p_include_invisible) {
TreeItem *TreeItem::get_next_visible(bool p_wrap) {
TreeItem *loop = this;
TreeItem *next_item = _get_next_in_tree(p_wrap);
- while (next_item && !next_item->is_visible()) {
+ while (next_item && !next_item->is_visible_in_tree()) {
next_item = next_item->_get_next_in_tree(p_wrap);
if (next_item == loop) {
// Check that we haven't looped all the way around to the start.
@@ -1641,6 +1663,7 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_visible", "enable"), &TreeItem::set_visible);
ClassDB::bind_method(D_METHOD("is_visible"), &TreeItem::is_visible);
+ ClassDB::bind_method(D_METHOD("is_visible_in_tree"), &TreeItem::is_visible_in_tree);
ClassDB::bind_method(D_METHOD("uncollapse_tree"), &TreeItem::uncollapse_tree);
@@ -1790,7 +1813,7 @@ Size2 Tree::_get_cell_icon_size(const TreeItem::Cell &p_cell) const {
}
int Tree::compute_item_height(TreeItem *p_item) const {
- if ((p_item == root && hide_root) || !p_item->is_visible()) {
+ if ((p_item == root && hide_root) || !p_item->is_visible_in_tree()) {
return 0;
}
@@ -1848,7 +1871,7 @@ int Tree::compute_item_height(TreeItem *p_item) const {
}
int Tree::get_item_height(TreeItem *p_item) const {
- if (!p_item->is_visible()) {
+ if (!p_item->is_visible_in_tree()) {
return 0;
}
int height = compute_item_height(p_item);
@@ -2050,7 +2073,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
return -1; //draw no more!
}
- if (!p_item->is_visible()) {
+ if (!p_item->is_visible_in_tree()) {
return 0;
}
@@ -2507,7 +2530,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
// Draw relationship lines.
- if (theme_cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root) && c->is_visible()) {
+ if (theme_cache.draw_relationship_lines > 0 && (!hide_root || c->parent != root) && c->is_visible_in_tree()) {
int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? theme_cache.h_separation : theme_cache.item_margin);
int parent_ofs = p_pos.x + theme_cache.item_margin;
Point2i root_pos = Point2i(root_ofs, children_pos.y + child_self_height / 2) - theme_cache.offset + p_draw_ofs;
@@ -2788,7 +2811,7 @@ void Tree::_range_click_timeout() {
}
int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int x_limit, bool p_double_click, TreeItem *p_item, MouseButton p_button, const Ref<InputEventWithModifiers> &p_mod) {
- if (p_item && !p_item->is_visible()) {
+ if (p_item && !p_item->is_visible_in_tree()) {
// Skip any processing of invisible items.
return 0;
}
@@ -4797,7 +4820,7 @@ int Tree::get_item_offset(TreeItem *p_item) const {
return ofs;
}
- if ((it != root || !hide_root) && it->is_visible()) {
+ if ((it != root || !hide_root) && it->is_visible_in_tree()) {
ofs += compute_item_height(it);
ofs += theme_cache.v_separation;
}
@@ -5171,7 +5194,7 @@ void Tree::_do_incr_search(const String &p_add) {
TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int &section) const {
Point2 pos = p_pos;
- if ((root != p_item || !hide_root) && p_item->is_visible()) {
+ if ((root != p_item || !hide_root) && p_item->is_visible_in_tree()) {
h = compute_item_height(p_item) + theme_cache.v_separation;
if (pos.y < h) {
if (drop_mode_flags == DROP_MODE_ON_ITEM) {
@@ -5204,7 +5227,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
h = 0;
}
- if (p_item->is_collapsed() || !p_item->is_visible()) {
+ if (p_item->is_collapsed() || !p_item->is_visible_in_tree()) {
return nullptr; // do not try children, it's collapsed
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 194de1e994..21696d8216 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -129,6 +129,7 @@ private:
bool collapsed = false; // won't show children
bool visible = true;
+ bool parent_visible_in_tree = true;
bool disable_folding = false;
int custom_min_height = 0;
@@ -147,6 +148,8 @@ private:
void _changed_notify();
void _cell_selected(int p_cell);
void _cell_deselected(int p_cell);
+ void _handle_visibility_changed(bool p_visible);
+ void _propagate_visibility_changed(bool p_parent_visible_in_tree);
void _change_tree(Tree *p_tree);
@@ -300,6 +303,7 @@ public:
void set_visible(bool p_visible);
bool is_visible();
+ bool is_visible_in_tree() const;
void uncollapse_tree();
diff --git a/tests/core/string/test_string.h b/tests/core/string/test_string.h
index 8d2607b874..da742d0183 100644
--- a/tests/core/string/test_string.h
+++ b/tests/core/string/test_string.h
@@ -642,48 +642,59 @@ struct test_27_data {
TEST_CASE("[String] Begins with") {
test_27_data tc[] = {
+ // Test cases for true:
{ "res://foobar", "res://", true },
+ { "abc", "abc", true },
+ { "abc", "", true },
+ { "", "", true },
+ // Test cases for false:
{ "res", "res://", false },
- { "abc", "abc", true }
+ { "abcdef", "foo", false },
+ { "abc", "ax", false },
+ { "", "abc", false }
};
size_t count = sizeof(tc) / sizeof(tc[0]);
bool state = true;
- for (size_t i = 0; state && i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
String s = tc[i].data;
state = s.begins_with(tc[i].part) == tc[i].expected;
- if (state) {
- String sb = tc[i].part;
- state = s.begins_with(sb) == tc[i].expected;
- }
- CHECK(state);
- if (!state) {
- break;
- }
- };
- CHECK(state);
+ CHECK_MESSAGE(state, "first check failed at: ", i);
+
+ String sb = tc[i].part;
+ state = s.begins_with(sb) == tc[i].expected;
+ CHECK_MESSAGE(state, "second check failed at: ", i);
+ }
+
+ // Test "const char *" version also with nullptr.
+ String s("foo");
+ state = s.begins_with(nullptr) == false;
+ CHECK_MESSAGE(state, "nullptr check failed");
+
+ String empty("");
+ state = empty.begins_with(nullptr) == false;
+ CHECK_MESSAGE(state, "nullptr check with empty string failed");
}
TEST_CASE("[String] Ends with") {
test_27_data tc[] = {
+ // test cases for true:
{ "res://foobar", "foobar", true },
+ { "abc", "abc", true },
+ { "abc", "", true },
+ { "", "", true },
+ // test cases for false:
{ "res", "res://", false },
- { "abc", "abc", true }
+ { "", "abc", false },
+ { "abcdef", "foo", false },
+ { "abc", "xc", false }
};
size_t count = sizeof(tc) / sizeof(tc[0]);
- bool state = true;
- for (size_t i = 0; state && i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
String s = tc[i].data;
- state = s.ends_with(tc[i].part) == tc[i].expected;
- if (state) {
- String sb = tc[i].part;
- state = s.ends_with(sb) == tc[i].expected;
- }
- CHECK(state);
- if (!state) {
- break;
- }
- };
- CHECK(state);
+ String sb = tc[i].part;
+ bool state = s.ends_with(sb) == tc[i].expected;
+ CHECK_MESSAGE(state, "check failed at: ", i);
+ }
}
TEST_CASE("[String] format") {