Skip to content

Commit

Permalink
Add IntCb option
Browse files Browse the repository at this point in the history
  • Loading branch information
ikt32 committed Dec 6, 2020
1 parent 4085116 commit 4982b14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ bool Menu::IntOption(const std::string& option, int &var, int min, int max, int
return processOptionItemControls(var, min, max, step);
}

bool Menu::IntOptionCb(const std::string& option, int& var, int min, int max, int step,
const std::function<bool(int&)>& extFunc, const std::vector<std::string>& details) {
Option(option, details);
std::string printVar = std::to_string(var);

bool highlighted = currentoption == optioncount;

drawOptionValue(printVar, highlighted, max - min);
return processOptionItemControls(var, min, max, step, extFunc);
}

bool Menu::FloatOption(const std::string& option, float &var, float min, float max, float step,
const std::vector<std::string>& details) {
Option(option, details);
Expand Down
4 changes: 3 additions & 1 deletion menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class Menu {
*/
bool IntOption(const std::string& option, int &var, int min, int max, int step = 1, const std::vector<std::string>&
details = {});
bool IntOptionCb(const std::string& option, int& var, int min, int max, int step,
const std::function<bool(int&)>& extFunc, const std::vector<std::string>& details = {});

/*
* Option that changes a float value with optional custom-sized steps.
Expand Down Expand Up @@ -453,7 +455,7 @@ class Menu {
if (var > max) var = min;

if (optionpress) {
float var_ = var;
T var_ = var;
if (f(var_)) {
var = var_;
}
Expand Down

0 comments on commit 4982b14

Please sign in to comment.