Set UI scale

This commit is contained in:
Matt Parker
2025-11-18 02:11:04 +10:00
parent ac29c29f0b
commit a9adcb8d8a
5 changed files with 39 additions and 12 deletions

View File

@@ -12,3 +12,4 @@ script = ExtResource("2_e87mh")
[node name="SettingsWindow" parent="." instance=ExtResource("3_x07a0")]
unique_name_in_owner = true
visible = false

View File

@@ -9,8 +9,13 @@ public partial class SettingsWindow : Window
{
CloseRequested += Hide;
_uiScaleSpinBox = GetNode<SpinBox>("%UiScaleSpinBox");
//_uiScaleSlider.Value = Singletons.AppState.IdeSettings.UiScale;
_uiScaleSpinBox.ValueChanged += OnUiScaleSpinBoxValueChanged;
AboutToPopup += OnAboutToPopup;
}
private void OnAboutToPopup()
{
_uiScaleSpinBox.Value = Singletons.AppState.IdeSettings.UiScale;
}
private void OnUiScaleSpinBoxValueChanged(double value)
@@ -19,5 +24,6 @@ public partial class SettingsWindow : Window
Singletons.AppState.IdeSettings.UiScale = valueFloat;
GetTree().GetRoot().ContentScaleFactor = valueFloat;
PopupCenteredRatio(0.5f); // Re-size the window after scaling
}
}

View File

@@ -1,34 +1,58 @@
[gd_scene load_steps=2 format=3 uid="uid://dnh73b3speojs"]
[gd_scene load_steps=3 format=3 uid="uid://dnh73b3speojs"]
[ext_resource type="Script" uid="uid://b7umbl07avv6d" path="res://Features/Settings/SettingsWindow.cs" id="1_xkmyt"]
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_xkmyt"]
[node name="SettingsWindow" type="Window"]
oversampling_override = 1.0
title = "Settings"
initial_position = 2
size = Vector2i(845, 400)
transient = true
transient_to_focused = true
exclusive = true
popup_window = true
popup_wm_hint = true
script = ExtResource("1_xkmyt")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
[node name="HSplitContainer" type="HSplitContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 4
theme_override_constants/minimum_grab_thickness = 10
theme_override_icons/grabber = SubResource("PlaceholderTexture2D_xkmyt")
split_offset = 200
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
[node name="PanelContainer2" type="PanelContainer" parent="HSplitContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="HSplitContainer/PanelContainer2"]
layout_mode = 2
[node name="PanelContainer" type="PanelContainer" parent="HSplitContainer"]
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/PanelContainer"]
layout_mode = 2
theme_override_constants/margin_left = 10
theme_override_constants/margin_top = 5
theme_override_constants/margin_right = 10
theme_override_constants/margin_bottom = 5
[node name="VBoxContainer2" type="VBoxContainer" parent="HSplitContainer/PanelContainer/MarginContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2"]
layout_mode = 2
[node name="Label" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/HBoxContainer"]
layout_mode = 2
text = "UI Scale"
[node name="UiScaleSpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
[node name="UiScaleSpinBox" type="SpinBox" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
min_value = 0.5

View File

@@ -27,6 +27,7 @@ public partial class IdeWindow : Control
SharpIdeMsbuildLocator.Register();
GodotOtelExtensions.AddServiceDefaults();
Singletons.AppState = AppStateLoader.LoadAppStateFromConfigFile();
GetTree().GetRoot().ContentScaleFactor = Singletons.AppState.IdeSettings.UiScale;
//GetWindow().SetMinSize(new Vector2I(1152, 648));
Callable.From(() => PickSolution(true)).CallDeferred();
}

View File

@@ -34,11 +34,6 @@ 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={