MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ pick_one()

template<typename T>
std::optional< T > MayaFlux::detail::pick_one ( std::string title,
std::vector< T > items,
std::function< std::string(const T &)> label )

Open a picker and wait for the choice.

Blocks until the user chooses or closes the window, so it must not be called from the event thread. Portal::Forma must be initialized and the engine running.

Returns
The chosen item, or nothing when the window was closed or items is empty.

Definition at line 18 of file API/Prompt.hpp.

20{
21 auto promise = std::make_shared<std::promise<std::optional<T>>>();
22 auto future = promise->get_future();
23
24 Portal::Forma::pick<T>(std::move(title), std::move(items), std::move(label),
25 [promise](std::optional<T> chosen) { promise->set_value(std::move(chosen)); });
26
27 return Parallel::await_future(std::move(future));
28}
T await_future(std::future< T > future)
Definition Dispatch.hpp:153
void pick(std::string title, std::vector< std::string > labels, PickCallback callback)
Open a window of clickable rows, one per label, and report the choice.
Definition Picker.cpp:49

References MayaFlux::Parallel::await_future(), and MayaFlux::Portal::Forma::pick().

Referenced by MayaFlux::choose_serial_port().

Here is the call graph for this function:
Here is the caller graph for this function: