Ver Fonte

misc: chore: Remove duplicated styling blocks in MainMenuBarView in favor of a reusable Avalonia Style.

Evan Husted há 1 ano atrás
pai
commit
880a8ae748

+ 13 - 0
src/Ryujinx/Assets/Styles/CheckboxMenuItemStyle.axaml

@@ -0,0 +1,13 @@
+<Styles xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+    <Style Selector="MenuItem.withCheckbox Viewbox#PART_IconPresenter">
+        <Setter Property="MaxHeight" Value="36" />
+        <Setter Property="MinHeight" Value="36" />
+        <Setter Property="MaxWidth" Value="36" />
+        <Setter Property="MinWidth" Value="36" />
+    </Style>
+    <Style Selector="MenuItem.withCheckbox ContentPresenter#PART_HeaderPresenter">
+        <Setter Property="Padding" Value="-10,0,0,0" />
+    </Style>
+</Styles>
+

+ 3 - 1
src/Ryujinx/Ryujinx.csproj

@@ -123,12 +123,13 @@
       <Generator>MSBuild:Compile</Generator>
     </AvaloniaResource>
     <AvaloniaResource Include="Assets\Styles\Styles.xaml" />
+    <AvaloniaResource Include="Assets\Styles\CheckboxMenuItemStyle.axaml" />
   </ItemGroup>
 
   <ItemGroup>
     <None Remove="Assets\locales.json" />
-    <None Remove="Assets\Styles\Styles.xaml" />
     <None Remove="Assets\Styles\Themes.xaml" />
+    <None Remove="Assets\Styles\CheckboxMenuItemStyle.xaml" />
     <None Remove="Assets\Icons\Controller_JoyConLeft.svg" />
     <None Remove="Assets\Icons\Controller_JoyConPair.svg" />
     <None Remove="Assets\Icons\Controller_JoyConRight.svg" />
@@ -150,6 +151,7 @@
     </EmbeddedResource>
     <EmbeddedResource Include="Assets\locales.json" />
     <EmbeddedResource Include="Assets\Styles\Styles.xaml" />
+    <EmbeddedResource Include="Assets\Styles\CheckboxMenuItemStyle.axaml" />
     <EmbeddedResource Include="Assets\Icons\Controller_JoyConLeft.svg" />
     <EmbeddedResource Include="Assets\Icons\Controller_JoyConPair.svg" />
     <EmbeddedResource Include="Assets\Icons\Controller_JoyConRight.svg" />

+ 1 - 0
src/Ryujinx/RyujinxApp.axaml

@@ -16,5 +16,6 @@
     <Application.Styles>
         <sty:FluentAvaloniaTheme PreferUserAccentColor="True" PreferSystemTheme="False" />
         <StyleInclude Source="/Assets/Styles/Styles.xaml" />
+        <StyleInclude Source="/Assets/Styles/CheckboxMenuItemStyle.axaml"/>
     </Application.Styles>
 </Application>

+ 13 - 83
src/Ryujinx/UI/Views/Main/MainMenuBarView.axaml

@@ -81,25 +81,16 @@
                 <MenuItem
                     Command="{Binding ToggleFullscreen}"
                     Header="{ext:Locale MenuBarOptionsToggleFullscreen}"
+                    Classes="withCheckbox"
                     Padding="0"
                     Icon="{ext:Icon fa-solid fa-expand}"
                     InputGesture="F11">
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
                 </MenuItem>
                 <MenuItem
                     Padding="0"
                     Command="{Binding ToggleStartGamesInFullscreen}"
-                    Header="{ext:Locale MenuBarOptionsStartGamesInFullscreen}">
+                    Header="{ext:Locale MenuBarOptionsStartGamesInFullscreen}"
+                    Classes="withCheckbox">
                     <MenuItem.Icon>
                         <CheckBox
                             MinWidth="{DynamicResource CheckBoxSize}"
@@ -107,22 +98,12 @@
                             IsChecked="{Binding StartGamesInFullscreen, Mode=TwoWay}"
                             Padding="0" />
                     </MenuItem.Icon>
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
                 </MenuItem>
                 <MenuItem
                     Padding="0"
                     Command="{Binding ToggleStartGamesWithoutUI}"
-                    Header="{ext:Locale MenuBarOptionsStartGamesWithoutUI}">
+                    Header="{ext:Locale MenuBarOptionsStartGamesWithoutUI}"
+                    Classes="withCheckbox">
                     <MenuItem.Icon>
                         <CheckBox
                             MinWidth="{DynamicResource CheckBoxSize}"
@@ -130,23 +111,13 @@
                             IsChecked="{Binding StartGamesWithoutUI, Mode=TwoWay}"
                             Padding="0" />
                     </MenuItem.Icon>
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
                 </MenuItem>
                 <MenuItem
                     Padding="0"
                     IsVisible="{Binding ShowConsoleVisible}"
                     Command="{Binding ToggleShowConsole}"
-                    Header="{ext:Locale MenuBarOptionsShowConsole}">
+                    Header="{ext:Locale MenuBarOptionsShowConsole}"
+                    Classes="withCheckbox">
                     <MenuItem.Icon>
                         <CheckBox
                             MinWidth="{DynamicResource CheckBoxSize}"
@@ -154,35 +125,14 @@
                             IsChecked="{Binding ShowConsole, Mode=TwoWay}"
                             Padding="0" />
                     </MenuItem.Icon>
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
                 </MenuItem>
                 <Separator/>
                 <MenuItem
                     Name="ChangeLanguageMenuItem" 
                     Padding="0"
                     Header="{ext:Locale MenuBarOptionsChangeLanguage}"
-                    Icon="{ext:Icon fa-solid fa-language}">
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
+                    Icon="{ext:Icon fa-solid fa-language}"
+                    Classes="withCheckbox">
                 </MenuItem>
                 <MenuItem 
                     Name="ToggleFileTypesMenuItem" 
@@ -194,18 +144,8 @@
                     Padding="0"
                     Header="{ext:Locale MenuBarOptionsSettings}"
                     Icon="{ext:Icon fa-solid fa-gear}"
-                    ToolTip.Tip="{ext:Locale OpenSettingsTooltip}">
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
+                    ToolTip.Tip="{ext:Locale OpenSettingsTooltip}"
+                    Classes="withCheckbox">
                 </MenuItem>
                 <MenuItem
                     Command="{Binding ManageProfiles}"
@@ -213,18 +153,8 @@
                     Header="{ext:Locale MenuBarOptionsManageUserProfiles}"
                     Icon="{ext:Icon mdi-account}"
                     IsEnabled="{Binding EnableNonGameRunningControls}"
-                    ToolTip.Tip="{ext:Locale OpenProfileManagerTooltip}">
-                    <MenuItem.Styles>
-                        <Style Selector="Viewbox#PART_IconPresenter">
-                            <Setter Property="MaxHeight" Value="36" />
-                            <Setter Property="MinHeight" Value="36" />
-                            <Setter Property="MaxWidth" Value="36" />
-                            <Setter Property="MinWidth" Value="36" />
-                        </Style>
-                        <Style Selector="ContentPresenter#PART_HeaderPresenter">
-                            <Setter Property="Padding" Value="-10,0,0,0" />
-                        </Style>
-                    </MenuItem.Styles>
+                    ToolTip.Tip="{ext:Locale OpenProfileManagerTooltip}"
+                    Classes="withCheckbox">
                 </MenuItem>
             </MenuItem>
             <MenuItem