53enum class PreferenceType
67 class PreferenceBuilder;
71 Color(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)
72 : m_r{r}, m_g{g}, m_b{b}, m_a{a}
77 std::uint8_t m_r, m_g, m_b, m_a;
83 using base_type = std::int64_t;
92 void AddEnumMember(
const std::string& name, base_type value);
93 const std::string& GetName(base_type value)
const;
94 base_type GetValue(
const std::string& name)
const;
95 const std::vector<std::string>& GetNames()
const;
96 bool HasNameFor(base_type value)
const;
97 bool HasValueFor(
const std::string& name)
const;
107 void AddEnumMember(
const std::string& name, E value)
109 const auto val =
static_cast<base_type
>(value);
110 this->AddEnumMember(name, val);
114 std::map<std::string, base_type> m_forwardMap;
115 std::map<base_type, std::string> m_backwardMap;
116 std::vector<std::string> m_names;
124 using PreferenceValue =
125 typename std::aligned_union<
128 sizeof(std::int64_t),
133 sizeof(FontDescription)
144 std::string m_identifier;
146 std::string m_description;
147 PreferenceType m_type;
148 PreferenceValue m_value;
149 bool m_isVisible{
true};
150 Unit m_unit{Unit::UNIT_COUNTS};
151 bool m_hasValue{
false};
155 Preference(PreferenceType type, std::string identifier)
156 : m_identifier{std::move(identifier)}, m_type{type}
182 const std::string& GetIdentifier()
const;
183 const std::string& GetLabel()
const;
184 const std::string& GetDescription()
const;
185 void SetFont(
const FontDescription& font);
186 FontDescription GetFont()
const;
187 std::int64_t GetEnumRaw()
const;
188 void SetEnumRaw(std::int64_t value);
189 PreferenceType GetType()
const;
190 bool GetBool()
const;
191 double GetReal()
const;
192 std::int64_t GetInt()
const;
193 const std::string& GetString()
const;
194 std::string ToString()
const;
195 bool GetIsVisible()
const;
196 ImU32 GetColor()
const;
198 void SetBool(
bool value);
199 void SetReal(
double value);
200 void SetInt(std::int64_t value);
201 void SetString(std::string value);
202 void SetColor(
const ImU32& value);
204 void SetLabel(std::string label);
205 void SetDescription(std::string description);
210 template<
typename E >
213 return static_cast<E
>(this->GetEnumRaw());
216 template<
typename E >
217 void SetEnum(E value)
219 this->SetEnumRaw(
static_cast<std::int64_t
>(value));
231 template<
typename E >
239 const T& GetValueRaw()
const
241 return *
reinterpret_cast<const T*
>(&m_value);
247 return *
reinterpret_cast<T*
>(&m_value);
253 void Construct(T value)
255 new (&m_value) T(std::move(value));
279 template<
typename E >
282 this->m_pref.m_mapping.AddEnumMember<E>(name, value);
283 return std::move(*
this);
288template<
typename E >
291 return EnumRaw(std::move(identifier),
static_cast<std::int64_t
>(defaultValue));
Declaration of FontManager.
Definition: Preference.h:82
Definition: Preference.h:120
A unit of measurement, plus conversion to pretty-printed output.
Definition: Unit.h:57
Definition: Preference.h:265
Definition: Preference.h:70