From b4bb22ba06f89168c948e6001c51972575ca968b Mon Sep 17 00:00:00 2001 From: Ahmad Tantowi Date: Fri, 20 Oct 2023 21:02:12 +0700 Subject: 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 --------- Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com> --- src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml.cs') diff --git a/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml.cs index 44426295..9425d7b5 100644 --- a/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Main/MainStatusBarView.axaml.cs @@ -53,5 +53,20 @@ namespace Ryujinx.Ava.UI.Views.Main { Window.LoadApplications(); } + + private void VolumeStatus_OnPointerWheelChanged(object sender, PointerWheelEventArgs e) + { + // Change the volume by 5% at a time + float newValue = Window.ViewModel.Volume + (float)e.Delta.Y * 0.05f; + + Window.ViewModel.Volume = newValue switch + { + < 0 => 0, + > 1 => 1, + _ => newValue, + }; + + e.Handled = true; + } } } -- cgit v1.2.3