From 502afc0a4890e67c43f9c13c9780a8cc7714f297 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 4 Apr 2017 18:09:16 +0200 Subject: [PATCH] some fixes to BarGraph so Direction works properly --- osu.Game/Graphics/UserInterface/BarGraph.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index ce8a5f18b8..2daa19bb4e 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -24,9 +24,12 @@ namespace osu.Game.Graphics.UserInterface set { direction = value; + base.Direction = (direction & BarDirection.Horizontal) > 0 ? FillDirection.Vertical : FillDirection.Horizontal; foreach (var bar in Children) + { + bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / Children.Count()) : new Vector2(1.0f / Children.Count(), 1); bar.Direction = direction; - base.Direction = direction == BarDirection.LeftToRight || direction == BarDirection.RightToLeft ? FillDirection.Vertical : FillDirection.Horizontal; + } } } @@ -40,13 +43,13 @@ namespace osu.Game.Graphics.UserInterface if (graphBars.Count > i) { graphBars[i].Length = values[i] / values.Max(); - graphBars[i].Width = 1.0f / values.Count; + graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1); } else Add(new Bar { RelativeSizeAxes = Axes.Both, - Width = 1.0f / values.Count, + Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1), Length = values[i] / values.Max(), Direction = Direction, BackgroundColour = new Color4(0, 0, 0, 0), @@ -165,9 +168,12 @@ namespace osu.Game.Graphics.UserInterface public enum BarDirection { - LeftToRight, - RightToLeft, - TopToBottom, - BottomToTop, + LeftToRight = 1 << 0, + RightToLeft = 1 << 1, + TopToBottom = 1 << 2, + BottomToTop = 1 << 3, + + Vertical = TopToBottom | BottomToTop, + Horizontal = LeftToRight | RightToLeft, } } \ No newline at end of file