Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 protected bool Equals(PaneBounds other)
 {
     return(Equals(Pane, other.Pane) && Bounds.Equals(other.Bounds));
 }
Ejemplo n.º 4
0
        public IInputListener Focus(Coord pos)
        {
            PaneBounds target = GetTopPaneBounds(pos);

            return(target?.Pane.Focus(pos - target.Bounds.MinExtent) ?? this);
        }
Ejemplo n.º 5
0
        public void OnMouseClick(Coord pos)
        {
            PaneBounds target = GetTopPaneBounds(pos);

            target?.Pane.OnMouseClick(pos - target.Bounds.MinExtent);
        }
Ejemplo n.º 6
0
 protected bool Equals(PaneBounds other)
 {
     return(Equals(Pane, other.Pane));
 }