Example #1
0
        public GuiSystem(ViewportAdapter viewportAdapter, IGuiRenderer renderer)
        {
            _viewportAdapter = viewportAdapter;
            _renderer        = renderer;

            _mouseListener                  = new MouseListener(viewportAdapter);
            _mouseListener.MouseMoved      += (s, e) => OnPointerMoved(GuiPointerEventArgs.FromMouseArgs(e));
            _mouseListener.MouseDown       += (s, e) => OnPointerDown(GuiPointerEventArgs.FromMouseArgs(e));
            _mouseListener.MouseUp         += (s, e) => OnPointerUp(GuiPointerEventArgs.FromMouseArgs(e));
            _mouseListener.MouseWheelMoved += (s, e) => _focusedControl?.OnScrolled(e.ScrollWheelDelta);

            _touchListener = new TouchListener(viewportAdapter);
            _touchListener.TouchStarted += (s, e) => OnPointerDown(GuiPointerEventArgs.FromTouchArgs(e));
            _touchListener.TouchMoved   += (s, e) => OnPointerMoved(GuiPointerEventArgs.FromTouchArgs(e));
            _touchListener.TouchEnded   += (s, e) => OnPointerUp(GuiPointerEventArgs.FromTouchArgs(e));

            _keyboardListener             = new KeyboardListener();
            _keyboardListener.KeyTyped   += (sender, args) => _focusedControl?.OnKeyTyped(this, args);
            _keyboardListener.KeyPressed += (sender, args) => _focusedControl?.OnKeyPressed(this, args);

            Screens = new GuiScreenCollection(this)
            {
                ItemAdded = InitializeScreen
            };
        }
        public GuiSystem(ViewportAdapter viewportAdapter, IGuiRenderer renderer)
        {
            _renderer = renderer;

            _mouseListener             = new MouseListener(viewportAdapter);
            _mouseListener.MouseMoved += (s, e) => OnPointerMoved(GuiPointerEventArgs.FromMouseArgs(e));
            _mouseListener.MouseDown  += (s, e) => OnPointerDown(GuiPointerEventArgs.FromMouseArgs(e));
            _mouseListener.MouseUp    += (s, e) => OnPointerUp(GuiPointerEventArgs.FromMouseArgs(e));

            _touchListener = new TouchListener(viewportAdapter);
            _touchListener.TouchStarted += (s, e) => OnPointerDown(GuiPointerEventArgs.FromTouchArgs(e));
            _touchListener.TouchMoved   += (s, e) => OnPointerMoved(GuiPointerEventArgs.FromTouchArgs(e));
            _touchListener.TouchEnded   += (s, e) => OnPointerUp(GuiPointerEventArgs.FromTouchArgs(e));

            _keyboardListener             = new KeyboardListener();
            _keyboardListener.KeyTyped   += (sender, args) => _focusedControl?.OnKeyTyped(args);
            _keyboardListener.KeyPressed += (sender, args) => _focusedControl?.OnKeyPressed(args);
        }