run panel and run menu v1

This commit is contained in:
Matt Parker
2025-08-25 18:15:11 +10:00
parent 01844228ef
commit 26ac3e5724
11 changed files with 223 additions and 26 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bnprs1lvjyaji"
path="res://.godot/imported/Play.png-f33bbb4899ca2148d51910992d85a9eb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Features/Run/Play.png"
dest_files=["res://.godot/imported/Play.png-f33bbb4899ca2148d51910992d85a9eb.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using GDExtensionBindgen;
using Godot;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
namespace SharpIDE.Godot.Features.Run;
public partial class RunPanel : Control
{
private Terminal _terminal = null!;
private TabBar _tabBar = null!;
private Panel _tabsPanel = null!;
public override void _Ready()
{
_tabBar = GetNode<TabBar>("%TabBar");
_tabsPanel = GetNode<Panel>("%TabsPanel");
var test = GetNode<Control>("VBoxContainer/TabsPanel/Terminal");
_terminal = new Terminal(test);
_terminal.Write("Hello from SharpIDE.Godot!\n");
}
public override void _Process(double delta)
{
//_terminal.Write("a");
}
public void NewRunStarted(SharpIdeProjectModel projectModel)
{
var terminal = new Terminal();
_tabBar.AddTab(projectModel.Name);
_tabsPanel.AddChild(terminal);
}
}

View File

@@ -0,0 +1 @@
uid://ddivigavjclyb

View File

@@ -0,0 +1,42 @@
[gd_scene load_steps=2 format=3 uid="uid://bcoytt3bw0gpe"]
[ext_resource type="Script" uid="uid://ddivigavjclyb" path="res://Features/Run/RunPanel.cs" id="1_sq1l4"]
[node name="RunPanel" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_sq1l4")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
[node name="TabBar" type="TabBar" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
current_tab = 0
tab_close_display_policy = 2
tab_count = 1
tab_0/title = "WebApi"
[node name="TabsPanel" type="Panel" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="Terminal" type="Terminal" parent="VBoxContainer/TabsPanel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

View File

@@ -0,0 +1 @@
global using static SharpIDE.Godot.NodeExtensions;

View File

@@ -0,0 +1 @@
uid://dv0ry6n8t1vb

View File

@@ -1,11 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Godot;
using Microsoft.Build.Locator;
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Debugging;
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
using SharpIDE.Godot.Features.Run;
namespace SharpIDE.Godot;
@@ -15,39 +15,62 @@ public partial class IdeRoot : Control
private FileDialog _fileDialog = null!;
private SharpIdeCodeEdit _sharpIdeCodeEdit = null!;
private SolutionExplorerPanel _solutionExplorerPanel = null!;
private RunPanel _runPanel = null!;
private MenuButton _runMenuButton = null!;
public override void _Ready()
{
MSBuildLocator.RegisterDefaults();
_openSlnButton = GetNode<Button>("%OpenSlnButton");
_runMenuButton = GetNode<MenuButton>("%RunMenuButton");
var popup = _runMenuButton.GetPopup();
popup.HideOnItemSelection = false;
_sharpIdeCodeEdit = GetNode<SharpIdeCodeEdit>("%SharpIdeCodeEdit");
_fileDialog = GetNode<FileDialog>("%OpenSolutionDialog");
_solutionExplorerPanel = GetNode<SolutionExplorerPanel>("%SolutionExplorerPanel");
_fileDialog.FileSelected += OnFileSelected;
_runPanel = GetNode<RunPanel>("%RunPanel");
_openSlnButton.Pressed += () => _fileDialog.Visible = true;
//_fileDialog.Visible = true;
var test = new DebuggingService();
_ = test.Test();
OnFileSelected(@"C:\Users\Matthew\Documents\Git\BlazorCodeBreaker\BlazorCodeBreaker.slnx");
}
private async void OnFileSelected(string path)
private void OnFileSelected(string path)
{
try
_ = Task.Run(async () =>
{
GD.Print($"Selected: {path}");
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
_solutionExplorerPanel.SolutionModel = solutionModel;
_solutionExplorerPanel.RepopulateTree();
RoslynAnalysis.StartSolutionAnalysis(path);
var infraProject = solutionModel.AllProjects.Single(s => s.Name == "Infrastructure");
var diFile = infraProject.Files.Single(s => s.Name == "DependencyInjection.cs");
await _sharpIdeCodeEdit.SetSharpIdeFile(diFile);
}
catch (Exception e)
{
GD.PrintErr($"Error loading solution: {e.Message}");
GD.PrintErr(e.StackTrace);
}
try
{
GD.Print($"Selected: {path}");
var solutionModel = await VsPersistenceMapper.GetSolutionModel(path);
_solutionExplorerPanel.SolutionModel = solutionModel;
Callable.From(_solutionExplorerPanel.RepopulateTree).CallDeferred();
RoslynAnalysis.StartSolutionAnalysis(path);
var infraProject = solutionModel.AllProjects.Single(s => s.Name == "Infrastructure");
var diFile = infraProject.Files.Single(s => s.Name == "DependencyInjection.cs");
await this.InvokeAsync(async () => await _sharpIdeCodeEdit.SetSharpIdeFile(diFile));
var tasks = solutionModel.AllProjects.Select(p => p.MsBuildEvaluationProjectTask).ToList();
await Task.WhenAll(tasks).ConfigureAwait(false);
var runnableProjects = solutionModel.AllProjects.Where(p => p.IsRunnable).ToList();
await this.InvokeAsync(() =>
{
var popup = _runMenuButton.GetPopup();
foreach (var project in runnableProjects)
{
popup.AddItem(project.Name);
}
_runMenuButton.Disabled = false;
});
//var runnableProject = solutionModel.AllProjects.First(s => s.IsRunnable);
//await this.InvokeAsync(() => _runPanel.NewRunStarted(runnableProject));
}
catch (Exception e)
{
GD.PrintErr($"Error loading solution: {e.Message}");
GD.PrintErr(e.StackTrace);
}
});
}
}

View File

@@ -1,9 +1,11 @@
[gd_scene load_steps=6 format=3 uid="uid://b2oniigcp5ew5"]
[gd_scene load_steps=8 format=3 uid="uid://b2oniigcp5ew5"]
[ext_resource type="Script" uid="uid://bavypuy7b375x" path="res://IdeRoot.cs" id="1_whawi"]
[ext_resource type="Texture2D" uid="uid://bnprs1lvjyaji" path="res://Features/Run/Play.png" id="2_8x8ub"]
[ext_resource type="Script" uid="uid://du2lt7r1p1qfy" path="res://SharpIdeCodeEdit.cs" id="2_qjf5e"]
[ext_resource type="FontFile" uid="uid://7jc0nj310cu6" path="res://CascadiaCode.ttf" id="2_rk34b"]
[ext_resource type="Script" uid="uid://bai53k7ongbxw" path="res://SolutionExplorerPanel.cs" id="2_tcy02"]
[ext_resource type="PackedScene" uid="uid://bcoytt3bw0gpe" path="res://Features/Run/RunPanel.tscn" id="5_y3aoi"]
[sub_resource type="FontVariation" id="FontVariation_y3aoi"]
base_font = ExtResource("2_rk34b")
@@ -29,16 +31,32 @@ grow_horizontal = 2
grow_vertical = 2
[node name="Panel" type="Panel" parent="VBoxContainer"]
custom_minimum_size = Vector2(0, 40)
custom_minimum_size = Vector2(0, 42)
layout_mode = 2
[node name="OpenSlnButton" type="Button" parent="VBoxContainer/Panel"]
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/Panel"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="OpenSlnButton" type="Button" parent="VBoxContainer/Panel/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 0
offset_right = 78.0
offset_bottom = 31.0
layout_mode = 2
text = "Open Sln"
[node name="Spacer" type="Control" parent="VBoxContainer/Panel/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="RunMenuButton" type="MenuButton" parent="VBoxContainer/Panel/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
disabled = true
icon = ExtResource("2_8x8ub")
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
@@ -95,6 +113,10 @@ item_0/id = 0
[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer/VSplitContainer"]
layout_mode = 2
[node name="RunPanel" parent="VBoxContainer/HBoxContainer/VSplitContainer/Panel" instance=ExtResource("5_y3aoi")]
unique_name_in_owner = true
layout_mode = 1
[node name="OpenSolutionDialog" type="FileDialog" parent="."]
unique_name_in_owner = true
title = "Open a File"

View File

@@ -0,0 +1,39 @@
using System;
using System.Threading.Tasks;
using Godot;
namespace SharpIDE.Godot;
public static class NodeExtensions
{
public static Task InvokeAsync(this Node node, Action workItem)
{
var taskCompletionSource = new TaskCompletionSource();
//WorkerThreadPool.AddTask();
Callable.From(() =>
{
workItem();
taskCompletionSource.SetResult();
}).CallDeferred();
return taskCompletionSource.Task;
}
public static Task InvokeAsync(this Node node, Func<Task> workItem)
{
var taskCompletionSource = new TaskCompletionSource();
//WorkerThreadPool.AddTask();
Callable.From(async void () =>
{
try
{
await workItem();
taskCompletionSource.SetResult();
}
catch (Exception ex)
{
taskCompletionSource.SetException(ex);
}
}).CallDeferred();
return taskCompletionSource.Task;
}
}

View File

@@ -0,0 +1 @@
uid://cpdxatadoqpmm