|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
A header showing the current choice that opens into a list of options. More...
#include <Dropdown.hpp>
Collaboration diagram for MayaFlux::Portal::Forma::Dropdown:Public Member Functions | |
| Kinesis::AABB2D | bounds () const noexcept |
| Header strip region, satisfying Kinesis::HasBounds. | |
| Dropdown & | initial (size_t index) |
| Dropdown & | max_visible (uint32_t rows) |
| Dropdown & | on_select (std::function< void(size_t)> fn) |
| Dropdown & | options (std::vector< std::string > labels) |
| MAYAFLUX_API Dropdown & | place (Surface &surface, LayoutCursor &cursor, float row_h) |
| Register using the cursor's column extents. | |
| MAYAFLUX_API Dropdown & | place (Surface &surface, LayoutCursor &cursor, float x_min, float x_max, float row_h) |
| Register the header and its option rows and wire their input. | |
Public Attributes | |
| LayoutCursor | cursor_out |
| Cursor positioned below the header. Valid after place(). | |
| Kinesis::AABB2D | header_bounds {} |
| NDC region occupied by the header strip. Valid after place(). | |
| uint32_t | header_id {} |
| Element id of the header strip. Valid after place(). | |
| size_t | m_initial {} |
| Index chosen before any interaction. Default: 0. | |
| std::vector< std::string > | m_labels |
| Option captions, in display order. | |
| uint32_t | m_max_visible { 8 } |
| Rows shown at once before the list scrolls. Default: 8. | |
| std::function< void(size_t)> | m_on_select |
| Called with the index each time a row is chosen. | |
| std::shared_ptr< MappedState< bool > > | open |
| Whether the list is showing. Valid after place(). | |
| std::shared_ptr< MappedState< size_t > > | selected |
| Index of the chosen option. Valid after place(). | |
A header showing the current choice that opens into a list of options.
Configure with the setters, then place() once. After place(), selected, open, header_id, header_bounds and cursor_out are populated. The list overlays whatever lies below the header and does not advance the cursor. The header reads "v" before the current choice while closed and "^" while open. Choosing a row writes its index to selected, updates the header and closes the list. Lists longer than max_visible() scroll with the mouse wheel.
selected is registered with the Bridge, so Forma::bridge().at(selected) reads the index like any other state. A Bridge inbound write changes the index but not the header caption.
Definition at line 31 of file Dropdown.hpp.