Exemple #1
0
            /// <inheritdoc />
            public override bool OnMouseDown(Vector2 location, MouseButton button)
            {
                if (base.OnMouseDown(location, button))
                {
                    // Clear flags
                    _isMovingSelection = false;
                    _rightMouseDown    = false;
                    _leftMouseDown     = false;
                    return(true);
                }

                // Cache data
                _isMovingSelection = false;
                _mousePos          = location;
                if (button == MouseButton.Left)
                {
                    _leftMouseDown    = true;
                    _leftMouseDownPos = location;
                }
                if (button == MouseButton.Right)
                {
                    _rightMouseDown    = true;
                    _rightMouseDownPos = 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.Select();
                        }
                        // Check if node isn't selected
                        else if (!keyframe.IsSelected)
                        {
                            // Select node
                            _editor.ClearSelection();
                            keyframe.Select();
                        }

                        // Start moving selected nodes
                        StartMouseCapture();
                        _mouseMoveAmount        = 0;
                        _isMovingSelection      = true;
                        _movingSelectionViewPos = _editor.ViewOffset;
                        _editor.OnEditingStart();
                        Focus();
                        return(true);
                    }
                }
                else
                {
                    if (_leftMouseDown)
                    {
                        // Start selecting
                        StartMouseCapture();
                        _editor.ClearSelection();
                        Focus();
                        return(true);
                    }
                    if (_rightMouseDown)
                    {
                        // Start navigating
                        StartMouseCapture();
                        Focus();
                        return(true);
                    }
                }

                Focus();
                return(true);
            }
            /// <inheritdoc />
            public override bool OnMouseDown(Vector2 location, MouseButton button)
            {
                if (base.OnMouseDown(location, button))
                {
                    // Clear flags
                    _isMovingSelection = false;
                    _rightMouseDown    = false;
                    _leftMouseDown     = false;
                    return(true);
                }

                // Cache data
                _isMovingSelection = 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.Select();
                        }
                        // Check if node isn't selected
                        else if (!keyframe.IsSelected)
                        {
                            // Select node
                            _editor.ClearSelection();
                            keyframe.Select();
                        }

                        // Start moving selected nodes
                        StartMouseCapture();
                        _isMovingSelection = true;
                        _movedKeyframes    = false;
                        var viewRect = _editor._mainPanel.GetClientArea();
                        _movingSelectionStart = PointToKeyframes(location, ref viewRect).X;
                        if (_movingSelectionOffsets == null || _movingSelectionOffsets.Length != _editor._keyframes.Count)
                        {
                            _movingSelectionOffsets = new float[_editor._keyframes.Count];
                        }
                        for (int i = 0; i < _movingSelectionOffsets.Length; i++)
                        {
                            _movingSelectionOffsets[i] = _editor._keyframes[i].Time - _movingSelectionStart;
                        }
                        _editor.OnEditingStart();
                        Focus();
                        Tooltip?.Hide();
                        return(true);
                    }
                }
                else
                {
                    if (_leftMouseDown)
                    {
                        // Start selecting
                        StartMouseCapture();
                        _editor.ClearSelection();
                        Focus();
                        return(true);
                    }
                    if (_rightMouseDown)
                    {
                        // Start navigating
                        StartMouseCapture();
                        Focus();
                        return(true);
                    }
                }

                Focus();
                return(true);
            }