mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Implement EditorTextbox
This commit is contained in:
@ -35,9 +35,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private class TestCommentEditor : CommentEditor
|
private class TestCommentEditor : CommentEditor
|
||||||
{
|
{
|
||||||
protected override string EmptyTextboxText() => @"This textbox is empty";
|
protected override string FooterText => @"Footer text. And it is pretty long. Cool.";
|
||||||
|
|
||||||
protected override string FooterText() => @"Footer text. And it is pretty long. Cool.";
|
protected override string CommitButtonText => @"Commit";
|
||||||
|
|
||||||
|
protected override string TextboxPlaceholderText => @"This textbox is empty";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,20 +7,32 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Comments
|
namespace osu.Game.Overlays.Comments
|
||||||
{
|
{
|
||||||
public abstract class CommentEditor : CompositeDrawable
|
public abstract class CommentEditor : CompositeDrawable
|
||||||
{
|
{
|
||||||
private const int footer_height = 40;
|
private const int footer_height = 40;
|
||||||
|
private const int side_padding = 8;
|
||||||
|
|
||||||
|
protected abstract string FooterText { get; }
|
||||||
|
|
||||||
|
protected abstract string CommitButtonText { get; }
|
||||||
|
|
||||||
|
protected abstract string TextboxPlaceholderText { get; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = footer_height * 2;
|
AutoSizeAxes = Axes.Y;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
CornerRadius = 6;
|
CornerRadius = 6;
|
||||||
|
BorderThickness = 3;
|
||||||
|
BorderColour = colourProvider.Background3;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
@ -29,31 +41,70 @@ namespace osu.Game.Overlays.Comments
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colourProvider.Background3
|
Colour = colourProvider.Background3
|
||||||
},
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new EditorTextbox
|
||||||
|
{
|
||||||
|
Height = footer_height,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
PlaceholderText = TextboxPlaceholderText
|
||||||
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Name = "Footer",
|
Name = "Footer",
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = footer_height,
|
Height = footer_height,
|
||||||
Padding = new MarginPadding { Horizontal = 8 },
|
Padding = new MarginPadding { Horizontal = side_padding },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.GetFont(size: 12),
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
||||||
Shadow = false,
|
Text = FooterText
|
||||||
Text = FooterText()
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract string FooterText();
|
private class EditorTextbox : BasicTextBox
|
||||||
|
{
|
||||||
|
protected override float LeftRightPadding => side_padding;
|
||||||
|
|
||||||
protected abstract string EmptyTextboxText();
|
protected override Color4 SelectionColour => Color4.LightSkyBlue;
|
||||||
|
|
||||||
|
private OsuSpriteText placeholder;
|
||||||
|
|
||||||
|
public EditorTextbox()
|
||||||
|
{
|
||||||
|
Masking = false;
|
||||||
|
TextContainer.Height = 0.4f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OverlayColourProvider colourProvider)
|
||||||
|
{
|
||||||
|
BackgroundUnfocused = BackgroundFocused = colourProvider.Background5;
|
||||||
|
placeholder.Colour = colourProvider.Background3;
|
||||||
|
BackgroundCommit = Color4.LightSkyBlue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override SpriteText CreatePlaceholder() => placeholder = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(weight: FontWeight.Regular),
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user