diff --git a/doc/classes/EditorDock.xml b/doc/classes/EditorDock.xml index 0aaefc0720f..86457706cd2 100644 --- a/doc/classes/EditorDock.xml +++ b/doc/classes/EditorDock.xml @@ -67,6 +67,12 @@ Closes the dock, making its tab hidden. + + + + Focuses the dock's tab (or window if it's floating). If the dock was closed, it will be opened. If it's a bottom dock, makes the bottom panel visible. + + diff --git a/editor/docks/editor_dock.cpp b/editor/docks/editor_dock.cpp index 1214fc4d22b..a38a2851805 100644 --- a/editor/docks/editor_dock.cpp +++ b/editor/docks/editor_dock.cpp @@ -41,6 +41,7 @@ void EditorDock::_set_default_slot_bind(EditorPlugin::DockSlot p_slot) { void EditorDock::_bind_methods() { ClassDB::bind_method(D_METHOD("open"), &EditorDock::open); + ClassDB::bind_method(D_METHOD("make_visible"), &EditorDock::make_visible); ClassDB::bind_method(D_METHOD("close"), &EditorDock::close); ClassDB::bind_method(D_METHOD("set_title", "title"), &EditorDock::set_title); @@ -108,6 +109,10 @@ void EditorDock::open() { } } +void EditorDock::make_visible() { + EditorDockManager::get_singleton()->focus_dock(this); +} + void EditorDock::close() { if (is_open) { EditorDockManager::get_singleton()->close_dock(this); diff --git a/editor/docks/editor_dock.h b/editor/docks/editor_dock.h index abfa2ecdebe..60547f83c93 100644 --- a/editor/docks/editor_dock.h +++ b/editor/docks/editor_dock.h @@ -87,6 +87,7 @@ public: EditorDock(); void open(); + void make_visible(); void close(); void set_title(const String &p_title); diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs index 4ea212ad5f6..8cb8f21c2df 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs @@ -52,7 +52,7 @@ namespace GodotTools.Build { var plugin = GodotSharpEditor.Instance; plugin.ShowErrorDialog(message, "Build error"); - plugin.MakeBottomPanelItemVisible(plugin.MSBuildPanel); + plugin.MSBuildPanel.MakeVisible(); } private static string GetLogFilePath(BuildInfo buildInfo) diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs index 986da478605..9421ee73559 100644 --- a/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs +++ b/modules/mono/editor/GodotTools/GodotTools/Build/MSBuildPanel.cs @@ -7,11 +7,8 @@ using File = GodotTools.Utils.File; namespace GodotTools.Build { - public partial class MSBuildPanel : MarginContainer, ISerializationListener + public partial class MSBuildPanel : EditorDock, ISerializationListener { - [Signal] - public delegate void BuildStateChangedEventHandler(); - #nullable disable private MenuButton _buildMenuButton; private Button _openLogsFolderButton; @@ -27,21 +24,23 @@ namespace GodotTools.Build private readonly object _pendingBuildLogTextLock = new object(); private string _pendingBuildLogText = string.Empty; - public Texture2D? GetBuildStateIcon() + public void UpdateBuildStateIcon() { + Texture2D? icon = null; if (IsBuildingOngoing) - return GetThemeIcon("Stop", "EditorIcons"); + icon = GetThemeIcon("Stop", "EditorIcons"); if (_problemsView.WarningCount > 0 && _problemsView.ErrorCount > 0) - return GetThemeIcon("ErrorWarning", "EditorIcons"); + icon = GetThemeIcon("ErrorWarning", "EditorIcons"); if (_problemsView.WarningCount > 0) - return GetThemeIcon("Warning", "EditorIcons"); + icon = GetThemeIcon("Warning", "EditorIcons"); if (_problemsView.ErrorCount > 0) - return GetThemeIcon("Error", "EditorIcons"); + icon = GetThemeIcon("Error", "EditorIcons"); - return null; + DockIcon = icon; + ForceShowIcon = icon != null; } private enum BuildMenuOptions @@ -142,7 +141,7 @@ namespace GodotTools.Build _problemsView.SetDiagnostics(new[] { diagnostic }); - EmitSignal(SignalName.BuildStateChanged); + UpdateBuildStateIcon(); } private void BuildStarted(BuildInfo buildInfo) @@ -156,7 +155,7 @@ namespace GodotTools.Build _problemsView.UpdateProblemsView(); - EmitSignal(SignalName.BuildStateChanged); + UpdateBuildStateIcon(); } private void BuildFinished(BuildResult result) @@ -169,7 +168,7 @@ namespace GodotTools.Build _problemsView.UpdateProblemsView(); - EmitSignal(SignalName.BuildStateChanged); + UpdateBuildStateIcon(); } private void UpdateBuildLogText() @@ -201,6 +200,17 @@ namespace GodotTools.Build } } + public MSBuildPanel() + { + Name = "MSBuild".TTR(); + IconName = "BuildCSharp"; + DefaultSlot = EditorPlugin.DockSlot.Bottom; + AvailableLayouts = DockLayout.Horizontal | DockLayout.Floating; + Global = false; + Transient = true; + ClipContents = false; + } + public override void _Ready() { base._Ready(); diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index 955a413e092..6bc8f1d41a8 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -118,7 +118,7 @@ namespace GodotTools private void _ShowDotnetFeatures() { - _bottomPanelBtn.Show(); + MSBuildPanel.Open(); _toolBarBuildButton.Show(); } @@ -456,12 +456,6 @@ namespace GodotTools } } - private void BuildStateChanged() - { - if (_bottomPanelBtn != null) - _bottomPanelBtn.Icon = MSBuildPanel.GetBuildStateIcon(); - } - public override void _EnablePlugin() { base._EnablePlugin(); @@ -511,8 +505,7 @@ namespace GodotTools _confirmCreateSlnDialog.Confirmed += () => CreateProjectSolution(); MSBuildPanel = new MSBuildPanel(); - MSBuildPanel.BuildStateChanged += BuildStateChanged; - _bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR()); + AddDock(MSBuildPanel); AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" }); @@ -546,7 +539,7 @@ namespace GodotTools } else { - _bottomPanelBtn.Hide(); + MSBuildPanel.Close(); _toolBarBuildButton.Hide(); } _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln); @@ -657,9 +650,6 @@ namespace GodotTools base._DisablePlugin(); _editorSettings.SettingsChanged -= OnSettingsChanged; - - // Custom signals aren't automatically disconnected currently. - MSBuildPanel.BuildStateChanged -= BuildStateChanged; } public override void _ExitTree()