// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
namespace FlaxEditor.GUI.Timeline.Tracks
{
///
/// The base class for timeline tracks that use single media.
///
/// The type of the media.
///
public abstract class SingleMediaTrack : Track
where TMedia : Media, new()
{
///
/// Gets the track media.
///
public TMedia TrackMedia
{
get
{
TMedia media;
if (Media.Count == 0)
{
media = new TMedia
{
StartFrame = 0,
DurationFrames = Timeline?.DurationFrames ?? 60,
};
AddMedia(media);
}
else
{
media = (TMedia)Media[0];
}
return media;
}
}
///
protected SingleMediaTrack(ref TrackCreateOptions options)
: base(ref options)
{
}
///
public override void OnSpawned()
{
// Ensure to have minimum valid media count
for (int i = Media.Count; i < MinMediaCount; i++)
{
var m = new TMedia
{
StartFrame = 0,
DurationFrames = Timeline?.DurationFrames ?? 60,
};
AddMedia(m);
}
base.OnSpawned();
}
}
}