Class Window

java.lang.Object
icyllis.modernui.core.Window
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
ActivityWindow

@NotThreadSafe public class Window extends Object implements AutoCloseable
Represents a GLFW platform window, with 3D API surface attached to it.

There's must be a main window in Modern UI, any other windows share the same 3D context of the main one. Each window have its Activity Context and its own presentation screen. Any sub-window (e.g. tooltips, toasts) will not exceed its platform window area.

Most window methods must be only called on main thread.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Window states.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    End of types of system windows.
    protected final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Window(long handle)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Destroys the window and remove all callbacks.
    static Window
    get(long handle)
     
    final long
    Get the pointer of this window in the GLFW.
    int
    Returns the framebuffer height for this window in pixels.
    int
    Returns the window height in virtual screen coordinates.
    int
    Returns the window width in virtual screen coordinates.
    int
    Returns the y-coordinate of the top-left corner of this window in virtual screen coordinate system.
    int
    Returns the x-coordinate of the top-left corner of this window in virtual screen coordinate system.
    int
    Returns the framebuffer width for this window in pixels.
    void
     
    void
    Makes the OpenGL context of this window on the current calling thread.
    void
     
    void
     
    void
     
    void
    setIcon(Bitmap... icons)
    Sets window icon.
    void
    setShouldClose(boolean value)
    Sets the value of the close flag of the specified window.
    void
    Sets window title.
    boolean
    Gets whether this window is marked should be closed.
    void
     
    void
    Swaps the front and back buffers of the specified window when rendering with OpenGL.
    void
    swapInterval(int interval)
    Sets the swap interval for the current OpenGL context.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LAST_SYSTEM_WINDOW

      public static final int LAST_SYSTEM_WINDOW
      End of types of system windows.
      See Also:
    • mHandle

      protected final long mHandle
  • Constructor Details

    • Window

      public Window(long handle)
  • Method Details

    • get

      @Nullable public static Window get(long handle)
    • getHandle

      public final long getHandle()
      Get the pointer of this window in the GLFW.
      Returns:
      the handle of the window
    • shouldClose

      public boolean shouldClose()
      Gets whether this window is marked should be closed. For example, by clicking the close button in the title bar.
      Returns:
      true if this window should be closed
    • setShouldClose

      public void setShouldClose(boolean value)
      Sets the value of the close flag of the specified window. This can be used to override the user's attempt to close the window, or to signal that it should be closed.
      Parameters:
      value - should close
    • setTitle

      public void setTitle(@NonNull String title)
      Sets window title.
    • setIcon

      public void setIcon(@Nullable Bitmap... icons)
      Sets window icon.
    • makeCurrent

      public void makeCurrent()
      Makes the OpenGL context of this window on the current calling thread. It can only be on one thread at the same time.
    • swapBuffers

      public void swapBuffers()
      Swaps the front and back buffers of the specified window when rendering with OpenGL.
    • swapInterval

      public void swapInterval(int interval)
      Sets the swap interval for the current OpenGL context.
      Parameters:
      interval - the interval
    • getWidth

      public int getWidth()
      Returns the framebuffer width for this window in pixels.
      Returns:
      the framebuffer width
    • getHeight

      public int getHeight()
      Returns the framebuffer height for this window in pixels.
      Returns:
      the framebuffer height
    • getScreenY

      public int getScreenY()
      Returns the x-coordinate of the top-left corner of this window in virtual screen coordinate system.
      Returns:
      the x-coordinate of this window
    • getScreenX

      public int getScreenX()
      Returns the y-coordinate of the top-left corner of this window in virtual screen coordinate system.
      Returns:
      the y-coordinate of this window
    • getScreenWidth

      public int getScreenWidth()
      Returns the window width in virtual screen coordinates.
      Returns:
      window width
    • getScreenHeight

      public int getScreenHeight()
      Returns the window height in virtual screen coordinates.
      Returns:
      window height
    • minimize

      public void minimize()
    • restore

      public void restore()
    • maximize

      public void maximize()
    • show

      public void show()
    • hide

      public void hide()
    • close

      public void close()
      Destroys the window and remove all callbacks.
      Specified by:
      close in interface AutoCloseable