run panel tabs
This commit is contained in:
@@ -34,7 +34,7 @@ public class DebuggingService
|
|||||||
var debugProtocolHost = new DebugProtocolHost(process.StandardInput.BaseStream, process.StandardOutput.BaseStream, false);
|
var debugProtocolHost = new DebugProtocolHost(process.StandardInput.BaseStream, process.StandardOutput.BaseStream, false);
|
||||||
debugProtocolHost.LogMessage += (sender, args) =>
|
debugProtocolHost.LogMessage += (sender, args) =>
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Log message: {args.Message}");
|
//Console.WriteLine($"Log message: {args.Message}");
|
||||||
};
|
};
|
||||||
debugProtocolHost.EventReceived += (sender, args) =>
|
debugProtocolHost.EventReceived += (sender, args) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace SharpIDE.Application.Features.Events;
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
|
||||||
|
namespace SharpIDE.Application.Features.Events;
|
||||||
|
|
||||||
public static class GlobalEvents
|
public static class GlobalEvents
|
||||||
{
|
{
|
||||||
@@ -7,4 +9,10 @@ public static class GlobalEvents
|
|||||||
|
|
||||||
public static event Func<Task> StartedRunningProject = () => Task.CompletedTask;
|
public static event Func<Task> StartedRunningProject = () => Task.CompletedTask;
|
||||||
public static void InvokeStartedRunningProject() => StartedRunningProject?.Invoke();
|
public static void InvokeStartedRunningProject() => StartedRunningProject?.Invoke();
|
||||||
|
|
||||||
|
public static event Func<SharpIdeProjectModel, Task> ProjectStartedRunning = _ => Task.CompletedTask;
|
||||||
|
public static void InvokeProjectStartedRunning(SharpIdeProjectModel project) => ProjectStartedRunning?.Invoke(project);
|
||||||
|
|
||||||
|
public static event Func<SharpIdeProjectModel, Task> ProjectStoppedRunning = _ => Task.CompletedTask;
|
||||||
|
public static void InvokeProjectStoppedRunning(SharpIdeProjectModel project) => ProjectStoppedRunning?.Invoke(project);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public class RunService
|
|||||||
project.OpenInRunPanel = true;
|
project.OpenInRunPanel = true;
|
||||||
GlobalEvents.InvokeProjectsRunningChanged();
|
GlobalEvents.InvokeProjectsRunningChanged();
|
||||||
GlobalEvents.InvokeStartedRunningProject();
|
GlobalEvents.InvokeStartedRunningProject();
|
||||||
|
GlobalEvents.InvokeProjectStartedRunning(project);
|
||||||
project.InvokeProjectStartedRunning();
|
project.InvokeProjectStartedRunning();
|
||||||
await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
|
await process.WaitForExitAsync().WaitAsync(project.RunningCancellationTokenSource.Token).ConfigureAwait(ConfigureAwaitOptions.SuppressThrowing);
|
||||||
if (project.RunningCancellationTokenSource.IsCancellationRequested)
|
if (project.RunningCancellationTokenSource.IsCancellationRequested)
|
||||||
@@ -118,6 +119,7 @@ public class RunService
|
|||||||
if (project.RunningCancellationTokenSource is null) throw new InvalidOperationException($"Project {project.Name} does not have a running cancellation token source.");
|
if (project.RunningCancellationTokenSource is null) throw new InvalidOperationException($"Project {project.Name} does not have a running cancellation token source.");
|
||||||
|
|
||||||
await project.RunningCancellationTokenSource.CancelAsync().ConfigureAwait(false);
|
await project.RunningCancellationTokenSource.CancelAsync().ConfigureAwait(false);
|
||||||
|
GlobalEvents.InvokeProjectStoppedRunning(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetRunArguments(SharpIdeProjectModel project)
|
private string GetRunArguments(SharpIdeProjectModel project)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 291 B |
@@ -3,15 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://bnprs1lvjyaji"
|
uid="uid://bnprs1lvjyaji"
|
||||||
path="res://.godot/imported/Play.png-f33bbb4899ca2148d51910992d85a9eb.ctex"
|
path="res://.godot/imported/Play.png-3438a21a8b920e7517d04626c592e8b6.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Features/Run/Play.png"
|
source_file="res://Features/Run/Resources/Play.png"
|
||||||
dest_files=["res://.godot/imported/Play.png-f33bbb4899ca2148d51910992d85a9eb.ctex"]
|
dest_files=["res://.godot/imported/Play.png-3438a21a8b920e7517d04626c592e8b6.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
BIN
src/SharpIDE.Godot/Features/Run/Resources/Running.png
Normal file
BIN
src/SharpIDE.Godot/Features/Run/Resources/Running.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 743 B |
34
src/SharpIDE.Godot/Features/Run/Resources/Running.png.import
Normal file
34
src/SharpIDE.Godot/Features/Run/Resources/Running.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://76nkes2imlf2"
|
||||||
|
path="res://.godot/imported/Running.png-d687d5fa2c32934f935f7cb594c7886d.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Features/Run/Resources/Running.png"
|
||||||
|
dest_files=["res://.godot/imported/Running.png-d687d5fa2c32934f935f7cb594c7886d.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
|
||||||
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 607 B |
@@ -3,15 +3,15 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://csj1r7s3u10ch"
|
uid="uid://csj1r7s3u10ch"
|
||||||
path="res://.godot/imported/Stop.png-369cb830460ee73ee5ab96abbb3f5c92.ctex"
|
path="res://.godot/imported/Stop.png-57d1375a399a106e4fdece5825762ac9.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://Features/Run/Stop.png"
|
source_file="res://Features/Run/Resources/Stop.png"
|
||||||
dest_files=["res://.godot/imported/Stop.png-369cb830460ee73ee5ab96abbb3f5c92.ctex"]
|
dest_files=["res://.godot/imported/Stop.png-57d1375a399a106e4fdece5825762ac9.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://d2ewm2lajutpv"]
|
[gd_scene load_steps=4 format=3 uid="uid://d2ewm2lajutpv"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://btsnapfx0dlbb" path="res://Features/Run/RunMenuItem.cs" id="1_syj0f"]
|
[ext_resource type="Script" uid="uid://btsnapfx0dlbb" path="res://Features/Run/RunMenuItem.cs" id="1_syj0f"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bnprs1lvjyaji" path="res://Features/Run/Play.png" id="1_xfxpu"]
|
[ext_resource type="Texture2D" uid="uid://bnprs1lvjyaji" path="res://Features/Run/Resources/Play.png" id="1_xfxpu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://csj1r7s3u10ch" path="res://Features/Run/Stop.png" id="4_cd138"]
|
[ext_resource type="Texture2D" uid="uid://csj1r7s3u10ch" path="res://Features/Run/Resources/Stop.png" id="4_cd138"]
|
||||||
|
|
||||||
[node name="RunMenuItem" type="HBoxContainer"]
|
[node name="RunMenuItem" type="HBoxContainer"]
|
||||||
offset_right = 40.0
|
offset_right = 40.0
|
||||||
|
|||||||
@@ -1,33 +1,58 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using GDExtensionBindgen;
|
using GDExtensionBindgen;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using SharpIDE.Application.Features.Events;
|
||||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
|
||||||
namespace SharpIDE.Godot.Features.Run;
|
namespace SharpIDE.Godot.Features.Run;
|
||||||
|
|
||||||
public partial class RunPanel : Control
|
public partial class RunPanel : Control
|
||||||
{
|
{
|
||||||
private Terminal _terminal = null!;
|
|
||||||
private TabBar _tabBar = null!;
|
private TabBar _tabBar = null!;
|
||||||
private Panel _tabsPanel = null!;
|
private Panel _tabsPanel = null!;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public Texture2D RunningIcon { get; set; } = null!;
|
||||||
|
|
||||||
|
private PackedScene _runPanelTabScene = GD.Load<PackedScene>("res://Features/Run/RunPanelTab.tscn");
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_tabBar = GetNode<TabBar>("%TabBar");
|
_tabBar = GetNode<TabBar>("%TabBar");
|
||||||
|
_tabBar.ClearTabs();
|
||||||
_tabsPanel = GetNode<Panel>("%TabsPanel");
|
_tabsPanel = GetNode<Panel>("%TabsPanel");
|
||||||
var test = GetNode<Control>("VBoxContainer/TabsPanel/Terminal");
|
GlobalEvents.ProjectStartedRunning += async projectModel =>
|
||||||
_terminal = new Terminal(test);
|
{
|
||||||
_terminal.Write("Hello from SharpIDE.Godot!\n");
|
await this.InvokeAsync(() => ProjectStartedRunning(projectModel));
|
||||||
|
};
|
||||||
|
GlobalEvents.ProjectStoppedRunning += async projectModel =>
|
||||||
|
{
|
||||||
|
await this.InvokeAsync(() => ProjectStoppedRunning(projectModel));
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public void ProjectStartedRunning(SharpIdeProjectModel projectModel)
|
||||||
{
|
{
|
||||||
//_terminal.Write("a");
|
var existingRunPanelTab = _tabsPanel.GetChildren().OfType<RunPanelTab>().SingleOrDefault(s => s.Project == projectModel);
|
||||||
}
|
if (existingRunPanelTab != null)
|
||||||
|
{
|
||||||
public void NewRunStarted(SharpIdeProjectModel projectModel)
|
_tabBar.SetTabIcon(existingRunPanelTab.TabBarTab, RunningIcon);
|
||||||
{
|
existingRunPanelTab.ClearTerminal();
|
||||||
var terminal = new Terminal();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var runPanelTab = _runPanelTabScene.Instantiate<RunPanelTab>();
|
||||||
|
runPanelTab.Project = projectModel;
|
||||||
_tabBar.AddTab(projectModel.Name);
|
_tabBar.AddTab(projectModel.Name);
|
||||||
_tabsPanel.AddChild(terminal);
|
var tabIdx = _tabBar.GetTabCount() - 1;
|
||||||
|
runPanelTab.TabBarTab = tabIdx;
|
||||||
|
_tabBar.SetTabIcon(runPanelTab.TabBarTab, RunningIcon);
|
||||||
|
_tabsPanel.AddChild(runPanelTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ProjectStoppedRunning(SharpIdeProjectModel projectModel)
|
||||||
|
{
|
||||||
|
var runPanelTab = _tabsPanel.GetChildren().OfType<RunPanelTab>().Single(s => s.Project == projectModel);
|
||||||
|
_tabBar.SetTabIcon(runPanelTab.TabBarTab, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://bcoytt3bw0gpe"]
|
[gd_scene load_steps=3 format=3 uid="uid://bcoytt3bw0gpe"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ddivigavjclyb" path="res://Features/Run/RunPanel.cs" id="1_sq1l4"]
|
[ext_resource type="Script" uid="uid://ddivigavjclyb" path="res://Features/Run/RunPanel.cs" id="1_sq1l4"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://76nkes2imlf2" path="res://Features/Run/Resources/Running.png" id="2_tu4jg"]
|
||||||
|
|
||||||
[node name="RunPanel" type="Control"]
|
[node name="RunPanel" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
@@ -10,8 +11,11 @@ anchor_bottom = 1.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("1_sq1l4")
|
script = ExtResource("1_sq1l4")
|
||||||
|
RunningIcon = ExtResource("2_tu4jg")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
z_index = 100
|
||||||
|
y_sort_enabled = true
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@@ -33,10 +37,18 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="Terminal" type="Terminal" parent="VBoxContainer/TabsPanel"]
|
[node name="Label" type="Label" parent="."]
|
||||||
|
visible = false
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 15
|
anchors_preset = 8
|
||||||
anchor_right = 1.0
|
anchor_left = 0.5
|
||||||
anchor_bottom = 1.0
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -64.0
|
||||||
|
offset_top = -11.5
|
||||||
|
offset_right = 64.0
|
||||||
|
offset_bottom = 11.5
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
text = "Nothing to show"
|
||||||
|
|||||||
24
src/SharpIDE.Godot/Features/Run/RunPanelTab.cs
Normal file
24
src/SharpIDE.Godot/Features/Run/RunPanelTab.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using GDExtensionBindgen;
|
||||||
|
using Godot;
|
||||||
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
|
||||||
|
namespace SharpIDE.Godot.Features.Run;
|
||||||
|
|
||||||
|
public partial class RunPanelTab : Control
|
||||||
|
{
|
||||||
|
private Terminal _terminal = null!;
|
||||||
|
|
||||||
|
public SharpIdeProjectModel Project { get; set; } = null!;
|
||||||
|
public int TabBarTab { get; set; }
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_terminal = new Terminal();
|
||||||
|
AddChild(_terminal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearTerminal()
|
||||||
|
{
|
||||||
|
_terminal.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/SharpIDE.Godot/Features/Run/RunPanelTab.cs.uid
Normal file
1
src/SharpIDE.Godot/Features/Run/RunPanelTab.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://ouskvcd0yaub
|
||||||
20
src/SharpIDE.Godot/Features/Run/RunPanelTab.tscn
Normal file
20
src/SharpIDE.Godot/Features/Run/RunPanelTab.tscn
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cjopkm4osnp27"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ouskvcd0yaub" path="res://Features/Run/RunPanelTab.cs" id="1_dx3i6"]
|
||||||
|
|
||||||
|
[node name="RunPanelTab" 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_dx3i6")
|
||||||
|
|
||||||
|
[node name="Terminal" type="Terminal" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
[gd_scene load_steps=8 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="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="Texture2D" uid="uid://bnprs1lvjyaji" path="res://Features/Run/Resources/Play.png" id="2_8x8ub"]
|
||||||
[ext_resource type="Script" uid="uid://du2lt7r1p1qfy" path="res://SharpIdeCodeEdit.cs" id="2_qjf5e"]
|
[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="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="Script" uid="uid://bai53k7ongbxw" path="res://SolutionExplorerPanel.cs" id="2_tcy02"]
|
||||||
|
|||||||
@@ -12,8 +12,15 @@ public static class NodeExtensions
|
|||||||
//WorkerThreadPool.AddTask();
|
//WorkerThreadPool.AddTask();
|
||||||
Callable.From(() =>
|
Callable.From(() =>
|
||||||
{
|
{
|
||||||
workItem();
|
try
|
||||||
taskCompletionSource.SetResult();
|
{
|
||||||
|
workItem();
|
||||||
|
taskCompletionSource.SetResult();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
taskCompletionSource.SetException(ex);
|
||||||
|
}
|
||||||
}).CallDeferred();
|
}).CallDeferred();
|
||||||
return taskCompletionSource.Task;
|
return taskCompletionSource.Task;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user