Add shared rectangle selection for all timeline tracks to select keyframes

#519
This commit is contained in:
Wojtek Figat
2021-08-24 17:14:41 +02:00
parent 603c9fac07
commit 0063ec3527
11 changed files with 493 additions and 94 deletions

View File

@@ -225,7 +225,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// The child volume track for audio track. Used to animate audio volume over time.
/// </summary>
/// <seealso cref="FlaxEditor.GUI.Timeline.Track" />
class AudioVolumeTrack : Track
class AudioVolumeTrack : Track, IKeyframesEditorContext
{
/// <summary>
/// Gets the archetype.
@@ -478,7 +478,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks
return;
Curve.Visible = Visible;
if (!Visible)
{
Curve.ClearSelection();
return;
}
Curve.KeyframesEditorContext = Timeline;
Curve.CustomViewPanning = Timeline.OnKeyframesViewPanning;
Curve.Bounds = new Rectangle(_audioMedia.X, Y + 1.0f, _audioMedia.Width, Height - 2.0f);
@@ -639,5 +643,32 @@ namespace FlaxEditor.GUI.Timeline.Tracks
base.OnDestroy();
}
/// <inheritdoc />
public void OnKeyframesDeselect(IKeyframesEditor editor)
{
if (Curve != null && Curve.Visible)
Curve.OnKeyframesDeselect(editor);
}
/// <inheritdoc />
public void OnKeyframesSelection(IKeyframesEditor editor, ContainerControl control, Rectangle selection)
{
if (Curve != null && Curve.Visible)
Curve.OnKeyframesSelection(editor, control, selection);
}
/// <inheritdoc />
public int OnKeyframesSelectionCount()
{
return Curve != null && Curve.Visible ? Curve.OnKeyframesSelectionCount() : 0;
}
/// <inheritdoc />
public void OnKeyframesDelete(IKeyframesEditor editor)
{
if (Curve != null && Curve.Visible)
Curve.OnKeyframesDelete(editor);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// The timeline track for animating object property via Curve.
/// </summary>
/// <seealso cref="MemberTrack" />
public abstract class CurvePropertyTrackBase : MemberTrack
public abstract class CurvePropertyTrackBase : MemberTrack, IKeyframesEditorContext
{
private sealed class Splitter : Control
{
@@ -226,8 +226,12 @@ namespace FlaxEditor.GUI.Timeline.Tracks
return;
Curve.Visible = Visible;
if (!Visible)
{
Curve.ClearSelection();
return;
}
var expanded = IsExpanded;
Curve.KeyframesEditorContext = Timeline;
Curve.CustomViewPanning = Timeline.OnKeyframesViewPanning;
Curve.Bounds = new Rectangle(Timeline.StartOffset, Y + 1.0f, Timeline.Duration * Timeline.UnitsPerSecond * Timeline.Zoom, Height - 2.0f);
Curve.ViewScale = new Vector2(Timeline.Zoom, Curve.ViewScale.Y);
@@ -240,11 +244,13 @@ namespace FlaxEditor.GUI.Timeline.Tracks
if (expanded)
{
if (_splitter == null)
{
_splitter = new Splitter
{
_track = this,
Parent = Curve,
};
}
var splitterHeight = 4.0f;
_splitter.Bounds = new Rectangle(0, Curve.Height - splitterHeight, Curve.Width, splitterHeight);
}
@@ -424,6 +430,33 @@ namespace FlaxEditor.GUI.Timeline.Tracks
base.OnDestroy();
}
/// <inheritdoc />
public void OnKeyframesDeselect(IKeyframesEditor editor)
{
if (Curve != null && Curve.Visible)
Curve.OnKeyframesDeselect(editor);
}
/// <inheritdoc />
public void OnKeyframesSelection(IKeyframesEditor editor, ContainerControl control, Rectangle selection)
{
if (Curve != null && Curve.Visible)
Curve.OnKeyframesSelection(editor, control, selection);
}
/// <inheritdoc />
public int OnKeyframesSelectionCount()
{
return Curve != null && Curve.Visible ? Curve.OnKeyframesSelectionCount() : 0;
}
/// <inheritdoc />
public void OnKeyframesDelete(IKeyframesEditor editor)
{
if (Curve != null && Curve.Visible)
Curve.OnKeyframesDelete(editor);
}
}
/// <summary>

View File

@@ -16,7 +16,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// The timeline track for invoking events on a certain points in the time.
/// </summary>
/// <seealso cref="MemberTrack" />
public class EventTrack : MemberTrack
public class EventTrack : MemberTrack, IKeyframesEditorContext
{
/// <summary>
/// Gets the archetype.
@@ -285,7 +285,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks
return;
Events.Visible = Visible;
if (!Visible)
{
Events.ClearSelection();
return;
}
Events.KeyframesEditorContext = Timeline;
Events.CustomViewPanning = Timeline.OnKeyframesViewPanning;
Events.Bounds = new Rectangle(Timeline.StartOffset, Y + 1.0f, Timeline.Duration * Timeline.UnitsPerSecond * Timeline.Zoom, Height - 2.0f);
Events.ViewScale = new Vector2(Timeline.Zoom, 1.0f);
@@ -407,5 +411,32 @@ namespace FlaxEditor.GUI.Timeline.Tracks
base.OnDestroy();
}
/// <inheritdoc />
public void OnKeyframesDeselect(IKeyframesEditor editor)
{
if (Events != null && Events.Visible)
Events.OnKeyframesDeselect(editor);
}
/// <inheritdoc />
public void OnKeyframesSelection(IKeyframesEditor editor, ContainerControl control, Rectangle selection)
{
if (Events != null && Events.Visible)
Events.OnKeyframesSelection(editor, control, selection);
}
/// <inheritdoc />
public int OnKeyframesSelectionCount()
{
return Events != null && Events.Visible ? Events.OnKeyframesSelectionCount() : 0;
}
/// <inheritdoc />
public void OnKeyframesDelete(IKeyframesEditor editor)
{
if (Events != null && Events.Visible)
Events.OnKeyframesDelete(editor);
}
}
}

