Move from function pointers to std::function

This commit is contained in:
2024-08-19 01:07:52 +02:00
parent 45aa67473f
commit d257dc154f
9 changed files with 15 additions and 23 deletions
+2 -3
View File
@@ -4,13 +4,12 @@
#include "UI_x_boxes.hpp"
#define UI_CHECKBOX_TYPE std::string("UIcheckbox")
typedef void (*UI_checkbox_on_change) (std::string id, std::vector<std::string> selected);
class UI_checkbox : public UI_x_boxes
{
public:
UI_checkbox();
UI_checkbox(std::string id, std::string text, Color fg_color, Color bg_color, std::vector<std::string> options, UI_checkbox_on_change on_change = nullptr);
UI_checkbox(std::string id, std::string text, Color fg_color, Color bg_color, std::vector<std::string> options, std::function<void(std::string, std::vector<std::string>)> on_change = nullptr);
UI_checkbox(const json& j);
void toggle_selected(size_t selected);
@@ -23,5 +22,5 @@ class UI_checkbox : public UI_x_boxes
private:
std::vector<bool> p_selected;
UI_checkbox_on_change p_on_change;
std::function<void(std::string, std::vector<std::string>)> p_on_change;
};