Jazz2::UI::Windows::MenuBarItem class

Item of the menu bar, opens its menu.

Base classes

class Element
Element of the interface.

Constructors, destructors, conversion operators

MenuBarItem(MenuBar* bar, StringView label, Function<void(SmallVectorImpl<MenuEntry>&)>&& builder)
Creates a new instance, the builder fills the menu when it's opened.

Public functions

void Open(bool fromKeyboard = false)
Opens the menu, fromKeyboard highlights its first item.
auto GetMnemonicIndex() const -> std::int32_t
Returns the index of the letter of the label that opens the menu with Alt, or -1.
auto Measure(const Context& context, Vector2f available) -> Vector2f override
Returns the size the element wants, in pixels.
auto MeasureDependsOnAvailable() const -> bool override
Returns false if what Measure() returns doesn't depend on the available size, it's measured once a frame then.
void Draw(Painter& painter) override
Draws the element and its children.
void Update(float timeMult) override
Advances animations of the element and its children.
auto AcceptsPointer() const -> bool override
Returns true if the element takes the pointer itself.
auto OnPointerDown(const PointerEvent& event) -> bool override
Called when the pointer is pressed over the element, returns true to keep getting it until released.

Public variables

String Label
Text.
Function<void(SmallVectorImpl<MenuEntry>&)> Builder
Fills the menu when it's opened.

Function documentation

Vector2f Jazz2::UI::Windows::MenuBarItem::Measure(const Context& context, Vector2f available) override

Returns the size the element wants, in pixels.

The available size is what the parent can give, a size without limit is a very large number.