From 148551afa2874088f34319a20c0ed967d377a526 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Tue, 6 Mar 2018 14:12:37 +0900
Subject: [PATCH 1/4] osu!-side changes in-line with framework layout changes

---
 osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs | 2 +-
 osu.Game/Screens/Menu/FlowContainerWithOrigin.cs                | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs
index 9f028490ef..5e92eead46 100644
--- a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs
@@ -12,6 +12,6 @@ namespace osu.Game.Graphics.Containers
     {
         protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
 
-        protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
+        public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
     }
 }
diff --git a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
index 29ae35fca4..e61c309931 100644
--- a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
+++ b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
@@ -22,7 +22,7 @@ namespace osu.Game.Screens.Menu
 
         protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
 
-        protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
+        public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
 
         public override Anchor Origin => Anchor.Custom;
 

From 27e0ed4ea8fb6299ddc8b8c54949fbd9bbf6dccc Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Tue, 6 Mar 2018 14:16:17 +0900
Subject: [PATCH 2/4] Update framework

---
 osu-framework | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/osu-framework b/osu-framework
index 71900dc350..adf1e9548d 160000
--- a/osu-framework
+++ b/osu-framework
@@ -1 +1 @@
-Subproject commit 71900dc350bcebbb60d912d4023a1d2a6bbbc3c1
+Subproject commit adf1e9548d1fff8717c87eedb358a3c2517358a8

From 78d73d4c11c40772221a75a9dd859a5e92aec1b9 Mon Sep 17 00:00:00 2001
From: smoogipoo <smoogipoo@smgi.me>
Date: Tue, 6 Mar 2018 17:20:58 +0900
Subject: [PATCH 3/4] Additional fixes for flow ordering after framework
 changes

---
 .../ReverseChildIDFillFlowContainer.cs        |  4 ---
 .../Graphics/UserInterface/OsuTabControl.cs   | 14 +++++++++
 osu.Game/Overlays/Chat/ChatTabControl.cs      |  4 +--
 osu.Game/Overlays/Music/PlaylistList.cs       | 20 +++++--------
 osu.Game/Overlays/NotificationOverlay.cs      |  5 ++--
 .../Notifications/NotificationSection.cs      |  7 +++--
 .../Sections/Ranks/DrawableProfileScore.cs    | 10 ++++---
 osu.Game/Overlays/Settings/SettingsItem.cs    |  3 +-
 .../Screens/Menu/FlowContainerWithOrigin.cs   |  4 ---
 osu.Game/Screens/Select/Footer.cs             | 30 +++++++++++--------
 .../Select/Options/BeatmapOptionsOverlay.cs   |  7 +++--
 11 files changed, 63 insertions(+), 45 deletions(-)

diff --git a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs
index 5e92eead46..5803c8a5db 100644
--- a/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs
+++ b/osu.Game/Graphics/Containers/ReverseChildIDFillFlowContainer.cs
@@ -1,8 +1,6 @@
 // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
 // 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.Containers;
 
@@ -11,7 +9,5 @@ namespace osu.Game.Graphics.Containers
     public class ReverseChildIDFillFlowContainer<T> : FillFlowContainer<T> where T : Drawable
     {
         protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
-
-        public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
     }
 }
diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs
index 7ad9bc73a8..20385a7dae 100644
--- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs
+++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs
@@ -9,6 +9,7 @@ using osu.Framework.Allocation;
 using osu.Framework.Extensions;
 using osu.Framework.Extensions.Color4Extensions;
 using osu.Framework.Graphics;
+using osu.Framework.Graphics.Containers;
 using osu.Framework.Graphics.Shapes;
 using osu.Framework.Graphics.Sprites;
 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
         {
             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);
+        }
     }
 }
