1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 19:43:03 +08:00
osu-lazer/osu.Game/Skinning/Components/BoxElement.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2.0 KiB
C#
Raw Normal View History

// 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.
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Configuration;
using osu.Game.Localisation.SkinComponents;
using osu.Game.Overlays.Settings;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Skinning.Components
{
public partial class BoxElement : CompositeDrawable, ISerialisableDrawable
{
public bool UsesFixedAnchor { get; set; }
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription),
SettingControlType = typeof(SettingsPercentageSlider<float>))]
public new BindableFloat CornerRadius { get; } = new BindableFloat(0.25f)
{
MinValue = 0,
MaxValue = 0.5f,
Precision = 0.01f
};
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.Colour), nameof(SkinnableComponentStrings.ColourDescription))]
2024-09-20 22:38:26 +08:00
public BindableColour4 AccentColour { get; } = new BindableColour4(Colour4.White);
public BoxElement()
{
Size = new Vector2(400, 80);
InternalChildren = new Drawable[]
{
new Box
{
Colour = Color4.White,
RelativeSizeAxes = Axes.Both,
},
};
Masking = true;
}
protected override void LoadComplete()
{
base.LoadComplete();
AccentColour.BindValueChanged(_ => Colour = AccentColour.Value, true);
}
protected override void Update()
{
base.Update();
base.CornerRadius = CornerRadius.Value * Math.Min(DrawWidth, DrawHeight);
}
}
}