From 4256db8df4491761dc9905839247a87a074216f5 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 30 Sep 2025 19:04:03 +1000 Subject: [PATCH] popup window v3 --- .../Features/SlnPicker/SlnPicker.cs | 11 +++-------- src/SharpIDE.Godot/IdeWindow.cs | 15 ++++++++------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs index 250f752..82b864f 100644 --- a/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs +++ b/src/SharpIDE.Godot/Features/SlnPicker/SlnPicker.cs @@ -2,6 +2,7 @@ using Godot; namespace SharpIDE.Godot.Features.SlnPicker; +// This is a bit of a mess intertwined with the optional popup window public partial class SlnPicker : Control { private FileDialog _fileDialog = null!; @@ -17,16 +18,10 @@ public partial class SlnPicker : Control var windowParent = GetParentOrNull(); _fileDialog.FileSelected += path => { - _tcs.SetResult(path); windowParent?.Hide(); + _tcs.SetResult(path); }; - _fileDialog.Canceled += () => _tcs.SetResult(null); - windowParent?.CloseRequested += OnCloseRequested; - } - - private void OnCloseRequested() - { - _tcs.SetResult(null); + windowParent?.CloseRequested += () => _tcs.SetResult(null); } public async Task GetSelectedSolutionPath() diff --git a/src/SharpIDE.Godot/IdeWindow.cs b/src/SharpIDE.Godot/IdeWindow.cs index 0ba45d3..c4508ef 100644 --- a/src/SharpIDE.Godot/IdeWindow.cs +++ b/src/SharpIDE.Godot/IdeWindow.cs @@ -36,14 +36,15 @@ public partial class IdeWindow : Control } else { - var window = GetNode("Window"); - window.Title = "Open Solution"; - window.AddChild(_slnPicker); - window.Popup(); - window.CloseRequested += () => + var popupWindow = GetNode("Window"); + var windowSize = GetWindow().GetSize(); + popupWindow.Size = windowSize with { X = windowSize.X / 2, Y = windowSize.Y / 2 }; + popupWindow.Title = "Open Solution"; + popupWindow.AddChild(_slnPicker); + popupWindow.Popup(); + popupWindow.CloseRequested += () => { - window.Hide(); - //window.QueueFreeChildren(); + popupWindow.Hide(); }; } _ = Task.GodotRun(async () =>