2021-05-11 12:12:24 +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;
|
2021-05-13 12:16:20 +08:00
|
|
|
using Newtonsoft.Json;
|
2021-05-11 12:12:24 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
|
|
|
/// <summary>
|
2021-05-13 17:51:23 +08: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 12:12:24 +08:00
|
|
|
/// </summary>
|
2021-05-13 12:16:20 +08:00
|
|
|
[Serializable]
|
2021-05-13 17:51:23 +08:00
|
|
|
public partial class SkinnableTargetComponentsContainer : Container, ISkinnableDrawable
|
2021-05-11 12:12:24 +08:00
|
|
|
{
|
2021-05-13 16:03:17 +08:00
|
|
|
public bool IsEditable => false;
|
|
|
|
|
2021-06-08 20:22:35 +08:00
|
|
|
public bool UsesFixedAnchor { get; set; }
|
2021-06-07 11:47:47 +08:00
|
|
|
|
2022-11-09 12:44:59 +08:00
|
|
|
private readonly Action<Container>? applyDefaults;
|
2021-05-11 12:12:24 +08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Construct a wrapper with defaults that should be applied once.
|
|
|
|
/// </summary>
|
2021-05-13 15:43:42 +08:00
|
|
|
/// <param name="applyDefaults">A function to apply the default layout.</param>
|
2021-05-13 17:51:23 +08:00
|
|
|
public SkinnableTargetComponentsContainer(Action<Container> applyDefaults)
|
2021-05-11 12:12:24 +08:00
|
|
|
: this()
|
|
|
|
{
|
|
|
|
this.applyDefaults = applyDefaults;
|
|
|
|
}
|
|
|
|
|
2021-05-13 12:16:20 +08:00
|
|
|
[JsonConstructor]
|
2021-05-13 17:51:23 +08:00
|
|
|
public SkinnableTargetComponentsContainer()
|
2021-05-11 12:12:24 +08: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 16:29:11 +08:00
|
|
|
ScheduleAfterChildren(() => applyDefaults?.Invoke(this));
|
2021-05-11 12:12:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|