Small UX improvements to tracks

This commit is contained in:
Chandler Cox
2024-11-21 20:00:26 -06:00
parent d4b663cd1a
commit c8b97b8a38
2 changed files with 36 additions and 1 deletions

View File

@@ -1446,6 +1446,17 @@ namespace FlaxEditor.GUI.Timeline
{
GetTracks(SelectedTracks[i], tracks);
}
// Find the lowest track position for selection
int lowestTrackLocation = Tracks.Count - 1;
for (int i = 0; i < tracks.Count; i++)
{
var trackToDelete = tracks[i];
if (trackToDelete.TrackIndex < lowestTrackLocation)
{
lowestTrackLocation = trackToDelete.TrackIndex;
}
}
SelectedTracks.Clear();
if (withUndo && Undo != null && Undo.Enabled)
{
@@ -1468,6 +1479,18 @@ namespace FlaxEditor.GUI.Timeline
}
OnTracksChanged();
MarkAsEdited();
// Select track above deleted tracks unless track is first track
if (Tracks.Count > 0)
{
if (lowestTrackLocation - 1 >= 0)
Select(Tracks[lowestTrackLocation - 1]);
else
Select(Tracks[0]);
SelectedTracks[0].Focus();
}
}
/// <summary>
@@ -1655,6 +1678,14 @@ namespace FlaxEditor.GUI.Timeline
}
OnTracksChanged();
MarkAsEdited();
// Deselect and select new clones.
Deselect();
foreach (var clone in clones)
{
Select(clone, true);
}
SelectedTracks[0].Focus();
}

View File

@@ -61,6 +61,9 @@ namespace FlaxEditor.GUI.Timeline.Undo
_timeline.AddTrack(track, false);
track.TrackIndex = _order;
_timeline.OnTracksOrderChanged();
_timeline.Focus();
_timeline.Select(track);
track.Focus();
}
private void Remove()
@@ -68,10 +71,11 @@ namespace FlaxEditor.GUI.Timeline.Undo
var track = _timeline.FindTrack(_name);
if (track == null)
{
Editor.LogWarning($"Cannot remove track {_name}. It doesn't already exists.");
Editor.LogWarning($"Cannot remove track {_name}. It doesn't exist.");
return;
}
_timeline.Delete(track, false);
_timeline.Focus();
}
public string ActionString => _isAdd ? "Add track" : "Remove track";