Final Platform Layer  0.9.6-beta
Window style & layout

Reading/Setting the style

Decoration (Border, Titlebar)

By default, a window is decorated. This means that it has a border, a title bar, and can be moved by the user.
If you enable window decorations, your window will have a border and a title bar always.

Use fplIsWindowDecorated() to determine if the window has decoration enabled or not.
Use fplSetWindowDecorated() to enable/disable the window decoration.

Example:

// Enable window decoration
// Disable window decoration
// Toggle window decoration
Note
You can overwrite the default decoration behavior by changing the value in fplWindowSettings::isDecorated from the fplSettings::window field at startup.

Floating (Always on top)

By default, a window is not in floating mode. This means when another window gets focus, your window loses its focus.
If you set your window to floating instead, your window will always be on top of others.

Use fplIsWindowFloating() to determine if the window is floating or not.
Use fplSetWindowFloating() to enable/disable the window floating.

Example:

// Enable window floating
// Disable window floating
// Toggle window floating
Note
You can overwrite the default floating behavior by changing the value in fplWindowSettings::isFloating from the fplSettings::window field at startup.

Resizeable

By default, a window is resizeable. This means you can resize your window however you like.

Use fplIsWindowResizable() to determine if the window is resizable or not.
Use fplSetWindowResizeable() to enable/disable the window resizing.

Example:

// Enable resizing of the window
// Disable resizing of the window
// Toggle window resizing mode
Note
You can overwrite the default resizable behavior by changing the value in fplWindowSettings::isResizable from the fplSettings::window field at startup.

Getting/Changing the size/position

Window position

By default, a window uses either the default position from the platform or a fixed location of 0x0 screen units.

Use fplSetWindowPosition() to change the position of the window Use fplGetWindowPosition() to retrieve the current absolute window position from the top-left corner

Example:

// Retrieve absolute window position
if (fplGetWindowPosition(&curPos)) {
// Do something with the window position
}
// Change window absolute position to 0x0

Window size

By default, a window is created using either the default size of the platform or a fixed size of 400x400 screen units.

Use fplSetWindowSize() to change the size of the area of the window.
Use fplGetWindowSize() to get the size of the area of the window.

Example:

// Retrieve window inner/client size
fplWindowSize curSize;
if (fplGetWindowSize(&curSize)) {
// Do something with the client size
}
// Change window size to fit 800x600 screen units inside the client area
fplSetWindowSize(800, 600);
Note
You can overwrite the default window size by changing the value in fplWindowSettings::windowSize from the fplSettings::window field at startup.
Changing the window size changes the total size of the window - when decorations are enabled.

Fullscreen size

By default, the window is created in non-fullscreen mode, using fplWindowSettings::windowSize from the fplSettings::window or the default window size. See Window size for more details.

Use fplSetWindowFullscreenSize() to enable/disable fullscreen for the window with a given size and a color depth with support of switching the screen-resolution if needed.
Use fplSetWindowFullscreenRect() to enable/disable fullscreen for the window with a given size and a position without changing the screen-resolution.
Use fplIsWindowFullscreen() to determine if the window is in fullscreen mode or not.

Enable fullscreen example:

// Enable fullscreen on the nearest desktop
// or
// Enable fullscreen on the nearest desktop
// Enable 1080p fullscreen on the nearest desktop
fplSetWindowFullscreenSize(true, 1920, 1080, 0);
// Switch to 1080p screen resolution with a refresh rate of 60 Hz on the nearest desktop
fplSetWindowFullscreenSize(true, 1920, 1080, 60);
// Enable a 4k stretched resolution on two 1080p monitor left-right configuration
fplSetWindowFullscreenRect(true, 0, 0, 3840, 1080);

Disable fullscreen example:

// Disable fullscreen size
// or
// Disable fullscreen rect
fplSetWindowFullscreenRect(false, 0, 0, 0, 0);
// or
// Disable fullscreen

Query fullscreen state:

// Do something on fullscreen mode
}
// Toggle fullscreen
fplSetWindowFullscreenSize(!fplIsWindowFullScreen(), 0, 0, 0);
Note
Set fplWindowSettings::isFullscreen to true to enable fullscreen at startup.
You can overwrite the fullscreen window size by changing the value in fplWindowSettings::fullscreenSize from the fplSettings::window field at startup.
You can overwrite the fullscreen refresh rate by changing the value in fplWindowSettings::fullscreenRefreshRate from the fplSettings::window field at startup.
If width or height in the fplWindowSettings.fullscreenSize field is zero, the current desktop rectangle is used from the nearest display.

Changing the window cursor

By default, the window has cursors enabled. Use fplSetWindowCursorEnabled to show/hide the cursor.

Example:

// Enable the cursor
// Disable the cursor

Get/Set the window title

By default, the window has an unnamed title. Use fplSetWindowTitle to set a window title on runtime.