diff --git a/osu.Game/Overlays/Chat/ChatTabControl.cs b/osu.Game/Overlays/Chat/ChatTabControl.cs
index f028590bb4..1d3dab249d 100644
--- a/osu.Game/Overlays/Chat/ChatTabControl.cs
+++ b/osu.Game/Overlays/Chat/ChatTabControl.cs
@@ -53,9 +53,9 @@ namespace osu.Game.Overlays.Chat
 
         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
-                TabContainer.ChangeChildDepth(selectorTab, float.MaxValue);
+                TabContainer.SetLayoutPosition(selectorTab, float.MaxValue);
 
             base.AddTabItem(item, addToDropdown);
 
diff --git a/osu.Game/Overlays/Music/PlaylistList.cs b/osu.Game/Overlays/Music/PlaylistList.cs
index 31b7d0f9aa..03ce7fd88f 100644
--- a/osu.Game/Overlays/Music/PlaylistList.cs
+++ b/osu.Game/Overlays/Music/PlaylistList.cs
@@ -101,11 +101,10 @@ namespace osu.Game.Overlays.Music
 
             public void AddBeatmapSet(BeatmapSetInfo beatmapSet)
             {
-                items.Add(new PlaylistItem(beatmapSet)
-                {
-                    OnSelect = set => OnSelect?.Invoke(set),
-                    Depth = items.Count
-                });
+                var newItem = new PlaylistItem(beatmapSet) { OnSelect = set => OnSelect?.Invoke(set) };
+
+                items.Add(newItem);
+                items.SetLayoutPosition(newItem, items.Count);
             }
 
             public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
@@ -197,7 +196,7 @@ namespace osu.Game.Overlays.Music
             {
                 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
                 // the item positions as they are being transformed
@@ -219,15 +218,15 @@ namespace osu.Game.Overlays.Music
                 if (srcIndex < dstIndex)
                 {
                     for (int i = srcIndex + 1; i <= dstIndex; i++)
-                        items.ChangeChildDepth(items[i], i - 1);
+                        items.SetLayoutPosition(items[i], i - 1);
                 }
                 else
                 {
                     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
@@ -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 ItemSearchContainer()
diff --git a/osu.Game/Overlays/NotificationOverlay.cs b/osu.Game/Overlays/NotificationOverlay.cs
index 2f46bb4a71..48ad507d88 100644
--- a/osu.Game/Overlays/NotificationOverlay.cs
+++ b/osu.Game/Overlays/NotificationOverlay.cs
@@ -129,7 +129,6 @@ namespace osu.Game.Overlays
         public void Post(Notification notification) => postScheduler.Add(() =>
         {
             ++runningDepth;
-            notification.Depth = notification.DisplayOnTop ? runningDepth : -runningDepth;
 
             notification.Closed += notificationClosed;
 
@@ -138,7 +137,9 @@ namespace osu.Game.Overlays
                 hasCompletionTarget.CompletionTarget = Post;
 
             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();
         });
diff --git a/osu.Game/Overlays/Notifications/NotificationSection.cs b/osu.Game/Overlays/Notifications/NotificationSection.cs
index 13a69fbe3a..533f5326e3 100644
--- a/osu.Game/Overlays/Notifications/NotificationSection.cs
+++ b/osu.Game/Overlays/Notifications/NotificationSection.cs
@@ -25,10 +25,13 @@ namespace osu.Game.Overlays.Notifications
         private FlowContainer<Notification> notifications;
 
         public int DisplayedCount => notifications.Count(n => !n.WasClosed);
-
         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;
 
diff --git a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs
index 51b202844a..bb1a409f2e 100644
--- a/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs
+++ b/osu.Game/Overlays/Profile/Sections/Ranks/DrawableProfileScore.cs
@@ -40,16 +40,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
         [BackgroundDependencyLoader(true)]
         private void load(OsuColour colour)
         {
-            RightFlowContainer.Add(new OsuSpriteText
+            var text = new OsuSpriteText
             {
                 Text = $"accuracy: {Score.Accuracy:P2}",
                 Anchor = Anchor.TopRight,
                 Origin = Anchor.TopRight,
                 Colour = colour.GrayA,
                 TextSize = 11,
-                Font = "Exo2.0-RegularItalic",
-                Depth = -1,
-            });
+                Font = "Exo2.0-RegularItalic"
+            };
+
+            RightFlowContainer.Add(text);
+            RightFlowContainer.SetLayoutPosition(text, 1);
 
             LeftFlowContainer.Add(new BeatmapMetadataContainer(Score.Beatmap));
             LeftFlowContainer.Add(new OsuSpriteText
diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs
index 5afc415d83..cc290fe1bb 100644
--- a/osu.Game/Overlays/Settings/SettingsItem.cs
+++ b/osu.Game/Overlays/Settings/SettingsItem.cs
@@ -45,7 +45,8 @@ namespace osu.Game.Overlays.Settings
                 if (text == null)
                 {
                     // 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;
diff --git a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
index e61c309931..ae1e995373 100644
--- a/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
+++ b/osu.Game/Screens/Menu/FlowContainerWithOrigin.cs
@@ -4,8 +4,6 @@
 using osu.Framework.Graphics;
 using osu.Framework.Graphics.Containers;
 using OpenTK;
-using System.Collections.Generic;
-using System.Linq;
 
 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);
 
-        public override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
-
         public override Anchor Origin => Anchor.Custom;
 
         public override Vector2 OriginPosition
diff --git a/osu.Game/Screens/Select/Footer.cs b/osu.Game/Screens/Select/Footer.cs
index 21e6108489..be83d7b500 100644
--- a/osu.Game/Screens/Select/Footer.cs
+++ b/osu.Game/Screens/Select/Footer.cs
@@ -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>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
         /// </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,
-            Height = play_song_select_button_height,
-            Width = play_song_select_button_width,
-            Depth = depth,
-            SelectedColour = colour,
-            DeselectedColour = colour.Opacity(0.5f),
-            Hotkey = hotkey,
-            Hovered = updateModeLight,
-            HoverLost = updateModeLight,
-            Action = action,
-        });
+            var button = new FooterButton
+            {
+                Text = text,
+                Height = play_song_select_button_height,
+                Width = play_song_select_button_width,
+                Depth = depth,
+                SelectedColour = colour,
+                DeselectedColour = colour.Opacity(0.5f),
+                Hotkey = hotkey,
+                Hovered = updateModeLight,
+                HoverLost = updateModeLight,
+                Action = action,
+            };
+
+            buttons.Add(button);
+            buttons.SetLayoutPosition(button, -depth);
+        }
 
         private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
 
diff --git a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs
index 2e8b2f9014..dee1ec4511 100644
--- a/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs
+++ b/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs
@@ -95,7 +95,7 @@ namespace osu.Game.Screens.Select.Options
         /// </param>
         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,
                 SecondLineText = secondLine,
@@ -108,7 +108,10 @@ namespace osu.Game.Screens.Select.Options
                     action?.Invoke();
                 },
                 HotKey = hotkey
-            });
+            };
+
+            buttonsContainer.Add(button);
+            buttonsContainer.SetLayoutPosition(button, depth);
         }
     }
 }

From 08c469a8b3494446ea5d4d9e7294164a86cfc9f3 Mon Sep 17 00:00:00 2001
From: Dean Herbert <pe@ppy.sh>
Date: Wed, 7 Mar 2018 13:22:08 +0900
Subject: [PATCH 4/4] Update framework

---
 osu-framework | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/osu-framework b/osu-framework
index adf1e9548d..6372fb22c1 160000
--- a/osu-framework
+++ b/osu-framework
@@ -1 +1 @@
-Subproject commit adf1e9548d1fff8717c87eedb358a3c2517358a8
+Subproject commit 6372fb22c1c85f600921a139849b8dedf71026d5