mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 10:53:21 +08:00
Update game ScrollContainer
usage in line with framework changes
See https://github.com/ppy/osu-framework/pull/6467.
This commit is contained in:
parent
73adc4dfd7
commit
94ea003d90
@ -138,7 +138,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddUntilStep("section top is visible", () =>
|
||||
{
|
||||
var scrollContainer = container.ChildrenOfType<UserTrackingScrollContainer>().Single();
|
||||
float sectionPosition = scrollContainer.GetChildPosInContent(container.Children[scrollIndex]);
|
||||
double sectionPosition = scrollContainer.GetChildPosInContent(container.Children[scrollIndex]);
|
||||
return scrollContainer.Current < sectionPosition;
|
||||
});
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ namespace osu.Game.Graphics.Containers
|
||||
/// <param name="extraScroll">An added amount to scroll beyond the requirement to bring the target into view.</param>
|
||||
public void ScrollIntoView(Drawable d, bool animated = true, float extraScroll = 0)
|
||||
{
|
||||
float childPos0 = GetChildPosInContent(d);
|
||||
float childPos1 = GetChildPosInContent(d, d.DrawSize);
|
||||
double childPos0 = GetChildPosInContent(d);
|
||||
double childPos1 = GetChildPosInContent(d, d.DrawSize);
|
||||
|
||||
float minPos = Math.Min(childPos0, childPos1);
|
||||
float maxPos = Math.Max(childPos0, childPos1);
|
||||
double minPos = Math.Min(childPos0, childPos1);
|
||||
double maxPos = Math.Max(childPos0, childPos1);
|
||||
|
||||
if (minPos < Current || (minPos > Current && d.DrawSize[ScrollDim] > DisplayableContent))
|
||||
ScrollTo(minPos - extraScroll, animated);
|
||||
|
@ -208,7 +208,7 @@ namespace osu.Game.Graphics.Containers
|
||||
private float getScrollTargetForDrawable(Drawable target)
|
||||
{
|
||||
// implementation similar to ScrollIntoView but a bit more nuanced.
|
||||
return scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre;
|
||||
return (float)(scrollContainer.GetChildPosInContent(target) - scrollContainer.DisplayableContent * scroll_y_centre);
|
||||
}
|
||||
|
||||
public void ScrollToTop() => scrollContainer.ScrollTo(0);
|
||||
@ -259,7 +259,7 @@ namespace osu.Game.Graphics.Containers
|
||||
updateSectionsMargin();
|
||||
}
|
||||
|
||||
float currentScroll = scrollContainer.Current;
|
||||
float currentScroll = (float)scrollContainer.Current;
|
||||
|
||||
if (currentScroll != lastKnownScroll)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
|
||||
protected override void OnUserScroll(double value, bool animated = true, double? distanceDecay = default)
|
||||
{
|
||||
UserScrolling = true;
|
||||
base.OnUserScroll(value, animated, distanceDecay);
|
||||
@ -53,7 +53,7 @@ namespace osu.Game.Graphics.Containers
|
||||
base.ScrollFromMouseEvent(e);
|
||||
}
|
||||
|
||||
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
|
||||
public new void ScrollTo(double value, bool animated = true, double? distanceDecay = null)
|
||||
{
|
||||
UserScrolling = false;
|
||||
base.ScrollTo(value, animated, distanceDecay);
|
||||
|
@ -375,8 +375,8 @@ namespace osu.Game.Online.Leaderboards
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
float fadeBottom = scrollContainer.Current + scrollContainer.DrawHeight;
|
||||
float fadeTop = scrollContainer.Current + LeaderboardScore.HEIGHT;
|
||||
float fadeBottom = (float)(scrollContainer.Current + scrollContainer.DrawHeight);
|
||||
float fadeTop = (float)(scrollContainer.Current + LeaderboardScore.HEIGHT);
|
||||
|
||||
if (!scrollContainer.IsScrolledToEnd())
|
||||
fadeBottom -= LeaderboardScore.HEIGHT;
|
||||
|
@ -41,13 +41,13 @@ namespace osu.Game.Overlays.Chat
|
||||
|
||||
#region Scroll handling
|
||||
|
||||
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = null)
|
||||
protected override void OnUserScroll(double value, bool animated = true, double? distanceDecay = null)
|
||||
{
|
||||
base.OnUserScroll(value, animated, distanceDecay);
|
||||
updateTrackState();
|
||||
}
|
||||
|
||||
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
|
||||
public new void ScrollTo(double value, bool animated = true, double? distanceDecay = null)
|
||||
{
|
||||
base.ScrollTo(value, animated, distanceDecay);
|
||||
updateTrackState();
|
||||
|
@ -117,7 +117,7 @@ namespace osu.Game.Overlays.Chat
|
||||
if (chatLine == null)
|
||||
return;
|
||||
|
||||
float center = scroll.GetChildPosInContent(chatLine, chatLine.DrawSize / 2) - scroll.DisplayableContent / 2;
|
||||
double center = scroll.GetChildPosInContent(chatLine, chatLine.DrawSize / 2) - scroll.DisplayableContent / 2;
|
||||
scroll.ScrollTo(Math.Clamp(center, 0, scroll.ScrollableExtent));
|
||||
chatLine.Highlight();
|
||||
|
||||
|
@ -710,13 +710,13 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
// the bounds below represent the horizontal range of scroll items to be considered fully visible/active, in the scroll's internal coordinate space.
|
||||
// note that clamping is applied to the left scroll bound to ensure scrolling past extents does not change the set of active columns.
|
||||
float leftVisibleBound = Math.Clamp(Current, 0, ScrollableExtent);
|
||||
float rightVisibleBound = leftVisibleBound + DrawWidth;
|
||||
double leftVisibleBound = Math.Clamp(Current, 0, ScrollableExtent);
|
||||
double rightVisibleBound = leftVisibleBound + DrawWidth;
|
||||
|
||||
// if a movement is occurring at this time, the bounds below represent the full range of columns that the scroll movement will encompass.
|
||||
// this will be used to ensure that columns do not change state from active to inactive back and forth until they are fully scrolled past.
|
||||
float leftMovementBound = Math.Min(Current, Target);
|
||||
float rightMovementBound = Math.Max(Current, Target) + DrawWidth;
|
||||
double leftMovementBound = Math.Min(Current, Target);
|
||||
double rightMovementBound = Math.Max(Current, Target) + DrawWidth;
|
||||
|
||||
foreach (var column in Child)
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
sidebarContainer.Height = DrawHeight;
|
||||
sidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
sidebarContainer.Y = (float)Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
}
|
||||
|
||||
private void loadListing(int? year = null)
|
||||
|
@ -88,7 +88,7 @@ namespace osu.Game.Overlays
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
// don't block header by applying padding equal to the visible header height
|
||||
loadingContainer.Padding = new MarginPadding { Top = Math.Max(0, Header.Height - ScrollFlow.Current) };
|
||||
loadingContainer.Padding = new MarginPadding { Top = (float)Math.Max(0, Header.Height - ScrollFlow.Current) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
public ScrollBackButton Button { get; private set; }
|
||||
|
||||
private readonly Bindable<float?> lastScrollTarget = new Bindable<float?>();
|
||||
private readonly Bindable<double?> lastScrollTarget = new Bindable<double?>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
@ -63,7 +63,7 @@ namespace osu.Game.Overlays
|
||||
Button.State = Target > button_scroll_position || lastScrollTarget.Value != null ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
|
||||
protected override void OnUserScroll(float value, bool animated = true, double? distanceDecay = default)
|
||||
protected override void OnUserScroll(double value, bool animated = true, double? distanceDecay = default)
|
||||
{
|
||||
base.OnUserScroll(value, animated, distanceDecay);
|
||||
|
||||
@ -112,7 +112,7 @@ namespace osu.Game.Overlays
|
||||
private readonly Box background;
|
||||
private readonly SpriteIcon spriteIcon;
|
||||
|
||||
public Bindable<float?> LastScrollTarget = new Bindable<float?>();
|
||||
public Bindable<double?> LastScrollTarget = new Bindable<double?>();
|
||||
|
||||
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace osu.Game.Overlays
|
||||
if (articlePage != null)
|
||||
{
|
||||
articlePage.SidebarContainer.Height = DrawHeight;
|
||||
articlePage.SidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
articlePage.SidebarContainer.Y = (float)Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
/// <summary>
|
||||
/// The timeline's scroll position in the last frame.
|
||||
/// </summary>
|
||||
private float lastScrollPosition;
|
||||
private double lastScrollPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The track time in the last frame.
|
||||
@ -322,7 +322,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
/// </summary>
|
||||
public double VisibleRange => editorClock.TrackLength / Zoom;
|
||||
|
||||
public double TimeAtPosition(float x)
|
||||
public double TimeAtPosition(double x)
|
||||
{
|
||||
return x / Content.DrawWidth * editorClock.TrackLength;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
}
|
||||
|
||||
private void transformZoomTo(float newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
|
||||
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));
|
||||
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, (float)Current), newZoom, duration, easing));
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when <see cref="Zoom"/> has changed.
|
||||
|
@ -114,15 +114,15 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
if (requiresScroll && TrackedScore != null)
|
||||
{
|
||||
float scrollTarget = scroll.GetChildPosInContent(TrackedScore) + TrackedScore.DrawHeight / 2 - scroll.DrawHeight / 2;
|
||||
double scrollTarget = scroll.GetChildPosInContent(TrackedScore) + TrackedScore.DrawHeight / 2 - scroll.DrawHeight / 2;
|
||||
|
||||
scroll.ScrollTo(scrollTarget);
|
||||
}
|
||||
|
||||
const float panel_height = GameplayLeaderboardScore.PANEL_HEIGHT;
|
||||
|
||||
float fadeBottom = scroll.Current + scroll.DrawHeight;
|
||||
float fadeTop = scroll.Current + panel_height;
|
||||
float fadeBottom = (float)(scroll.Current + scroll.DrawHeight);
|
||||
float fadeTop = (float)(scroll.Current + panel_height);
|
||||
|
||||
if (scroll.IsScrolledToStart()) fadeTop -= panel_height;
|
||||
if (!scroll.IsScrolledToEnd()) fadeBottom -= panel_height;
|
||||
|
@ -334,7 +334,7 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private partial class Scroll : OsuScrollContainer
|
||||
{
|
||||
public new float Target => base.Target;
|
||||
public new double Target => base.Target;
|
||||
|
||||
public Scroll()
|
||||
: base(Direction.Horizontal)
|
||||
@ -344,7 +344,7 @@ namespace osu.Game.Screens.Ranking
|
||||
/// <summary>
|
||||
/// The target that will be scrolled to instantaneously next frame.
|
||||
/// </summary>
|
||||
public float? InstantScrollTarget;
|
||||
public double? InstantScrollTarget;
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
|
@ -611,12 +611,12 @@ namespace osu.Game.Screens.Select
|
||||
/// <summary>
|
||||
/// The position of the lower visible bound with respect to the current scroll position.
|
||||
/// </summary>
|
||||
private float visibleBottomBound => Scroll.Current + DrawHeight + BleedBottom;
|
||||
private float visibleBottomBound => (float)(Scroll.Current + DrawHeight + BleedBottom);
|
||||
|
||||
/// <summary>
|
||||
/// The position of the upper visible bound with respect to the current scroll position.
|
||||
/// </summary>
|
||||
private float visibleUpperBound => Scroll.Current - BleedTop;
|
||||
private float visibleUpperBound => (float)(Scroll.Current - BleedTop);
|
||||
|
||||
public void FlushPendingFilterOperations()
|
||||
{
|
||||
@ -1006,7 +1006,7 @@ namespace osu.Game.Screens.Select
|
||||
// we take the difference in scroll height and apply to all visible panels.
|
||||
// this avoids edge cases like when the visible panels is reduced suddenly, causing ScrollContainer
|
||||
// to enter clamp-special-case mode where it animates completely differently to normal.
|
||||
float scrollChange = scrollTarget.Value - Scroll.Current;
|
||||
float scrollChange = (float)(scrollTarget.Value - Scroll.Current);
|
||||
Scroll.ScrollTo(scrollTarget.Value, false);
|
||||
foreach (var i in Scroll)
|
||||
i.Y += scrollChange;
|
||||
@ -1217,12 +1217,12 @@ namespace osu.Game.Screens.Select
|
||||
private const float top_padding = 10;
|
||||
private const float bottom_padding = 70;
|
||||
|
||||
protected override float ToScrollbarPosition(float scrollPosition)
|
||||
protected override float ToScrollbarPosition(double scrollPosition)
|
||||
{
|
||||
if (Precision.AlmostEquals(0, ScrollableExtent))
|
||||
return 0;
|
||||
|
||||
return top_padding + (ScrollbarMovementExtent - (top_padding + bottom_padding)) * (scrollPosition / ScrollableExtent);
|
||||
return (float)(top_padding + (ScrollbarMovementExtent - (top_padding + bottom_padding)) * (scrollPosition / ScrollableExtent));
|
||||
}
|
||||
|
||||
protected override float FromScrollbarPosition(float scrollbarPosition)
|
||||
@ -1230,7 +1230,7 @@ namespace osu.Game.Screens.Select
|
||||
if (Precision.AlmostEquals(0, ScrollbarMovementExtent))
|
||||
return 0;
|
||||
|
||||
return ScrollableExtent * ((scrollbarPosition - top_padding) / (ScrollbarMovementExtent - (top_padding + bottom_padding)));
|
||||
return (float)(ScrollableExtent * ((scrollbarPosition - top_padding) / (ScrollbarMovementExtent - (top_padding + bottom_padding))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user