mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Move common table layout logic into EditorTable
abstract class
This commit is contained in:
@ -8,12 +8,9 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -25,6 +22,9 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
[Resolved]
|
||||
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private EditorClock clock { get; set; }
|
||||
|
||||
public IEnumerable<ControlPointGroup> ControlGroups
|
||||
{
|
||||
set
|
||||
@ -37,7 +37,14 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
|
||||
foreach (var group in value)
|
||||
{
|
||||
BackgroundFlow.Add(new RowBackground(group));
|
||||
BackgroundFlow.Add(new RowBackground(group)
|
||||
{
|
||||
Action = () =>
|
||||
{
|
||||
selectedGroup.Value = group;
|
||||
clock.SeekSmoothlyTo(group.Time);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Columns = createHeaders();
|
||||
@ -45,6 +52,16 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
selectedGroup.BindValueChanged(group =>
|
||||
{
|
||||
foreach (var b in BackgroundFlow) b.Selected = b.Item == group.NewValue;
|
||||
}, true);
|
||||
}
|
||||
|
||||
private TableColumn[] createHeaders()
|
||||
{
|
||||
var columns = new List<TableColumn>
|
||||
@ -140,100 +157,5 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class RowBackground : OsuClickableContainer
|
||||
{
|
||||
private readonly ControlPointGroup controlGroup;
|
||||
private const int fade_duration = 100;
|
||||
|
||||
private readonly Box hoveredBackground;
|
||||
|
||||
[Resolved]
|
||||
private EditorClock clock { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
||||
|
||||
public RowBackground(ControlPointGroup controlGroup)
|
||||
{
|
||||
this.controlGroup = controlGroup;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Height = 25;
|
||||
|
||||
AlwaysPresent = true;
|
||||
|
||||
CornerRadius = 3;
|
||||
Masking = true;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
hoveredBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
},
|
||||
};
|
||||
|
||||
Action = () =>
|
||||
{
|
||||
selectedGroup.Value = controlGroup;
|
||||
clock.SeekSmoothlyTo(controlGroup.Time);
|
||||
};
|
||||
}
|
||||
|
||||
private Color4 colourHover;
|
||||
private Color4 colourSelected;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
hoveredBackground.Colour = colourHover = colours.BlueDarker;
|
||||
colourSelected = colours.YellowDarker;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
selectedGroup.BindValueChanged(group => { Selected = controlGroup == group.NewValue; }, true);
|
||||
}
|
||||
|
||||
private bool selected;
|
||||
|
||||
protected bool Selected
|
||||
{
|
||||
get => selected;
|
||||
set
|
||||
{
|
||||
if (value == selected)
|
||||
return;
|
||||
|
||||
selected = value;
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateState();
|
||||
return base.OnHover(e);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
updateState();
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
hoveredBackground.FadeColour(selected ? colourSelected : colourHover, 450, Easing.OutQuint);
|
||||
|
||||
if (selected || IsHovered)
|
||||
hoveredBackground.FadeIn(fade_duration, Easing.OutQuint);
|
||||
else
|
||||
hoveredBackground.FadeOut(fade_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user