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(scoped_refptr<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 SetTitle(const std::string& title)

Set window title.

Parameters

std::string GetTitle() const

Get window title.

Return

std::string

void SetBackgroundColor(Color color)

Set the background color of the window.

Parameters

void SetToolbar(scoped_refptr<Toolbar> toolbar) macOS

Set the window toolbar.

Parameters

Toolbar* GetToolbar() const macOS

Return the window toolbar.

Return

Toolbar*

void SetTitleVisible(bool visible) macOS

Set whether the title is visible, when title was hidden the toolber would be moved into the area previously occupied by the title.

Parameters

bool IsTitleVisible() const; macOS

Return whether title is visible.

Return

bool

void SetFullSizeContentView(bool full) macOS

Set the NSFullSizeContentViewWindowMask style on the window.

Parameters

bool IsFullSizeContentView() const macOS

Return whether the window has NSFullSizeContentViewWindowMask style.

Return

bool

void SetSkipTaskbar(bool skip) Windows Linux

Set whether to hide the window from taskbar.

Parameters

void SetIcon(scoped_refptr<Image> icon) Windows Linux

Set the window icon.

Parameters

void SetMenuBar(scoped_refptr<MenuBar> menubar) Windows Linux

Set the window menu bar.

Parameters

MenuBar* GetMenuBar() const Windows Linux

Return the window menu bar.

Return

MenuBar*

Window* GetParentWindow() const

Return the parent window.

Return

Window*

void AddChildWindow(scoped_refptr<Window> child)

Make child a child window of this window.

This method will do nothing if child already has a parent window.

Parameters

void RemoveChildWindow(Window* child)

Remove this window as child's parent window.

Parameters

std::vector<Window*> GetChildWindows() const

Return all the child windows of this window.

Return

std::vector<Window*>

NativeWindow GetNative() const

Return the native instance wrapped the window.

Return

NativeWindow

Events

void on_close(Window* self)

Emitted when the window is closed.

Parameters

Preventable

No.

void on_focus(Window* self)

Emitted when the window is focused.

Parameters

Preventable

No.

void on_blur(Window* self)

Emitted when the window lost focus.

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