Toolbar

Window toolbar.

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

This view is only implemented for macOS by wrapping NSToolbar. The API is still experimental and will be changed in future. Currently certain items are not aligned correctly in toolbar.

The toolbar items are not added manually like the normal views, instead you have to implement the get_item delegate which creates items on request, and then call SetDefaultItemIdentifiers to specify the default items to show.

Constructors

Toolbar(const std::string& identifier)

Create a new Toolbar view with identifier.

Within the application all toolbars with the same identifier are synchronized to maintain the same state, including for example, the display mode and item order. The identifier is used as the autosave name for toolbars that save their configuration.

Parameters

Class properties

const char* kFlexibleSpaceItemIdentifier

The identifier of the Flexible Space toolbar item.

const char* kSpaceItemIdentifier

The identifier of the Space toolbar item.

Methods

void SetDefaultItemIdentifiers(const std::vector<std::string>& identifiers)

Set the identifiers of default items that would show in toolbar.

Parameters

void SetAllowedItemIdentifiers(const std::vector<std::string>& identifiers)

Set the identifiers of the items that are allowed to show in toolbar.

Parameters

void SetAllowCustomization(bool allow)

Set whether users are allowed to customize the toolbar.

Parameters

void SetDisplayMode(Toolbar::DisplayMode mode)

Set the display mode of the toolbar items.

Parameters

void SetVisible(bool visible)

Set whether toolbar is visible.

Parameters

bool IsVisible() const

Return whether toolbar is visible.

Return

bool

std::string GetIdentifier() const

Return the identifier of the toolbar.

Return

std::string

NativeToolbar GetNative() const

Return the underlying native view of the toolbar.

Return

NativeToolbar

Delegates

Toolbar::Item get_item(Toolbar* toolbar, const std::string& identifier)

Called lazily when the toolbar is going to get the item with identifier.

You should not cache the item to be returned.

Parameters

Return

Toolbar::Item