From fefd53a0daaf9ec764a6f2831576469d1f53446c Mon Sep 17 00:00:00 2001 From: Hertzole <contact@hertzole.se> Date: Tue, 11 Feb 2025 01:10:40 +0100 Subject: [PATCH] feat: option to turn off smooth scrolling --- ILSpy/App.xaml | 9 ++++++++- ILSpy/App.xaml.cs | 6 +++++- ILSpy/Controls/ZoomScrollViewer.xaml | 9 ++++++++- ILSpy/Options/DisplaySettings.cs | 8 ++++++++ ILSpy/Options/DisplaySettingsPanel.xaml | 1 + ILSpy/Properties/Resources.Designer.cs | 9 +++++++++ ILSpy/Properties/Resources.resx | 3 +++ 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ILSpy/App.xaml b/ILSpy/App.xaml index ce2e14086..1d00e1ee8 100644 --- a/ILSpy/App.xaml +++ b/ILSpy/App.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:styles="urn:TomsToolbox.Wpf.Styles" xmlns:toms="urn:TomsToolbox" - xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes"> + xmlns:themes="clr-namespace:ICSharpCode.ILSpy.Themes" + xmlns:ilSpy="clr-namespace:ICSharpCode.ILSpy"> <Application.Resources> <Style x:Key="DialogWindow" TargetType="{x:Type Window}"> <Setter Property="ShowInTaskbar" Value="False" /> @@ -25,6 +26,12 @@ <Style TargetType="ScrollViewer"> <Setter Property="toms:AdvancedScrollWheelBehavior.Attach" Value="WithAnimation" /> + <Style.Triggers> + <!-- Allow for disabling smooth scrolling --> + <DataTrigger Binding="{Binding Path=DisplaySettings.EnableSmoothScrolling, Source={x:Static ilSpy:App.SettingsService}}" Value="False"> + <Setter Property="toms:AdvancedScrollWheelBehavior.Attach" Value="None"/> + </DataTrigger> + </Style.Triggers> </Style> </Application.Resources> diff --git a/ILSpy/App.xaml.cs b/ILSpy/App.xaml.cs index c82af3125..eabe3bce2 100644 --- a/ILSpy/App.xaml.cs +++ b/ILSpy/App.xaml.cs @@ -59,6 +59,10 @@ namespace ICSharpCode.ILSpy public static IExportProvider ExportProvider { get; private set; } + private readonly SettingsService settingsService; + + public static SettingsService SettingsService => Current.settingsService; + internal record ExceptionData(Exception Exception) { public string PluginName { get; init; } @@ -69,7 +73,7 @@ namespace ICSharpCode.ILSpy var cmdArgs = Environment.GetCommandLineArgs().Skip(1); CommandLineArguments = CommandLineArguments.Create(cmdArgs); - var settingsService = new SettingsService(); + settingsService = new SettingsService(); bool forceSingleInstance = (CommandLineArguments.SingleInstance ?? true) && !settingsService.MiscSettings.AllowMultipleInstances; diff --git a/ILSpy/Controls/ZoomScrollViewer.xaml b/ILSpy/Controls/ZoomScrollViewer.xaml index 509b8d636..3bd4ace05 100644 --- a/ILSpy/Controls/ZoomScrollViewer.xaml +++ b/ILSpy/Controls/ZoomScrollViewer.xaml @@ -1,7 +1,8 @@ <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:ICSharpCode.ILSpy.Controls" - xmlns:toms="urn:TomsToolbox"> + xmlns:toms="urn:TomsToolbox" + xmlns:ilSpy="clr-namespace:ICSharpCode.ILSpy"> <Style TargetType="{x:Type Controls:ZoomScrollViewer}"> <Setter Property="toms:AdvancedScrollWheelBehavior.Attach" Value="WithAnimation" /> @@ -33,6 +34,12 @@ </ControlTemplate> </Setter.Value> </Setter> + <Style.Triggers> + <!-- Allow for disabling smooth scrolling --> + <DataTrigger Binding="{Binding Path=DisplaySettings.EnableSmoothScrolling, Source={x:Static ilSpy:App.SettingsService}}" Value="False"> + <Setter Property="toms:AdvancedScrollWheelBehavior.Attach" Value="WithoutAnimation" /> + </DataTrigger> + </Style.Triggers> </Style> <!-- Template for CollapsiblePanel --> diff --git a/ILSpy/Options/DisplaySettings.cs b/ILSpy/Options/DisplaySettings.cs index 9eb07b394..8b21987bb 100644 --- a/ILSpy/Options/DisplaySettings.cs +++ b/ILSpy/Options/DisplaySettings.cs @@ -148,6 +148,12 @@ namespace ICSharpCode.ILSpy.Options set => SetProperty(ref showRawOffsetsAndBytesBeforeInstruction, value); } + private bool enableSmoothScrolling; + public bool EnableSmoothScrolling { + get => enableSmoothScrolling; + set => SetProperty(ref enableSmoothScrolling, value); + } + public XName SectionName => "DisplaySettings"; public void LoadFromXml(XElement section) @@ -172,6 +178,7 @@ namespace ICSharpCode.ILSpy.Options UseNestedNamespaceNodes = (bool?)section.Attribute("UseNestedNamespaceNodes") ?? false; ShowRawOffsetsAndBytesBeforeInstruction = (bool?)section.Attribute("ShowRawOffsetsAndBytesBeforeInstruction") ?? false; StyleWindowTitleBar = (bool?)section.Attribute("StyleWindowTitleBar") ?? false; + EnableSmoothScrolling = (bool?)section.Attribute("EnableSmoothScrolling") ?? true; } public XElement SaveToXml() @@ -198,6 +205,7 @@ namespace ICSharpCode.ILSpy.Options section.SetAttributeValue("UseNestedNamespaceNodes", UseNestedNamespaceNodes); section.SetAttributeValue("ShowRawOffsetsAndBytesBeforeInstruction", ShowRawOffsetsAndBytesBeforeInstruction); section.SetAttributeValue("StyleWindowTitleBar", StyleWindowTitleBar); + section.SetAttributeValue("EnableSmoothScrolling", EnableSmoothScrolling); return section; } diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml b/ILSpy/Options/DisplaySettingsPanel.xaml index 9fb50d7a9..7df9a6b60 100644 --- a/ILSpy/Options/DisplaySettingsPanel.xaml +++ b/ILSpy/Options/DisplaySettingsPanel.xaml @@ -78,6 +78,7 @@ <StackPanel Margin="3"> <CheckBox IsChecked="{Binding Settings.SortResults}" Content="{x:Static properties:Resources.SortResultsFitness}"></CheckBox> <CheckBox IsChecked="{Binding Settings.StyleWindowTitleBar}" Content="{x:Static properties:Resources.StyleTheWindowTitleBar}"></CheckBox> + <CheckBox IsChecked="{Binding Settings.EnableSmoothScrolling}" Content="{x:Static properties:Resources.EnableSmoothScrolling}"></CheckBox> </StackPanel> </GroupBox> </StackPanel> diff --git a/ILSpy/Properties/Resources.Designer.cs b/ILSpy/Properties/Resources.Designer.cs index 01628056b..7e9235cae 100644 --- a/ILSpy/Properties/Resources.Designer.cs +++ b/ILSpy/Properties/Resources.Designer.cs @@ -1722,6 +1722,15 @@ namespace ICSharpCode.ILSpy.Properties { } } + /// <summary> + /// Looks up a localized string similar to Enable smooth scrolling. + /// </summary> + public static string EnableSmoothScrolling { + get { + return ResourceManager.GetString("EnableSmoothScrolling", resourceCulture); + } + } + /// <summary> /// Looks up a localized string similar to Enable word wrap. /// </summary> diff --git a/ILSpy/Properties/Resources.resx b/ILSpy/Properties/Resources.resx index bcb79fae7..a6e65ca67 100644 --- a/ILSpy/Properties/Resources.resx +++ b/ILSpy/Properties/Resources.resx @@ -591,6 +591,9 @@ Are you sure you want to continue?</value> <data name="EnableFoldingBlocksBraces" xml:space="preserve"> <value>Enable folding on all blocks in braces</value> </data> + <data name="EnableSmoothScrolling" xml:space="preserve"> + <value>Enable smooth scrolling</value> + </data> <data name="EnableWordWrap" xml:space="preserve"> <value>Enable word wrap</value> </data>