Starting work on moving GUI to event system (doesnt compile)
This commit is contained in:
parent
f1a855edc3
commit
ef7dfcef05
69 changed files with 4296 additions and 3709 deletions
19
src/GUIStuff/ElementHelpers/RadioButtonHelpers.hpp
Normal file
19
src/GUIStuff/ElementHelpers/RadioButtonHelpers.hpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include "../GUIManager.hpp"
|
||||
|
||||
namespace GUIStuff { namespace ElementHelpers {
|
||||
|
||||
void radio_button_field(GUIManager& gui, const char* id, std::string_view name, const std::function<bool()>& isTicked, const std::function<void()>& onClick);
|
||||
|
||||
template <typename T> void radio_button_selector(GUIManager& gui, const char* id, T* data, const std::vector<std::pair<std::string_view, T>>& options, const std::function<void()>& onClick = nullptr) {
|
||||
gui.push_id(id);
|
||||
for(size_t i = 0; i < options.size(); i++) {
|
||||
gui.push_id(i);
|
||||
auto& option = options[i];
|
||||
radio_button_field(gui, "Option", option.first, [data, optionVal = option.second]{ return *data == optionVal; }, [data, optionVal = option.second, onClick]{ *data = optionVal; if(onClick) onClick(); });
|
||||
gui.pop_id();
|
||||
}
|
||||
gui.pop_id();
|
||||
}
|
||||
|
||||
}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue