Skip to content

Commit

Permalink
Allow customising ScrollContainer's scrollbar mapping
Browse files Browse the repository at this point in the history
For use in osu!.
  • Loading branch information
peppy committed Nov 11, 2024
1 parent f3bdd4e commit 23913b7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions osu.Framework/Graphics/Containers/ScrollContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ protected override bool OnScroll(ScrollEvent e)
return true;
}

private void onScrollbarMovement(float value) => OnUserScroll(Clamp(fromScrollbarPosition(value)), false);
private void onScrollbarMovement(float value) => OnUserScroll(Clamp(FromScrollbarPosition(value)), false);

/// <summary>
/// Immediately offsets the current and target scroll position.
Expand Down Expand Up @@ -576,12 +576,12 @@ protected override void UpdateAfterChildren()

if (ScrollDirection == Direction.Horizontal)
{
Scrollbar.X = toScrollbarPosition(Current);
Scrollbar.X = ToScrollbarPosition(Current);
ScrollContent.X = -Current + ScrollableExtent * ScrollContent.RelativeAnchorPosition.X;
}
else
{
Scrollbar.Y = toScrollbarPosition(Current);
Scrollbar.Y = ToScrollbarPosition(Current);
ScrollContent.Y = -Current + ScrollableExtent * ScrollContent.RelativeAnchorPosition.Y;
}
}
Expand All @@ -591,7 +591,7 @@ protected override void UpdateAfterChildren()
/// </summary>
/// <param name="scrollPosition">The absolute scroll position (e.g. <see cref="Current"/>).</param>
/// <returns>The scrollbar position.</returns>
private float toScrollbarPosition(float scrollPosition)
protected virtual float ToScrollbarPosition(float scrollPosition)
{
if (Precision.AlmostEquals(0, ScrollableExtent))
return 0;
Expand All @@ -604,7 +604,7 @@ private float toScrollbarPosition(float scrollPosition)
/// </summary>
/// <param name="scrollbarPosition">The scrollbar position.</param>
/// <returns>The absolute scroll position.</returns>
private float fromScrollbarPosition(float scrollbarPosition)
protected virtual float FromScrollbarPosition(float scrollbarPosition)
{
if (Precision.AlmostEquals(0, ScrollbarMovementExtent))
return 0;
Expand Down

0 comments on commit 23913b7

Please sign in to comment.