Skip to content

Commit

Permalink
Remove the action toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Aug 18, 2024
1 parent 03e182a commit c8df918
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 61 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose
/// <summary>
/// Button that able to receive the <see cref="KaraokeEditAction"/> event.
/// </summary>
public abstract partial class KeyActionButton : ActionButton, IKeyBindingHandler<KaraokeEditAction>, IHasIKeyBindingHandlerOrder
public abstract partial class KeyActionButton : ToolbarButton, IKeyBindingHandler<KaraokeEditAction>, IHasIKeyBindingHandlerOrder
{
protected abstract KaraokeEditAction EditAction { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osuTK;

Expand All @@ -15,47 +17,63 @@ namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Beatmaps.Lyrics.Content.Compose
/// </summary>
public abstract partial class ToolbarButton : OsuClickableContainer
{
public void SetIcon(Drawable icon)
{
Size = new Vector2(SpecialActionToolbar.HEIGHT);
IconContainer.Icon = icon;
IconContainer.Show();
}

[Resolved]
private TextureStore textures { get; set; } = null!;

public void SetIcon(string texture) =>
SetIcon(new Sprite
[Resolved]
private OsuColour colours { get; set; } = null!;

protected ConstrainedIconContainer IconContainer;

protected ToolbarButton()
{
Children = new Drawable[]
{
Texture = textures.Get(texture),
});
IconContainer = new ConstrainedIconContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(SpecialActionToolbar.ICON_SIZE),
Alpha = 0,
},
};
}

public void SetIcon(IconUsage iconUsage) =>
SetIcon(new SpriteIcon
{
Icon = iconUsage,
});

public void SetIcon(Drawable icon)
{
Size = new Vector2(SpecialActionToolbar.HEIGHT);
IconContainer.Icon = icon;
IconContainer.Show();
}

protected void SetState(bool enabled)
{
IconContainer.Icon.Alpha = enabled ? 1f : 0.5f;
Enabled.Value = enabled;
}

protected ConstrainedIconContainer IconContainer;
protected override bool OnClick(ClickEvent e)
{
ToggleClickEffect();

protected ToolbarButton()
return base.OnClick(e);
}

public void ToggleClickEffect()
{
Children = new Drawable[]
if (Enabled.Value)
{
IconContainer = new ConstrainedIconContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(SpecialActionToolbar.ICON_SIZE),
Alpha = 0,
},
};
IconContainer.FadeOut(100).Then().FadeIn();
}
else
{
IconContainer.FadeColour(colours.Red, 100).Then().FadeColour(Colour4.White);
}
}
}

0 comments on commit c8df918

Please sign in to comment.