Add option to disable timeline Media resizing by the user
This commit is contained in:
@@ -61,7 +61,11 @@ namespace FlaxEditor.GUI.Timeline
|
||||
public int DurationFrames
|
||||
{
|
||||
get => Media.DurationFrames;
|
||||
set => Media.DurationFrames = value;
|
||||
set
|
||||
{
|
||||
if (Media.CanResize)
|
||||
Media.DurationFrames = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,7 +75,11 @@ namespace FlaxEditor.GUI.Timeline
|
||||
public float Duration
|
||||
{
|
||||
get => Media.Duration;
|
||||
set => Media.Duration = value;
|
||||
set
|
||||
{
|
||||
if (Media.CanResize)
|
||||
Media.Duration = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool UseFrames => Media.Timeline.TimeShowMode == Timeline.TimeShowModes.Frames;
|
||||
@@ -204,6 +212,11 @@ namespace FlaxEditor.GUI.Timeline
|
||||
/// </summary>
|
||||
public bool CanDelete;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this media can be resized (duration changed).
|
||||
/// </summary>
|
||||
public bool CanResize;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Media"/> class.
|
||||
/// </summary>
|
||||
@@ -341,7 +354,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, moveColor, moveThickness);
|
||||
}
|
||||
else if (IsMouseOver && MoveLeftEdgeRect.Contains(ref _mouseLocation))
|
||||
else if (IsMouseOver && CanResize && MoveLeftEdgeRect.Contains(ref _mouseLocation))
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperLeft, bounds.BottomLeft, Color.Yellow);
|
||||
}
|
||||
@@ -349,7 +362,7 @@ namespace FlaxEditor.GUI.Timeline
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, moveColor, moveThickness);
|
||||
}
|
||||
else if (IsMouseOver && MoveRightEdgeRect.Contains(ref _mouseLocation))
|
||||
else if (IsMouseOver && CanResize && MoveRightEdgeRect.Contains(ref _mouseLocation))
|
||||
{
|
||||
Render2D.DrawLine(bounds.UpperRight, bounds.BottomRight, Color.Yellow);
|
||||
}
|
||||
@@ -369,8 +382,8 @@ namespace FlaxEditor.GUI.Timeline
|
||||
_startMoveLocation = Root.MousePosition;
|
||||
_startMoveStartFrame = StartFrame;
|
||||
_startMoveDuration = DurationFrames;
|
||||
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(ref location);
|
||||
_startMoveRightEdge = MoveRightEdgeRect.Contains(ref location);
|
||||
_startMoveLeftEdge = MoveLeftEdgeRect.Contains(ref location) && CanResize;
|
||||
_startMoveRightEdge = MoveRightEdgeRect.Contains(ref location) && CanResize;
|
||||
|
||||
StartMouseCapture(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user