Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions doc/classes/EditorDock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@
<constant name="DOCK_LAYOUT_FLOATING" value="4" enum="DockLayout" is_bitfield="true">
Allows making the dock floating (opened as a separate window).
</constant>
<constant name="DOCK_LAYOUT_MAIN_SCREEN" value="8" enum="DockLayout" is_bitfield="true">
Allows using the dock as main screen.
</constant>
<constant name="DOCK_LAYOUT_ALL" value="7" enum="DockLayout" is_bitfield="true">
Allows placing the dock in all available slots.
Allows placing the dock in all available slots, except in main screen.
</constant>
<constant name="DOCK_SLOT_NONE" value="-1" enum="DockSlot">
The dock is closed.
Expand Down Expand Up @@ -194,7 +197,10 @@
<constant name="DOCK_SLOT_BOTTOM_R" value="10" enum="DockSlot">
Dock slot at the bottom, below bottom panel, on the right side.
</constant>
<constant name="DOCK_SLOT_MAX" value="11" enum="DockSlot">
<constant name="DOCK_SLOT_MAIN_SCREEN" value="11" enum="DockSlot">
The editor's main screen.
</constant>
<constant name="DOCK_SLOT_MAX" value="12" enum="DockSlot">
Represents the size of the [enum DockSlot] enum.
</constant>
</constants>
Expand Down
15 changes: 10 additions & 5 deletions doc/classes/EditorInterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@
Returns the current path being viewed in the [FileSystemDock].
</description>
</method>
<method name="get_dock_by_name">
<return type="EditorDock" />
<param index="0" name="name" type="String" />
<description>
Returns an [EditorDock] with the specified [param name]. [param name] must match the original (untranslated) title of the tab in question exactly (e.g., [code]2D[/code], [code]Scene[/code], [code]Audio[/code]). Returns [code]null[/code] if the dock was not found.
</description>
</method>
<method name="get_edited_scene_root" qualifiers="const">
<return type="Node" />
<description>
Expand All @@ -102,12 +109,10 @@
Returns the language currently used for the editor interface.
</description>
</method>
<method name="get_editor_main_screen" qualifiers="const">
<method name="get_editor_main_screen" qualifiers="const" deprecated="This method no longer returns the main screen. Only used for legacy main screen plugins.">
<return type="VBoxContainer" />
<description>
Returns the editor control responsible for main screen plugins and tools. Use it with plugins that implement [method EditorPlugin._has_main_screen].
[b]Note:[/b] This node is a [VBoxContainer], which means that if you add a [Control] child to it, you need to set the child's [member Control.size_flags_vertical] to [constant Control.SIZE_EXPAND_FILL] to make it use the full available space.
[b]Warning:[/b] Removing and freeing this node will render a part of the editor useless and may cause a crash.
Returns the editor control responsible for legacy main screen plugins and tools.
</description>
</method>
<method name="get_editor_paths" qualifiers="const">
Expand Down Expand Up @@ -509,7 +514,7 @@
[b]Note:[/b] The feature profile that gets activated must be located in the [code]feature_profiles[/code] directory, as a file with the [code].profile[/code] extension. If a profile could not be found, an error occurs. The editor configuration folder can be found by using [method EditorPaths.get_config_dir].
</description>
</method>
<method name="set_main_screen_editor">
<method name="set_main_screen_editor" deprecated="Use [method get_dock_by_name] with [method EditorDock.make_visible] instead.">
<return type="void" />
<param index="0" name="name" type="String" />
<description>
Expand Down
32 changes: 6 additions & 26 deletions doc/classes/EditorPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
This is for editors that edit script-based objects. You can return a list of breakpoints in the format ([code]script:line[/code]), for example: [code]res://path_to_script.gd:25[/code].
</description>
</method>
<method name="_get_plugin_icon" qualifiers="virtual const">
<method name="_get_plugin_icon" qualifiers="virtual const" deprecated="Use [member EditorDock.dock_icon] of a main screen dock.">
<return type="Texture2D" />
<description>
Override this method in your plugin to return a [Texture2D] in order to give it an icon.
Expand Down Expand Up @@ -261,6 +261,7 @@
<description>
Override this method in your plugin to provide the name of the plugin when displayed in the Godot editor.
For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", "Game", and "Asset Store" buttons.
[b]Note:[/b] Main screen plugins should instead use [member EditorDock.title] of a main screen dock.
</description>
</method>
<method name="_get_state" qualifiers="virtual const">
Expand Down Expand Up @@ -326,32 +327,11 @@
[b]Note:[/b] Each plugin should handle only one type of objects at a time. If a plugin handles more types of objects and they are edited at the same time, it will result in errors.
</description>
</method>
<method name="_has_main_screen" qualifiers="virtual const">
<method name="_has_main_screen" qualifiers="virtual const" deprecated="Use [method add_dock] instead, with [member EditorDock.default_slot] set to [constant EditorDock.DOCK_SLOT_MAIN_SCREEN].">
<return type="bool" />
<description>
Returns [code]true[/code] if this is a main screen editor plugin (it goes in the workspace selector together with [b]2D[/b], [b]3D[/b], [b]Script[/b], [b]Game[/b], and [b]Asset Store[/b]).
When the plugin's workspace is selected, other main screen plugins will be hidden, but your plugin will not appear automatically. It needs to be added as a child of [method EditorInterface.get_editor_main_screen] and made visible inside [method _make_visible].
Use [method _get_plugin_name] and [method _get_plugin_icon] to customize the plugin button's appearance.
[codeblock]
var plugin_control

