custom popup
This commit is contained in:
23
src/SharpIDE.Godot/Features/Run/RunMenuItem.cs
Normal file
23
src/SharpIDE.Godot/Features/Run/RunMenuItem.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||
|
||||
namespace SharpIDE.Godot.Features.Run;
|
||||
|
||||
public partial class RunMenuItem : HBoxContainer
|
||||
{
|
||||
public SharpIdeProjectModel Project { get; set; } = null!;
|
||||
private Label _label = null!;
|
||||
private Button _runButton = null!;
|
||||
public override void _Ready()
|
||||
{
|
||||
_label = GetNode<Label>("Label");
|
||||
_runButton = GetNode<Button>("RunButton");
|
||||
_runButton.Pressed += OnRunButtonPressed;
|
||||
_label.Text = Project.Name;
|
||||
}
|
||||
|
||||
private async void OnRunButtonPressed()
|
||||
{
|
||||
await Singletons.RunService.RunProject(Project).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
1
src/SharpIDE.Godot/Features/Run/RunMenuItem.cs.uid
Normal file
1
src/SharpIDE.Godot/Features/Run/RunMenuItem.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://btsnapfx0dlbb
|
||||
21
src/SharpIDE.Godot/Features/Run/RunMenuItem.tscn
Normal file
21
src/SharpIDE.Godot/Features/Run/RunMenuItem.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://d2ewm2lajutpv"]
|
||||
|
||||
[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"]
|
||||
|
||||
[node name="RunMenuItem" type="HBoxContainer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
script = ExtResource("1_syj0f")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
layout_mode = 2
|
||||
text = "Project Name"
|
||||
|
||||
[node name="Spacer" type="Control" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="RunButton" type="Button" parent="."]
|
||||
layout_mode = 2
|
||||
icon = ExtResource("1_xfxpu")
|
||||
@@ -16,15 +16,24 @@ public partial class IdeRoot : Control
|
||||
private SharpIdeCodeEdit _sharpIdeCodeEdit = null!;
|
||||
private SolutionExplorerPanel _solutionExplorerPanel = null!;
|
||||
private RunPanel _runPanel = null!;
|
||||
private MenuButton _runMenuButton = null!;
|
||||
private Button _runMenuButton = null!;
|
||||
private Popup _runMenuPopup = null!;
|
||||
|
||||
private readonly PackedScene _runMenuItemScene = ResourceLoader.Load<PackedScene>("res://Features/Run/RunMenuItem.tscn");
|
||||
public override void _Ready()
|
||||
{
|
||||
MSBuildLocator.RegisterDefaults();
|
||||
|
||||
_openSlnButton = GetNode<Button>("%OpenSlnButton");
|
||||
_runMenuButton = GetNode<MenuButton>("%RunMenuButton");
|
||||
var popup = _runMenuButton.GetPopup();
|
||||
popup.HideOnItemSelection = false;
|
||||
_runMenuPopup = GetNode<Popup>("%RunMenuPopup");
|
||||
_runMenuButton = GetNode<Button>("%RunMenuButton");
|
||||
_runMenuButton.Pressed += () =>
|
||||
{
|
||||
var popupMenuPosition = _runMenuButton.GlobalPosition;
|
||||
const int buttonHeight = 44;
|
||||
_runMenuPopup.Position = new Vector2I((int)popupMenuPosition.X, (int)popupMenuPosition.Y + buttonHeight);
|
||||
_runMenuPopup.Popup();
|
||||
};
|
||||
|
||||
_sharpIdeCodeEdit = GetNode<SharpIdeCodeEdit>("%SharpIdeCodeEdit");
|
||||
_fileDialog = GetNode<FileDialog>("%OpenSolutionDialog");
|
||||
@@ -56,10 +65,12 @@ public partial class IdeRoot : Control
|
||||
var runnableProjects = solutionModel.AllProjects.Where(p => p.IsRunnable).ToList();
|
||||
await this.InvokeAsync(() =>
|
||||
{
|
||||
var popup = _runMenuButton.GetPopup();
|
||||
var runMenuPopupVbox = _runMenuPopup.GetNode<VBoxContainer>("VBoxContainer");
|
||||
foreach (var project in runnableProjects)
|
||||
{
|
||||
popup.AddItem(project.Name);
|
||||
var runMenuItem = _runMenuItemScene.Instantiate<RunMenuItem>();
|
||||
runMenuItem.Project = project;
|
||||
runMenuPopupVbox.AddChild(runMenuItem);
|
||||
}
|
||||
_runMenuButton.Disabled = false;
|
||||
});
|
||||
|
||||
@@ -51,12 +51,21 @@ text = "Open Sln"
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="RunMenuButton" type="MenuButton" parent="VBoxContainer/Panel/HBoxContainer"]
|
||||
[node name="RunMenuButton" type="Button" parent="VBoxContainer/Panel/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
focus_mode = 0
|
||||
disabled = true
|
||||
icon = ExtResource("2_8x8ub")
|
||||
|
||||
[node name="RunMenuPopup" type="Popup" parent="VBoxContainer/Panel/HBoxContainer/RunMenuButton"]
|
||||
unique_name_in_owner = true
|
||||
size = Vector2i(151, 100)
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/Panel/HBoxContainer/RunMenuButton/RunMenuPopup"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
@@ -106,6 +115,7 @@ auto_brace_completion_highlight_matching = true
|
||||
script = ExtResource("2_qjf5e")
|
||||
|
||||
[node name="CodeFixesMenu" type="PopupMenu" parent="VBoxContainer/HBoxContainer/VSplitContainer/HSplitContainer/SharpIdeCodeEdit"]
|
||||
size = Vector2i(217, 100)
|
||||
item_count = 1
|
||||
item_0/text = "Getting Context Actions..."
|
||||
item_0/id = 0
|
||||
|
||||
8
src/SharpIDE.Godot/Singletons.cs
Normal file
8
src/SharpIDE.Godot/Singletons.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using SharpIDE.Application.Features.Run;
|
||||
|
||||
namespace SharpIDE.Godot;
|
||||
|
||||
public static class Singletons
|
||||
{
|
||||
public static RunService RunService { get; } = new RunService();
|
||||
}
|
||||
1
src/SharpIDE.Godot/Singletons.cs.uid
Normal file
1
src/SharpIDE.Godot/Singletons.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://hgugdj2v8ufh
|
||||
Reference in New Issue
Block a user