1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 14:57:25 +08:00
osu-lazer/osu.Game/Graphics/UserInterfaceV2/RoundedButton.cs

52 lines
1.4 KiB
C#
Raw Normal View History

2021-10-11 02:21:41 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2021-10-11 02:32:56 +08:00
using System.Collections.Generic;
using JetBrains.Annotations;
2021-10-11 02:21:41 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2021-10-11 02:32:56 +08:00
using osu.Framework.Graphics.Containers;
2021-10-11 02:21:41 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
2021-10-11 02:21:41 +08:00
namespace osu.Game.Graphics.UserInterfaceV2
{
2021-10-11 02:32:56 +08:00
public class RoundedButton : OsuButton, IFilterable
2021-10-11 02:21:41 +08:00
{
public override float Height
{
get => base.Height;
set
{
base.Height = value;
if (IsLoaded)
updateCornerRadius();
}
}
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] OverlayColourProvider overlayColourProvider, OsuColour colours)
2021-10-11 02:21:41 +08:00
{
BackgroundColour = overlayColourProvider?.Highlight1 ?? colours.Blue3;
2021-10-11 02:21:41 +08:00
}
protected override void LoadComplete()
{
base.LoadComplete();
updateCornerRadius();
}
private void updateCornerRadius() => Content.CornerRadius = DrawHeight / 2;
2021-10-11 02:32:56 +08:00
public virtual IEnumerable<string> FilterTerms => new[] { Text.ToString() };
public bool MatchingFilter
{
set => this.FadeTo(value ? 1 : 0);
}
public bool FilteringActive { get; set; }
2021-10-11 02:21:41 +08:00
}
}