1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 02:32:59 +08:00

Update framework; amend ToolbarButton to use padding and Children initialiser.

This commit is contained in:
Dean Herbert 2016-10-12 12:22:19 +09:00
parent cb5e4287e2
commit c0ea061bd4
7 changed files with 52 additions and 88 deletions

@ -1 +1 @@
Subproject commit 1f770847b245e6d250e63e60c24e9e84131d15e7
Subproject commit f47b7132ca5d579e7a4c011bbfa38a7bb6c91c6a

View File

@ -12,7 +12,7 @@ namespace osu.Framework.VisualTests
[STAThread]
public static void Main(string[] args)
{
BasicGameHost host = Host.GetSuitableHost();
BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests");
host.Add(new VisualTestGame());
host.Run();
}

View File

@ -13,7 +13,7 @@ namespace osu.Desktop
[STAThread]
public static void Main()
{
BasicGameHost host = Host.GetSuitableHost();
BasicGameHost host = Host.GetSuitableHost(@"osu");
host.Add(new OsuGame());
host.Run();
}

View File

@ -82,7 +82,7 @@ namespace osu.Game.GameModes.Menu
buttonFlow = new FlowContainerWithOrigin
{
Anchor = Anchor.Centre,
Padding = new Vector2(-wedge_width, 0),
Spacing = new Vector2(-wedge_width, 0),
Children = new Drawable[]
{
settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O),

View File

@ -47,7 +47,7 @@ namespace osu.Game.Online.Chat.Display
Direction = FlowDirection.VerticalOnly,
RelativeSizeAxes = Axes.X,
LayoutEasing = EasingTypes.Out,
Padding = new Vector2(1, 1)
Spacing = new Vector2(1, 1)
}
}
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Drawables;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Online.Chat.Display
{
@ -54,10 +55,10 @@ namespace osu.Game.Online.Chat.Display
}
}
},
new PaddingContainer
new Container
{
RelativeSizeAxes = Axes.X,
Padding = new Padding { Left = padding + 10 },
Padding = new MarginPadding { Left = padding + 10 },
Children = new Drawable[]
{
new SpriteText

View File

@ -10,6 +10,7 @@ using osu.Framework.Input;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Primitives;
namespace osu.Game.Overlays
{
@ -29,7 +30,6 @@ namespace osu.Game.Overlays
set
{
DrawableText.Text = value;
paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1;
}
}
@ -55,110 +55,73 @@ namespace osu.Game.Overlays
protected TextAwesome DrawableIcon;
protected SpriteText DrawableText;
protected Box HoverBackground;
private Drawable paddingLeft;
private Drawable paddingRight;
private Drawable paddingIcon;
private FlowContainer tooltipContainer;
private SpriteText tooltip1;
private SpriteText tooltip2;
public new float Padding
{
get { return paddingLeft.Size.X; }
set
{
paddingLeft.Size = new Vector2(value, 1);
paddingRight.Size = new Vector2(value, 1);
tooltipContainer.Position = new Vector2(value, tooltipContainer.Position.Y);
}
}
public ToolbarButton()
{
HoverBackground = new Box
Children = new Drawable[]
{
RelativeSizeAxes = Axes.Both,
Additive = true,
Colour = new Color4(60, 60, 60, 255),
Alpha = 0,
};
DrawableIcon = new TextAwesome
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
};
DrawableText = new SpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
};
tooltipContainer = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Anchor = Anchor.BottomLeft,
Position = new Vector2(0, -5),
Alpha = 0,
Children = new[]
HoverBackground = new Box
{
tooltip1 = new SpriteText()
RelativeSizeAxes = Axes.Both,
Additive = true,
Colour = new Color4(60, 60, 60, 255),
Alpha = 0,
},
new FlowContainer
{
Direction = FlowDirection.HorizontalOnly,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Padding = new MarginPadding { Left = 5, Right = 5 },
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
TextSize = 22,
DrawableIcon = new TextAwesome
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
DrawableText = new SpriteText
{
Margin = new MarginPadding { Left = 5 },
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
},
tooltip2 = new SpriteText
},
tooltipContainer = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Anchor = Anchor.BottomLeft,
Position = new Vector2(5, -5),
Alpha = 0,
Children = new[]
{
TextSize = 15
tooltip1 = new SpriteText()
{
TextSize = 22,
},
tooltip2 = new SpriteText
{
TextSize = 15
}
}
}
};
paddingLeft = new Container { RelativeSizeAxes = Axes.Y };
paddingRight = new Container { RelativeSizeAxes = Axes.Y };
paddingIcon = new Container
{
Size = new Vector2(5, 0),
Alpha = 0
};
Padding = 10;
RelativeSizeAxes = Axes.Y;
Size = new Vector2(WIDTH, 1);
}
public override void Load()
{
base.Load();
Children = new Drawable[]
{
HoverBackground,
new FlowContainer
{
Direction = FlowDirection.HorizontalOnly,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
paddingLeft,
DrawableIcon,
paddingIcon,
DrawableText,
paddingRight
},
},
tooltipContainer
};
}
protected override void Update()
{
base.Update();
//todo: find a way to avoid using this (autosize needs to be able to ignore certain drawables.. in this case the tooltip)
Size = new Vector2(WIDTH + DrawableText.Size.X, 1);
Size = new Vector2(WIDTH + (DrawableText.IsVisible ? DrawableText.Size.X : 0), 1);
}
protected override bool OnClick(InputState state)