Window

Native window.

Header#include "nativeui/window.h"
Namespacenamespace nu
Typeclass (RefCounted)

Constructors

Window(const Window::Options& options)

Create a new window with options.

Parameters

Methods

void Close()

Request to close the window.

bool HasFrame() const

Return whether window has a native frame.

Return

bool

bool IsTransparent() const

Return whether window is transparent.

Return

bool

void SetHasShadow(bool has)

Set whether window should have shadow.

Depending on platform, this may not work.

Parameters

bool HasShadow() const

Return whether window has shadow.

Return

bool

void SetContentView(View* view)

Set the content view of the window.

The content view will always be resized to fill window's client area.

Parameters

View* GetContentView() const

Return the content view of the window.

Return

View*

void Center()

Move the window to the center of the screen.

void SetContentSize(const SizeF& size)

Resize window to make the content view fit size.

Parameters

SizeF GetContentSize() const

Return the size of content view.

Return

SizeF

void SetBounds(const RectF& bounds)

Change the position and size of the window.

Parameters

RectF GetBounds() const

Return the position and size of the window.

Return

RectF

void SetSizeConstraints(const SizeF& minsize, const SizeF& maxsize)

Set the minimum and maximum sizes of the window.

Passing an empty size means no constraint.

Parameters

std::tuple<SizeF, SizeF> GetSizeConstraints() const

Return minimum and maximum sizes of the window.

Return

std::tuple<SizeF, SizeF>

void SetContentSizeConstraints(const SizeF& minsize, const SizeF& maxsize)

Set the minimum and maximum content sizes of the window.

Passing an empty size means no constraint.

Parameters

std::tuple<SizeF, SizeF> GetContentSizeConstraints() const

Return minimum and maximum content sizes of the window.

Return

std::tuple<SizeF, SizeF>

void Activate()

Show the window and activate it.

void Deactivate()

Move the focus away from the window.

bool IsActive() const

Return whether window has focus.

Return

bool

void SetVisible(bool visible)

Show/hide the window.

Parameters

bool IsVisible() const

Return whether window is visible.

Return

bool

void SetAlwaysOnTop(bool top)

Make the window always show above other normal windows.

Parameters

bool IsAlwaysOnTop() const

Return whether window is always above other normal windows.

Return

bool

void SetFullscreen(bool fullscreen)

Enter/leave fullscreen state.

Parameters

bool IsFullscreen() const

Return whether window is in fullscreen.

Return

bool

void Maximize()

Maximize the window.

void Unmaximize()

Unmaximize the window.

bool IsMaximized() const

Return whether window is maximized.

Return

bool

void Minimize()

Minimize the window.

void Restore()

Restore the minimized window.

bool IsMinimized() const

Return whether window is minimized.

Return

bool

void SetResizable(bool resizable)

Set whether window can be resized.

Parameters

bool IsResizable() const

Return whether window can be resized.

Return

bool

void SetMaximizable(bool maximizable)

Set whether window can be maximize.

Parameters

bool IsMaximizable() const

Return whether window can be maximize.

Return

bool

void SetMinimizable(bool minimizable)

Set whether window can be minimized.

Parameters

bool IsMinimizable() const

Return whether window can be minimized.

Return

bool

void SetMovable(bool movable)

Set whether window can be moved.

Parameters

bool IsMovable() const

Return whether window can be moved.

Return

bool

void SetBackgroundColor(Color color)

Set the background color of the window.

Parameters

void SetMenuBar(MenuBar* menubar) Windows Linux

Set the window menu bar.

Parameters

MenuBar* GetMenuBar() const Windows Linux

Return the window menu bar.

Return

MenuBar*

NativeWindow GetNative() const

Return the native instance wrapped the window.

Return

NativeWindow

Events

void on_close(Window* self)

Emitted when the window is going to be closed.

Parameters

Preventable

No.

Delegates

bool should_close(Window* self)

Called when user requests to close the window, should return whether the window can be closed.

Parameters

Return

bool