Now full screen editor plugins have the ability to hide their tab button in the top bar.

This commit is contained in:
Relintai 2022-08-20 17:20:34 +02:00
parent 7e7126f2b0
commit 98acdf8270
5 changed files with 74 additions and 45 deletions

View File

@ -219,7 +219,15 @@
<return type="void" />
<argument index="0" name="name" type="String" />
<description>
Sets the editor's current main screen to the one specified in [code]name[/code]. [code]name[/code] must match the text of the tab in question exactly ([code]2D[/code], [code]3D[/code], [code]Script[/code], [code]AssetLib[/code]).
Sets the editor's current main screen to the one specified in [code]name[/code]. It will also make the editor's tab button at the top to be visible if it weren't. [code]name[/code] must match the text of the tab in question exactly like: [code]2D[/code], [code]3D[/code], [code]Script[/code].
</description>
</method>
<method name="set_main_screen_editor_tab_button_visible">
<return type="void" />
<argument index="0" name="name" type="String" />
<argument index="1" name="visible" type="bool" />
<description>
Sets whether the specified main screen's button is visible or not. Will not change the main screen. [code]name[/code] must match the text of the tab in question exactly like: [code]2D[/code], [code]3D[/code], [code]Script[/code], [code]AssetLib[/code].
</description>
</method>
<method name="set_plugin_enabled">

View File

