diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FileContextMenu.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FileContextMenu.cs new file mode 100644 index 0000000..dcf2495 --- /dev/null +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FileContextMenu.cs @@ -0,0 +1,45 @@ +using Godot; +using SharpIDE.Application.Features.SolutionDiscovery; + +namespace SharpIDE.Godot.Features.SolutionExplorer; + +file enum FileContextMenuOptions +{ + Open = 0, + RevealInFileExplorer = 1, + CopyFullPath = 2 +} + +public partial class SolutionExplorerPanel +{ + private void OpenContextMenuFile(SharpIdeFile file) + { + var menu = new PopupMenu(); + AddChild(menu); + menu.AddItem("Open", (int)FileContextMenuOptions.Open); + menu.AddItem("Reveal in File Explorer", (int)FileContextMenuOptions.RevealInFileExplorer); + menu.AddSeparator(); + menu.AddItem("Copy Full Path", (int)FileContextMenuOptions.CopyFullPath); + menu.PopupHide += () => menu.QueueFree(); + menu.IdPressed += id => + { + var actionId = (FileContextMenuOptions)id; + if (actionId is FileContextMenuOptions.Open) + { + GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(file, null); + } + else if (actionId is FileContextMenuOptions.RevealInFileExplorer) + { + OS.ShellOpen(Path.GetDirectoryName(file.Path)!); + } + else if (actionId is FileContextMenuOptions.CopyFullPath) + { + DisplayServer.ClipboardSet(file.Path); + } + }; + + var globalMousePosition = GetGlobalMousePosition(); + menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y); + menu.Popup(); + } +} \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs new file mode 100644 index 0000000..c133d42 --- /dev/null +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/FolderContextMenu.cs @@ -0,0 +1,32 @@ +using Godot; +using SharpIDE.Application.Features.SolutionDiscovery; + +namespace SharpIDE.Godot.Features.SolutionExplorer; + +file enum FolderContextMenuOptions +{ + RevealInFileExplorer = 1 +} + +public partial class SolutionExplorerPanel +{ + private void OpenContextMenuFolder(SharpIdeFolder folder) + { + var menu = new PopupMenu(); + AddChild(menu); + menu.AddItem("Reveal in File Explorer", (int)FolderContextMenuOptions.RevealInFileExplorer); + menu.PopupHide += () => menu.QueueFree(); + menu.IdPressed += id => + { + var actionId = (FolderContextMenuOptions)id; + if (actionId is FolderContextMenuOptions.RevealInFileExplorer) + { + OS.ShellOpen(folder.Path); + } + }; + + var globalMousePosition = GetGlobalMousePosition(); + menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y); + menu.Popup(); + } +} \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/ProjectContextMenu.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/ProjectContextMenu.cs new file mode 100644 index 0000000..8e11646 --- /dev/null +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/ContextMenus/ProjectContextMenu.cs @@ -0,0 +1,57 @@ +using Godot; +using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence; + +namespace SharpIDE.Godot.Features.SolutionExplorer; + +file enum ProjectContextMenuOptions +{ + Run = 0, + Build = 1, + Rebuild = 2, + Clean = 3, + Restore = 4 +} + +public partial class SolutionExplorerPanel +{ + private void OpenContextMenuProject(SharpIdeProjectModel project) + { + var menu = new PopupMenu(); + AddChild(menu); + menu.AddItem("Run", (int)ProjectContextMenuOptions.Run); + menu.AddSeparator(); + menu.AddItem("Build", (int)ProjectContextMenuOptions.Build); + menu.AddItem("Rebuild", (int)ProjectContextMenuOptions.Rebuild); + menu.AddItem("Clean", (int)ProjectContextMenuOptions.Clean); + menu.AddItem("Restore", (int)ProjectContextMenuOptions.Restore); + menu.PopupHide += () => menu.QueueFree(); + menu.IdPressed += id => + { + var actionId = (ProjectContextMenuOptions)id; + if (actionId is ProjectContextMenuOptions.Run) + { + + } + if (actionId is ProjectContextMenuOptions.Build) + { + + } + else if (actionId is ProjectContextMenuOptions.Rebuild) + { + + } + else if (actionId is ProjectContextMenuOptions.Clean) + { + + } + else if (actionId is ProjectContextMenuOptions.Restore) + { + + } + }; + + var globalMousePosition = GetGlobalMousePosition(); + menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y); + menu.Popup(); + } +} \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs b/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs index ef63b48..07fbe40 100644 --- a/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs +++ b/src/SharpIDE.Godot/Features/SolutionExplorer/SolutionExplorerPanel.cs @@ -50,99 +50,6 @@ public partial class SolutionExplorerPanel : MarginContainer } } - private void OpenContextMenuFolder(SharpIdeFolder folder) - { - var menu = new PopupMenu(); - AddChild(menu); - menu.AddItem("Reveal in File Explorer", 0); - menu.PopupHide += () => menu.QueueFree(); - menu.IdPressed += id => - { - if (id is 0) - { - // Reveal in File Explorer - OS.ShellOpen(folder.Path); - } - }; - - var globalMousePosition = GetGlobalMousePosition(); - menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y); - menu.Popup(); - } - - private void OpenContextMenuProject(SharpIdeProjectModel project) - { - var menu = new PopupMenu(); - AddChild(menu); - menu.AddItem("Run", 0); - menu.AddSeparator(); - menu.AddItem("Build", 1); - menu.AddItem("Rebuild", 2); - menu.AddItem("Clean", 3); - menu.PopupHide += () => - { - GD.Print("QueueFree menu"); - menu.QueueFree(); - }; - menu.IdPressed += id => - { - if (id is 0) - { - // Run project - } - if (id is 1) - { - // Build project - } - else if (id is 2) - { - // Rebuild project - } - else if (id is 3) - { - // Clean project - } - }; - - var globalMousePosition = GetGlobalMousePosition(); - menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y); - menu.Popup(); - } - - private void OpenContextMenuFile(SharpIdeFile file) - { - var menu = new PopupMenu(); - AddChild(menu); - menu.AddItem("Open", 0); - menu.AddItem("Reveal in File Explorer", 1); - menu.AddSeparator(); - menu.AddItem("Copy Full Path", 2); - menu.PopupHide += () => - { - GD.Print("QueueFree menu"); - menu.QueueFree(); - }; - menu.IdPressed += id => - { - if (id is 0) - { - GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(file, null); - } - else if (id is 1) - { - OS.ShellOpen(Path.GetDirectoryName(file.Path)!); - } - else if (id is 2) - { - DisplayServer.ClipboardSet(file.Path); - } - }; - - var globalMousePosition = GetGlobalMousePosition(); - menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y); - menu.Popup(); - } - private async Task OnFileExternallySelected(SharpIdeFile file, SharpIdeFileLinePosition? fileLinePosition) { await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);