Esempio n. 1
0
 private void WindowOnMouseEnterActions(SDL.SDL_WindowEvent sdlWindowEvent)
 {
     if (!isMouseVisible && !isMouseCurrentlyHidden)
     {
         Cursor.Hide();
         isMouseCurrentlyHidden = true;
     }
 }
Esempio n. 2
0
 private void GameForm_RestoredActions(SDL.SDL_WindowEvent e)
 {
     if (previousWindowState == FormWindowState.Minimized)
     {
         ResumeRendering?.Invoke(this, EventArgs.Empty);
     }
     previousWindowState = FormWindowState.Normal;
 }
Esempio n. 3
0
 private void WindowOnMouseLeaveActions(SDL.SDL_WindowEvent sdlWindowEvent)
 {
     if (isMouseCurrentlyHidden)
     {
         Cursor.Show();
         isMouseCurrentlyHidden = false;
     }
 }
Esempio n. 4
0
 private void GameForm_FocusEvent(SDL.SDL_WindowEvent e)
 {
     if (e.data1 == 0)
     {
         return;               // make no change
     }
     GameBase.PauseRendering = e.data1 == 2;
 }
Esempio n. 5
0
 private void OnSizeChanged(SDL.SDL_WindowEvent eventArgs)
 {
     SetSurfaceSize(new Vector2(uiControl.ClientSize.Width, uiControl.ClientSize.Height));
     if (IsPositionLocked)
     {
         // update center of screen for locking cursor
         relativeCapturedPosition         = new Point(uiControl.ClientSize.Width / 2, uiControl.ClientSize.Height / 2);
         uiControl.RelativeCursorPosition = relativeCapturedPosition;
     }
 }
Esempio n. 6
0
        private void GameForm_ResizeEndActions(SDL.SDL_WindowEvent e)
        {
            if (isUserResizing && cachedSize.Equals(Size))
            {
                UserResized?.Invoke(this, EventArgs.Empty);
                // UpdateScreen();
            }

            isUserResizing = false;
            ResumeRendering?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 7
0
        private void GameForm_MaximizedActions(SDL.SDL_WindowEvent e)
        {
            if (previousWindowState == FormWindowState.Minimized)
            {
                ResumeRendering?.Invoke(this, EventArgs.Empty);
            }

            previousWindowState = FormWindowState.Maximized;

            UserResized?.Invoke(this, EventArgs.Empty);
            //UpdateScreen();
            cachedSize = Size;
        }
Esempio n. 8
0
 private void GameForm_ResizeBeginActions(SDL.SDL_WindowEvent e)
 {
     if (Graphics.GraphicsDevice.Platform == Graphics.GraphicsPlatform.Vulkan && OriginalSize.HasValue)
     {
         // resizing not supported, return to original resolution
         Size = cachedSize = OriginalSize.Value;
     }
     else
     {
         isUserResizing = true;
         PauseRendering?.Invoke(this, EventArgs.Empty);
         cachedSize = Size;
     }
 }
Esempio n. 9
0
        private void GameForm_ResizeEndActions(SDL.SDL_WindowEvent e)
        {
            if (Graphics.GraphicsDevice.Platform == Graphics.GraphicsPlatform.Vulkan && OriginalSize.HasValue)
            {
                // resizing not supported, return to original resolution
                Size = cachedSize = OriginalSize.Value;
            }
            else
            {
                if (isUserResizing && cachedSize.Equals(Size))
                {
                    UserResized?.Invoke(this, EventArgs.Empty);
                    // UpdateScreen();
                }

                isUserResizing = false;
                ResumeRendering?.Invoke(this, EventArgs.Empty);
            }
        }
Esempio n. 10
0
        private void GameForm_RestoredActions(SDL.SDL_WindowEvent e)
        {
            if (previousWindowState == FormWindowState.Minimized)
            {
                ResumeRendering?.Invoke(this, EventArgs.Empty);
            }

            var newSize = Size;

            if (!isUserResizing && (!newSize.Equals(cachedSize) || previousWindowState == FormWindowState.Maximized))
            {
                previousWindowState = FormWindowState.Normal;

                // Only update when cachedSize is != 0
                if (cachedSize != Size2.Empty)
                {
                    isSizeChangedWithoutResizeBegin = true;
                }
            }

            previousWindowState = FormWindowState.Normal;
        }
Esempio n. 11
0
 private void OnSizeChanged(SDL.SDL_WindowEvent eventArgs)
 {
     SetSurfaceSize(new Vector2(uiControl.ClientSize.Width, uiControl.ClientSize.Height));
 }
Esempio n. 12
0
 private void GameForm_MinimizedActions(SDL.SDL_WindowEvent e)
 {
     previousWindowState = FormWindowState.Minimized;
     PauseRendering?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 13
0
 private void GameForm_ResizeBeginActions(SDL.SDL_WindowEvent e)
 {
     isUserResizing = true;
     cachedSize     = Size;
     PauseRendering?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 14
0
 private void GameForm_ActivateActions(SDL.SDL_WindowEvent e)
 {
     AppDeactivated?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 15
0
 public WindowClosingEventArgs(SDL.SDL_WindowEvent evt)
 {
     Cancel = false;
 }
Esempio n. 16
0
 private void UiWindowOnSizeChanged(SDL.SDL_WindowEvent eventArgs)
 {
     ControlWidth  = UiControl.ClientSize.Width;
     ControlHeight = UiControl.ClientSize.Height;
 }
Esempio n. 17
0
 private void GameForm_DeActivateActions(SDL.SDL_WindowEvent e)
 {
     AppActivated?.Invoke(this, EventArgs.Empty);
     isActive = false;
 }
Esempio n. 18
0
        static void ProcessWindowEvent(Sdl2NativeWindow window, SDL.SDL_WindowEvent e)
        {
            switch (e.windowEvent)
            {
            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
                var close_args = new System.ComponentModel.CancelEventArgs();
                window.Closing(window, close_args);
                if (!close_args.Cancel)
                {
                    window.Closed(window, EventArgs.Empty);
                    //window.DestroyWindow();
                }
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER:
                window.MouseEnter(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE:
                window.MouseLeave(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_EXPOSED:
                // do nothing
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                window.is_focused = true;
                window.FocusedChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                window.is_focused = false;
                window.FocusedChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_HIDDEN:
                window.is_visible = false;
                window.VisibleChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SHOWN:
                window.is_visible = true;
                window.VisibleChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MAXIMIZED:
                window.previous_window_state = window.window_state;
                window.window_state          = OpenTK.WindowState.Maximized;
                window.WindowStateChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MINIMIZED:
                window.previous_window_state = window.window_state;
                window.window_state          = OpenTK.WindowState.Minimized;
                window.WindowStateChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESTORED:
                window.window_state = window.previous_window_state;
                window.WindowStateChanged(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MOVED:
                window.Move(window, EventArgs.Empty);
                break;

            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_RESIZED:
            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
                window.Resize(window, EventArgs.Empty);
                break;

            default:
                Debug.Print("SDL2 unhandled event: {0}", e.type);
                break;
            }
        }
Esempio n. 19
0
 private void WindowOnResizeEndActions(SDL.SDL_WindowEvent sdlWindowEvent)
 {
     OnClientSizeChanged(window, EventArgs.Empty);
 }
Esempio n. 20
0
 public WindowResizedEventArgs(SDL.SDL_WindowEvent evt)
 {
     _evt = evt;
 }