2021-04-28 09:34:34 +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.
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2022-03-11 14:27:27 +00:00
|
|
|
using System;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.TypeExtensions;
|
2021-05-13 08:03:17 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
2021-04-30 03:42:32 +00:00
|
|
|
namespace osu.Game.Skinning
|
2021-04-28 09:34:34 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Denotes a drawable which, as a drawable, can be adjusted via skinning specifications.
|
|
|
|
/// </summary>
|
2021-05-13 08:06:00 +00:00
|
|
|
public interface ISkinnableDrawable : IDrawable
|
2021-04-28 09:34:34 +00:00
|
|
|
{
|
2021-05-13 08:03:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Whether this component should be editable by an end user.
|
|
|
|
/// </summary>
|
|
|
|
bool IsEditable => true;
|
2021-06-07 03:47:47 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2021-06-22 07:40:48 +00:00
|
|
|
/// In the context of the skin layout editor, whether this <see cref="ISkinnableDrawable"/> has a permanent anchor defined.
|
|
|
|
/// If <see langword="false"/>, this <see cref="ISkinnableDrawable"/>'s <see cref="Drawable.Anchor"/> is automatically determined by proximity,
|
|
|
|
/// If <see langword="true"/>, a fixed anchor point has been defined.
|
2021-06-07 03:47:47 +00:00
|
|
|
/// </summary>
|
2021-06-08 12:22:35 +00:00
|
|
|
bool UsesFixedAnchor { get; set; }
|
2022-03-11 14:27:27 +00:00
|
|
|
|
|
|
|
void CopyAdjustedSetting(IBindable target, object source)
|
|
|
|
{
|
|
|
|
if (source is IBindable sourceBindable)
|
|
|
|
{
|
|
|
|
// copy including transfer of default values.
|
|
|
|
target.BindTo(sourceBindable);
|
|
|
|
target.UnbindFrom(sourceBindable);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(target is IParseable parseable))
|
|
|
|
throw new InvalidOperationException($"Bindable type {target.GetType().ReadableName()} is not {nameof(IParseable)}.");
|
|
|
|
|
|
|
|
parseable.Parse(source);
|
|
|
|
}
|
|
|
|
}
|
2021-04-28 09:34:34 +00:00
|
|
|
}
|
|
|
|
}
|