claude: treballant en el nou define_buttons
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "menu_option.h"
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class ActionListOption : public MenuOption {
|
||||
public:
|
||||
using ValueGetter = std::function<std::string()>;
|
||||
using ValueSetter = std::function<void(const std::string&)>;
|
||||
using ActionExecutor = std::function<void()>;
|
||||
|
||||
ActionListOption(
|
||||
const std::string& caption,
|
||||
ServiceMenu::SettingsGroup group,
|
||||
std::vector<std::string> options,
|
||||
ValueGetter getter,
|
||||
ValueSetter setter,
|
||||
ActionExecutor action_executor,
|
||||
bool hidden = false
|
||||
);
|
||||
|
||||
// Implementaciones de MenuOption
|
||||
[[nodiscard]] auto getBehavior() const -> Behavior override;
|
||||
[[nodiscard]] auto getValueAsString() const -> std::string override;
|
||||
[[nodiscard]] auto getMaxValueWidth(Text* text) const -> int override;
|
||||
void adjustValue(bool up) override;
|
||||
void executeAction() override;
|
||||
void sync(); //override;
|
||||
|
||||
private:
|
||||
std::vector<std::string> options_;
|
||||
ValueGetter value_getter_;
|
||||
ValueSetter value_setter_;
|
||||
ActionExecutor action_executor_;
|
||||
size_t current_index_;
|
||||
|
||||
void updateCurrentIndex();
|
||||
[[nodiscard]] auto findCurrentIndex() const -> size_t;
|
||||
};
|
||||
Reference in New Issue
Block a user