private void MouseControlOverObjects() { #region If over a window, exit out Cursor cursor = GuiManager.Cursor; if (cursor.WindowOver != null) { return; } #endregion // See if the mouse is over anything PositionedObject objectOver = GetObjectOver(); #region Cursor Push if (GuiManager.Cursor.PrimaryPush) { mObjectGrabbed = objectOver; if (mObjectGrabbed != null) { PositionedObjectMover.SetStartPosition(mObjectGrabbed); } if (mObjectGrabbed == null) { SelectObject <Sprite>(null, mCurrentSprites); SelectObject <Text>(null, mCurrentTexts); } else if (SpriteGrabbed != null) { SelectObject(SpriteGrabbed, mCurrentSprites); } else if (SpriteFrameGrabbed != null) { SelectObject(SpriteFrameGrabbed, mCurrentSpriteFrames); } else if (PositionedModelGrabbed != null) { SelectObject(PositionedModelGrabbed, mCurrentPositionedModels); } else if (TextGrabbed != null) { SelectObject(TextGrabbed, mCurrentTexts); } } #endregion #region Cursor Down (Drag) if (cursor.PrimaryDown) { PerformDraggingObjectControl(); } #endregion #region Cursor Click if (cursor.PrimaryClick) { cursor.StaticPosition = false; } #endregion }
/// <summary> /// Controls selecting new Shapes and performing move, scale, and rotate (when appropriate). /// </summary> #endregion private void CursorControlOverShapes() { if (GuiManager.DominantWindowActive) { return; } Cursor cursor = GuiManager.Cursor; #region Pushing selects and grabs a Shape or the corner of a Polygon if (cursor.PrimaryPush) { #region If the user has not interacted with the corners then see check for grabbing any Shapes if (mReactiveHud.HasPolygonEdgeGrabbed == false) { mObjectGrabbed = GetShapeOver(cursor.PrimaryDoublePush); ShowErrorIfObjectCanNotBeGrabbed(); // If the object is not null store its original position. This will be used // for SHIFT+drag which allows movement only on one axis. if (mObjectGrabbed != null) { PositionedObjectMover.SetStartPosition(mObjectGrabbed); } cursor.SetObjectRelativePosition(mObjectGrabbed); if (PolygonGrabbed != null) { UndoManager.AddToWatch(PolygonGrabbed); SelectPolygon(PolygonGrabbed); } if (AxisAlignedCubeGrabbed != null) { UndoManager.AddToWatch(AxisAlignedCubeGrabbed); SelectAxisAlignedCube(AxisAlignedCubeGrabbed); } if (AxisAlignedRectangleGrabbed != null) { UndoManager.AddToWatch(AxisAlignedRectangleGrabbed); SelectAxisAlignedRectangle(AxisAlignedRectangleGrabbed); } if (CircleGrabbed != null) { UndoManager.AddToWatch(CircleGrabbed); SelectCircle(CircleGrabbed); } if (SphereGrabbed != null) { UndoManager.AddToWatch(SphereGrabbed); SelectSphere(SphereGrabbed); } if (mObjectGrabbed == null) { DeselectAll(); } } #endregion } #endregion #region Holding the button down can be used to drag objects if (cursor.PrimaryDown) { PerformDraggingUpdate(); } #endregion #region Clicking (releasing) the mouse lets go of grabbed Polygons if (cursor.PrimaryClick) { if (PolygonGrabbed != null) { UndoManager.RecordUndos <Polygon>(); UndoManager.ClearObjectsWatching <Polygon>(); } if (AxisAlignedRectangleGrabbed != null) { UndoManager.RecordUndos <AxisAlignedRectangle>(); UndoManager.ClearObjectsWatching <AxisAlignedRectangle>(); } if (AxisAlignedCubeGrabbed != null) { UndoManager.RecordUndos <AxisAlignedCube>(); UndoManager.ClearObjectsWatching <AxisAlignedCube>(); } if (CircleGrabbed != null) { UndoManager.RecordUndos <Circle>(); UndoManager.ClearObjectsWatching <Circle>(); } if (SphereGrabbed != null) { UndoManager.RecordUndos <Sphere>(); UndoManager.ClearObjectsWatching <Sphere>(); } mObjectGrabbed = null; cursor.StaticPosition = false; cursor.ObjectGrabbed = null; } #endregion }