Jazz2::UI::Windows::RadialMenu class

Menu of items in a ring around a point, as the weapon wheel of the game.

It's made for a finger held on the screen or a gamepad: an item is picked by pointing in its direction, the farther from the middle the surer, or by a tap on it. The middle of the ring closes it without picking anything. It opens growing out of its middle.

Base classes

class Element
Element of the interface.

Public static functions

static auto Show(Surface& surface, Vector2f center, SmallVectorImpl<MenuEntry>&& entries, Function<void()>&& onClosed = {}) -> RadialMenu*
Shows a menu around a point, onClosed is called when it's closed, picked from or not.

Constructors, destructors, conversion operators

RadialMenu(SmallVectorImpl<MenuEntry>&& entries, Vector2f center)
Creates a menu of entries around a point in pixels of the screen.

Public functions

void PointTo(Vector2f direction)
Picks the item in a direction from the middle, a short one picks none.
void Confirm()
Runs the item picked and closes the menu, or only closes it if none is picked.
auto Measure(const Context& context, Vector2f available) -> Vector2f override
Returns the size the element wants, in pixels.
void Arrange(const Context& context, const Rectf& bounds) override
Places the element and its children.
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 HitTest(Vector2f pos) -> Element* override
Returns the element under a position that takes the pointer, or nullptr.
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 OnPointerMove(const PointerEvent& event) override
Called when the pointer moves while pressed over the element.
void OnPointerUp(const PointerEvent& event, bool inside) override
Called when the pointer is released, inside tells whether it's still over the element.

Function documentation

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