internal void OnMoveStart(Vector2 location) { // Start moving selected keyframes _isMovingSelection = true; _movedKeyframes = false; var viewRect = _editor._mainPanel.GetClientArea(); _movingSelectionStart = PointToKeyframes(location, ref viewRect); if (_movingSelectionOffsets == null || _movingSelectionOffsets.Length != _editor._points.Count) { _movingSelectionOffsets = new Vector2[_editor._points.Count]; } for (int i = 0; i < _movingSelectionOffsets.Length; i++) { _movingSelectionOffsets[i] = _editor._points[i].Point - _movingSelectionStart; } _editor.OnEditingStart(); }
/// <inheritdoc /> public override bool OnMouseDown(Vector2 location, MouseButton button) { if (base.OnMouseDown(location, button)) { // Clear flags _isMovingSelection = false; _isMovingTangent = false; _rightMouseDown = false; _leftMouseDown = false; return(true); } // Cache data _isMovingSelection = false; _isMovingTangent = false; _mousePos = location; if (button == MouseButton.Left) { _leftMouseDown = true; _leftMouseDownPos = location; } if (button == MouseButton.Right) { _rightMouseDown = true; _rightMouseDownPos = location; _movingViewLastPos = location; } // Check if any node is under the mouse var underMouse = GetChildAt(location); if (underMouse is KeyframePoint keyframe) { if (_leftMouseDown) { // Check if user is pressing control if (Root.GetKey(KeyboardKeys.Control)) { // Add to selection keyframe.IsSelected = true; _editor.UpdateTangents(); } // Check if node isn't selected else if (!keyframe.IsSelected) { // Select node _editor.ClearSelection(); keyframe.IsSelected = true; _editor.UpdateTangents(); } // Start moving selected nodes StartMouseCapture(); _isMovingSelection = true; _movedKeyframes = false; var viewRect = _editor._mainPanel.GetClientArea(); _movingSelectionStart = PointToKeyframes(location, ref viewRect); if (_movingSelectionOffsets == null || _movingSelectionOffsets.Length != _editor._points.Count) { _movingSelectionOffsets = new Vector2[_editor._points.Count]; } for (int i = 0; i < _movingSelectionOffsets.Length; i++) { _movingSelectionOffsets[i] = _editor._points[i].Point - _movingSelectionStart; } _editor.OnEditingStart(); Focus(); Tooltip?.Hide(); return(true); } } else if (underMouse is TangentPoint tangent && tangent.Visible) { if (_leftMouseDown) { // Start moving tangent StartMouseCapture(); _isMovingTangent = true; _movedKeyframes = false; _movingTangent = tangent; _editor.OnEditingStart(); Focus(); Tooltip?.Hide(); return(true); } }