Ejemplo n.º 1
0
        internal void UpdateBoundingRectSize()
        {
            AnimationInfo anim = this.Animations[_currentAnimationID];
            int           maxW = 0;
            int           maxH = 0;

            for (int i = 0; i < anim.AnimationFrames.Count; i++)
            {
                if (this.Material.Areas.ContainsKey(anim.AnimationFrames[i].Area))
                {
                    maxW = SquidMath.Max(maxW,
                                         this.Material.Areas[anim.AnimationFrames[i].Area].Width);
                    maxH = SquidMath.Max(maxH,
                                         this.Material.Areas[anim.AnimationFrames[i].Area].Height);
                }
                else
                {
                    maxW = this.Material.Texture.Width;
                    maxH = this.Material.Texture.Height;
                    break;
                }
            }
            _boundingRectSize = new Vector2(maxW, maxH);
            this.UpdateBoundingRect();
        }
Ejemplo n.º 2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            Point mousePos = new Point(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y);

            _highlightedTile = -1;
            for (int i = 0; i < _rowsCountOnTexture * ParentGrid.ColumnsCountOnTexture; i++)
            {
                Point     tilePos  = GetPosOfTile(i);
                Rectangle tileRect = new Rectangle(tilePos.X, tilePos.Y, ParentGrid.TileSize.X, ParentGrid.TileSize.Y);
                if (SquidMath.IsPointInsideRectangle(mousePos, tileRect))
                {
                    _highlightedTile = i;
                    break;
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                if (_highlightedTile > -1)
                {
                    if (!TileGridEditor.Instance.SelectedBrushTiles.Contains(_highlightedTile))
                    {
                        TileGridEditor.Instance.SelectedBrushTiles.Add(_highlightedTile);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void UpdateSourceRectangleControls()
 {
     _ignoreNumericUpDownEvent         = true;
     toolStripButtonAutoDetect.Enabled = true;
     if (spriteEditorControl.Sprite.SourceRectangle != null)
     {
         toolStripButtonUseFullTexture.Enabled = true;
         numericUpDownRectX.Value   = (decimal)spriteEditorControl.Sprite.SourceRectangle.Value.X;
         numericUpDownRectY.Value   = (decimal)spriteEditorControl.Sprite.SourceRectangle.Value.Y;
         numericUpDownRectW.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Width - numericUpDownRectX.Value;
         numericUpDownRectH.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Height - numericUpDownRectY.Value;
         numericUpDownRectW.Value   = (decimal)SquidMath.Clamp(spriteEditorControl.Sprite.SourceRectangle.Value.Width,
                                                               (int)numericUpDownRectW.Minimum, (int)numericUpDownRectW.Maximum);
         numericUpDownRectH.Value = (decimal)SquidMath.Clamp(spriteEditorControl.Sprite.SourceRectangle.Value.Height,
                                                             (int)numericUpDownRectH.Minimum, (int)numericUpDownRectH.Maximum);
     }
     else
     {
         toolStripButtonUseFullTexture.Enabled = false;
         numericUpDownRectX.Value = 0;
         numericUpDownRectY.Value = 0;
         if (spriteEditorControl.Sprite.Material != null)
         {
             numericUpDownRectW.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Width;
             numericUpDownRectH.Maximum = (decimal)spriteEditorControl.Sprite.Material.Texture.Height;
             numericUpDownRectW.Value   = (decimal)spriteEditorControl.Sprite.Material.Texture.Width;
             numericUpDownRectH.Value   = (decimal)spriteEditorControl.Sprite.Material.Texture.Height;
         }
     }
     _ignoreNumericUpDownEvent             = false;
     toolStripButtonShowWholeImage.Visible = spriteEditorControl.Sprite.SourceRectangle.HasValue;
 }
Ejemplo n.º 4
0
 public void MouseClicked(Point mousePos)
 {
     if (_selectionMode == SpriteEditorSelectionMode.SelectingTile)
     {
         Vector2 translatedPos = ParentEditor.ZoomBox.Camera
                                 .ConvertToWorldPos(new Vector2(mousePos.X, mousePos.Y));
         if (SquidMath.IsPointInsideRectangle(new Point((int)translatedPos.X, (int)translatedPos.Y)
                                              , _spriteRectangles[_selectedRectangle]))
         {
             _selectionMode = SpriteEditorSelectionMode.Tiled;
             Rectangle spriteRect = _spriteRectangles[_selectedRectangle];
             Sprite.MaterialArea = _selectedRectangle;
             this.ParentEditor.RefreshAreaCombo();
         }
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Called by the parent form when the mouse is moving on the control
 /// </summary>
 /// <param name="mousePos">The mouse position relative to the control</param>
 public void CheckMousePosition(Point mousePos)
 {
     if (_selectionMode == SpriteEditorSelectionMode.SelectingTile)
     {
         Vector2 translatedPos = ParentEditor.ZoomBox.Camera
                                 .ConvertToWorldPos(new Vector2(mousePos.X, mousePos.Y));
         foreach (var rect in this.SpriteRectangles)
         {
             Rectangle translatedRect = rect.Value;
             if (SquidMath.IsPointInsideRectangle(new Point((int)translatedPos.X, (int)translatedPos.Y),
                                                  translatedRect))
             {
                 _selectedRectangle = rect.Key;
             }
         }
     }
 }
        protected void DrawBrushTileHighlight(Color color)
        {
            if (_brushStartPoint.X > -1 && _brushStartPoint.Y > -1)
            {
                Point clampedSize = _brushSize;
                clampedSize.X = SquidMath.Clamp(_brushStartPoint.X + clampedSize.X,
                                                0, TileGrid.TileCols) - _brushStartPoint.X;
                clampedSize.Y = SquidMath.Clamp(_brushStartPoint.Y + clampedSize.Y,
                                                0, TileGrid.TileRows) - _brushStartPoint.Y;

                Vector2 pos = new Vector2(_brushStartPoint.X * TileGrid.TileSize.X * TileGrid.Scale.X,
                                          _brushStartPoint.Y * TileGrid.TileSize.Y * TileGrid.Scale.Y);
                Vector2 size = new Vector2(clampedSize.X * TileGrid.TileSize.X * TileGrid.Scale.X,
                                           clampedSize.Y * TileGrid.TileSize.Y * TileGrid.Scale.Y);
                DrawingManager.DrawFilledRectangle(TileGrid.Layer, pos, size,
                                                   color, TileGrid.BlendingType);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Insert a children bone at specific index
        /// </summary>
        public void InsertChildBone(int index, CompositeBone childBone)
        {
            index = SquidMath.Clamp(index, 0, _childBones.Count);
            _childBones.Insert(index, childBone);
            childBone.ParentBone = this;
            childBone.Parent     = this.Parent;
            CompositeBone precedingBone;

            if (index == 0)
            {
                precedingBone = this;
            }
            else
            {
                precedingBone = this.ChildBones[index - 1];
            }
            // sync transforms
            for (int i = 0; i < Parent.Animations.Count; i++)
            {
                // loop through every keyframe to sync them
                for (int j = 0; j < Parent.Animations[i].KeyFrames.Count; j++)
                {
                    CompositeKeyFrame keyframe = Parent.Animations[i].KeyFrames[j];
                    // loop to find the previous bone
                    for (int k = 0; k < keyframe.BoneTransforms.Count; k++)
                    {
                        CompositeBoneTransform transform = keyframe.BoneTransforms[k];
                        if (transform.Bone.Equals(precedingBone))
                        {
                            CompositeBoneTransform newTransform = new CompositeBoneTransform();
                            newTransform.Parent        = keyframe;
                            newTransform.BoneReference = childBone.Name;
                            // insert the new bone just after the preceding bone
                            keyframe.BoneTransforms.Insert(k + 1, newTransform);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public Vector2 GetNewEmissionPoint()
        {
            Vector2 emissionPointOffset = Vector2.Zero;

            switch (type)
            {
            case EmitterShapeType.Rectangle:
                emissionPointOffset.X = Randomizer.Float(-size.X / 2.0f, size.X / 2.0f);
                emissionPointOffset.Y = Randomizer.Float(-size.Y / 2.0f, size.Y / 2.0f);
                break;

            case EmitterShapeType.Circle:
                Vector2 radius = new Vector2(Randomizer.Float(0f, size.X), Randomizer.Float(0f, size.Y));
                float   angle  = Randomizer.AngleInRadians();
                emissionPointOffset.X = radius.X * SquidMath.CosFromRadians(angle);
                emissionPointOffset.Y = radius.Y * SquidMath.SinFromRadians(angle);
                break;

            case EmitterShapeType.CircleOutline:
                float angle2 = Randomizer.AngleInRadians();
                emissionPointOffset.X = size.X * SquidMath.CosFromRadians(angle2);
                emissionPointOffset.Y = size.Y * SquidMath.SinFromRadians(angle2);
                break;

            case EmitterShapeType.TextureMask:
                // choose an array index at random
                if (maskPoints.Length > 0)
                {
                    int arrayIndex = Randomizer.Integer(0, maskPoints.Length - 1);
                    emissionPointOffset = maskPoints[arrayIndex];
                }
                break;

            default:
                break;
            }
            return(emissionPointOffset + offset + position);
        }
        private void StoreCopyOfSelectedTiles()
        {
            int layer = TileGridEditor.Instance.SelectedLayer;

            if (_selectedTiles.Count > 0)
            {
                _clipboardTiles.Clear();

                Point topLeft = new Point(TileGrid.TileCols - 1, TileGrid.TileRows - 1);
                // locate the top left most coords of the group
                for (int i = 0; i < _selectedTiles.Count; i++)
                {
                    topLeft.X = SquidMath.Min(topLeft.X, _selectedTiles[i].X);
                    topLeft.Y = SquidMath.Min(topLeft.Y, _selectedTiles[i].Y);
                }
                Console.WriteLine("TopLeft: " + topLeft);
                for (int i = 0; i < _selectedTiles.Count; i++)
                {
                    TileCopy tileCopy = new TileCopy();
                    tileCopy.Tile = TileGrid.TileLayers[layer]
                                    .Tiles[_selectedTiles[i].X][_selectedTiles[i].Y];
                    Point disp = new Point();
                    disp.X = _selectedTiles[i].X - topLeft.X;
                    disp.Y = _selectedTiles[i].Y - topLeft.Y;
                    tileCopy.Displacement = disp;
                    _clipboardTiles.Add(tileCopy);
                }

                Console.WriteLine("======== CLIPBOARD ========");
                for (int i = 0; i < _clipboardTiles.Count; i++)
                {
                    Console.WriteLine(i + "] " + _clipboardTiles[i].Tile + ", Disp: " + _clipboardTiles[i].Displacement);
                }
                TileGridEditor.Instance.SetEnableStatePasteIcon(true);
            }
        }
Ejemplo n.º 10
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (SceneManager.ActiveScene != null)
            {
                // update the mouse position (this will update the Scene mouse too)
                this.RealMousePos = new Vector2(e.X, e.Y);
                if (SquidEditorForm.Instance.SceneEditorTool == SquidEditorSceneEditorTool.Select)
                {
                    // if the user is dragging selected item(s)
                    if (_isDraggingItem == true && _selectedItems.Count > 0)
                    {
                        Vector2 dragDistance     = SceneMousePos - _dragItemStartPos;
                        Vector2 diffDragDistance = Vector2.Zero;
                        dragDistance.X = (float)Math.Round(dragDistance.X);
                        dragDistance.Y = (float)Math.Round(dragDistance.Y);
                        //Console.WriteLine("dragDistance: " + dragDistance + " start: " + _dragItemStartPos);
                        if (dragDistance.LengthSquared() > 0)
                        {
                            if (shouldMakeCopy == true)
                            {
                                shouldMakeCopy = false;
                                SquidEditorForm.Instance.CopySelectedItems();
                                List <SceneItem> _newItems = SquidEditorForm.Instance.PasteSelectedItems();
                                _selectedItems.Clear();
                                foreach (var item in _newItems)
                                {
                                    _selectedItems.Add(item);
                                }
                            }
                            foreach (SceneItem item in _selectedItems)
                            {
                                Vector2 newPos = item.Position + dragDistance;
                                if (Preferences.ShowGrid == true && Preferences.SnapToGrid == true)
                                {
                                    #region SnapToGrid
                                    Point   gridSize     = Preferences.GridSizes[Preferences.SelectedGrid - 1];
                                    int     snapZone     = Preferences.GridAttractionZones[Preferences.SelectedGrid - 1];
                                    int     left         = item.BoundingRect.Left + (int)dragDistance.X;
                                    int     right        = item.BoundingRect.Right + (int)dragDistance.X;
                                    int     top          = item.BoundingRect.Top + (int)dragDistance.Y;
                                    int     bottom       = item.BoundingRect.Bottom + (int)dragDistance.Y;
                                    Vector2 halfGridSize = new Vector2(gridSize.X / 2, gridSize.Y);
                                    Vector2 leftSnap     = new Vector2(
                                        SquidMath.Floor(left / (float)gridSize.X),
                                        left % (float)gridSize.X);
                                    Vector2 rightSnap = new Vector2(
                                        SquidMath.Ceiling(right / (float)gridSize.X),
                                        ((float)gridSize.X - right
                                         % (float)gridSize.X) % (float)gridSize.X);
                                    if (leftSnap.X < 0)
                                    {
                                        leftSnap.Y = (gridSize.X + leftSnap.Y) % gridSize.X;
                                    }
                                    if (leftSnap.Y > halfGridSize.X)
                                    {
                                        leftSnap.X += 1;
                                        leftSnap.Y  = leftSnap.Y - gridSize.X;
                                    }
                                    if (rightSnap.Y > halfGridSize.X)
                                    {
                                        rightSnap.X -= 1;
                                        rightSnap.Y  = rightSnap.Y - gridSize.X;
                                    }

                                    Vector2 snapX = Vector2.Zero;
                                    if (Math.Abs(leftSnap.Y) <= Math.Abs(rightSnap.Y))
                                    {
                                        snapX = leftSnap;
                                    }
                                    else
                                    {
                                        snapX = rightSnap;
                                    }
                                    //Console.WriteLine("L: " + leftSnap + " R: " + rightSnap + " ");
                                    if (Math.Abs(snapX.Y) <= (float)snapZone)
                                    {
                                        float diff   = newPos.X - (float)left;
                                        float oldPos = newPos.X;
                                        newPos.X = snapX.X * gridSize.X + diff;
                                        if (snapX != leftSnap)
                                        {
                                            newPos.X -= right - left;
                                        }
                                        diffDragDistance.X = newPos.X - oldPos;
                                    }

                                    Vector2 topSnap = new Vector2(
                                        SquidMath.Floor(top / (float)gridSize.Y),
                                        top % (float)gridSize.Y);
                                    Vector2 bottomSnap = new Vector2(
                                        SquidMath.Ceiling(bottom / (float)gridSize.Y),
                                        ((float)gridSize.Y - bottom
                                         % (float)gridSize.Y) % (float)gridSize.Y);
                                    if (topSnap.X < 0)
                                    {
                                        topSnap.Y = (gridSize.Y + topSnap.Y) % gridSize.Y;
                                    }
                                    if (topSnap.Y > halfGridSize.X)
                                    {
                                        topSnap.X += 1;
                                        topSnap.Y  = topSnap.Y - gridSize.Y;
                                    }
                                    if (bottomSnap.Y > halfGridSize.X)
                                    {
                                        bottomSnap.X -= 1;
                                        bottomSnap.Y  = bottomSnap.Y - gridSize.Y;
                                    }

                                    Vector2 snapY = Vector2.Zero;
                                    if (Math.Abs(topSnap.Y) <= Math.Abs(bottomSnap.Y))
                                    {
                                        snapY = topSnap;
                                    }
                                    else
                                    {
                                        snapY = bottomSnap;
                                    }
                                    //Console.WriteLine("T: " + topSnap + " B: " + bottomSnap + " ");
                                    if (Math.Abs(snapY.Y) <= (float)snapZone)
                                    {
                                        float diff   = newPos.Y - (float)top;
                                        float oldPos = newPos.Y;
                                        newPos.Y = snapY.X * gridSize.Y + diff;
                                        if (snapY != topSnap)
                                        {
                                            newPos.Y -= bottom - top;
                                        }
                                        diffDragDistance.Y = newPos.Y - oldPos;
                                    }
                                    #endregion
                                }
                                item.Position = newPos;
                                SquidEditorForm.Instance.SceneWasModified = true;
                            }
                            _refreshSceneItemProperties = true;
                        }
                        _dragItemStartPos = SceneMousePos;
                        if (diffDragDistance.X != 0)
                        {
                            _dragItemStartPos.X += diffDragDistance.X;
                        }
                        if (diffDragDistance.Y != 0)
                        {
                            _dragItemStartPos.Y += diffDragDistance.Y;
                        }
                    }
                    else
                    {
                        // check if the mouse is hovering an object
                        // and highlight it
                        _highlightedItem = null;
                        foreach (SceneItem item in SceneManager.ActiveScene.SceneItems)
                        {
                            if (item is PostProcessAnimation)
                            {
                                continue;
                            }
                            Microsoft.Xna.Framework.Point mousePoint
                                = new Microsoft.Xna.Framework.Point((int)SceneMousePos.X,
                                                                    (int)SceneMousePos.Y);
                            if (SquidMath.IsPointInsideRectangle(mousePoint, item.BoundingRect))
                            {
                                if (item.Visible)
                                {
                                    _highlightedItem = item;
                                }
                            }
                        }
                        // check the selected items and give them priority over the others
                        foreach (SceneItem item in _selectedItems)
                        {
                            Microsoft.Xna.Framework.Point mousePoint
                                = new Microsoft.Xna.Framework.Point((int)SceneMousePos.X,
                                                                    (int)SceneMousePos.Y);
                            if (SquidMath.IsPointInsideRectangle(mousePoint, item.BoundingRect))
                            {
                                if (item.Visible)
                                {
                                    _highlightedItem = item;
                                }
                            }
                        }
                    }
                }
                // Check for scene dragging with the mouse
                if (_isDraggingScene == true)
                {
                    Camera  cam          = SceneManager.ActiveScene.ActiveCameras[0];
                    Vector2 dragDistance = -(RealMousePos - _dragSceneStartPos) / cam.Zoom;
                    cam.Position += dragDistance;
                    _refreshSceneItemProperties = true;
                    _dragSceneStartPos          = RealMousePos;
                }
            }
        }
Ejemplo n.º 11
0
        public void LerpSceneItemWith(CompositeBoneTransform nextState, float amount, bool nextStateOverride)
        {
            // original is only used when bone.Interpolate is set to false, and refer to the 1st KF of the 1st anim
            SceneItem item    = GetSceneItem();
            String    subItem = GetSubItem();

            if (String.IsNullOrEmpty(subItem) == false && item is ISubItemCollection)
            {
                ((ISubItemCollection)item).SetCurrentSubItem(subItem);
            }
            if (item != null)
            {
                item.Update(1 / 60f);
                amount = MathHelper.Clamp(amount, 0, 1);
                CompositeEntity        parentEntity    = Parent.Parent.Parent;
                CompositeBoneTransform parentTransform = this.ParentBoneTransform;
                _currentVisibleState = GetVisibilityState(parentTransform);
                if (_currentVisibleState == false)
                {
                    return;
                }
                bool nextStateVisibility = nextState.GetVisibilityState(nextState.ParentBoneTransform);
                // no lerping if the next state isnt visible
                if (nextStateVisibility == false)
                {
                    nextState = this;
                }
                if (nextStateOverride == true)
                {
                    _position = nextState.Position;
                    _scale    = nextState.Scale;
                    _rotation = nextState.Rotation;
                }
                else
                {
                    _position = Vector2.Lerp(this.Position, nextState.Position, amount);
                    _scale    = Vector2.Lerp(this.Scale, nextState.Scale, amount);
                    _rotation = MathHelper.Lerp(this.Rotation, nextState.Rotation, amount);
                }
                if (this.Opacity.HasValue == true || nextState.Opacity.HasValue == true)
                {
                    if (this.Opacity.HasValue == true && nextState.Opacity.HasValue == false)
                    {
                        _opacity = this.Opacity.Value;
                    }
                    else if (this.Opacity.HasValue == false && nextState.Opacity.HasValue == true)
                    {
                        _opacity = nextState.Opacity.Value;
                    }
                    else
                    {
                        _opacity = SquidMath.Lerp(this.Opacity.Value, nextState.Opacity.Value, amount);
                    }
                }
                else
                {
                    _opacity = null;
                }
                _transformPivot     = item.GetAbsolutePivot(false);
                item.FlipHorizontal = parentEntity.FlipHorizontal ^ this.FlipHorizontal;
                item.FlipVertical   = parentEntity.FlipVertical ^ this.FlipVertical;
                if (parentEntity.FlipHorizontal == true)
                {
                    _position.X       = -_position.X;
                    _transformPivot.X = item.BoundingRectSize.X - _transformPivot.X;
                    _rotation         = -_rotation;
                }
                if (parentEntity.FlipVertical == true)
                {
                    _position.Y       = -_position.Y;
                    _transformPivot.Y = item.BoundingRectSize.Y - _transformPivot.Y;
                    _rotation         = -_rotation;
                }
                if (parentEntity.Scale != Vector2.One)
                {
                    _position *= parentEntity.Scale;
                }
                if (parentEntity.Rotation != 0)
                {
                    Vector2 offset = _position;
                    float   length = offset.Length();
                    double  angle  = Math.Atan2((float)offset.Y, (float)offset.X) + parentEntity.Rotation;
                    offset.X  = (float)(length * Math.Cos(angle));
                    offset.Y  = (float)(length * Math.Sin(angle));
                    _position = offset;
                }
                if (parentTransform != null)
                {
                    if (this.InheritRotation.HasValue == false && this.Bone.InheritRotation == true ||
                        this.InheritRotation.HasValue == true && this.InheritRotation == true)
                    {
                        _rotation += parentTransform.CurrentRotation;
                    }
                    if (this.InheritScale.HasValue == false && this.Bone.InheritScale == true ||
                        this.InheritScale.HasValue == true && this.InheritScale == true)
                    {
                        _scale *= parentTransform.CurrentScale;
                    }
                    if (this.InheritPosition.HasValue == false && this.Bone.InheritPosition == true ||
                        this.InheritPosition.HasValue == true && this.InheritPosition == true)
                    {
                        Vector2 offset = _position;
                        float   length = offset.Length();
                        double  angle  = Math.Atan2((float)offset.Y, (float)offset.X) + parentTransform._rotation;
                        offset.X  = (float)(length * Math.Cos(angle));
                        offset.Y  = (float)(length * Math.Sin(angle));
                        _position = parentTransform.CurrentPosition + offset;
                    }
                }
            }
        }
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (this.ParentEditor.SelectedCompositeKeyFrame != null)
     {
         // update the mouse position (this will update the Scene mouse too)
         RealMousePos = new Vector2(e.X, e.Y);
         // if the user is dragging selected item(s)
         if (_isDraggingItem == true && this.SelectedBones.Count > 0)
         {
             Vector2 dragDistance = this.SceneMousePos - _dragItemStartPos;
             if (dragDistance.LengthSquared() > 0)
             {
                 foreach (String boneTransformRef in this.SelectedBones)
                 {
                     CompositeBoneTransform boneTransform
                         = this.ParentEditor.SelectedCompositeKeyFrame.GetBoneTransformFromKeyFrame(
                               this.ParentEditor.SelectedCompositeKeyFrame, boneTransformRef);
                     if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                     {
                         float originalAngle = _dragItemStartPos.Angle();
                         float targetAngle   = this.SceneMousePos.Angle();
                         boneTransform.Rotation = MathHelper.WrapAngle((float)Math.Round((double)(boneTransform.Rotation + (targetAngle - originalAngle)), 2));
                     }
                     else
                     {
                         boneTransform.Position += dragDistance;
                     }
                 }
                 _refreshSceneItemProperties = true;
                 ParentEditor.UpdatePreview  = true;
             }
             _dragItemStartPos = SceneMousePos;
         }
         else
         {
             // check if the mouse is hovering an object
             // and highlight it
             this.HighlightedBone = null;
             foreach (CompositeBoneTransform boneTransform
                      in ParentEditor.SelectedCompositeKeyFrame.BoneTransforms)
             {
                 // ignore 'locked' bones
                 if (boneTransform.IsPositionCurrentlyInherited() == true)
                 {
                     continue;
                 }
                 SceneItem boneTransformSceneItem = boneTransform.GetSceneItem();
                 if (boneTransform.IsVisible == true && boneTransformSceneItem != null)
                 {
                     Rectangle boundingRect = boneTransformSceneItem.BoundingRect;
                     Microsoft.Xna.Framework.Point mousePoint
                         = new Microsoft.Xna.Framework.Point((int)SceneMousePos.X,
                                                             (int)SceneMousePos.Y);
                     if (SquidMath.IsPointInsideRectangle(mousePoint, boundingRect))
                     {
                         this.HighlightedBone = boneTransform.BoneReference;
                     }
                 }
             }
             // check the selected items and give them priority over the others
             foreach (String boneTransformRef in this.SelectedBones)
             {
                 CompositeBoneTransform boneTransform
                     = ParentEditor.SelectedCompositeKeyFrame.GetBoneTransformFromKeyFrame(
                           ParentEditor.SelectedCompositeKeyFrame, boneTransformRef);
                 SceneItem boneTransformSceneItem = boneTransform.GetSceneItem();
                 if (boneTransform.IsVisible == true && boneTransformSceneItem != null)
                 {
                     Rectangle boundingRect = boneTransformSceneItem.BoundingRect;
                     Microsoft.Xna.Framework.Point mousePoint
                         = new Microsoft.Xna.Framework.Point((int)SceneMousePos.X,
                                                             (int)SceneMousePos.Y);
                     if (SquidMath.IsPointInsideRectangle(mousePoint, boundingRect))
                     {
                         this.HighlightedBone = boneTransformRef;
                     }
                 }
             }
         }
         // Check for scene dragging with the mouse
         if (_isDraggingScene == true)
         {
             Vector2 dragDistance = -(RealMousePos - _dragSceneStartPos);
             ParentEditor.ZoomBox.Camera.Position += dragDistance;
             _dragSceneStartPos = RealMousePos;
         }
     }
 }
 protected Point ClampTile(Point tileCoord)
 {
     tileCoord.X = SquidMath.Clamp(tileCoord.X, 0, TileGrid.TileCols - 1);
     tileCoord.Y = SquidMath.Clamp(tileCoord.Y, 0, TileGrid.TileRows - 1);
     return(tileCoord);
 }