Jazz2::UI::Windows::Dropdown class

Shows a value and opens a menu to choose another one.

Base classes

class Element
Element of the interface.

Constructors, destructors, conversion operators

Dropdown(Function<String()>&& textFunc, Function<void(SmallVectorImpl<MenuEntry>&)>&& builder)
Creates a new instance, the builder fills the menu when it's opened.

Public functions

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 Update(float timeMult) override
Advances animations of the element and its children.
void Draw(Painter& painter) override
Draws 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.
void OnPointerUp(const PointerEvent& event, bool inside) override
Called when the pointer is released, inside tells whether it's still over the element.
auto YieldsToScroll() const -> bool override
Returns true if a press on the element may become scrolling of the list it's in.
auto IsTabStop() const -> bool override
Returns true if Tab can give the element the keyboard focus.
auto OnKeyPressed(const KeyboardEvent& event) -> bool override
Called when a key is pressed while the element has the focus, returns true if it was used.
auto OnWheel(const PointerEvent& event) -> bool override
The wheel over it chooses the choice before or after the one shown checked, without going around.
void Open(bool fromKeyboard)
Opens the list, fromKeyboard highlights an item in it.
auto StepChoice(std::int32_t direction) -> bool
Chooses the choice before or after the one shown checked, as picking it in the list does.

Public variables

Function<String()> TextFunc
Returns the text shown.
Function<void(SmallVectorImpl<MenuEntry>&)> Builder
Fills the menu when it's opened, it may also do something else and leave the menu empty.

Function documentation

Vector2f Jazz2::UI::Windows::Dropdown::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.

bool Jazz2::UI::Windows::Dropdown::YieldsToScroll() const override

Returns true if a press on the element may become scrolling of the list it's in.

A finger dragged over a button scrolls the list then, the button isn't clicked. Elements that are dragged themselves keep the press.

bool Jazz2::UI::Windows::Dropdown::IsTabStop() const override

Returns true if Tab can give the element the keyboard focus.

Buttons and other controls are reached by Tab too, though a click doesn't focus them. Every element that can take the focus can, by default.

bool Jazz2::UI::Windows::Dropdown::StepChoice(std::int32_t direction)

Chooses the choice before or after the one shown checked, as picking it in the list does.

Disabled choices and separators are skipped, it doesn't go around the ends. Returns false if no choice is shown checked, so there's nothing to go on from.