func _enter_tree():
plugin_control = preload("my_plugin_control.tscn").instantiate()
EditorInterface.get_editor_main_screen().add_child(plugin_control)
plugin_control.hide()

func _has_main_screen():
return true

func _make_visible(visible):
plugin_control.visible = visible

func _get_plugin_name():
return "My Super Cool Plugin 3000"

func _get_plugin_icon():
return EditorInterface.get_editor_theme().get_icon("Node", "EditorIcons")
[/codeblock]
Return [code]true[/code] if this is a main screen editor plugin (it goes in the workspace selector together with [b]2D[/b], [b]3D[/b], [b]Script[/b], [b]Game[/b], and [b]Asset Store[/b]).
You can add a main screen dock by using [EditorDock] with [constant EditorDock.DOCK_LAYOUT_MAIN_SCREEN] as available layout.
</description>
</method>
<method name="_make_visible" qualifiers="virtual">
Expand Down Expand Up @@ -424,7 +404,7 @@
[b]Note:[/b] A plugin instance can belong only to a single context menu slot.
</description>
</method>
<method name="add_control_to_bottom_panel" deprecated="Use [method add_dock] instead, with [member EditorDock.default_slot] set to [constant DOCK_SLOT_BOTTOM].">
<method name="add_control_to_bottom_panel" deprecated="Use [method add_dock] instead, with [member EditorDock.default_slot] set to [constant EditorDock.DOCK_SLOT_BOTTOM].">
<return type="Button" />
<param index="0" name="control" type="Control" />
<param index="1" name="title" type="String" />
Expand Down
3 changes: 3 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@
<member name="interface/editor/docks/dock_tab_style" type="int" setter="" getter="">
Tab style of editor docks, except bottom docks.
</member>
<member name="interface/editor/docks/main_screen_dock_tab_style" type="int" setter="" getter="">
Tab style of editor docks located at the editor's main screen.
</member>
<member name="interface/editor/fonts/code_font" type="String" setter="" getter="">
The font to use for the script editor. Must be a resource of a [Font] type such as a [code].ttf[/code] or [code].otf[/code] font file.
</member>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/ScriptEditor.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ScriptEditor" inherits="PanelContainer" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<class name="ScriptEditor" inherits="EditorDock" api_type="editor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Godot editor's script editor.
</brief_description>
Expand Down
41 changes: 35 additions & 6 deletions editor/asset_library/asset_library_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/version.h"
#include "editor/docks/editor_dock_manager.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
Expand Down Expand Up @@ -1047,6 +1048,12 @@ void EditorAssetLibrary::_notification(int p_what) {
case NOTIFICATION_READY: {
add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("bg"), SNAME("AssetLib")));
error_label->move_to_front();

if (EditorNode::get_singleton()) {
EditorNode::get_singleton()->get_gui_base()->connect(SceneStringName(theme_changed), callable_mp(this, &EditorAssetLibrary::_update_margins));
} else if (ProjectManager::get_singleton()) {
ProjectManager::get_singleton()->connect(SceneStringName(theme_changed), callable_mp(this, &EditorAssetLibrary::_update_margins));
}
} break;

case NOTIFICATION_TRANSLATION_CHANGED: {
Expand All @@ -1069,7 +1076,7 @@ void EditorAssetLibrary::_notification(int p_what) {
// Focus the search box automatically when switching to the Templates tab (in the Project Manager)
// or switching to the AssetLib tab (in the editor).
// The Project Manager's project filter box is automatically focused in the project manager code.
filter->grab_focus();
callable_mp((Control *)filter, &Control::grab_focus).call_deferred(false);
#endif

if (initial_loading) {
Expand Down Expand Up @@ -1167,6 +1174,10 @@ void EditorAssetLibrary::_update_repository_options() {
}
}

void EditorAssetLibrary::_update_margins() {
update_layout(get_current_layout(), get_current_slot());
}

void EditorAssetLibrary::shortcut_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());

Expand All @@ -1181,6 +1192,21 @@ void EditorAssetLibrary::shortcut_input(const Ref<InputEvent> &p_event) {
}
}