Example:

// Set window title
fplSetWindowTitle("My awesome application");
// Get the window title
char titleBuffer[FPL_MAX_NAME_LENGTH];
fplGetWindowTitle(titleBuffer, fplArrayCount(titleBuffer));
Note
You can overwrite the window title by changing the value in fplWindowSettings::title from the fplSettings::window field at startup.

Get/Set the window state

By default, the window has a normal default state.

Example:

// Iconify the window
// Maximize the window
// Reset to the normal when not normal
if (curState != fplWindowState_Normal) {
}
Note
When the window is in fullscreen mode, fplWindowState_Fullscreen is returned from fplGetWindowState() always.
Warning
The window state fplWindowState_Fullscreen can never be set.

Notes

Note
Use fplSetDefaultWindowSettings() to initialize a fplWindowSettings to a default state.
fplSetWindowPosition
fpl_platform_api void fplSetWindowPosition(const int32_t left, const int32_t top)
Changes the window absolute position to the given coordinates.
fplGetWindowState
fpl_platform_api fplWindowState fplGetWindowState()
Gets the current window state.
fplWindowPosition
A structure containing the position of a window.
Definition: final_platform_layer.h:3828
fplSetWindowState
fpl_platform_api bool fplSetWindowState(const fplWindowState newState)
Changes the current window state.
fplSetWindowDecorated
fpl_platform_api void fplSetWindowDecorated(const bool value)
Enables or disables the window decoration (Titlebar, Border, etc.).
fplWindowState_Iconify
Iconify/Minimize window state.
Definition: final_platform_layer.h:6169
fplSetWindowCursorEnabled
fpl_platform_api void fplSetWindowCursorEnabled(const bool value)
Enables or disables the window cursor.
fplWindowState_Normal
Normal window state.
Definition: final_platform_layer.h:6167
fplArrayCount
#define fplArrayCount(arr)
Returns the element count from a static array. This should ideally produce a compile error when passi...
Definition: final_platform_layer.h:2254
fplSetWindowFullscreenRect
fpl_platform_api bool fplSetWindowFullscreenRect(const bool value, const int32_t x, const int32_t y, const int32_t width, const int32_t height)
Enables or disables fullscreen mode based on the given rectangle.
fplEnableWindowFullscreen
fpl_platform_api bool fplEnableWindowFullscreen()
Enables fullscreen mode on the nearest display.
fplSetWindowTitle
fpl_platform_api void fplSetWindowTitle(const char *title)
Changes the window title to the given string.
fplIsWindowFloating
fpl_platform_api bool fplIsWindowFloating()
Gets the window floating state as boolean.
fplIsWindowResizable
fpl_platform_api bool fplIsWindowResizable()
Gets the window resizable state as boolean.
fplSetWindowResizeable
fpl_platform_api void fplSetWindowResizeable(const bool value)
Enables or disables the ability to resize the window.
fplSetWindowSize
fpl_platform_api void fplSetWindowSize(const uint32_t width, const uint32_t height)
Resizes the window to fit the inner size based on the given size.
fplSetWindowFloating
fpl_platform_api void fplSetWindowFloating(const bool value)
Enables or disables the window floating (Top-most)
fplDisableWindowFullscreen
fpl_platform_api bool fplDisableWindowFullscreen()
Switches the window back to window mode.
fplWindowSize
A structure containing the size of a window.
Definition: final_platform_layer.h:3820
fplIsWindowFullscreen
fpl_platform_api bool fplIsWindowFullscreen()
Gets the window fullscreen state as boolean.
fplSetWindowFullscreenSize
fpl_platform_api bool fplSetWindowFullscreenSize(const bool value, const uint32_t fullscreenWidth, const uint32_t fullscreenHeight, const uint32_t refreshRate)
Enables or disables fullscreen mode based on the given size and the current display.
fplGetWindowPosition
fpl_platform_api bool fplGetWindowPosition(fplWindowPosition *outPos)
Retrieves the absolute window position.
fplWindowState_Maximize
Maximize window state.
Definition: final_platform_layer.h:6171
fplGetWindowTitle
fpl_common_api char * fplGetWindowTitle(char *outTitle, const size_t maxOutTitleLength)
Retrieves the window title and writes it into the output string.
FPL_MAX_NAME_LENGTH
#define FPL_MAX_NAME_LENGTH
Maximum length of a name (in characters)
Definition: final_platform_layer.h:2541
fplIsWindowDecorated
fpl_platform_api bool fplIsWindowDecorated()
Gets the window decorated state as boolean.
fplGetWindowSize
fpl_platform_api bool fplGetWindowSize(fplWindowSize *outSize)
Retrieves the inner window size.
fplWindowState
fplWindowState
An enumeration containg the states of a window.
Definition: final_platform_layer.h:6163