Hyprland/src/helpers/CMType.cpp
Filip Mikina 34812c33db
hyprctl: include color management presets and sdr information (#12019)
* move string parsing for eCMType to its own namespace, similar to how
`src/protocols/types/ContentType.cpp` is done
* expose cm type and sdr settings in `hyprctl monitors`, format floats
to .2f
2025-10-24 20:18:39 +01:00

23 lines
967 B
C++

#include "CMType.hpp"
#include <optional>
#include <string>
#include <unordered_map>
static std::unordered_map<std::string, NCMType::eCMType> const table = {{"auto", NCMType::CM_AUTO}, {"srgb", NCMType::CM_SRGB}, {"wide", NCMType::CM_WIDE},
{"edid", NCMType::CM_EDID}, {"hdr", NCMType::CM_HDR}, {"hdredid", NCMType::CM_HDR_EDID},
{"dcip3", NCMType::CM_DCIP3}, {"dp3", NCMType::CM_DP3}, {"adobe", NCMType::CM_ADOBE}};
std::optional<NCMType::eCMType> NCMType::fromString(const std::string cmType) {
auto it = table.find(cmType);
if (it == table.end())
return std::nullopt;
return it->second;
}
std::string NCMType::toString(eCMType cmType) {
for (const auto& [key, value] : table) {
if (value == cmType)
return key;
}
return "";
}