mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Add EditorSidebar
component
This commit is contained in:
52
osu.Game/Screens/Edit/Components/EditorSidebar.cs
Normal file
52
osu.Game/Screens/Edit/Components/EditorSidebar.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A sidebar area that can be attached to the left or right edge of the screen.
|
||||
/// Houses scrolling sectionised content.
|
||||
/// </summary>
|
||||
internal class EditorSidebar : Container<EditorSidebarSection>
|
||||
{
|
||||
private readonly Box background;
|
||||
|
||||
protected override Container<EditorSidebarSection> Content { get; }
|
||||
|
||||
public EditorSidebar()
|
||||
{
|
||||
Width = 250;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new OsuScrollContainer
|
||||
{
|
||||
Padding = new MarginPadding { Left = 20 },
|
||||
ScrollbarOverlapsContent = false,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = Content = new FillFlowContainer<EditorSidebarSection>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
background.Colour = colourProvider.Background5;
|
||||
}
|
||||
}
|
||||
}
|
73
osu.Game/Screens/Edit/Components/EditorSidebarSection.cs
Normal file
73
osu.Game/Screens/Edit/Components/EditorSidebarSection.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components
|
||||
{
|
||||
public class EditorSidebarSection : Container
|
||||
{
|
||||
protected override Container<Drawable> Content { get; }
|
||||
|
||||
public EditorSidebarSection(LocalisableString sectionName)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SectionHeader(sectionName),
|
||||
Content = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public class SectionHeader : CompositeDrawable
|
||||
{
|
||||
private readonly LocalisableString text;
|
||||
|
||||
public SectionHeader(LocalisableString text)
|
||||
{
|
||||
this.text = text;
|
||||
|
||||
Margin = new MarginPadding { Vertical = 10, Horizontal = 5 };
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = text,
|
||||
Font = OsuFont.Default.With(size: 16, weight: FontWeight.SemiBold),
|
||||
},
|
||||
new Circle
|
||||
{
|
||||
Y = 18,
|
||||
Colour = colourProvider.Highlight1,
|
||||
Size = new Vector2(28, 2),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user