mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:13:20 +08:00
Merge pull request #2175 from smoogipoo/flowcontainer-changes
Update framework with FlowContainer changes
This commit is contained in:
commit
b84367c52a
@ -1 +1 @@
|
|||||||
Subproject commit 71900dc350bcebbb60d912d4023a1d2a6bbbc3c1
|
Subproject commit 6372fb22c1c85f600921a139849b8dedf71026d5
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
|
||||||
@ -11,7 +9,5 @@ namespace osu.Game.Graphics.Containers
|
|||||||
public class ReverseChildIDFillFlowContainer<T> : FillFlowContainer<T> where T : Drawable
|
public class ReverseChildIDFillFlowContainer<T> : FillFlowContainer<T> where T : Drawable
|
||||||
{
|
{
|
||||||
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
@ -56,6 +57,14 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
|
||||||
|
{
|
||||||
|
Direction = FillDirection.Full,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Depth = -1,
|
||||||
|
Masking = true
|
||||||
|
};
|
||||||
|
|
||||||
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
||||||
{
|
{
|
||||||
protected readonly SpriteText Text;
|
protected readonly SpriteText Text;
|
||||||
@ -239,5 +248,10 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class OsuTabFillFlowContainer : TabFillFlowContainer
|
||||||
|
{
|
||||||
|
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,9 @@ namespace osu.Game.Overlays.Chat
|
|||||||
|
|
||||||
protected override void AddTabItem(TabItem<Channel> item, bool addToDropdown = true)
|
protected override void AddTabItem(TabItem<Channel> item, bool addToDropdown = true)
|
||||||
{
|
{
|
||||||
if (selectorTab.Depth < float.MaxValue)
|
if (item != selectorTab && TabContainer.GetLayoutPosition(selectorTab) < float.MaxValue)
|
||||||
// performTabSort might've made selectorTab's position wonky, fix it
|
// performTabSort might've made selectorTab's position wonky, fix it
|
||||||
TabContainer.ChangeChildDepth(selectorTab, float.MaxValue);
|
TabContainer.SetLayoutPosition(selectorTab, float.MaxValue);
|
||||||
|
|
||||||
base.AddTabItem(item, addToDropdown);
|
base.AddTabItem(item, addToDropdown);
|
||||||
|
|
||||||
|
@ -101,11 +101,10 @@ namespace osu.Game.Overlays.Music
|
|||||||
|
|
||||||
public void AddBeatmapSet(BeatmapSetInfo beatmapSet)
|
public void AddBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
items.Add(new PlaylistItem(beatmapSet)
|
var newItem = new PlaylistItem(beatmapSet) { OnSelect = set => OnSelect?.Invoke(set) };
|
||||||
{
|
|
||||||
OnSelect = set => OnSelect?.Invoke(set),
|
items.Add(newItem);
|
||||||
Depth = items.Count
|
items.SetLayoutPosition(newItem, items.Count);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
@ -197,7 +196,7 @@ namespace osu.Game.Overlays.Music
|
|||||||
{
|
{
|
||||||
var itemsPos = items.ToLocalSpace(nativeDragPosition);
|
var itemsPos = items.ToLocalSpace(nativeDragPosition);
|
||||||
|
|
||||||
int srcIndex = (int)draggedItem.Depth;
|
int srcIndex = (int)items.GetLayoutPosition(draggedItem);
|
||||||
|
|
||||||
// Find the last item with position < mouse position. Note we can't directly use
|
// Find the last item with position < mouse position. Note we can't directly use
|
||||||
// the item positions as they are being transformed
|
// the item positions as they are being transformed
|
||||||
@ -219,15 +218,15 @@ namespace osu.Game.Overlays.Music
|
|||||||
if (srcIndex < dstIndex)
|
if (srcIndex < dstIndex)
|
||||||
{
|
{
|
||||||
for (int i = srcIndex + 1; i <= dstIndex; i++)
|
for (int i = srcIndex + 1; i <= dstIndex; i++)
|
||||||
items.ChangeChildDepth(items[i], i - 1);
|
items.SetLayoutPosition(items[i], i - 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = dstIndex; i < srcIndex; i++)
|
for (int i = dstIndex; i < srcIndex; i++)
|
||||||
items.ChangeChildDepth(items[i], i + 1);
|
items.SetLayoutPosition(items[i], i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
items.ChangeChildDepth(draggedItem, dstIndex);
|
items.SetLayoutPosition(draggedItem, dstIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ItemSearchContainer : FillFlowContainer<PlaylistItem>, IHasFilterableChildren
|
private class ItemSearchContainer : FillFlowContainer<PlaylistItem>, IHasFilterableChildren
|
||||||
@ -243,9 +242,6 @@ namespace osu.Game.Overlays.Music
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare with reversed ChildID and Depth
|
|
||||||
protected override int Compare(Drawable x, Drawable y) => base.Compare(y, x);
|
|
||||||
|
|
||||||
public IEnumerable<IFilterable> FilterableChildren => Children;
|
public IEnumerable<IFilterable> FilterableChildren => Children;
|
||||||
|
|
||||||
public ItemSearchContainer()
|
public ItemSearchContainer()
|
||||||
|
@ -129,7 +129,6 @@ namespace osu.Game.Overlays
|
|||||||
public void Post(Notification notification) => postScheduler.Add(() =>
|
public void Post(Notification notification) => postScheduler.Add(() =>
|
||||||
{
|
{
|
||||||
++runningDepth;
|
++runningDepth;
|
||||||
notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
|
|
||||||
|
|
||||||
notification.Closed += notificationClosed;
|
notification.Closed += notificationClosed;
|
||||||
|
|
||||||
@ -138,7 +137,9 @@ namespace osu.Game.Overlays
|
|||||||
hasCompletionTarget.CompletionTarget = Post;
|
hasCompletionTarget.CompletionTarget = Post;
|
||||||
|
|
||||||
var ourType = notification.GetType();
|
var ourType = notification.GetType();
|
||||||
sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)))?.Add(notification);
|
|
||||||
|
var section = sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
||||||
|
section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth);
|
||||||
|
|
||||||
updateCounts();
|
updateCounts();
|
||||||
});
|
});
|
||||||
|
@ -25,10 +25,13 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
private FlowContainer<Notification> notifications;
|
private FlowContainer<Notification> notifications;
|
||||||
|
|
||||||
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
|
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
|
||||||
|
|
||||||
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
|
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
|
||||||
|
|
||||||
public void Add(Notification notification) => notifications.Add(notification);
|
public void Add(Notification notification, float position)
|
||||||
|
{
|
||||||
|
notifications.Add(notification);
|
||||||
|
notifications.SetLayoutPosition(notification, position);
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> AcceptTypes;
|
public IEnumerable<Type> AcceptTypes;
|
||||||
|
|
||||||
|
@ -40,16 +40,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuColour colour)
|
private void load(OsuColour colour)
|
||||||
{
|
{
|
||||||
RightFlowContainer.Add(new OsuSpriteText
|
var text = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = $"accuracy: {Score.Accuracy:P2}",
|
Text = $"accuracy: {Score.Accuracy:P2}",
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Colour = colour.GrayA,
|
Colour = colour.GrayA,
|
||||||
TextSize = 11,
|
TextSize = 11,
|
||||||
Font = "Exo2.0-RegularItalic",
|
Font = "Exo2.0-RegularItalic"
|
||||||
Depth = -1,
|
};
|
||||||
});
|
|
||||||
|
RightFlowContainer.Add(text);
|
||||||
|
RightFlowContainer.SetLayoutPosition(text, 1);
|
||||||
|
|
||||||
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
|
||||||
LeftFlowContainer.Add(new OsuSpriteText
|
LeftFlowContainer.Add(new OsuSpriteText
|
||||||
|
@ -45,7 +45,8 @@ namespace osu.Game.Overlays.Settings
|
|||||||
if (text == null)
|
if (text == null)
|
||||||
{
|
{
|
||||||
// construct lazily for cases where the label is not needed (may be provided by the Control).
|
// construct lazily for cases where the label is not needed (may be provided by the Control).
|
||||||
Add(text = new OsuSpriteText { Depth = 1 });
|
Add(text = new OsuSpriteText());
|
||||||
|
FlowContent.SetLayoutPosition(text, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
text.Text = value;
|
text.Text = value;
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Menu
|
namespace osu.Game.Screens.Menu
|
||||||
{
|
{
|
||||||
@ -22,8 +20,6 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
|
||||||
|
|
||||||
public override Anchor Origin => Anchor.Custom;
|
public override Anchor Origin => Anchor.Custom;
|
||||||
|
|
||||||
public override Vector2 OriginPosition
|
public override Vector2 OriginPosition
|
||||||
|
@ -41,19 +41,25 @@ namespace osu.Game.Screens.Select
|
|||||||
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
||||||
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
||||||
/// </param>
|
/// </param>
|
||||||
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton
|
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
||||||
{
|
{
|
||||||
Text = text,
|
var button = new FooterButton
|
||||||
Height = play_song_select_button_height,
|
{
|
||||||
Width = play_song_select_button_width,
|
Text = text,
|
||||||
Depth = depth,
|
Height = play_song_select_button_height,
|
||||||
SelectedColour = colour,
|
Width = play_song_select_button_width,
|
||||||
DeselectedColour = colour.Opacity(0.5f),
|
Depth = depth,
|
||||||
Hotkey = hotkey,
|
SelectedColour = colour,
|
||||||
Hovered = updateModeLight,
|
DeselectedColour = colour.Opacity(0.5f),
|
||||||
HoverLost = updateModeLight,
|
Hotkey = hotkey,
|
||||||
Action = action,
|
Hovered = updateModeLight,
|
||||||
});
|
HoverLost = updateModeLight,
|
||||||
|
Action = action,
|
||||||
|
};
|
||||||
|
|
||||||
|
buttons.Add(button);
|
||||||
|
buttons.SetLayoutPosition(button, -depth);
|
||||||
|
}
|
||||||
|
|
||||||
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ namespace osu.Game.Screens.Select.Options
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void AddButton(string firstLine, string secondLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
public void AddButton(string firstLine, string secondLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
||||||
{
|
{
|
||||||
buttonsContainer.Add(new BeatmapOptionsButton
|
var button = new BeatmapOptionsButton
|
||||||
{
|
{
|
||||||
FirstLineText = firstLine,
|
FirstLineText = firstLine,
|
||||||
SecondLineText = secondLine,
|
SecondLineText = secondLine,
|
||||||
@ -108,7 +108,10 @@ namespace osu.Game.Screens.Select.Options
|
|||||||
action?.Invoke();
|
action?.Invoke();
|
||||||
},
|
},
|
||||||
HotKey = hotkey
|
HotKey = hotkey
|
||||||
});
|
};
|
||||||
|
|
||||||
|
buttonsContainer.Add(button);
|
||||||
|
buttonsContainer.SetLayoutPosition(button, depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user