Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Settings window so that content expands as it resizes #193

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Stardrop/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ private async Task DisplaySettingsWindow()
{
Program.helper.Log($"Opening settings window");

var editorWindow = new SettingsWindow();
var editorWindow = new SettingsWindow(this.Height);
editorWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
if (await editorWindow.ShowDialog<bool>(this))
{
Expand Down
30 changes: 13 additions & 17 deletions Stardrop/Views/SettingsWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
MinWidth="430"
MinHeight="430"
Width="430"
Height="500"
Background="{DynamicResource ThemeBackgroundBrush}"
HasSystemDecorations="true"
ExtendClientAreaToDecorationsHint="true"
Expand Down Expand Up @@ -157,32 +156,29 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="25" />
<RowDefinition Height="50" />
<RowDefinition Height="Auto" />
Comment on lines -162 to -166
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, as the stuff inside the ScrollViewer is no longer part of this Grid.

</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Border Grid.Row="0" BorderBrush="{DynamicResource HighlightBrush}" BorderThickness="0 0 0 2" Grid.ColumnSpan="2">
<Menu Name="menuBar" KeyboardNavigation.TabNavigation="None">
<Image Source="/Assets/icon.ico" Stretch="None"/>
<TextBlock Text="{i18n:Translate ui.window.settings.name}" Margin="-10 0 0 0" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
</Menu>
</Border>
<Menu Name="windowMenu" IsVisible="{Binding ShowMainMenu}" HorizontalAlignment="Right" KeyboardNavigation.TabNavigation="None" Grid.Column="1">
<Menu Name="windowMenu" Grid.Row="0" IsVisible="{Binding ShowMainMenu}" HorizontalAlignment="Right" KeyboardNavigation.TabNavigation="None" Grid.Column="1">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not strictly necessary, because any item without a Grid.Row set is implicitly 0, but this makes things more consistent.

<Button Name="exitButton" i:Attached.Icon="mdi-close" Margin="0 0 -10 0" Foreground="{DynamicResource ThemeForegroundBrush}" Background="Transparent"/>
</Menu>

<ScrollViewer AllowAutoHide="True" Height="350" Grid.Row="1" Grid.ColumnSpan="2">
<ScrollViewer AllowAutoHide="True" Grid.Row="1" Grid.ColumnSpan="2">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the explicit height, which will allow the ScrollViewer to expand to fit its container.

<StackPanel>
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Margin="10 10 0 0">
<StackPanel Margin="10 10 0 0">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, and all of the other children inside the StackPanel are no longer part of a Grid (and never were, actually), so don't need this.

<TextBlock Text="{i18n:Translate ui.settings_window.labels.smapi_path}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
<TextBox Name="smapiFolderPathBox" Text="{Binding SMAPIPath}" ToolTip.Tip="{Binding ToolTip_SMAPI}" Margin="10 10 0 0" Height="10" Width="350" BorderBrush="{DynamicResource HighlightBrush}" HorizontalAlignment="Left"/>
<Button Name="smapiFolderButton" Margin="360 -32 0 0" i:Attached.Icon="mdi-folder" Foreground="{DynamicResource ThemeForegroundBrush}" Background="Transparent" HorizontalAlignment="Left" />
Expand All @@ -196,7 +192,7 @@
<Button Name="modInstallButton" Margin="360 -32 0 0" i:Attached.Icon="mdi-folder" Foreground="{DynamicResource ThemeForegroundBrush}" Background="Transparent" HorizontalAlignment="Left" />
</StackPanel>

<StackPanel Grid.Row="2" Margin="10 10 0 0">
<StackPanel Margin="10 10 0 0">
<TextBlock Text="{i18n:Translate ui.settings_window.labels.themes}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
<ComboBox Name="themeComboBox" ToolTip.Tip="{Binding ToolTip_Theme}" Margin="10 10 0 10" Width="150" Background="{DynamicResource ThemeBackgroundBrush}" Foreground="{DynamicResource ThemeForegroundBrush}" BorderBrush="{DynamicResource HighlightBrush}" HorizontalAlignment="Left"/>
<TextBlock Text="{i18n:Translate ui.settings_window.labels.languages}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
Expand All @@ -205,7 +201,7 @@
<ComboBox Name="groupingComboBox" ToolTip.Tip="{Binding ToolTip_Grouping}" Margin="10 10 0 0" Width="150" Background="{DynamicResource ThemeBackgroundBrush}" Foreground="{DynamicResource ThemeForegroundBrush}" BorderBrush="{DynamicResource HighlightBrush}" HorizontalAlignment="Left"/>
</StackPanel>

<StackPanel Grid.Row="3" Margin="10 25 0 0">
<StackPanel Margin="10 25 0 0">
<TextBlock Text="{i18n:Translate ui.settings_window.labels.nexus}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
<StackPanel Orientation="Horizontal" IsVisible="{Binding ShowNexusServers}">
<TextBlock Text="{i18n:Translate ui.settings_window.labels.preferred_server}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
Expand All @@ -215,7 +211,7 @@
<CheckBox Name="askBeforeNXMInstallCheckbox" IsChecked="{Binding IsAskingBeforeAcceptingNXM}" Content="{i18n:Translate ui.settings_window.buttons.always_ask_for_NXM_installs}" ToolTip.Tip="{Binding ToolTip_AlwaysAskNXMFiles}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
</StackPanel>

<StackPanel Grid.Row="4" Margin="10 25 0 0">
<StackPanel Margin="10 25 0 0">
<TextBlock Text="{i18n:Translate ui.settings_window.labels.miscellaneous}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
<CheckBox Name="ignoreHiddenFoldersCheckbox" IsChecked="{Binding IgnoreHiddenFolders}" Content="{i18n:Translate ui.settings_window.buttons.ignore_hidden_folders}" ToolTip.Tip="{Binding ToolTip_IgnoreHiddenFolders}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
<CheckBox Name="enableProfileSpecificModConfigsCheckbox" IsChecked="{Binding EnableProfileSpecificModConfigs}" Content="{i18n:Translate ui.settings_window.buttons.enable_profile_specific_mod_configs}" ToolTip.Tip="{Binding ToolTip_EnableProfileSpecificModConfigs}" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="{DynamicResource ThemeForegroundBrush}" />
Expand All @@ -226,10 +222,10 @@
</StackPanel>
</ScrollViewer>

<Border Grid.Row="5" BorderBrush="{DynamicResource HighlightBrush}" BorderThickness="0 0 0 2" Grid.ColumnSpan="2"/>
<DockPanel Grid.Row="6" Grid.Column="1" Margin="0 0 0 0">
<Button Name="applyButton" ToolTip.Tip="{Binding ToolTip_Save}" i:Attached.Icon="mdi-check" Margin="0 0 15 0" BorderBrush="{DynamicResource HighlightBrush}" Foreground="Green" Background="Transparent" HorizontalAlignment="Right"/>
<Button Name="cancelButton" IsCancel="True" ToolTip.Tip="{Binding ToolTip_Cancel}" i:Attached.Icon="mdi-cancel" Margin="0 0 15 0" BorderBrush="{DynamicResource HighlightBrush}" Foreground="Red" Background="Transparent" HorizontalAlignment="Right"/>
</DockPanel>
<Border Grid.Row="2" Grid.ColumnSpan="2" BorderBrush="{DynamicResource HighlightBrush}" BorderThickness="0 0 0 2" Height="4"/>
<Grid Grid.Row="3" Grid.ColumnSpan="2" RowDefinitions="Auto, Auto" ColumnDefinitions="Auto, Auto" HorizontalAlignment="Right" Margin="0 15 0 15">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little container grid, to hold the two buttons. This probably could have just been a StackPanel with a Horizontal Orientation too, but ¯\_(ツ)_/¯

<Button Name="applyButton" Grid.Row="1" Grid.Column="0" ToolTip.Tip="{Binding ToolTip_Save}" i:Attached.Icon="mdi-check" Margin="0 0 15 0" BorderBrush="{DynamicResource HighlightBrush}" Foreground="Green" Background="Transparent" HorizontalAlignment="Right"/>
<Button Name="cancelButton" Grid.Row="1" Grid.Column="1" IsCancel="True" ToolTip.Tip="{Binding ToolTip_Cancel}" i:Attached.Icon="mdi-cancel" Margin="0 0 15 0" BorderBrush="{DynamicResource HighlightBrush}" Foreground="Red" Background="Transparent" HorizontalAlignment="Right"/>
</Grid>
</Grid>
</Window>
7 changes: 6 additions & 1 deletion Stardrop/Views/SettingsWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public partial class SettingsWindow : Window
public SettingsWindow()
{
InitializeComponent();
this.SizeToContent = SizeToContent.Height;

// Set the datacontext
DataContext = new SettingsWindowViewModel();
Expand Down Expand Up @@ -129,6 +128,12 @@ public SettingsWindow()
#endif
}

public SettingsWindow(double parentWindowHeight) : this()
{
// Adjust the height of the this window to be slightly smaller than the parent
this.Height = parentWindowHeight - (parentWindowHeight / 4);
}

private async void RegisterNXMButton_Click(object? sender, RoutedEventArgs e)
{
if (NXMProtocol.Validate(Program.executablePath) is false)
Expand Down