aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Ava/UI/Controls
diff options
context:
space:
mode:
authorAhmad Tantowi <ahmadtantowi@outlook.com>2023-10-20 21:02:12 +0700
committerGitHub <noreply@github.com>2023-10-20 16:02:12 +0200
commitb4bb22ba06f89168c948e6001c51972575ca968b (patch)
tree44e71b5fe08adcac5a04f89095be3f7ca341b965 /src/Ryujinx.Ava/UI/Controls
parent6fdf7748455b2b71f99885239f8dc31390de2687 (diff)
Avalonia: Make slider scrollable with mouse wheel (#5760)
* Add scrollable custom control based on TickFrequency * Use custom slider to update value when pointer wheel scrolled * Remove extra xaml file * Address formatting issues * Only scroll one element at a time * Add OnPointerWheelChanged event to VolumeStatus button Co-authored-by: Ahmad Tantowi <ahmadtantowi@outlook.com> --------- Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
Diffstat (limited to 'src/Ryujinx.Ava/UI/Controls')
-rw-r--r--src/Ryujinx.Ava/UI/Controls/SliderScroll.axaml.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Ryujinx.Ava/UI/Controls/SliderScroll.axaml.cs b/src/Ryujinx.Ava/UI/Controls/SliderScroll.axaml.cs
new file mode 100644
index 00000000..81d3bc30
--- /dev/null
+++ b/src/Ryujinx.Ava/UI/Controls/SliderScroll.axaml.cs
@@ -0,0 +1,31 @@
+using Avalonia.Controls;
+using Avalonia.Input;
+using System;
+
+namespace Ryujinx.Ava.UI.Controls
+{
+ public class SliderScroll : Slider
+ {
+ protected override Type StyleKeyOverride => typeof(Slider);
+
+ protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
+ {
+ var newValue = Value + e.Delta.Y * TickFrequency;
+
+ if (newValue < Minimum)
+ {
+ Value = Minimum;
+ }
+ else if (newValue > Maximum)
+ {
+ Value = Maximum;
+ }
+ else
+ {
+ Value = newValue;
+ }
+
+ e.Handled = true;
+ }
+ }
+}