add setting for theme

This commit is contained in:
Matt Parker
2026-01-30 19:35:24 +10:00
parent 20f3399f54
commit 21ad2a3e3f
2 changed files with 51 additions and 0 deletions

View File

@@ -7,15 +7,22 @@ public partial class SettingsWindow : Window
private SpinBox _uiScaleSpinBox = null!; private SpinBox _uiScaleSpinBox = null!;
private LineEdit _debuggerFilePathLineEdit = null!; private LineEdit _debuggerFilePathLineEdit = null!;
private CheckButton _debuggerUseSharpDbgCheckButton = null!; private CheckButton _debuggerUseSharpDbgCheckButton = null!;
private OptionButton _themeOptionButton = null!;
private Theme _lightTheme = ResourceLoader.Load<Theme>("uid://epmt8kq6efrs");
private Theme _darkTheme = ResourceLoader.Load<Theme>("uid://dc7l6bjhn61i5");
public override void _Ready() public override void _Ready()
{ {
CloseRequested += Hide; CloseRequested += Hide;
_uiScaleSpinBox = GetNode<SpinBox>("%UiScaleSpinBox"); _uiScaleSpinBox = GetNode<SpinBox>("%UiScaleSpinBox");
_debuggerFilePathLineEdit = GetNode<LineEdit>("%DebuggerFilePathLineEdit"); _debuggerFilePathLineEdit = GetNode<LineEdit>("%DebuggerFilePathLineEdit");
_debuggerUseSharpDbgCheckButton = GetNode<CheckButton>("%DebuggerUseSharpDbgCheckButton"); _debuggerUseSharpDbgCheckButton = GetNode<CheckButton>("%DebuggerUseSharpDbgCheckButton");
_themeOptionButton = GetNode<OptionButton>("%ThemeOptionButton");
_uiScaleSpinBox.ValueChanged += OnUiScaleSpinBoxValueChanged; _uiScaleSpinBox.ValueChanged += OnUiScaleSpinBoxValueChanged;
_debuggerFilePathLineEdit.TextChanged += OnDebuggerFilePathChanged; _debuggerFilePathLineEdit.TextChanged += OnDebuggerFilePathChanged;
_debuggerUseSharpDbgCheckButton.Toggled += OnDebuggerUseSharpDbgToggled; _debuggerUseSharpDbgCheckButton.Toggled += OnDebuggerUseSharpDbgToggled;
_themeOptionButton.ItemSelected += OnThemeItemSelected;
AboutToPopup += OnAboutToPopup; AboutToPopup += OnAboutToPopup;
} }
@@ -44,4 +51,18 @@ public partial class SettingsWindow : Window
{ {
Singletons.AppState.IdeSettings.DebuggerUseSharpDbg = pressed; Singletons.AppState.IdeSettings.DebuggerUseSharpDbg = pressed;
} }
private void OnThemeItemSelected(long index)
{
var selectedTheme = _themeOptionButton.GetItemText((int)index);
var rootWindow = GetTree().GetRoot();
if (selectedTheme is "Light")
{
rootWindow.Theme = _lightTheme;
}
else if (selectedTheme is "Dark")
{
rootWindow.Theme = _darkTheme;
}
}
} }

View File

@@ -125,3 +125,33 @@ text = "Necessary if 'Use SharpDbg' is disabled. Get netcoredbg from"
layout_mode = 2 layout_mode = 2
text = "here" text = "here"
uri = "https://github.com/Samsung/netcoredbg/releases" uri = "https://github.com/Samsung/netcoredbg/releases"
[node name="VBoxContainer4" type="VBoxContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2" unique_id=1649657136]
layout_mode = 2
theme_override_constants/separation = 2
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer4" unique_id=987671656]
layout_mode = 2
[node name="Label" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer4/HBoxContainer2" unique_id=1404561371]
layout_mode = 2
text = "Theme"
[node name="ThemeOptionButton" type="OptionButton" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer4/HBoxContainer2" unique_id=1638166442]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
selected = 0
item_count = 2
popup/item_0/text = "Dark"
popup/item_0/id = 0
popup/item_1/text = "Light"
popup/item_1/id = 1
[node name="HBoxContainer" type="HBoxContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer4" unique_id=1201262823]
layout_mode = 2
[node name="Label2" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBoxContainer2/VBoxContainer4/HBoxContainer" unique_id=2074714339]
layout_mode = 2
theme_type_variation = &"Gray500Label"
text = "The Light theme is experimental, and may contain visual inconsistencies/glitches"