-
Notifications
You must be signed in to change notification settings - Fork 718
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scp): Add ability to reverse pointer wheel on the SCP for manage…
…d scrolling on skia and wasm
- Loading branch information
Showing
6 changed files
with
265 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.uno.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Windows.UI.Xaml; | ||
|
||
namespace Uno.UI.Xaml.Controls | ||
{ | ||
public class ScrollContentPresenter | ||
{ | ||
/// <summary> | ||
/// Backing property for the IsPointerWheelReversed attached property. | ||
/// </summary> | ||
public static readonly DependencyProperty IsPointerWheelReversedProperty = DependencyProperty.RegisterAttached( | ||
"IsPointerWheelReversed", | ||
typeof(bool), | ||
typeof(Windows.UI.Xaml.Controls.ScrollContentPresenter), | ||
new FrameworkPropertyMetadata((snd, e) => ((Windows.UI.Xaml.Controls.ScrollContentPresenter)snd).IsPointerWheelReversed = (bool)e.NewValue)); | ||
|
||
/// <summary> | ||
/// Gets a boolean which indicates if the pointer wheel should be reversed or not for the <paramref name="scrollViewer"/>. | ||
/// </summary> | ||
/// <param name="scrollViewer"></param> | ||
/// <returns></returns> | ||
public static bool GetIsPointerWheelReversed(Windows.UI.Xaml.Controls.ScrollContentPresenter scrollViewer) | ||
=> (bool)scrollViewer.GetValue(IsPointerWheelReversedProperty); | ||
|
||
/// <summary> | ||
/// Sets if the pointer wheel should be reversed or not for the <paramref name="scrollViewer"/>. | ||
/// </summary> | ||
/// <param name="scrollViewer">The target ScrollViewer to configure</param> | ||
/// <param name="isReversed">A boolean which indicates if the wheel should be reversed of not.</param> | ||
public static void SetIsPointerWheelReversed(Windows.UI.Xaml.Controls.ScrollContentPresenter scrollViewer, bool isReversed) | ||
=> scrollViewer.SetValue(IsPointerWheelReversedProperty, isReversed); | ||
|
||
} | ||
} | ||
|
||
namespace Windows.UI.Xaml.Controls | ||
{ | ||
partial class ScrollContentPresenter | ||
{ | ||
private bool _isPointerWheelReversed; | ||
|
||
/// <summary> | ||
/// Cached value of <see cref="Uno.UI.Xaml.Controls.ScrollContentPresenter.IsPointerWheelReversedProperty"/>, | ||
/// in order to not access the DP on each scroll (perf considerations) | ||
/// </summary> | ||
internal bool IsPointerWheelReversed | ||
{ | ||
get => _isPointerWheelReversed; | ||
set | ||
{ | ||
if (_isPointerWheelReversed != value) | ||
{ | ||
_isPointerWheelReversed = value; | ||
OnIsPointerWheelReversedChanged(value); | ||
} | ||
} | ||
} | ||
|
||
partial void OnIsPointerWheelReversedChanged(bool isReversed); | ||
} | ||
} |
Oops, something went wrong.