void EditorAssetLibrary::update_layout(EditorDock::DockLayout p_layout, int p_slot) {
Comment thread
KoBeWi marked this conversation as resolved.
begin_bulk_theme_override();
if (p_layout == DOCK_LAYOUT_FLOATING) {
remove_theme_constant_override("margin_left");
remove_theme_constant_override("margin_right");
remove_theme_constant_override("margin_bottom");
} else {
int margin = EditorNode::get_singleton()->get_editor_theme()->get_constant("base_margin", EditorStringName(Editor));
add_theme_constant_override("margin_left", margin);
add_theme_constant_override("margin_right", margin);
add_theme_constant_override("margin_bottom", margin);
}
end_bulk_theme_override();
}

void EditorAssetLibrary::_install_asset(const String &p_asset_id, const String &p_version, const String &p_download_url, const String &p_sha256) {
ERR_FAIL_NULL(description);

Expand Down Expand Up @@ -2136,6 +2162,13 @@ void EditorAssetLibrary::_bind_methods() {
}

EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
set_name(TTRC("Asset Store"));
set_icon_name("AssetStore");
set_available_layouts(EditorDock::DOCK_LAYOUT_MAIN_SCREEN | EditorDock::DOCK_LAYOUT_FLOATING);
set_default_slot(EditorDock::DOCK_SLOT_MAIN_SCREEN);
if (!Engine::get_singleton()->is_project_manager_hint()) {
set_dock_shortcut(ED_GET_SHORTCUT("editor/editor_asset_store"));
}
templates_only = p_templates_only;
loading_blocked = ((int)EDITOR_GET("network/connection/network_mode") == EditorSettings::NETWORK_OFFLINE);

Expand Down Expand Up @@ -2342,10 +2375,6 @@ bool AssetLibraryEditorPlugin::is_available() {
#endif
}

const Ref<Texture2D> AssetLibraryEditorPlugin::get_plugin_icon() const {
return EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("AssetStore"), EditorStringName(EditorIcons));
}

void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
addon_library->show();
Expand All @@ -2357,7 +2386,7 @@ void AssetLibraryEditorPlugin::make_visible(bool p_visible) {
AssetLibraryEditorPlugin::AssetLibraryEditorPlugin() {
addon_library = memnew(EditorAssetLibrary);
addon_library->set_v_size_flags(Control::SIZE_EXPAND_FILL);
EditorNode::get_singleton()->get_editor_main_screen()->get_control()->add_child(addon_library);
EditorDockManager::get_singleton()->add_dock(addon_library);
addon_library->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT);
addon_library->hide();
}
14 changes: 8 additions & 6 deletions editor/asset_library/asset_library_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#pragma once

#include "editor/asset_library/editor_asset_installer.h"
#include "editor/docks/editor_dock.h"
#include "editor/plugins/editor_plugin.h"
#include "scene/gui/box_container.h"
#include "scene/gui/grid_container.h"
Expand Down Expand Up @@ -249,8 +250,8 @@ class EditorAssetLibraryItemDownload : public MarginContainer {
EditorAssetLibraryItemDownload();
};

