A platform-specific window.
This class describes a platform-specific window and provides methods for managing it.
Creating a Window
To create a new Window, use the static Window::Create method:
static RefPtr< Window > Create(Monitor *monitor, uint32_t width, uint32_t height, bool fullscreen, unsigned int window_flags)
Create a new Window.
@ kWindowFlags_Titled
Definition Window.h:78
Setting a WindowListener
To receive callbacks for window-related events, set a WindowListener:
virtual void OnClose(
Window* window)
override {
printf("Window closed!\n");
}
};
A platform-specific window.
Definition Window.h:123
virtual WindowListener * listener()=0
Get the WindowListener, if any.
Interface for all Window-related events.
Definition Window.h:27
Coordinate Systems
Monitors and may windows may have a device scale applied by the OS (for example, a Retina display on macOS may have a 2x or 3x DPI scale).
To convert between screen coordinates and pixel coordinates, use the following equation:
pixel_coordinate = round(screen_coordinate *
scale)
virtual double scale() const =0
The DPI scale of the window.
|
virtual void | set_listener (WindowListener *listener)=0 |
| Set a WindowListener to receive callbacks for window-related events.
|
|
virtual WindowListener * | listener ()=0 |
| Get the WindowListener, if any.
|
|
virtual uint32_t | screen_width () const =0 |
| Get the window width (in screen coordinates).
|
|
virtual uint32_t | width () const =0 |
| Get the window width (in pixels).
|
|
virtual uint32_t | screen_height () const =0 |
| Get the window height (in screen coordinates).
|
|
virtual uint32_t | height () const =0 |
| Get the window height (in pixels).
|
|
virtual void | MoveTo (int x, int y)=0 |
| Move the window to a new position (in screen coordinates) relative to the top-left of the monitor area.
|
|
virtual void | MoveToCenter ()=0 |
| Move the window to the center of the monitor.
|
|
virtual int | x () const =0 |
| Get the x-position of the window (in screen coordinates) relative to the top-left of the monitor area.
|
|
virtual int | y () const =0 |
| Get the y-position of the window (in screen coordinates) relative to the top-left of the monitor area.
|
|
virtual bool | is_fullscreen () const =0 |
| Whether or not the window is fullscreen.
|
|
virtual bool | is_accelerated () const =0 |
| Whether or not the window is GPU accelerated.
|
|
virtual uint32_t | render_buffer_id () const =0 |
| The render buffer id of the the window's backing texture.
|
|
virtual double | scale () const =0 |
| The DPI scale of the window.
|
|
virtual void | SetTitle (const char *title)=0 |
| Set the window title.
|
|
virtual void | SetCursor (ultralight::Cursor cursor)=0 |
| Set the cursor.
|
|
virtual void | Show ()=0 |
| Show the window (if it was previously hidden).
|
|
virtual void | Hide ()=0 |
| Hide the window.
|
|
virtual bool | is_visible () const =0 |
| Whether or not the window is currently visible (not hidden).
|
|
virtual void | Close ()=0 |
| Close the window.
|
|
virtual int | ScreenToPixels (int val) const =0 |
| Convert screen coordinates to pixels using the current DPI scale.
|
|
virtual int | PixelsToScreen (int val) const =0 |
| Convert pixels to screen coordinates using the current DPI scale.
|
|
virtual void | DrawSurface (int x, int y, Surface *surface) |
| Draw a surface directly to window, used only by CPU renderer.
|
|
virtual void * | native_handle () const =0 |
| Get the underlying native window handle.
|
|
virtual void | EnableFrameStatistics () |
| Display frame statistics (FPS, frame times, etc.) in the titlebar.
|
|
virtual void | AddRef () const =0 |
|
virtual void | Release () const =0 |
|
virtual int | ref_count () const =0 |
|