public HasCursorOver ( Cursor cursor ) : bool | ||
cursor | Cursor | |
return | bool |
private GraphicalUiElement ReverseLoopToFindIpso(float x, float y, int indexToStartAt, int indexToEndAt, bool visibleToCheck, List <ElementWithState> elementStack) { GraphicalUiElement ipsoOver = null; if (indexToEndAt < -1) { throw new Exception("Index cannot be less than -1"); } if (indexToStartAt >= WireframeObjectManager.Self.AllIpsos.Count) { throw new Exception("Index must be less than the AllIpsos Count"); } // Let's try to get visible ones first, then if we don't find anything, look at invisible ones for (int i = indexToStartAt; i > indexToEndAt; i--) { GraphicalUiElement graphicalUiElement = WireframeObjectManager.Self.AllIpsos[i]; bool skip = graphicalUiElement.Tag is ScreenSave; if (!skip) { bool visible = IsIpsoVisible(graphicalUiElement); if (visible == visibleToCheck) { var hasCursorOver = false; if (graphicalUiElement.RenderableComponent is LinePolygon) { hasCursorOver = (graphicalUiElement.RenderableComponent as LinePolygon).IsPointInside(x, y); } else { hasCursorOver = graphicalUiElement.HasCursorOver(x, y); } if (hasCursorOver && (WireframeObjectManager.Self.IsRepresentation(graphicalUiElement))) { // hold on, even though this is a valid IPSO and the cursor is over it, we gotta see if // it's an instance that is locked. If so, we shouldn't select it! InstanceSave instanceSave = graphicalUiElement.Tag as InstanceSave; if (instanceSave == null || instanceSave.Locked == false) { ipsoOver = graphicalUiElement; break; } } } } } return(ipsoOver); }
public GraphicalUiElement GetRepresentationAt(float x, float y, bool skipSelected, List <ElementWithState> elementStack) { GraphicalUiElement ipsoOver = null; // First check if we're over the current GraphicalUiElement selectedRepresentation = WireframeObjectManager.Self.GetSelectedRepresentation(); if (InputLibrary.Keyboard.Self.KeyDown(Microsoft.Xna.Framework.Input.Keys.Space)) { int m = 3; } int indexToStartAt = -1; if (skipSelected) { if (selectedRepresentation != null) { indexToStartAt = WireframeObjectManager.Self.AllIpsos.IndexOf(selectedRepresentation); } } else { if (selectedRepresentation != null && selectedRepresentation.Tag is ScreenSave == false) { if (selectedRepresentation.HasCursorOver(x, y)) { ipsoOver = selectedRepresentation; } } } if (ipsoOver == null) { // We used to loop through the IPSOs that are part of the WireframeObjectManager, // but we want to do it in the order that they appear in the // Renderer. So we'll just loop through the IPositionedSizedObjects // in the Renderer's Layer[0], test if they're part of one of the WireframeObjectManager's // lists, and if so, check collision. if (indexToStartAt == -1) { indexToStartAt = WireframeObjectManager.Self.AllIpsos.Count; } #region First check only visible objects ipsoOver = ReverseLoopToFindIpso(x, y, indexToStartAt - 1, -1, true, elementStack); if (ipsoOver == null && indexToStartAt != WireframeObjectManager.Self.AllIpsos.Count - 1) { ipsoOver = ReverseLoopToFindIpso(x, y, WireframeObjectManager.Self.AllIpsos.Count - 1, indexToStartAt, true, elementStack); } #endregion #region If none were found, check invisible objects if (ipsoOver == null) { ipsoOver = ReverseLoopToFindIpso(x, y, indexToStartAt - 1, -1, false, elementStack); if (ipsoOver == null && indexToStartAt != WireframeObjectManager.Self.AllIpsos.Count - 1) { ipsoOver = ReverseLoopToFindIpso(x, y, WireframeObjectManager.Self.AllIpsos.Count - 1, indexToStartAt, false, elementStack); } } #endregion } // Right now we're going to assume that we only want to select IPSOs that represent the current // element or its InstanceSaves - not any children. So we're going to get the InstanceSave - if that's // null, get the ElementSave if (ipsoOver != null) { InstanceSave instance; ElementSave element; GetElementOrInstanceForIpso(ipsoOver, elementStack, out instance, out element); if (instance != null) { ipsoOver = WireframeObjectManager.Self.GetRepresentation(instance, elementStack); } else if (element != null) // both may be null if the user drag+dropped onto the wireframe window { try { ipsoOver = WireframeObjectManager.Self.GetRepresentation(element); } catch (Exception e) { int m = 3; throw e; } } } return(ipsoOver); }