Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix toolbar buttons not being clickable at screen edges #26530

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 52 additions & 42 deletions osu.Game/Overlays/Toolbar/ToolbarButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace osu.Game.Overlays.Toolbar
{
public abstract partial class ToolbarButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
{
public const float PADDING = 3;

protected GlobalAction? Hotkey { get; set; }

public void SetIcon(Drawable icon)
Expand Down Expand Up @@ -63,6 +65,7 @@ public LocalisableString TooltipSub

protected virtual Anchor TooltipAnchor => Anchor.TopLeft;

protected readonly Container ButtonContent;
protected ConstrainedIconContainer IconContainer;
protected SpriteText DrawableText;
protected Box HoverBackground;
Expand All @@ -80,59 +83,66 @@ public LocalisableString TooltipSub

protected ToolbarButton()
{
Width = Toolbar.HEIGHT;
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;

Padding = new MarginPadding(3);

Children = new Drawable[]
{
BackgroundContent = new Container
ButtonContent = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 6,
CornerExponent = 3f,
Children = new Drawable[]
{
HoverBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(80).Opacity(180),
Blending = BlendingParameters.Additive,
Alpha = 0,
},
flashBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Color4.White.Opacity(100),
Blending = BlendingParameters.Additive,
},
}
},
Flow = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Padding = new MarginPadding { Left = Toolbar.HEIGHT / 2, Right = Toolbar.HEIGHT / 2 },
Width = Toolbar.HEIGHT,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Padding = new MarginPadding(PADDING),
Children = new Drawable[]
{
IconContainer = new ConstrainedIconContainer
BackgroundContent = new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(20),
Alpha = 0,
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 6,
CornerExponent = 3f,
Children = new Drawable[]
{
HoverBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(80).Opacity(180),
Blending = BlendingParameters.Additive,
Alpha = 0,
},
flashBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Color4.White.Opacity(100),
Blending = BlendingParameters.Additive,
},
}
},
DrawableText = new OsuSpriteText
Flow = new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Padding = new MarginPadding { Left = Toolbar.HEIGHT / 2, Right = Toolbar.HEIGHT / 2 },
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Children = new Drawable[]
{
IconContainer = new ConstrainedIconContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(20),
Alpha = 0,
},
DrawableText = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
},
},
},
},
Expand Down
77 changes: 42 additions & 35 deletions osu.Game/Overlays/Toolbar/ToolbarClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,59 @@ private void load(OsuConfigManager config)
clockDisplayMode = config.GetBindable<ToolbarClockDisplayMode>(OsuSetting.ToolbarClockDisplayMode);
prefer24HourTime = config.GetBindable<bool>(OsuSetting.Prefer24HourTime);

Padding = new MarginPadding(3);

Children = new Drawable[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was old code, but can make this Child for less indent.

{
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 6,
CornerExponent = 3f,
Children = new Drawable[]
{
hoverBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(80).Opacity(180),
Blending = BlendingParameters.Additive,
Alpha = 0,
},
flashBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Color4.White.Opacity(100),
Blending = BlendingParameters.Additive,
},
}
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Padding = new MarginPadding(10),
Padding = new MarginPadding(ToolbarButton.PADDING),
Children = new Drawable[]
{
analog = new AnalogClockDisplay
new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 6,
CornerExponent = 3f,
Children = new Drawable[]
{
hoverBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(80).Opacity(180),
Blending = BlendingParameters.Additive,
Alpha = 0,
},
flashBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Colour = Color4.White.Opacity(100),
Blending = BlendingParameters.Additive,
},
}
},
digital = new DigitalClockDisplay
new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Padding = new MarginPadding(10),
Children = new Drawable[]
{
analog = new AnalogClockDisplay
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
digital = new DigitalClockDisplay
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Toolbar/ToolbarHomeButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public partial class ToolbarHomeButton : ToolbarButton
{
public ToolbarHomeButton()
{
Width *= 1.4f;
ButtonContent.Width *= 1.4f;
Hotkey = GlobalAction.Home;
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class ToolbarMusicButton : ToolbarOverlayToggleButton
public ToolbarMusicButton()
{
Hotkey = GlobalAction.ToggleNowPlaying;
AutoSizeAxes = Axes.X;
ButtonContent.AutoSizeAxes = Axes.X;
}

[BackgroundDependencyLoader(true)]
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Toolbar/ToolbarRulesetTabButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private partial class RulesetButton : ToolbarButton

public RulesetButton()
{
Padding = new MarginPadding(3)
ButtonContent.Padding = new MarginPadding(PADDING)
{
Bottom = 5
};
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Toolbar/ToolbarSettingsButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class ToolbarSettingsButton : ToolbarOverlayToggleButton
{
public ToolbarSettingsButton()
{
Width *= 1.4f;
ButtonContent.Width *= 1.4f;
Hotkey = GlobalAction.ToggleSettings;
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Toolbar/ToolbarUserButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public partial class ToolbarUserButton : ToolbarOverlayToggleButton

public ToolbarUserButton()
{
AutoSizeAxes = Axes.X;
ButtonContent.AutoSizeAxes = Axes.X;
}

[BackgroundDependencyLoader]
Expand Down
Loading