Merge pull request #172 from Tom94/better-anchors

Better anchors
This commit is contained in:
Dean Herbert
2016-11-15 14:48:21 +09:00
committed by GitHub
9 changed files with 35 additions and 24 deletions

View File

@ -20,6 +20,7 @@ using osu.Game.Modes.UI;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Desktop.VisualTests.Tests namespace osu.Desktop.VisualTests.Tests
{ {
@ -43,7 +44,7 @@ namespace osu.Desktop.VisualTests.Tests
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
TextSize = 40, TextSize = 40,
Count = 0, Count = 0,
Position = new Vector2(20, 20), Margin = new MarginPadding(20),
}; };
Add(score); Add(score);
@ -51,8 +52,8 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(10, 10), Margin = new MarginPadding(10),
InnerCountPosition = new Vector2(10, 10), InnerCountMargin = new MarginPadding(10),
Count = 0, Count = 0,
TextSize = 40, TextSize = 40,
}; };
@ -92,7 +93,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Position = new Vector2(20, 60), Position = new Vector2(-20, 60),
}; };
Add(accuracyCombo); Add(accuracyCombo);
@ -100,7 +101,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 160), Position = new Vector2(20, -160),
Count = 5, Count = 5,
}; };
Add(stars); Add(stars);
@ -109,7 +110,7 @@ namespace osu.Desktop.VisualTests.Tests
{ {
Origin = Anchor.BottomLeft, Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(20, 190), Position = new Vector2(20, -190),
Text = stars.Count.ToString("0.00"), Text = stars.Count.ToString("0.00"),
}; };
Add(starsLabel); Add(starsLabel);

View File

@ -3,6 +3,7 @@
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using OpenTK; using OpenTK;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Modes.Osu.UI namespace osu.Game.Modes.Osu.UI
{ {
@ -16,15 +17,15 @@ namespace osu.Game.Modes.Osu.UI
protected virtual float PopOutSmallScale => 1.1f; protected virtual float PopOutSmallScale => 1.1f;
protected virtual bool CanPopOutWhileRolling => false; protected virtual bool CanPopOutWhileRolling => false;
public Vector2 InnerCountPosition public MarginPadding InnerCountMargin
{ {
get get
{ {
return DisplayedCountSpriteText.Position; return DisplayedCountSpriteText.Margin;
} }
set set
{ {
DisplayedCountSpriteText.Position = value; DisplayedCountSpriteText.Margin = value;
} }
} }

View File

@ -6,6 +6,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Modes.UI; using osu.Game.Modes.UI;
using OpenTK; using OpenTK;
using OpenTK.Input; using OpenTK.Input;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Modes.Osu.UI namespace osu.Game.Modes.Osu.UI
{ {
@ -37,7 +38,7 @@ namespace osu.Game.Modes.Osu.UI
FadeTime = 50, FadeTime = 50,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
Position = new Vector2(10), Margin = new MarginPadding(10),
Counters = new KeyCounter[] Counters = new KeyCounter[]
{ {
new KeyCounterKeyboard(@"Z", Key.Z), new KeyCounterKeyboard(@"Z", Key.Z),

View File

@ -7,6 +7,7 @@ using osu.Framework.Input;
using osu.Framework.Threading; using osu.Framework.Threading;
using OpenTK; using OpenTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Graphics.UserInterface.Volume namespace osu.Game.Graphics.UserInterface.Volume
{ {
@ -40,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface.Volume
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight, Origin = Anchor.BottomRight,
Position = new Vector2(10, 30), Margin = new MarginPadding { Left = 10, Right = 10, Top = 30, Bottom = 30 },
Spacing = new Vector2(15, 0), Spacing = new Vector2(15, 0),
}); });
} }

View File

@ -145,7 +145,7 @@ namespace osu.Game.Overlays
protected override void PopOut() protected override void PopOut()
{ {
MoveToY(-DrawSize.Y, transition_length, EasingTypes.InQuint); MoveToY(DrawSize.Y, transition_length, EasingTypes.InQuint);
FadeOut(transition_length, EasingTypes.InQuint); FadeOut(transition_length, EasingTypes.InQuint);
} }
} }

View File

@ -22,12 +22,13 @@ using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
public class MusicController : OverlayContainer public class MusicController : OverlayContainer
{ {
private static readonly Vector2 start_position = new Vector2(10, 60); private static readonly Vector2 start_position = new Vector2(0, 50);
private MusicControllerBackground backgroundSprite; private MusicControllerBackground backgroundSprite;
private DragBar progress; private DragBar progress;
@ -63,6 +64,8 @@ namespace osu.Game.Overlays
Anchor = Anchor.TopRight;//placeholder Anchor = Anchor.TopRight;//placeholder
Origin = Anchor.TopRight; Origin = Anchor.TopRight;
Position = start_position; Position = start_position;
Margin = new MarginPadding(10);
Children = new Drawable[] Children = new Drawable[]
{ {
title = new SpriteText title = new SpriteText
@ -90,7 +93,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Position = new Vector2(0, 30), Position = new Vector2(0, -30),
Action = () => Action = () =>
{ {
if (current?.Track == null) return; if (current?.Track == null) return;
@ -115,7 +118,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Position = new Vector2(-30, 30), Position = new Vector2(-30, -30),
Action = prev, Action = prev,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -133,7 +136,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomCentre, Anchor = Anchor.BottomCentre,
Position = new Vector2(30, 30), Position = new Vector2(30, -30),
Action = next, Action = next,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -151,7 +154,7 @@ namespace osu.Game.Overlays
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.BottomRight, Anchor = Anchor.BottomRight,
Position = new Vector2(20, 30), Position = new Vector2(20, -30),
Children = new Drawable[] Children = new Drawable[]
{ {
listButton = new TextAwesome listButton = new TextAwesome
@ -180,9 +183,7 @@ namespace osu.Game.Overlays
{ {
Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value); Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value);
if ((Anchor & Anchor.x2) > 0) // Diminish the drag distance as we go further to simulate "rubber band" feeling.
change.X = -change.X;
change *= (float)Math.Pow(change.Length, 0.7f) / change.Length; change *= (float)Math.Pow(change.Length, 0.7f) / change.Length;
MoveTo(start_position + change); MoveTo(start_position + change);

View File

@ -98,7 +98,7 @@ namespace osu.Game.Overlays
Direction = FlowDirection.VerticalOnly, Direction = FlowDirection.VerticalOnly,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft, Anchor = Anchor.BottomLeft,
Position = new Vector2(5, -5), Position = new Vector2(5, 5),
Alpha = 0, Alpha = 0,
Children = new[] Children = new[]
{ {

View File

@ -98,8 +98,6 @@ namespace osu.Game.Screens.Menu
} }
}; };
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), wedge_width, Key.P)); buttonsPlay.Add(new Button(@"solo", @"freeplay", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), wedge_width, Key.P));
buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M)); buttonsPlay.Add(new Button(@"multi", @"multiplayer", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M));
buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); buttonsPlay.Add(new Button(@"chart", @"charts", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke()));
@ -113,6 +111,14 @@ namespace osu.Game.Screens.Menu
buttonFlow.Add(buttonsTopLevel); buttonFlow.Add(buttonsTopLevel);
} }
protected override void LoadComplete()
{
base.LoadComplete();
// osuLogo.SizeForFlow relies on loading to be complete.
buttonFlow.Position = new Vector2(wedge_width * 2 - (button_width + osuLogo.SizeForFlow / 4), 0);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{ {
switch (args.Key) switch (args.Key)