@@ -276,5 +276,8 @@ namespace FlaxEditor.GUI
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void OnKeyframesDelete(IKeyframesEditor editor);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,31 +59,9 @@ namespace FlaxEditor.GUI
|
||||
_editor.UpdateTangents();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
|
||||
internal void OnMoveStart(Vector2 location)
|
||||
{
|
||||
// Pass all events
|
||||
location = PointFromParent(ref locationParent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseEnter(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
base.OnMouseEnter(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
// Start moving selection if movement started from the keyframe
|
||||
if (_leftMouseDown && !_isMovingSelection && GetChildAt(_leftMouseDownPos) is KeyframePoint)
|
||||
{
|
||||
// Start moving selected nodes
|
||||
// Start moving selected keyframes
|
||||
_isMovingSelection = true;
|
||||
_movedKeyframes = false;
|
||||
var viewRect = _editor._mainPanel.GetClientArea();
|
||||
@@ -95,42 +73,7 @@ namespace FlaxEditor.GUI
|
||||
_editor.OnEditingStart();
|
||||
}
|
||||
|
||||
// Moving view
|
||||
if (_rightMouseDown)
|
||||
{
|
||||
Vector2 delta = location - _movingViewLastPos;
|
||||
if (_editor.CustomViewPanning != null)
|
||||
delta = _editor.CustomViewPanning(delta);
|
||||
delta *= GetUseModeMask(_editor.EnablePanning) * _editor.ViewScale;
|
||||
if (delta.LengthSquared > 0.01f)
|
||||
{
|
||||
_editor._mainPanel.ViewOffset += delta;
|
||||
_movingViewLastPos = location;
|
||||
if (_editor.CustomViewPanning != null)
|
||||
{
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_editor.EnablePanning)
|
||||
{
|
||||
case UseMode.Vertical:
|
||||
Cursor = CursorType.SizeNS;
|
||||
break;
|
||||
case UseMode.Horizontal:
|
||||
Cursor = CursorType.SizeWE;
|
||||
break;
|
||||
case UseMode.On:
|
||||
Cursor = CursorType.SizeAll;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// Moving selection
|
||||
else if (_isMovingSelection)
|
||||
internal void OnMove(Vector2 location)
|
||||
{
|
||||
var viewRect = _editor._mainPanel.GetClientArea();
|
||||
var locationKeyframes = PointToKeyframes(location, ref viewRect);
|
||||
@@ -194,6 +137,90 @@ namespace FlaxEditor.GUI
|
||||
Cursor = CursorType.SizeAll;
|
||||
_movedKeyframes = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnMoveEnd(Vector2 location)
|
||||
{
|
||||
if (_movedKeyframes)
|
||||
{
|
||||
_editor.OnEdited();
|
||||
_editor.OnEditingEnd();
|
||||
_movedKeyframes = false;
|
||||
}
|
||||
_isMovingSelection = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
|
||||
{
|
||||
// Pass all events
|
||||
location = PointFromParent(ref locationParent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseEnter(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
base.OnMouseEnter(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
// Start moving selection if movement started from the keyframe
|
||||
if (_leftMouseDown && !_isMovingSelection && GetChildAt(_leftMouseDownPos) is KeyframePoint)
|
||||
{
|
||||
if (_editor.KeyframesEditorContext != null)
|
||||
_editor.KeyframesEditorContext.OnKeyframesMove(_editor, this, location, true, false);
|
||||
else
|
||||
OnMoveStart(location);
|
||||
}
|
||||
|
||||
// Moving view
|
||||
if (_rightMouseDown)
|
||||
{
|
||||
Vector2 delta = location - _movingViewLastPos;
|
||||
if (_editor.CustomViewPanning != null)
|
||||
delta = _editor.CustomViewPanning(delta);
|
||||
delta *= GetUseModeMask(_editor.EnablePanning) * _editor.ViewScale;
|
||||
if (delta.LengthSquared > 0.01f)
|
||||
{
|
||||
_editor._mainPanel.ViewOffset += delta;
|
||||
_movingViewLastPos = location;
|
||||
if (_editor.CustomViewPanning != null)
|
||||
{
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_editor.EnablePanning)
|
||||
{
|
||||
case UseMode.Vertical:
|
||||
Cursor = CursorType.SizeNS;
|
||||
break;
|
||||
case UseMode.Horizontal:
|
||||
Cursor = CursorType.SizeWE;
|
||||
break;
|
||||
case UseMode.On:
|
||||
Cursor = CursorType.SizeAll;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// Moving selection
|
||||
else if (_isMovingSelection)
|
||||
{
|
||||
if (_editor.KeyframesEditorContext != null)
|
||||
_editor.KeyframesEditorContext.OnKeyframesMove(_editor, this, location, false, false);
|
||||
else
|
||||
OnMove(location);
|
||||
return;
|
||||
}
|
||||
// Moving tangent
|
||||
@@ -374,11 +401,10 @@ namespace FlaxEditor.GUI
|
||||
// Moving keyframes
|
||||
else if (_isMovingSelection)
|
||||
{
|
||||
if (_movedKeyframes)
|
||||
{
|
||||
_editor.OnEdited();
|
||||
_editor.OnEditingEnd();
|
||||
}
|
||||
if (_editor.KeyframesEditorContext != null)
|
||||
_editor.KeyframesEditorContext.OnKeyframesMove(_editor, this, location, false, true);
|
||||
else
|
||||
OnMoveEnd(location);
|
||||
}
|
||||
|
||||
_isMovingSelection = false;
|
||||
@@ -509,5 +535,19 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
RemoveKeyframesInner();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
if (_points.Count == 0)
|
||||
return;
|
||||
location = _contents.PointFromParent(control, location);
|
||||
if (start)
|
||||
_contents.OnMoveStart(location);
|
||||
else if (end)
|
||||
_contents.OnMoveEnd(location);
|
||||
else
|
||||
_contents.OnMove(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,5 +40,15 @@ namespace FlaxEditor.GUI
|
||||
/// </summary>
|
||||
/// <param name="editor">The source editor.</param>
|
||||
void OnKeyframesDelete(IKeyframesEditor editor);
|
||||
|
||||
/// <summary>
|
||||
/// Called when keyframes selection should be moved.
|
||||
/// </summary>
|
||||
/// <param name="editor">The source editor.</param>
|
||||
/// <param name="control">The source movement control.</param>
|
||||
/// <param name="location">The source movement location (in source control local space).</param>
|
||||
/// <param name="start">The movement start flag.</param>
|
||||
/// <param name="end">The movement end flag.</param>
|
||||
void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,15 @@ namespace FlaxEditor.GUI
|
||||
/// </summary>
|
||||
/// <param name="editor">The source editor.</param>
|
||||
void OnKeyframesDelete(IKeyframesEditor editor);
|
||||
|
||||
/// <summary>
|
||||
/// Called when keyframes selection should be moved.
|
||||
/// </summary>
|
||||
/// <param name="editor">The source editor.</param>
|
||||
/// <param name="control">The source movement control.</param>
|
||||
/// <param name="location">The source movement location (in source control local space).</param>
|
||||
/// <param name="start">The movement start flag.</param>
|
||||
/// <param name="end">The movement end flag.</param>
|
||||
void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,29 +109,7 @@ namespace FlaxEditor.GUI
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
|
||||
{
|
||||
// Pass all events
|
||||
location = PointFromParent(ref locationParent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseEnter(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
base.OnMouseEnter(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
// Start moving selection if movement started from the keyframe
|
||||
if (_leftMouseDown && !_isMovingSelection && GetChildAt(_leftMouseDownPos) is KeyframePoint)
|
||||
internal void OnMoveStart(Vector2 location)
|
||||
{
|
||||
// Start moving selected nodes
|
||||
_isMovingSelection = true;
|
||||
@@ -145,30 +123,7 @@ namespace FlaxEditor.GUI
|
||||
_editor.OnEditingStart();
|
||||
}
|
||||
|
||||
// Moving view
|
||||
if (_rightMouseDown)
|
||||
{
|
||||
// Calculate delta
|
||||
Vector2 delta = location - _movingViewLastPos;
|
||||
if (delta.LengthSquared > 0.01f)
|
||||
{
|
||||
if (_editor.CustomViewPanning != null)
|
||||
delta = _editor.CustomViewPanning(delta);
|
||||
if (_editor.EnablePanning)
|
||||
{
|
||||
// Move view
|
||||
_editor.ViewOffset += delta * _editor.ViewScale;
|
||||
_movingViewLastPos = location;
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
else if (_editor.CustomViewPanning != null)
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// Moving selection
|
||||
else if (_isMovingSelection)
|
||||
internal void OnMove(Vector2 location)
|
||||
{
|
||||
var viewRect = _editor._mainPanel.GetClientArea();
|
||||
var locationKeyframes = PointToKeyframes(location, ref viewRect);
|
||||
@@ -203,7 +158,79 @@ namespace FlaxEditor.GUI
|
||||
Cursor = CursorType.SizeAll;
|
||||
_movedKeyframes = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnMoveEnd(Vector2 location)
|
||||
{
|
||||
if (_movedKeyframes)
|
||||
{
|
||||
_editor.OnEdited();
|
||||
_editor.OnEditingEnd();
|
||||
_editor.UpdateKeyframes();
|
||||
_movedKeyframes = false;
|
||||
}
|
||||
_isMovingSelection = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IntersectsContent(ref Vector2 locationParent, out Vector2 location)
|
||||
{
|
||||
// Pass all events
|
||||
location = PointFromParent(ref locationParent);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseEnter(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
base.OnMouseEnter(location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnMouseMove(Vector2 location)
|
||||
{
|
||||
_mousePos = location;
|
||||
|
||||
// Start moving selection if movement started from the keyframe
|
||||
if (_leftMouseDown && !_isMovingSelection && GetChildAt(_leftMouseDownPos) is KeyframePoint)
|
||||
{
|
||||
if (_editor.KeyframesEditorContext != null)
|
||||
_editor.KeyframesEditorContext.OnKeyframesMove(_editor, this, location, true, false);
|
||||
else
|
||||
OnMoveStart(location);
|
||||
}
|
||||
|
||||
// Moving view
|
||||
if (_rightMouseDown)
|
||||
{
|
||||
// Calculate delta
|
||||
Vector2 delta = location - _movingViewLastPos;
|
||||
if (delta.LengthSquared > 0.01f)
|
||||
{
|
||||
if (_editor.CustomViewPanning != null)
|
||||
delta = _editor.CustomViewPanning(delta);
|
||||
if (_editor.EnablePanning)
|
||||
{
|
||||
// Move view
|
||||
_editor.ViewOffset += delta * _editor.ViewScale;
|
||||
_movingViewLastPos = location;
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
else if (_editor.CustomViewPanning != null)
|
||||
Cursor = CursorType.SizeAll;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
// Moving selection
|
||||
else if (_isMovingSelection)
|
||||
{
|
||||
if (_editor.KeyframesEditorContext != null)
|
||||
_editor.KeyframesEditorContext.OnKeyframesMove(_editor, this, location, false, false);
|
||||
else
|
||||
OnMove(location);
|
||||
return;
|
||||
}
|
||||
// Selecting
|
||||
@@ -329,12 +356,10 @@ namespace FlaxEditor.GUI
|
||||
// Moving keyframes
|
||||
if (_isMovingSelection)
|
||||
{
|
||||
if (_movedKeyframes)
|
||||
{
|
||||
_editor.OnEdited();
|
||||
_editor.OnEditingEnd();
|
||||
_editor.UpdateKeyframes();
|
||||
}
|
||||
if (_editor.KeyframesEditorContext != null)
|
||||
_editor.KeyframesEditorContext.OnKeyframesMove(_editor, this, location, false, true);
|
||||
else
|
||||
OnMoveEnd(location);
|
||||
}
|
||||
|
||||
_isMovingSelection = false;
|
||||
@@ -1227,5 +1252,17 @@ namespace FlaxEditor.GUI
|
||||
{
|
||||
RemoveKeyframesInner();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
location = _contents.PointFromParent(control, location);
|
||||
if (start)
|
||||
_contents.OnMoveStart(location);
|
||||
else if (end)
|
||||
_contents.OnMoveEnd(location);
|
||||
else
|
||||
_contents.OnMove(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2458,5 +2458,16 @@ namespace FlaxEditor.GUI.Timeline
|
||||
trackContext.OnKeyframesDelete(editor);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
location = control.PointToParent(_backgroundArea, location);
|
||||
for (int i = 0; i < _tracks.Count; i++)
|
||||
{
|
||||
if (_tracks[i] is IKeyframesEditorContext trackContext)
|
||||
trackContext.OnKeyframesMove(editor, _backgroundArea, location, start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,5 +670,12 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
if (Curve != null && Curve.Visible)
|
||||
Curve.OnKeyframesDelete(editor);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
if (Curve != null && Curve.Visible)
|
||||
Curve.OnKeyframesMove(editor, control, location, start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +457,13 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
if (Curve != null && Curve.Visible)
|
||||
Curve.OnKeyframesDelete(editor);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
if (Curve != null && Curve.Visible)
|
||||
Curve.OnKeyframesMove(editor, control, location, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -438,5 +438,12 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
if (Events != null && Events.Visible)
|
||||
Events.OnKeyframesDelete(editor);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
if (Events != null && Events.Visible)
|
||||
Events.OnKeyframesMove(editor, control, location, start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,5 +418,12 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
if (Keyframes != null && Keyframes.Visible)
|
||||
Keyframes.OnKeyframesDelete(editor);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnKeyframesMove(IKeyframesEditor editor, ContainerControl control, Vector2 location, bool start, bool end)
|
||||
{
|
||||
if (Keyframes != null && Keyframes.Visible)
|
||||
Keyframes.OnKeyframesMove(editor, control, location, start, end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user