2021-10-10 18:21:41 +00: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-10 18:32:56 +00:00
|
|
|
using System.Collections.Generic;
|
2022-05-09 17:55:26 +00:00
|
|
|
using osu.Framework.Allocation;
|
2021-10-10 18:21:41 +00:00
|
|
|
using osu.Framework.Graphics;
|
2021-10-10 18:32:56 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-05-16 05:09:37 +00:00
|
|
|
using osu.Framework.Localisation;
|
2021-10-10 18:21:41 +00:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterfaceV2
|
|
|
|
{
|
2021-10-10 18:32:56 +00:00
|
|
|
public class RoundedButton : OsuButton, IFilterable
|
2021-10-10 18:21:41 +00:00
|
|
|
{
|
|
|
|
public override float Height
|
|
|
|
{
|
|
|
|
get => base.Height;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
base.Height = value;
|
|
|
|
|
|
|
|
if (IsLoaded)
|
|
|
|
updateCornerRadius();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-09 17:55:26 +00:00
|
|
|
[BackgroundDependencyLoader(true)]
|
2022-05-24 08:50:23 +00:00
|
|
|
private void load(OsuColour colours)
|
2022-05-09 17:55:26 +00:00
|
|
|
{
|
2022-05-24 08:50:23 +00:00
|
|
|
// According to flyte, buttons are supposed to have explicit colours for now.
|
|
|
|
// Not sure this is the correct direction, but we haven't decided on an `OverlayColourProvider` stand-in yet.
|
|
|
|
// This is a better default. See `SettingsButton` for an override which uses `OverlayColourProvider`.
|
|
|
|
DefaultBackgroundColour = colours.Blue3;
|
2022-05-09 17:55:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-10 18:21:41 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
updateCornerRadius();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateCornerRadius() => Content.CornerRadius = DrawHeight / 2;
|
2021-10-10 18:32:56 +00:00
|
|
|
|
2022-05-16 05:09:37 +00:00
|
|
|
public virtual IEnumerable<LocalisableString> FilterTerms => new[] { Text };
|
2021-10-10 18:32:56 +00:00
|
|
|
|
|
|
|
public bool MatchingFilter
|
|
|
|
{
|
|
|
|
set => this.FadeTo(value ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool FilteringActive { get; set; }
|
2021-10-10 18:21:41 +00:00
|
|
|
}
|
|
|
|
}
|