some fixes to BarGraph so Direction works properly

This commit is contained in:
Jorolf 2017-04-04 18:09:16 +02:00
parent b2731bb0a1
commit 502afc0a48

View File

@ -24,9 +24,12 @@ namespace osu.Game.Graphics.UserInterface
set set
{ {
direction = value; direction = value;
base.Direction = (direction & BarDirection.Horizontal) > 0 ? FillDirection.Vertical : FillDirection.Horizontal;
foreach (var bar in Children) 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; 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) if (graphBars.Count > i)
{ {
graphBars[i].Length = values[i] / values.Max(); 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 else
Add(new Bar Add(new Bar
{ {
RelativeSizeAxes = Axes.Both, 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(), Length = values[i] / values.Max(),
Direction = Direction, Direction = Direction,
BackgroundColour = new Color4(0, 0, 0, 0), BackgroundColour = new Color4(0, 0, 0, 0),
@ -165,9 +168,12 @@ namespace osu.Game.Graphics.UserInterface
public enum BarDirection public enum BarDirection
{ {
LeftToRight, LeftToRight = 1 << 0,
RightToLeft, RightToLeft = 1 << 1,
TopToBottom, TopToBottom = 1 << 2,
BottomToTop, BottomToTop = 1 << 3,
Vertical = TopToBottom | BottomToTop,
Horizontal = LeftToRight | RightToLeft,
} }
} }