class EditorAssetLibrary : public PanelContainer {
GDCLASS(EditorAssetLibrary, PanelContainer);
class EditorAssetLibrary : public EditorDock {
GDCLASS(EditorAssetLibrary, EditorDock);

String host;

Expand All @@ -260,6 +261,7 @@ class EditorAssetLibrary : public PanelContainer {
void _asset_open();
void _asset_file_selected(const String &p_file);
void _update_repository_options();
void _update_margins();

MarginContainer *library_mc = nullptr;
ScrollContainer *library_scroll = nullptr;
Expand Down Expand Up @@ -400,6 +402,7 @@ class EditorAssetLibrary : public PanelContainer {
static void _bind_methods();
void _notification(int p_what);
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
virtual void update_layout(EditorDock::DockLayout p_layout, int p_slot) override;

public:
EditorAssetLibrary(bool p_templates_only = false);
Expand All @@ -408,14 +411,13 @@ class EditorAssetLibrary : public PanelContainer {
class AssetLibraryEditorPlugin : public EditorPlugin {
GDCLASS(AssetLibraryEditorPlugin, EditorPlugin);

EditorAssetLibrary *addon_library = nullptr;
static inline EditorAssetLibrary *addon_library = nullptr;

public:
static bool is_available();
static EditorAssetLibrary *get_library() { return addon_library; }

virtual String get_plugin_name() const override { return TTRC("Asset Store"); }
virtual const Ref<Texture2D> get_plugin_icon() const override;
bool has_main_screen() const override { return true; }
virtual String get_plugin_name() const override { return "Asset Store"; }
virtual void edit(Object *p_object) override {}
virtual bool handles(Object *p_object) const override { return false; }
virtual void make_visible(bool p_visible) override;
Expand Down
5 changes: 2 additions & 3 deletions editor/doc/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "core/version.h"
#include "editor/doc/doc_data_compressed.gen.h"
#include "editor/docks/filesystem_dock.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/file_system/editor_file_system.h"
Expand Down Expand Up @@ -2355,7 +2354,7 @@ void EditorHelp::_update_doc() {
void EditorHelp::_request_help(const String &p_string) {
Error err = _goto_desc(p_string, false);
if (err == OK) {
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
ScriptEditor::get_singleton()->focus_editor();
}
}

Expand Down Expand Up @@ -4360,7 +4359,7 @@ void EditorHelpBit::_go_to_url(const String &p_what) {

void EditorHelpBit::_go_to_help(const String &p_what) {
if (ScriptEditor::get_singleton()) {
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
ScriptEditor::get_singleton()->focus_editor();
ScriptEditor::get_singleton()->goto_help(p_what);
} else {
_go_to_url(p_what);
Expand Down
4 changes: 2 additions & 2 deletions editor/doc/editor_help_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
#include "core/object/callable_mp.h"
#include "core/object/class_db.h"
#include "core/os/os.h"
#include "editor/editor_main_screen.h"
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "editor/gui/filter_line_edit.h"
#include "editor/script/script_editor_plugin.h"
#include "editor/settings/editor_feature_profile.h"
#include "editor/settings/editor_settings.h"
#include "editor/themes/editor_scale.h"
Expand Down Expand Up @@ -189,7 +189,7 @@ void EditorHelpSearch::_confirmed() {
}

// Activate the script editor and emit the signal with the documentation link to display.
EditorNode::get_singleton()->get_editor_main_screen()->select(EditorMainScreen::EDITOR_SCRIPT);
ScriptEditor::get_singleton()->focus_editor();

emit_signal(SNAME("go_to_help"), item->get_metadata(0));

Expand Down
19 changes: 15 additions & 4 deletions editor/docks/dock_tab_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ bool EditorDockDragHint::can_drop_data(const Point2 &p_point, const Variant &p_d
void EditorDockDragHint::drop_data(const Point2 &p_point, const Variant &p_data) {
// Drop dock into last spot if not over tabbar.
if (mouse_inside_tabbar) {
drop_tabbar->_handle_drop_data("tab_container_tab", p_point, p_data, callable_mp(this, &EditorDockDragHint::_drag_move_tab), callable_mp(this, &EditorDockDragHint::_drag_move_tab_from));
drop_tabbar->_handle_drop_data("tab_container_tab", p_point - (drop_tabbar->get_global_position() - get_global_position()), p_data, callable_mp(this, &EditorDockDragHint::_drag_move_tab), callable_mp(this, &EditorDockDragHint::_drag_move_tab_from));
} else {
EditorDockManager *dock_manager = EditorDockManager::get_singleton();
if (mouse_margin_index == -1) {
Expand Down Expand Up @@ -77,7 +77,7 @@ void EditorDockDragHint::gui_input(const Ref<InputEvent> &p_event) {
queue_redraw();
}
const Point2 pos = mm->get_position();
mouse_inside_tabbar = drop_tabbar_parent->get_rect().has_point(pos);
mouse_inside_tabbar = drop_tabbar_parent->get_global_rect().has_point(mm->get_global_position());

if (mouse_inside_tabbar) {
mouse_margin_index = -1;
Expand Down Expand Up @@ -194,7 +194,7 @@ void EditorDockDragHint::_notification(int p_what) {

// Only display tabbar hint if the mouse is over the tabbar.
if (mouse_inside_tabbar) {
draw_set_transform(drop_tabbar_parent->get_position()); // The TabBar isn't always on top.
draw_set_transform(Vector2(drop_tabbar->get_global_position().x - get_global_position().x, drop_tabbar_parent->get_position().y)); // The TabBar isn't always on top.
drop_tabbar->_draw_tab_drop(get_canvas_item());
}
} break;
Expand Down Expand Up @@ -317,11 +317,22 @@ EditorDock *DockTabContainer::get_dock(int p_idx) const {
return Object::cast_to<EditorDock>(get_tab_control(p_idx));
}

EditorDock *DockTabContainer::get_dock_by_name(const String &p_name) const {
for (int i = 0; i < get_tab_count(); i++) {
EditorDock *dock = get_dock(i);
ERR_CONTINUE(!dock);
if (dock->get_display_title() == p_name) {
return dock;
}
}
return nullptr;
}

void DockTabContainer::show_drag_hint() {
if (!is_visible_in_tree()) {
return;
}
drag_hint->set_rect(get_global_rect());
drag_hint->set_rect(get_drag_hint_rect());
drag_hint->show();
}

Expand Down
Loading