72 Color(std::uint8_t
r, std::uint8_t
g, std::uint8_t
b, std::uint8_t a)
73 : m_r{
r}, m_g{
g}, m_b{
b}, m_a{a}
78 std::uint8_t m_r, m_g, m_b, m_a;
80 ImU32 GetColor()
const
83 (m_b << IM_COL32_B_SHIFT) |
84 (m_g << IM_COL32_G_SHIFT) |
85 (m_r << IM_COL32_R_SHIFT) |
86 (m_a << IM_COL32_A_SHIFT);
110 using base_type = std::int64_t;
119 void AddEnumMember(
const std::string& name, base_type value);
120 const std::string& GetName(base_type value)
const;
121 base_type GetValue(
const std::string& name)
const;
122 const std::vector<std::string>& GetNames()
const;
123 bool HasNameFor(base_type value)
const;
124 bool HasValueFor(
const std::string& name)
const;
134 void AddEnumMember(
const std::string& name,
E value)
136 const auto val =
static_cast<base_type
>(value);
137 this->AddEnumMember(name, val);
141 std::map<std::string, base_type> m_forwardMap;
142 std::map<base_type, std::string> m_backwardMap;
143 std::vector<std::string> m_names;
148 friend class impl::PreferenceBuilder;
151 using PreferenceValue =
152 typename std::aligned_union<
155 sizeof(std::int64_t),
160 sizeof(FontDescription)
172 std::string m_identifier;
174 std::string m_description;
175 PreferenceType m_type;
176 PreferenceValue m_value;
177 PreferenceValue m_defaultValue;
178 bool m_isVisible{
true};
179 Unit m_unit{Unit::UNIT_COUNTS};
180 bool m_hasValue{
false};
185 : m_identifier{std::move(
identifier)}, m_type{type}
211 const std::string& GetIdentifier()
const;
212 const std::string& GetLabel()
const;
213 const std::string& GetDescription()
const;
214 void SetFont(
const FontDescription&
font);
215 FontDescription GetFont()
const;
216 std::int64_t GetEnumRaw()
const;
217 void SetEnumRaw(std::int64_t value);
218 PreferenceType GetType()
const;
219 bool GetBool()
const;
220 double GetReal()
const;
221 std::int64_t GetInt()
const;
222 const std::string& GetString()
const;
223 std::string ToString()
const;
224 bool GetIsVisible()
const;
226 void SetBool(
bool value);
227 void SetReal(
double value);
228 void SetInt(std::int64_t value);
229 void SetString(
const std::string& value);
231 void SetThemedColor(
size_t i,
const impl::Color& value);
232 void SetColor(
const ImU32& value);
234 void SetLabel(std::string label);
235 void SetDescription(std::string description);
237 void ResetToDefault();
241 template<
typename E >
244 return static_cast<E>(this->GetEnumRaw());
247 template<
typename E >
248 void SetEnum(
E value)
250 this->SetEnumRaw(
static_cast<std::int64_t
>(value));
258 static impl::PreferenceBuilder ThemedColor(
265 template<
typename E >
273 const T& GetValueRaw()
const
275 return *
reinterpret_cast<const T*
>(&m_value);
281 return *
reinterpret_cast<T*
>(&m_value);
287 void Construct(
T value)
289 new (&m_value)
T(std::move(value));