Text: revisada la classe

window_message: correcions
This commit is contained in:
2025-08-07 12:40:24 +02:00
parent 49145905e3
commit 100b7265d5
24 changed files with 467 additions and 444 deletions

View File

@@ -17,9 +17,9 @@
class MenuOption {
public:
enum class Behavior {
ADJUST, // Solo puede ajustar valor (como IntOption, BoolOption, ListOption)
SELECT, // Solo puede ejecutar acción (como ActionOption, FolderOption)
BOTH // Puede tanto ajustar como ejecutar acción (como ActionListOption)
ADJUST, // Solo puede ajustar valor (como IntOption, BoolOption, ListOption)
SELECT, // Solo puede ejecutar acción (como ActionOption, FolderOption)
BOTH // Puede tanto ajustar como ejecutar acción (como ActionListOption)
};
MenuOption(std::string caption, ServiceMenu::SettingsGroup group, bool hidden = false)
@@ -63,8 +63,8 @@ class BoolOption : public MenuOption {
}
auto getMaxValueWidth(Text *text_renderer) const -> int override {
return std::max(
text_renderer->lenght(Lang::getText("[SERVICE_MENU] ON"), -2),
text_renderer->lenght(Lang::getText("[SERVICE_MENU] OFF"), -2));
text_renderer->length(Lang::getText("[SERVICE_MENU] ON"), -2),
text_renderer->length(Lang::getText("[SERVICE_MENU] OFF"), -2));
}
private:
@@ -87,7 +87,7 @@ class IntOption : public MenuOption {
// Iterar por todos los valores posibles en el rango
for (int value = min_value_; value <= max_value_; value += step_value_) {
int width = text_renderer->lenght(std::to_string(value), -2);
int width = text_renderer->length(std::to_string(value), -2);
max_width = std::max(max_width, width);
}
@@ -135,7 +135,7 @@ class ListOption : public MenuOption {
auto getMaxValueWidth(Text *text_renderer) const -> int override {
int max_w = 0;
for (const auto &val : value_list_) {
max_w = std::max(max_w, text_renderer->lenght(val, -2));
max_w = std::max(max_w, text_renderer->length(val, -2));
}
return max_w;
}
@@ -179,24 +179,20 @@ class ActionOption : public MenuOption {
class ActionListOption : public MenuOption {
public:
using ValueGetter = std::function<std::string()>;
using ValueSetter = std::function<void(const 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)
: MenuOption(caption, group, hidden), options_(std::move(options)),
value_getter_(std::move(getter)), value_setter_(std::move(setter)),
action_executor_(std::move(action_executor)), current_index_(0) {
ActionListOption(const std::string &caption, ServiceMenu::SettingsGroup group, std::vector<std::string> options, ValueGetter getter, ValueSetter setter, ActionExecutor action_executor, bool hidden = false)
: MenuOption(caption, group, hidden), options_(std::move(options)), value_getter_(std::move(getter)), value_setter_(std::move(setter)), action_executor_(std::move(action_executor)), current_index_(0) {
updateCurrentIndex();
}
[[nodiscard]] auto getBehavior() const -> Behavior override { return Behavior::BOTH; }
[[nodiscard]] auto getValueAsString() const -> std::string override;
[[nodiscard]] auto getMaxValueWidth(Text* text) const -> int override;
[[nodiscard]] auto getMaxValueWidth(Text *text) const -> int override;
void adjustValue(bool up) override;
void executeAction() override;
void sync(); // Sincroniza con el valor actual
void sync(); // Sincroniza con el valor actual
private:
std::vector<std::string> options_;