mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 18:53:21 +08:00
Implement BreadcrumbControlOverlayHeader
This commit is contained in:
parent
f2ff57d6b7
commit
ac2280c4ef
@ -15,17 +15,18 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
public class BreadcrumbControl<T> : OsuTabControl<T>
|
public class BreadcrumbControl<T> : OsuTabControl<T>
|
||||||
{
|
{
|
||||||
private const float padding = 10;
|
private const float padding = 10;
|
||||||
private const float item_chevron_size = 10;
|
private float itemChevronSize;
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value)
|
protected override TabItem<T> CreateTabItem(T value) => new BreadcrumbTabItem(value, itemChevronSize)
|
||||||
{
|
{
|
||||||
AccentColour = AccentColour,
|
AccentColour = AccentColour,
|
||||||
};
|
};
|
||||||
|
|
||||||
protected override float StripWidth() => base.StripWidth() - (padding + item_chevron_size);
|
protected override float StripWidth() => base.StripWidth() - (padding + itemChevronSize);
|
||||||
|
|
||||||
public BreadcrumbControl()
|
public BreadcrumbControl(float itemChevronSize = 10)
|
||||||
{
|
{
|
||||||
|
this.itemChevronSize = itemChevronSize;
|
||||||
Height = 32;
|
Height = 32;
|
||||||
TabContainer.Spacing = new Vector2(padding, 0f);
|
TabContainer.Spacing = new Vector2(padding, 0f);
|
||||||
Current.ValueChanged += index =>
|
Current.ValueChanged += index =>
|
||||||
@ -41,7 +42,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
protected class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||||
{
|
{
|
||||||
public event Action<Visibility> StateChanged;
|
public event Action<Visibility> StateChanged;
|
||||||
|
|
||||||
@ -85,17 +86,17 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
public override void Show() => State = Visibility.Visible;
|
public override void Show() => State = Visibility.Visible;
|
||||||
|
|
||||||
public BreadcrumbTabItem(T value)
|
public BreadcrumbTabItem(T value, float itemChevronSize)
|
||||||
: base(value)
|
: base(value)
|
||||||
{
|
{
|
||||||
Text.Font = Text.Font.With(size: 18);
|
Text.Font = Text.Font.With(size: 18);
|
||||||
Text.Margin = new MarginPadding { Vertical = 8 };
|
Text.Margin = new MarginPadding { Vertical = 8 };
|
||||||
Padding = new MarginPadding { Right = padding + item_chevron_size };
|
Padding = new MarginPadding { Right = padding + itemChevronSize };
|
||||||
Add(Chevron = new SpriteIcon
|
Add(Chevron = new SpriteIcon
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Size = new Vector2(item_chevron_size),
|
Size = new Vector2(itemChevronSize),
|
||||||
Icon = FontAwesome.Solid.ChevronRight,
|
Icon = FontAwesome.Solid.ChevronRight,
|
||||||
Margin = new MarginPadding { Left = padding },
|
Margin = new MarginPadding { Left = padding },
|
||||||
Alpha = 0f,
|
Alpha = 0f,
|
||||||
|
10
osu.Game/Overlays/BreadcrumbControlOverlayHeader.cs
Normal file
10
osu.Game/Overlays/BreadcrumbControlOverlayHeader.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
public abstract class BreadcrumbControlOverlayHeader : OverlayHeader<OverlayHeaderBreadcrumbControl>
|
||||||
|
{
|
||||||
|
protected override OverlayHeaderBreadcrumbControl CreateControl() => new OverlayHeaderBreadcrumbControl();
|
||||||
|
}
|
||||||
|
}
|
@ -15,7 +15,7 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Changelog
|
namespace osu.Game.Overlays.Changelog
|
||||||
{
|
{
|
||||||
public class ChangelogHeader : OverlayHeader
|
public class ChangelogHeader : BreadcrumbControlOverlayHeader
|
||||||
{
|
{
|
||||||
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Changelog
|
|||||||
|
|
||||||
public UpdateStreamBadgeArea Streams;
|
public UpdateStreamBadgeArea Streams;
|
||||||
|
|
||||||
private const string listing_string = "Listing";
|
private const string listing_string = "listing";
|
||||||
|
|
||||||
public ChangelogHeader()
|
public ChangelogHeader()
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ using System;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.News
|
namespace osu.Game.Overlays.News
|
||||||
{
|
{
|
||||||
public class NewsHeader : OverlayHeader
|
public class NewsHeader : BreadcrumbControlOverlayHeader
|
||||||
{
|
{
|
||||||
private const string front_page_string = "frontpage";
|
private const string front_page_string = "frontpage";
|
||||||
|
|
||||||
|
@ -5,14 +5,16 @@ using JetBrains.Annotations;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
public abstract class OverlayHeader : Container
|
public abstract class OverlayHeader<TModel> : Container
|
||||||
|
where TModel : TabControl<string>
|
||||||
{
|
{
|
||||||
protected readonly OverlayHeaderTabControl TabControl;
|
protected readonly TModel TabControl;
|
||||||
|
|
||||||
private readonly Box titleBackground;
|
private readonly Box titleBackground;
|
||||||
private readonly Box controlBackground;
|
private readonly Box controlBackground;
|
||||||
@ -85,13 +87,7 @@ namespace osu.Game.Overlays
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.Gray,
|
Colour = Color4.Gray,
|
||||||
},
|
},
|
||||||
TabControl = new OverlayHeaderTabControl
|
TabControl = CreateControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN })
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomLeft,
|
|
||||||
Origin = Anchor.BottomLeft,
|
|
||||||
Height = 35,
|
|
||||||
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CreateContent()
|
CreateContent()
|
||||||
@ -105,5 +101,7 @@ namespace osu.Game.Overlays
|
|||||||
protected virtual Drawable CreateContent() => new Container();
|
protected virtual Drawable CreateContent() => new Container();
|
||||||
|
|
||||||
protected abstract ScreenTitle CreateTitle();
|
protected abstract ScreenTitle CreateTitle();
|
||||||
|
|
||||||
|
protected abstract TModel CreateControl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
osu.Game/Overlays/OverlayHeaderBreadcrumbControl.cs
Normal file
32
osu.Game/Overlays/OverlayHeaderBreadcrumbControl.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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 osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>
|
||||||
|
{
|
||||||
|
private const float item_chevron_size = 8;
|
||||||
|
|
||||||
|
public OverlayHeaderBreadcrumbControl()
|
||||||
|
: base(item_chevron_size)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value, item_chevron_size);
|
||||||
|
|
||||||
|
private class ControlTabItem : BreadcrumbTabItem
|
||||||
|
{
|
||||||
|
public ControlTabItem(string value, float itemChevronSize)
|
||||||
|
: base(value, itemChevronSize)
|
||||||
|
{
|
||||||
|
Text.Font = Text.Font.With(size: 14);
|
||||||
|
Chevron.Y = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,9 @@ namespace osu.Game.Overlays
|
|||||||
BarHeight = 1;
|
BarHeight = 1;
|
||||||
RelativeSizeAxes = Axes.None;
|
RelativeSizeAxes = Axes.None;
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
|
Anchor = Anchor.BottomLeft;
|
||||||
|
Origin = Anchor.BottomLeft;
|
||||||
|
Height = 35;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override TabItem<string> CreateTabItem(string value) => new OverlayHeaderTabItem(value)
|
protected override TabItem<string> CreateTabItem(string value) => new OverlayHeaderTabItem(value)
|
||||||
|
@ -15,7 +15,7 @@ using osu.Game.Users;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Profile
|
namespace osu.Game.Overlays.Profile
|
||||||
{
|
{
|
||||||
public class ProfileHeader : OverlayHeader
|
public class ProfileHeader : TabControlOverlayHeader
|
||||||
{
|
{
|
||||||
private UserCoverBackground coverContainer;
|
private UserCoverBackground coverContainer;
|
||||||
|
|
||||||
|
10
osu.Game/Overlays/TabControlOverlayHeader.cs
Normal file
10
osu.Game/Overlays/TabControlOverlayHeader.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
public abstract class TabControlOverlayHeader : OverlayHeader<OverlayHeaderTabControl>
|
||||||
|
{
|
||||||
|
protected override OverlayHeaderTabControl CreateControl() => new OverlayHeaderTabControl();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user