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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning
|
|
|
|
{
|
|
|
|
/// <summary>
|
2023-02-15 08:24:34 +00:00
|
|
|
/// A container which can be used to specify default skin components layouts.
|
|
|
|
/// Handles applying a default layout to the components.
|
2021-05-11 04:12:24 +00:00
|
|
|
/// </summary>
|
2023-02-15 08:24:34 +00:00
|
|
|
public partial class DefaultSkinComponentsContainer : Container
|
2021-05-11 04:12:24 +00:00
|
|
|
{
|
2022-11-09 04:44:59 +00:00
|
|
|
private readonly Action<Container>? applyDefaults;
|
2021-05-11 04:12:24 +00:00
|
|
|
|
|
|
|
/// <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>
|
2023-02-15 08:24:34 +00:00
|
|
|
public DefaultSkinComponentsContainer(Action<Container> applyDefaults)
|
2021-05-11 04:12:24 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2023-02-15 08:24:34 +00:00
|
|
|
|
|
|
|
this.applyDefaults = applyDefaults;
|
2021-05-11 04:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|