View File

@@ -15,7 +15,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// The timeline track for animating object property via keyframes collection.
/// </summary>
/// <seealso cref="MemberTrack" />
public class KeyframesPropertyTrack : MemberTrack
public class KeyframesPropertyTrack : MemberTrack, IKeyframesEditorContext
{
/// <summary>
/// Gets the archetype.
@@ -252,7 +252,11 @@ namespace FlaxEditor.GUI.Timeline.Tracks
return;
Keyframes.Visible = Visible;
if (!Visible)
{
Keyframes.ClearSelection();
return;
}
Keyframes.KeyframesEditorContext = Timeline;
Keyframes.CustomViewPanning = Timeline.OnKeyframesViewPanning;
Keyframes.Bounds = new Rectangle(Timeline.StartOffset, Y + 1.0f, Timeline.Duration * Timeline.UnitsPerSecond * Timeline.Zoom, Height - 2.0f);
Keyframes.ViewScale = new Vector2(Timeline.Zoom, 1.0f);
@@ -387,5 +391,32 @@ namespace FlaxEditor.GUI.Timeline.Tracks
base.OnDestroy();
}
/// <inheritdoc />
public void OnKeyframesDeselect(IKeyframesEditor editor)
{
if (Keyframes != null && Keyframes.Visible)
Keyframes.OnKeyframesDeselect(editor);
}
/// <inheritdoc />
public void OnKeyframesSelection(IKeyframesEditor editor, ContainerControl control, Rectangle selection)
{
if (Keyframes != null && Keyframes.Visible)
Keyframes.OnKeyframesSelection(editor, control, selection);
}
/// <inheritdoc />
public int OnKeyframesSelectionCount()
{
return Keyframes != null && Keyframes.Visible ? Keyframes.OnKeyframesSelectionCount() : 0;
}
/// <inheritdoc />
public void OnKeyframesDelete(IKeyframesEditor editor)
{
if (Keyframes != null && Keyframes.Visible)
Keyframes.OnKeyframesDelete(editor);
}
}
}