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

◆ pick() [2/2]

template<typename T >
void MayaFlux::Portal::Forma::pick ( std::string  title,
std::vector< T >  items,
std::type_identity_t< std::function< std::string(const T &)> >  label,
std::type_identity_t< std::function< void(std::optional< T >)>  ,
callback   
)

Typed form of pick: list items by label and receive the chosen item.

Same behaviour as pick. The callback receives a copy of the chosen item, or nullopt if the window was closed without a choice.

Template Parameters
TItem type, deduced from items.
Parameters
titleWindow title.
itemsCandidates, in display order.
labelMaps an item to its row caption.
callbackInvoked once with the chosen item or nullopt.

Definition at line 41 of file Picker.hpp.

46{
47 std::vector<std::string> labels;
48 labels.reserve(items.size());
49 for (const auto& item : items) {
50 labels.push_back(label(item));
51 }
52
53 pick(std::move(title), std::move(labels),
54 [items = std::move(items), callback = std::move(callback)](std::optional<size_t> index) {
55 callback(index ? std::optional<T>(items.at(*index)) : std::nullopt);
56 });
57}
uint32_t label
Definition Contours.cpp:16
PickCallback callback
Definition Picker.cpp:22
uint32_t index
Definition VKDevice.cpp:122

References callback, index, label, and pick().

+ Here is the call graph for this function: