neteja clang-tidy: enums uint8_t, includes, naming i altres
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm> // Para max, clamp
|
||||
#include <cmath> // Para std::lround
|
||||
#include <cstddef> // Para size_t
|
||||
#include <cstdint> // Para std::uint8_t
|
||||
#include <functional> // Para function
|
||||
#include <numeric> // Para accumulate
|
||||
#include <string> // Para allocator, string, basic_string, to_string, operator==, char_traits
|
||||
@@ -16,7 +18,7 @@
|
||||
class MenuOption {
|
||||
public:
|
||||
// --- Enums ---
|
||||
enum class Behavior {
|
||||
enum class Behavior : std::uint8_t {
|
||||
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)
|
||||
@@ -119,11 +121,11 @@ class VolumeOption : public MenuOption {
|
||||
|
||||
[[nodiscard]] auto getBehavior() const -> Behavior override { return Behavior::ADJUST; }
|
||||
[[nodiscard]] auto getValueAsString() const -> std::string override {
|
||||
int pct = static_cast<int>(*linked_variable_ * 100.0F + 0.5F);
|
||||
int pct = static_cast<int>(std::lround(*linked_variable_ * 100.0F));
|
||||
return std::to_string(pct);
|
||||
}
|
||||
void adjustValue(bool adjust_up) override {
|
||||
int current = static_cast<int>(*linked_variable_ * 100.0F + 0.5F);
|
||||
int current = static_cast<int>(std::lround(*linked_variable_ * 100.0F));
|
||||
int new_value = std::clamp(current + (adjust_up ? step_value_ : -step_value_), 0, 100);
|
||||
*linked_variable_ = static_cast<float>(new_value) / 100.0F;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user