Privatise button again

This commit is contained in:
Dan Balasescu 2021-12-10 00:38:18 +09:00
parent f9af239ed9
commit 05aa9635a8
4 changed files with 16 additions and 9 deletions

View File

@ -273,7 +273,7 @@ private void assertHandleVisibility(int index, bool visible)
private void assertDeleteButtonVisibility(int index, bool visible)
=> AddAssert($"delete button {index} {(visible ? "is" : "is not")} visible",
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(2 + index * 2).RemoveButton.Alpha > 0) == visible);
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(2 + index * 2).Alpha > 0) == visible);
private void createPlaylist(Action<TestPlaylist> setupPlaylist = null)
{

View File

@ -126,7 +126,7 @@ private void moveToItem(int index, Vector2? offset = null)
private void moveToDeleteButton(int index, Vector2? offset = null) => AddStep($"move mouse to delete button {index}", () =>
{
var item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(0).RemoveButton, offset);
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0), offset);
});
private void createPlaylist()

View File

@ -154,7 +154,7 @@ private void deleteItem(int index)
AddStep($"move mouse to delete button {index}", () =>
{
item = playlist.ChildrenOfType<OsuRearrangeableListItem<PlaylistItem>>().ElementAt(index);
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(0).RemoveButton);
InputManager.MoveMouseTo(item.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(0));
});
AddStep("click", () => InputManager.Click(MouseButton.Left));
@ -164,6 +164,6 @@ private void deleteItem(int index)
private void assertDeleteButtonVisibility(int index, bool visible)
=> AddUntilStep($"delete button {index} {(visible ? "is" : "is not")} visible",
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(index).RemoveButton.Alpha > 0) == visible);
() => (playlist.ChildrenOfType<DrawableRoomPlaylistItem.PlaylistRemoveButton>().ElementAt(index).Alpha > 0) == visible);
}
}

View File

@ -59,8 +59,6 @@ public class DrawableRoomPlaylistItem : OsuRearrangeableListItem<PlaylistItem>
public readonly PlaylistItem Item;
public Drawable RemoveButton { get; private set; }
private readonly DelayedLoadWrapper onScreenLoader = new DelayedLoadWrapper(Empty) { RelativeSizeAxes = Axes.Both };
private readonly IBindable<bool> valid = new Bindable<bool>();
private readonly Bindable<IBeatmapInfo> beatmap = new Bindable<IBeatmapInfo>();
@ -76,6 +74,7 @@ public class DrawableRoomPlaylistItem : OsuRearrangeableListItem<PlaylistItem>
private FillFlowContainer buttonsFlow;
private UpdateableAvatar ownerAvatar;
private Drawable showResultsButton;
private Drawable removeButton;
private PanelBackground panelBackground;
private FillFlowContainer mainFillFlow;
@ -192,8 +191,8 @@ public bool AllowDeletion
{
allowDeletion = value;
if (RemoveButton != null)
RemoveButton.Alpha = value ? 1 : 0;
if (removeButton != null)
removeButton.Alpha = value ? 1 : 0;
}
}
@ -417,7 +416,7 @@ private IEnumerable<Drawable> createButtons() => new[]
TooltipText = "View results"
},
Item.Beatmap.Value == null ? Empty() : new PlaylistDownloadButton(Item),
RemoveButton = new GrayButton(FontAwesome.Solid.MinusSquare)
removeButton = new PlaylistRemoveButton
{
Size = new Vector2(30, 30),
Alpha = AllowDeletion ? 1 : 0,
@ -433,6 +432,14 @@ protected override bool OnClick(ClickEvent e)
return true;
}
public class PlaylistRemoveButton : GrayButton
{
public PlaylistRemoveButton()
: base(FontAwesome.Solid.MinusSquare)
{
}
}
private sealed class PlaylistDownloadButton : BeatmapDownloadButton
{
private readonly PlaylistItem playlistItem;