@ -32,34 +32,35 @@
#include <stdlib.h>
#include "core/variant/array.h"
#include "core/object/class_db.h"
#include "core/math/color.h"
#include "core/config/engine.h"
#include "core/config/project_settings.h"
#include "core/containers/pool_vector.h"
#include "core/error/error_macros.h"
#include "core/io/image.h"
#include "core/input/input.h"
#include "core/input/input_event.h"
#include "core/input/shortcut.h"
#include "core/io/config_file.h"
#include "core/io/image.h"
#include "core/io/image_loader.h"
#include "core/io/resource_importer.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/math/color.h"
#include "core/math/math_defs.h"
#include "core/math/vector2.h"
#include "core/object/class_db.h"
#include "core/object/object_id.h"
#include "core/object/script_language.h"
#include "core/object/undo_redo.h"
#include "core/os/dir_access.h"
#include "core/os/file_access.h"
#include "core/input/input.h"
#include "core/input/input_event.h"
#include "core/os/keyboard.h"
#include "core/os/main_loop.h"
#include "core/os/memory.h"
#include "core/os/os.h"
#include "core/containers/pool_vector.h"
#include "core/string/print_string.h"
#include "core/config/project_settings.h"
#include "core/object/script_language.h"
#include "core/string/translation.h"
#include "core/object/undo_redo.h"
#include "core/variant/array.h"
#include "core/version.h"
#include "core/version_generated.gen.h"
#include "editor/animation_track_editor.h"
@ -177,7 +178,6 @@
#include "scene/gui/popup_menu.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/scroll_bar.h"
#include "core/input/shortcut.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/tabs.h"
@ -3071,6 +3071,7 @@ void EditorNode::select_editor_by_name(const String &p_name) {
for (int i = 0; i < main_editor_buttons.size(); i++) {
if (main_editor_buttons[i]->get_text() == p_name) {
main_editor_buttons[i]->set_visible(true);
_editor_select(i);
return;
}
@ -3079,6 +3080,19 @@ void EditorNode::select_editor_by_name(const String &p_name) {
ERR_FAIL_MSG("The editor name '" + p_name + "' was not found.");
}
void EditorNode::editor_set_visible_by_name(const String &p_name, const bool p_visible) {
ERR_FAIL_COND(p_name == "");
for (int i = 0; i < main_editor_buttons.size(); i++) {
if (main_editor_buttons[i]->get_text() == p_name) {
main_editor_buttons[i]->set_visible(p_visible);
return;
}
}
ERR_FAIL_MSG("The editor name '" + p_name + "' was not found.");
}
void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed) {
if (p_editor->has_main_screen()) {
ToolButton *tb = memnew(ToolButton);

View File

@ -230,6 +230,7 @@ public:
void hide_top_editors();
void select_editor_by_name(const String &p_name);
void editor_set_visible_by_name(const String &p_name, const bool p_visible);
void open_request(const String &p_path);

View File

@ -30,50 +30,50 @@
#include "editor_plugin.h"
#include "core/containers/pool_vector.h"
#include "core/containers/rid.h"
#include "core/containers/rid_handle.h"
#include "core/input/input_event.h"
#include "core/io/image.h"
#include "core/io/resource_importer.h"
#include "core/math/aabb.h"
#include "core/math/basis.h"
#include "core/math/color.h"
#include "core/math/math_defs.h"
#include "core/math/transform.h"
#include "core/math/vector3.h"
#include "core/object/class_db.h"
#include "core/object/resource.h"
#include "core/object/script_language.h"
#include "core/typedefs.h"
#include "editor/editor_autoload_settings.h"
#include "editor/editor_data.h"
#include "editor/editor_export.h"
#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/filesystem_dock.h"
#include "editor/import/editor_import_plugin.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/plugins/script_editor_plugin.h"
#include "editor/project_settings_editor.h"
#include "editor/script_create_dialog.h"
#include "editor_resource_preview.h"
#include "main/main.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
#include "scene/3d/camera.h"
#include "scene/gui/popup_menu.h"
#include "servers/rendering_server.h"
#include "core/object/class_db.h"
#include "core/math/color.h"
#include "core/io/image.h"
#include "core/io/resource_importer.h"
#include "core/math/aabb.h"
#include "core/math/basis.h"
#include "core/math/math_defs.h"
#include "core/math/transform.h"
#include "core/math/vector3.h"
#include "core/input/input_event.h"
#include "core/containers/pool_vector.h"
#include "core/object/resource.h"
#include "core/containers/rid.h"
#include "core/containers/rid_handle.h"
#include "core/object/script_language.h"
#include "core/typedefs.h"
#include "editor/editor_autoload_settings.h"
#include "editor/editor_data.h"
#include "editor/editor_file_system.h"
#include "editor/editor_inspector.h"
#include "editor/editor_scale.h"
#include "editor/import/editor_import_plugin.h"
#include "editor/import/resource_importer_scene.h"
#include "editor/plugins/script_editor_plugin.h"
#include "scene/gui/box_container.h"
#include "scene/gui/container.h"
#include "scene/gui/control.h"
#include "scene/gui/popup_menu.h"
#include "scene/gui/split_container.h"
#include "scene/gui/tab_container.h"
#include "scene/resources/mesh.h"
#include "scene/resources/texture.h"
#include "editor/script_create_dialog.h"
#include "servers/rendering_server.h"
class ConfigFile;
class ScriptCreateDialog;
@ -189,6 +189,10 @@ void EditorInterface::set_main_screen_editor(const String &p_name) {
EditorNode::get_singleton()->select_editor_by_name(p_name);
}
void EditorInterface::set_main_screen_editor_tab_button_visible(const String &p_name, const bool p_visible) {
EditorNode::get_singleton()->editor_set_visible_by_name(p_name, p_visible);
}
Control *EditorInterface::get_editor_viewport() {
return EditorNode::get_singleton()->get_viewport();
}
@ -387,6 +391,7 @@ void EditorInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
ClassDB::bind_method(D_METHOD("set_main_screen_editor_tab_button_visible", "name", "visible"), &EditorInterface::set_main_screen_editor_tab_button_visible);
ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);

View File

@ -36,20 +36,20 @@
#include "scene/resources/texture.h"
#include "core/variant/array.h"
#include "core/variant/dictionary.h"
#include "core/containers/list.h"
#include "core/containers/vector.h"
#include "core/error/error_list.h"
#include "core/error/error_macros.h"
#include "core/io/config_file.h"
#include "core/containers/list.h"
#include "core/object/method_bind.h"
#include "core/object/object.h"
#include "core/os/memory.h"
#include "core/object/reference.h"
#include "core/object/undo_redo.h"
#include "core/os/memory.h"
#include "core/string/ustring.h"
#include "core/variant/array.h"
#include "core/variant/dictionary.h"
#include "core/variant/variant.h"
#include "core/containers/vector.h"
class EditorNode;
class Spatial;
@ -138,6 +138,7 @@ public:
Vector<Ref<Texture>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size);
void set_main_screen_editor(const String &p_name);
void set_main_screen_editor_tab_button_visible(const String &p_name, const bool p_visible);
void set_distraction_free_mode(bool p_enter);
bool is_distraction_free_mode_enabled() const;