Skip to content

Commit 5a48bb4

Browse files
committed
highlight selected
1 parent 51775fb commit 5a48bb4

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

fluXis/Screens/Edit/Tabs/Storyboarding/Animations/StoryboardAnimationEntry.cs

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
using System.Linq;
33
using fluXis.Graphics.Containers;
44
using fluXis.Graphics.Sprites.Icons;
5+
using fluXis.Graphics.Sprites.Outline;
56
using fluXis.Screens.Edit.Tabs.Shared.Points.Settings;
67
using fluXis.Screens.Edit.Tabs.Shared.Points.Settings.Preset;
78
using fluXis.Screens.Edit.Tabs.Storyboarding.Timeline;
89
using fluXis.Storyboards;
910
using fluXis.Utils;
1011
using JetBrains.Annotations;
1112
using osu.Framework.Allocation;
13+
using osu.Framework.Bindables;
1214
using osu.Framework.Extensions;
1315
using osu.Framework.Graphics;
1416
using osu.Framework.Graphics.Containers;
@@ -30,13 +32,17 @@ public partial class StoryboardAnimationEntry : CompositeDrawable, IHasPopover
3032

3133
private float beatLength => map.MapInfo.GetTimingPoint(Animation.StartTime).MsPerBeat;
3234

35+
private BindableBool isSelected = new(false);
36+
3337
[CanBeNull]
3438
public Action<StoryboardAnimation> RequestRemove { get; init; }
3539

3640
public StoryboardAnimation Animation { get; }
3741
private readonly StoryboardAnimationRow row;
3842

3943
private readonly Circle length;
44+
private readonly OutlinedCircle outlineLength;
45+
private readonly FluXisSpriteIcon outlineDiamond;
4046

4147
public StoryboardAnimationEntry(StoryboardAnimation animation, StoryboardAnimationRow row, Colour4 color)
4248
{
@@ -49,6 +55,35 @@ public StoryboardAnimationEntry(StoryboardAnimation animation, StoryboardAnimati
4955
Size = new Vector2(StoryboardAnimationsList.ROW_HEIGHT);
5056
InternalChildren = new Drawable[]
5157
{
58+
length = new Circle
59+
{
60+
RelativeSizeAxes = Axes.Y,
61+
Height = 0.5f,
62+
Colour = color,
63+
Alpha = 0.5f,
64+
Anchor = Anchor.Centre,
65+
Origin = Anchor.CentreLeft,
66+
},
67+
outlineLength = new OutlinedCircle
68+
{
69+
RelativeSizeAxes = Axes.Y,
70+
Height = 0.5f,
71+
BorderThickness = 2f,
72+
Anchor = Anchor.Centre,
73+
Origin = Anchor.CentreLeft,
74+
Colour = color.Lighten(2f),
75+
Alpha = 0
76+
},
77+
outlineDiamond =new FluXisSpriteIcon
78+
{
79+
Icon = FontAwesome6.Solid.Diamond,
80+
RelativeSizeAxes = Axes.Both,
81+
Size = new Vector2(0.75f),
82+
Anchor = Anchor.Centre,
83+
Origin = Anchor.Centre,
84+
Colour = color.Lighten(1.5f),
85+
Alpha = 0
86+
},
5287
new FluXisSpriteIcon
5388
{
5489
Icon = FontAwesome6.Solid.Diamond,
@@ -58,36 +93,41 @@ public StoryboardAnimationEntry(StoryboardAnimation animation, StoryboardAnimati
5893
Origin = Anchor.Centre,
5994
Colour = color
6095
},
61-
length = new Circle
62-
{
63-
RelativeSizeAxes = Axes.Y,
64-
Height = 0.5f,
65-
Colour = color,
66-
Alpha = 0.5f,
67-
Anchor = Anchor.Centre,
68-
Origin = Anchor.CentreLeft,
69-
}
7096
};
7197
}
7298

99+
protected override void LoadComplete()
100+
{
101+
base.LoadComplete();
102+
isSelected.BindValueChanged(e =>
103+
{
104+
outlineDiamond.Alpha = e.NewValue ? 1f : 0f;
105+
outlineLength.Alpha = e.NewValue ? 1f : 0f;
106+
});
107+
}
108+
73109
protected override void Update()
74110
{
75111
base.Update();
76112

77113
X = Math.Clamp(timeline.PositionAtTime(Animation.StartTime, Parent!.DrawWidth), -DrawWidth / 2f, Parent.DrawWidth + DrawWidth / 2f);
78114

79115
var endX = timeline.PositionAtTime(Animation.EndTime, Parent!.DrawWidth);
80-
length.Width = Math.Max(endX - X, 0);
116+
var clamped = Math.Max(endX - X, 0);
117+
length.Width = clamped;
118+
outlineLength.Width = clamped;
81119
}
82120

83121
protected override bool OnClick(ClickEvent e)
84122
{
85123
this.ShowPopover();
124+
isSelected.Value = true;
86125
return true;
87126
}
88127

89128
public Popover GetPopover() => new FluXisPopover
90129
{
130+
OnClose = () => isSelected.Value = false,
91131
Child = new FillFlowContainer
92132
{
93133
Width = 380,

0 commit comments

Comments
 (0)