1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Add OnRowSelected event to EditorTable

This commit is contained in:
Jai Sharma 2022-11-27 02:47:54 +00:00
parent 792334a190
commit 3c56b9c93a
4 changed files with 18 additions and 9 deletions

View File

@ -19,6 +19,8 @@ namespace osu.Game.Screens.Edit
{ {
public abstract partial class EditorTable : TableContainer public abstract partial class EditorTable : TableContainer
{ {
public event Action<Drawable>? OnRowSelected;
private const float horizontal_inset = 20; private const float horizontal_inset = 20;
protected const float ROW_HEIGHT = 25; protected const float ROW_HEIGHT = 25;
@ -44,6 +46,17 @@ namespace osu.Game.Screens.Edit
}); });
} }
protected void SetRowSelected(object? item)
{
foreach (var b in BackgroundFlow)
{
b.Selected = ReferenceEquals(b.Item, item);
if (b.Selected)
OnRowSelected?.Invoke(b);
}
}
protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? default); protected override Drawable CreateHeader(int index, TableColumn column) => new HeaderText(column?.Header ?? default);
private partial class HeaderText : OsuSpriteText private partial class HeaderText : OsuSpriteText

View File

@ -63,17 +63,11 @@ namespace osu.Game.Screens.Edit.Timing
selectedGroup.BindValueChanged(_ => selectedGroup.BindValueChanged(_ =>
{ {
// TODO: This should scroll the selected row into view.
updateSelectedGroup(); updateSelectedGroup();
}, true); }, true);
} }
private void updateSelectedGroup() private void updateSelectedGroup() => SetRowSelected(selectedGroup?.Value);
{
// TODO: This should scroll the selected row into view.
foreach (var b in BackgroundFlow)
b.Selected = ReferenceEquals(b.Item, selectedGroup?.Value);
}
private TableColumn[] createHeaders() private TableColumn[] createHeaders()
{ {

View File

@ -86,7 +86,7 @@ namespace osu.Game.Screens.Edit.Timing
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Y,
Width = ControlPointTable.TIMING_COLUMN_WIDTH + margins, Width = ControlPointTable.TIMING_COLUMN_WIDTH + margins,
}, },
new OsuScrollContainer scroll = new OsuScrollContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = table = new ControlPointTable(), Child = table = new ControlPointTable(),
@ -140,6 +140,8 @@ namespace osu.Game.Screens.Edit.Timing
table.ControlGroups = controlPointGroups; table.ControlGroups = controlPointGroups;
changeHandler?.SaveState(); changeHandler?.SaveState();
}, true); }, true);
table.OnRowSelected += (drawable) => scroll.ScrollIntoView(drawable);
} }
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)

View File

@ -77,7 +77,7 @@ namespace osu.Game.Screens.Edit.Verify
selectedIssue = verify.SelectedIssue.GetBoundCopy(); selectedIssue = verify.SelectedIssue.GetBoundCopy();
selectedIssue.BindValueChanged(issue => selectedIssue.BindValueChanged(issue =>
{ {
foreach (var b in BackgroundFlow) b.Selected = b.Item == issue.NewValue; SetRowSelected(issue);
}, true); }, true);
} }