private static void HandleIsMouseOver(GuiElement element, MouseState newState) { if (!element.Bounds.Contains(newState.X, newState.Y)) { return; } HandleIsMouseOverForAllChildren(element, newState); }
private void HandleMouseMoved(GuiElement element, MouseState newState, MouseMovedEventHandler handler) { if (!element.Bounds.Contains(newState.X, newState.Y)) { return; } HandleMouseMovedForChildren(element, newState, handler); }
private void HandleMouseMovedForChildren(GuiElement element, MouseState newState, MouseMovedEventHandler handler) { foreach (var childElement in element.Children) { if (childElement.Bounds.Contains(newState.X, newState.Y) && childElement.IsMouseOver) { childElement.OnMouseMove(handler); if (handler.Handled) { return; } HandleMouseMovedForChildren(childElement, newState, handler); } } }
private static void HandleIsMouseOverForAllChildren(GuiElement parent, MouseState newState) { foreach (var childElement in parent.Children) { if (childElement.Bounds.Contains(newState.X, newState.Y)) { if (!childElement.IsMouseOver) { childElement.OnMouseOver(new EventHandler()); childElement.IsMouseOver = true; } HandleIsMouseOverForAllChildren(childElement, newState); } else if (childElement.IsMouseOver) { childElement.IsMouseOver = false; childElement.OnMouseLeft(new EventHandler()); } } }
private void AddChild(int column, int row, GuiElement element) { _childElementsByLinearTableIndex.Add(new Tuple <int, int>(column, row), element); Children.Add(element); }
public void AddChild(GuiElement child) { Children.Add(child); }
private static GuiElement InvokeEventForChildren <THandler>(MouseState state, GuiElement parent, THandler handler, Action <GuiElement, THandler> action) where THandler : EventHandler { foreach (var childElement in parent.Children) { if (childElement.Bounds.Contains(state.X, state.Y)) { action(childElement, handler); if (handler.Handled) { return(childElement); } return(InvokeEventForChildren(state, childElement, handler, action)); } } return(null); }
public void AddElement(GuiElement element) { _elements.Add(element); element.Arrange(Game.GetScreenRectangle()); }