2021-05-11 04:12:24 +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
|
|
|
|
|
2021-05-11 04:12:24 +00:00
|
|
|
using System;
|
2021-05-13 04:16:20 +00:00
|
|
|
using Newtonsoft.Json;
|
2021-05-11 04:12:24 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
|
|
|
/// <summary>
|
2021-05-13 09:51:23 +00:00
|
|
|
/// A container which groups the components of a <see cref="SkinnableTargetContainer"/> into a single object.
|
|
|
|
/// Optionally also applies a default layout to the components.
|
2021-05-11 04:12:24 +00:00
|
|
|
/// </summary>
|
2021-05-13 04:16:20 +00:00
|
|
|
[Serializable]
|
2021-05-13 09:51:23 +00:00
|
|
|
public class SkinnableTargetComponentsContainer : Container, ISkinnableDrawable
|
2021-05-11 04:12:24 +00:00
|
|
|
{
|
2021-05-13 08:03:17 +00:00
|
|
|
public bool IsEditable => false;
|
|
|
|
|
2021-06-08 12:22:35 +00:00
|
|
|
public bool UsesFixedAnchor { get; set; }
|
2021-06-07 03:47:47 +00:00
|
|
|
|
2021-05-11 04:12:24 +00:00
|
|
|
private readonly Action<Container> applyDefaults;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Construct a wrapper with defaults that should be applied once.
|
|
|
|
/// </summary>
|
2021-05-13 07:43:42 +00:00
|
|
|
/// <param name="applyDefaults">A function to apply the default layout.</param>
|
2021-05-13 09:51:23 +00:00
|
|
|
public SkinnableTargetComponentsContainer(Action<Container> applyDefaults)
|
2021-05-11 04:12:24 +00:00
|
|
|
: this()
|
|
|
|
{
|
|
|
|
this.applyDefaults = applyDefaults;
|
|
|
|
}
|
|
|
|
|
2021-05-13 04:16:20 +00:00
|
|
|
[JsonConstructor]
|
2021-05-13 09:51:23 +00:00
|
|
|
public SkinnableTargetComponentsContainer()
|
2021-05-11 04:12:24 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
// schedule is required to allow children to run their LoadComplete and take on their correct sizes.
|
2021-05-13 08:29:11 +00:00
|
|
|
ScheduleAfterChildren(() => applyDefaults?.Invoke(this));
|
2021-05-11 04:12:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|