1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 19:13:21 +08:00

Merge pull request #12397 from EVAST9919/editor-timeline-fix

Simplify ExtendableCircle component
This commit is contained in:
Dean Herbert 2021-04-13 22:22:38 +09:00 committed by GitHub
commit c574c19f80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -343,84 +343,31 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
/// <summary> /// <summary>
/// A circle with externalised end caps so it can take up the full width of a relative width area. /// A circle with externalised end caps so it can take up the full width of a relative width area.
/// </summary> /// </summary>
public class ExtendableCircle : Container public class ExtendableCircle : CompositeDrawable
{ {
private readonly Circle rightCircle; private readonly CircularContainer content;
private readonly Circle leftCircle;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => content.ReceivePositionalInputAt(screenSpacePos);
{
return base.ReceivePositionalInputAt(screenSpacePos)
|| leftCircle.ReceivePositionalInputAt(screenSpacePos)
|| rightCircle.ReceivePositionalInputAt(screenSpacePos);
}
public override Quad ScreenSpaceDrawQuad public override Quad ScreenSpaceDrawQuad => content.ScreenSpaceDrawQuad;
{
get
{
var leftQuad = leftCircle.ScreenSpaceDrawQuad;
if (Width == 0)
{
return leftQuad;
}
var rightQuad = rightCircle.ScreenSpaceDrawQuad;
return new Quad(leftQuad.TopLeft, rightQuad.TopRight, leftQuad.BottomLeft, rightQuad.BottomRight);
}
}
public ExtendableCircle() public ExtendableCircle()
{ {
var effect = new EdgeEffectParameters Padding = new MarginPadding { Horizontal = -circle_size / 2f };
InternalChild = content = new CircularContainer
{ {
Type = EdgeEffectType.Shadow, RelativeSizeAxes = Axes.Both,
Radius = 5, Masking = true,
Colour = Color4.Black.Opacity(0.4f) EdgeEffect = new EdgeEffectParameters
};
// TODO: figure how to do this whole thing with a single circle to avoid pixel-misaligned edges.
// just working with what i can make work for the time being..
const float fudge = 0.4f;
InternalChildren = new Drawable[]
{
new Container
{ {
RelativeSizeAxes = Axes.Both, Type = EdgeEffectType.Shadow,
Anchor = Anchor.CentreLeft, Radius = 5,
Origin = Anchor.CentreLeft, Colour = Color4.Black.Opacity(0.4f)
Padding = new MarginPadding { Vertical = fudge },
Masking = true,
AlwaysPresent = true,
EdgeEffect = effect,
}, },
leftCircle = new Circle Child = new Box
{ {
EdgeEffect = effect, RelativeSizeAxes = Axes.Both
Origin = Anchor.TopCentre, }
Size = new Vector2(circle_size)
},
rightCircle = new Circle
{
EdgeEffect = effect,
Anchor = Anchor.TopRight,
Origin = Anchor.TopCentre,
Size = new Vector2(circle_size)
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Vertical = fudge },
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new Box { RelativeSizeAxes = Axes.Both, }
}
},
}; };
} }
} }