mirror of
https://github.com/ppy/osu
synced 2025-03-11 05:49:12 +00:00
Add more documentation around the implementation of FontAdjustableSkinComponent
This commit is contained in:
parent
d63719a602
commit
64e7f6f138
@ -10,23 +10,30 @@ using osu.Game.Graphics;
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Skin element that contains text and have ability to control its font.
|
||||
/// A skin component that contains text and allows the user to choose its font.
|
||||
/// </summary>
|
||||
public abstract partial class FontAdjustableSkinComponent : Container, ISkinnableDrawable
|
||||
{
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
[SettingSource("Font", "Font to use.")]
|
||||
[SettingSource("Font", "The font to use.")]
|
||||
public Bindable<Typeface> Font { get; } = new Bindable<Typeface>(Typeface.Torus);
|
||||
|
||||
/// <summary>
|
||||
/// Implement to apply the user font selection to one or more components.
|
||||
/// </summary>
|
||||
protected abstract void SetFont(FontUsage font);
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Font.BindValueChanged(e =>
|
||||
{
|
||||
FontUsage f = OsuFont.GetFont(e.NewValue, weight: e.NewValue == Typeface.Venera ? FontWeight.Bold : FontWeight.Regular);
|
||||
// We only have bold weight for venera, so let's force that.
|
||||
FontWeight fontWeight = e.NewValue == Typeface.Venera ? FontWeight.Bold : FontWeight.Regular;
|
||||
|
||||
FontUsage f = OsuFont.GetFont(e.NewValue, weight: fontWeight);
|
||||
SetFont(f);
|
||||
}, true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user