mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Move dimming logic to custom scroll container
This commit is contained in:
parent
e9c9c764ca
commit
94d07e147f
@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
private DifficultyMultiplierDisplay? multiplierDisplay;
|
||||
private ModSettingsArea modSettingsArea = null!;
|
||||
private OsuScrollContainer columnScroll = null!;
|
||||
private ColumnScrollContainer columnScroll = null!;
|
||||
private ColumnFlowContainer columnFlow = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -98,7 +98,7 @@ namespace osu.Game.Overlays.Mods
|
||||
RelativePositionAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
columnScroll = new OsuScrollContainer(Direction.Horizontal)
|
||||
columnScroll = new ColumnScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = false,
|
||||
@ -320,26 +320,32 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
private class ColumnScrollContainer : OsuScrollContainer<ColumnFlowContainer>
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// 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 leftScrollBound = Math.Clamp(columnScroll.Current, 0, columnScroll.ScrollableExtent);
|
||||
float rightScrollBound = leftScrollBound + columnScroll.DrawWidth;
|
||||
|
||||
foreach (var column in columnFlow)
|
||||
public ColumnScrollContainer()
|
||||
: base(Direction.Horizontal)
|
||||
{
|
||||
// DrawWidth/DrawPosition do not include shear effects, and we want to know the full extents of the columns post-shear,
|
||||
// so we have to manually compensate.
|
||||
// additionally note that columnFlow.Parent is not columnScroll, but rather it is the scroll's internal container.
|
||||
// this is intentional in order to include margin of the columnFlow in calculations correctly and operate in the "scroll internal content space".
|
||||
var topLeft = column.ToSpaceOfOtherDrawable(new Vector2(-column.DrawHeight * SHEAR, 0), columnFlow.Parent);
|
||||
var topRight = column.ToSpaceOfOtherDrawable(new Vector2(column.DrawWidth, 0), columnFlow.Parent);
|
||||
}
|
||||
|
||||
column.Active.Value = Precision.AlmostBigger(topLeft.X, leftScrollBound)
|
||||
&& Precision.DefinitelyBigger(rightScrollBound, topRight.X);
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// 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 leftScrollBound = Math.Clamp(Current, 0, ScrollableExtent);
|
||||
float rightScrollBound = leftScrollBound + DrawWidth;
|
||||
|
||||
foreach (var column in Child)
|
||||
{
|
||||
// DrawWidth/DrawPosition do not include shear effects, and we want to know the full extents of the columns post-shear,
|
||||
// so we have to manually compensate.
|
||||
var topLeft = column.ToSpaceOfOtherDrawable(new Vector2(-column.DrawHeight * SHEAR, 0), ScrollContent);
|
||||
var topRight = column.ToSpaceOfOtherDrawable(new Vector2(column.DrawWidth, 0), ScrollContent);
|
||||
|
||||
column.Active.Value = Precision.AlmostBigger(topLeft.X, leftScrollBound)
|
||||
&& Precision.DefinitelyBigger(rightScrollBound, topRight.X);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user