mirror of
https://github.com/ppy/osu.git
synced 2025-01-29 06:43:02 +08:00
Update framework; amend ToolbarButton to use padding and Children initialiser.
This commit is contained in:
parent
cb5e4287e2
commit
c0ea061bd4
@ -1 +1 @@
|
|||||||
Subproject commit 1f770847b245e6d250e63e60c24e9e84131d15e7
|
Subproject commit f47b7132ca5d579e7a4c011bbfa38a7bb6c91c6a
|
@ -12,7 +12,7 @@ namespace osu.Framework.VisualTests
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
BasicGameHost host = Host.GetSuitableHost();
|
BasicGameHost host = Host.GetSuitableHost(@"osu-visual-tests");
|
||||||
host.Add(new VisualTestGame());
|
host.Add(new VisualTestGame());
|
||||||
host.Run();
|
host.Run();
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Desktop
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
BasicGameHost host = Host.GetSuitableHost();
|
BasicGameHost host = Host.GetSuitableHost(@"osu");
|
||||||
host.Add(new OsuGame());
|
host.Add(new OsuGame());
|
||||||
host.Run();
|
host.Run();
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ namespace osu.Game.GameModes.Menu
|
|||||||
buttonFlow = new FlowContainerWithOrigin
|
buttonFlow = new FlowContainerWithOrigin
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Padding = new Vector2(-wedge_width, 0),
|
Spacing = new Vector2(-wedge_width, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O),
|
settingsButton = new Button(@"settings", @"options", FontAwesome.gear, new Color4(85, 85, 85, 255), OnSettings, -wedge_width, Key.O),
|
||||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Online.Chat.Display
|
|||||||
Direction = FlowDirection.VerticalOnly,
|
Direction = FlowDirection.VerticalOnly,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
LayoutEasing = EasingTypes.Out,
|
LayoutEasing = EasingTypes.Out,
|
||||||
Padding = new Vector2(1, 1)
|
Spacing = new Vector2(1, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Drawables;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Online.Chat.Display
|
namespace osu.Game.Online.Chat.Display
|
||||||
{
|
{
|
||||||
@ -54,10 +55,10 @@ namespace osu.Game.Online.Chat.Display
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new PaddingContainer
|
new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Padding = new Padding { Left = padding + 10 },
|
Padding = new MarginPadding { Left = padding + 10 },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteText
|
new SpriteText
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Input;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -29,7 +30,6 @@ namespace osu.Game.Overlays
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
DrawableText.Text = value;
|
DrawableText.Text = value;
|
||||||
paddingIcon.Alpha = string.IsNullOrEmpty(value) ? 0 : 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,25 +55,13 @@ namespace osu.Game.Overlays
|
|||||||
protected TextAwesome DrawableIcon;
|
protected TextAwesome DrawableIcon;
|
||||||
protected SpriteText DrawableText;
|
protected SpriteText DrawableText;
|
||||||
protected Box HoverBackground;
|
protected Box HoverBackground;
|
||||||
private Drawable paddingLeft;
|
|
||||||
private Drawable paddingRight;
|
|
||||||
private Drawable paddingIcon;
|
|
||||||
private FlowContainer tooltipContainer;
|
private FlowContainer tooltipContainer;
|
||||||
private SpriteText tooltip1;
|
private SpriteText tooltip1;
|
||||||
private SpriteText tooltip2;
|
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()
|
public ToolbarButton()
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
HoverBackground = new Box
|
HoverBackground = new Box
|
||||||
{
|
{
|
||||||
@ -81,25 +69,34 @@ namespace osu.Game.Overlays
|
|||||||
Additive = true,
|
Additive = true,
|
||||||
Colour = new Color4(60, 60, 60, 255),
|
Colour = new Color4(60, 60, 60, 255),
|
||||||
Alpha = 0,
|
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[]
|
||||||
|
{
|
||||||
DrawableIcon = new TextAwesome
|
DrawableIcon = new TextAwesome
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
};
|
},
|
||||||
|
|
||||||
DrawableText = new SpriteText
|
DrawableText = new SpriteText
|
||||||
{
|
{
|
||||||
|
Margin = new MarginPadding { Left = 5 },
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
};
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
tooltipContainer = new FlowContainer
|
tooltipContainer = new FlowContainer
|
||||||
{
|
{
|
||||||
Direction = FlowDirection.VerticalOnly,
|
Direction = FlowDirection.VerticalOnly,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Position = new Vector2(0, -5),
|
Position = new Vector2(5, -5),
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
@ -112,53 +109,19 @@ namespace osu.Game.Overlays
|
|||||||
TextSize = 15
|
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;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Size = new Vector2(WIDTH, 1);
|
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()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.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)
|
//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)
|
protected override bool OnClick(InputState state)
|
||||||
|
Loading…
Reference in New Issue
Block a user