bool isSameAsAlreadySelectedElement(GuiElement element) { // is not the same if no element is selected if (!selectionTracker.isAnyGuiElementSelected) { return(false); } return(element == selectionTracker.selectedElement); }
void trySendDeselectionToElementIfNotSameElement(GuiElement element) { // if no element is/was selected we can't send it an deselection event if (!selectionTracker.isAnyGuiElementSelected) { return; } // if it is the same gui element sending it a deselection event is useless if (isSameAsAlreadySelectedElement(element)) { return; } // all fine, send delesection event sendDelesectionEventTo(selectionTracker.selectedElement); }
// called from outside when the mouse button was released public void eventMouseReleased(SpatialVectorDouble mousePosition) { IEnumerable <GuiElement> guiElementsUnderMousePositionAsEnumerable = positionChecker.getElementsWhichOverlapTheMousePosition(mousePosition); IList <GuiElement> guiElementsUnderMousePosition = new List <GuiElement>(guiElementsUnderMousePositionAsEnumerable); if (guiElementsUnderMousePosition.Count > 0) { // change the selection // we just take first GuiElement in case of multiple // NOTE< could be a problem if there are multiple elements under the mouse position, we let it this way for now > GuiElement elementUnderMousePosition = guiElementsUnderMousePosition[0]; // delesection trySendDeselectionToElementIfNotSameElement(elementUnderMousePosition); // selection if (!isSameAsAlreadySelectedElement(elementUnderMousePosition)) { changeSelectionTo(elementUnderMousePosition); } } }
public void removeAndDisposeGuiElement(GuiElement element) { guiElements.elements.Remove(element); // TODO< dispose > }
public void addGuiElement(GuiElement element) { guiElements.elements.Add(element); }
void sendDelesectionEventTo(GuiElement element) { throw new NotImplementedException(); // TODO }
void changeSelectionTo(GuiElement element) { selectionTracker.selectedElement = element; sendSelectionEventTo(element); }