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