From 761367cc170115f3dab60a5a0ec498bb40a62508 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Tue, 18 Nov 2025 00:09:12 +1000 Subject: [PATCH] ui scale spinbox --- .../Features/IdeSettings/AppState.cs | 1 + .../Features/Settings/SettingsWindow.cs | 14 +++++++++++++- .../Features/Settings/SettingsWindow.tscn | 13 +++---------- src/SharpIDE.Godot/project.godot | 6 ++++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs b/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs index 13f70b8..a68cc6d 100644 --- a/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs +++ b/src/SharpIDE.Godot/Features/IdeSettings/AppState.cs @@ -11,6 +11,7 @@ public class IdeSettings { public bool AutoOpenLastSolution { get; set; } public string? DebuggerExecutablePath { get; set; } + public float UiScale { get; set; } = 1.0f; } public record RecentSln diff --git a/src/SharpIDE.Godot/Features/Settings/SettingsWindow.cs b/src/SharpIDE.Godot/Features/Settings/SettingsWindow.cs index ff3554f..f85b8b1 100644 --- a/src/SharpIDE.Godot/Features/Settings/SettingsWindow.cs +++ b/src/SharpIDE.Godot/Features/Settings/SettingsWindow.cs @@ -4,8 +4,20 @@ namespace SharpIDE.Godot.Features.Settings; public partial class SettingsWindow : Window { + private SpinBox _uiScaleSpinBox = null!; public override void _Ready() { - CloseRequested += Hide; + CloseRequested += Hide; + _uiScaleSpinBox = GetNode("%UiScaleSpinBox"); + //_uiScaleSlider.Value = Singletons.AppState.IdeSettings.UiScale; + _uiScaleSpinBox.ValueChanged += OnUiScaleSpinBoxValueChanged; + } + + private void OnUiScaleSpinBoxValueChanged(double value) + { + var valueFloat = (float)value; + Singletons.AppState.IdeSettings.UiScale = valueFloat; + + GetTree().GetRoot().ContentScaleFactor = valueFloat; } } \ No newline at end of file diff --git a/src/SharpIDE.Godot/Features/Settings/SettingsWindow.tscn b/src/SharpIDE.Godot/Features/Settings/SettingsWindow.tscn index 00f288f..dfaf61f 100644 --- a/src/SharpIDE.Godot/Features/Settings/SettingsWindow.tscn +++ b/src/SharpIDE.Godot/Features/Settings/SettingsWindow.tscn @@ -8,6 +8,7 @@ title = "Settings" initial_position = 2 size = Vector2i(845, 400) transient = true +transient_to_focused = true exclusive = true popup_window = true popup_wm_hint = true @@ -27,16 +28,8 @@ layout_mode = 2 layout_mode = 2 text = "UI Scale" -[node name="HSlider" type="HSlider" parent="VBoxContainer/HBoxContainer"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 4 -min_value = 0.5 -max_value = 8.0 -step = 0.1 -value = 1.0 - -[node name="SpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"] +[node name="UiScaleSpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"] +unique_name_in_owner = true layout_mode = 2 min_value = 0.5 max_value = 8.0 diff --git a/src/SharpIDE.Godot/project.godot b/src/SharpIDE.Godot/project.godot index 13a7dc0..78b6025 100644 --- a/src/SharpIDE.Godot/project.godot +++ b/src/SharpIDE.Godot/project.godot @@ -25,6 +25,7 @@ ObservableTrackerRuntimeHook="*res://addons/R3.Godot/ObservableTrackerRuntimeHoo [display] window/energy_saving/keep_screen_on=false +window/stretch/scale_mode="integer" [dotnet] @@ -34,6 +35,11 @@ project/assembly_name="SharpIDE.Godot" enabled=PackedStringArray("res://addons/R3.Godot/plugin.cfg", "res://addons/csharp_gdextension_bindgen/plugin.cfg") +[gui] + +theme/default_font_multichannel_signed_distance_field=true +theme/default_font_generate_mipmaps=true + [input] CodeFixes={