public void OnMouseMove(Coord last, Coord current) { PaneBounds from = GetTopPaneBounds(last); PaneBounds to = GetTopPaneBounds(current); from?.Pane.OnMouseMove(last - from.Bounds.MinExtent, current - from.Bounds.MinExtent); if (!to.Equals(from)) { to?.Pane.OnMouseMove(last - to.Bounds.MinExtent, current - to.Bounds.MinExtent); } }
public void HandleInput() { while (Terminal.HasInput()) { int input = Terminal.Read(); if (input == Terminal.TK_MOUSE_LEFT) { PaneBounds target = GetTopPaneBounds(MousePos()); IInputListener newFocus = target.Pane.Focus(MousePos()); _windowListeners[target] = newFocus; if (newFocus != _focus) { _focus.LoseFocus(); _focus = newFocus; } target.Pane.OnMouseClick(MousePos()); } else if (input == Terminal.TK_MOUSE_MOVE) { _windowListeners.Keys.Last().Pane.OnMouseMove(_mouseLast, MousePos()); _mouseLast = MousePos(); } else if (input < Terminal.TK_MOUSE_LEFT) // All key presses { if (_gameControlConsumer.Consume(input)) { continue; } if ((input & Terminal.TK_KEY_RELEASED) == Terminal.TK_KEY_RELEASED) { _focus.OnKeyUp(input); } else { _focus.OnKeyDown(input); } } } }
protected bool Equals(PaneBounds other) { return(Equals(Pane, other.Pane) && Bounds.Equals(other.Bounds)); }
public IInputListener Focus(Coord pos) { PaneBounds target = GetTopPaneBounds(pos); return(target?.Pane.Focus(pos - target.Bounds.MinExtent) ?? this); }
public void OnMouseClick(Coord pos) { PaneBounds target = GetTopPaneBounds(pos); target?.Pane.OnMouseClick(pos - target.Bounds.MinExtent); }
protected bool Equals(PaneBounds other) { return(Equals(Pane, other.Pane)); }