5#ifndef MALENA_COMPONENT_H
6#define MALENA_COMPONENT_H
33 template<
typename... Ts>
36 static constexpr int value = (has_Image<Ts>::value + ... + 0);
42 template<
typename... Ts>
45 static constexpr int value = (has_Font<Ts>::value + ... + 0);
51 template<
typename... Ts>
54 static constexpr int value = (has_Sound<Ts>::value + ... + 0);
60 template<
typename T,
typename =
void>
61 struct has_Text : std::false_type {};
63 struct has_Text<T, std::void_t<typename T::Text>> : std::true_type {};
65 template<
typename... Ts>
68 static constexpr int value = (has_Text<Ts>::value + ... + 0);
75 template<
typename T,
typename =
void>
76 struct extract_manifest_or_void {
using type = void; };
79 struct extract_manifest_or_void<T, std::void_t<typename T::manifest_type>>
80 {
using type =
typename T::manifest_type; };
89 template<
typename... Traits>
90 struct HasCoreTraits : std::disjunction<
91 std::is_same<Traits, Subscribable>...,
92 std::is_same<Traits, Flaggable>...,
93 std::is_same<Traits, Positionable>...
106 template<
typename ComponentManifest = void,
typename... Traits>
110 public GatherFlags <ComponentManifest, Draggable, Traits...>::type,
111 public GatherStates<ComponentManifest, Draggable, Traits...>::type
114 !HasCoreTraits<Traits...>::value,
115 "[Malena] Subscribable, Flaggable, and Positionable are already "
116 "included via Core — do not pass them as traits."
166 template<
typename ComponentManifest,
typename... Traits>
174 using _AllManifests = std::tuple<
176 typename extract_manifest_or_void<Traits>::type...
183 typename extract_manifest_or_void<Traits>::type...
185 "[Malena] Images alias is ambiguous — two or more manifests in "
186 "this component's inheritance chain both declare an Images enum. "
187 "Use MyManifest::Images::VALUE syntax to qualify explicitly."
194 typename extract_manifest_or_void<Traits>::type...
196 "[Malena] Fonts alias is ambiguous — two or more manifests in "
197 "this component's inheritance chain both declare a Fonts enum. "
198 "Use MyManifest::Fonts::VALUE syntax to qualify explicitly."
205 typename extract_manifest_or_void<Traits>::type...
207 "[Malena] Sounds alias is ambiguous — two or more manifests in "
208 "this component's inheritance chain both declare a Sounds enum. "
209 "Use MyManifest::Sounds::VALUE syntax to qualify explicitly."
216 typename extract_manifest_or_void<Traits>::type...
218 "[Malena] Text alias is ambiguous — two or more manifests in "
219 "this component's inheritance chain both declare a Text enum. "
220 "Use MyManifest::Text::VALUE syntax to qualify explicitly."
232 template<
typename... Traits>
270 template<
typename First = void,
typename... Rest>
272 std::is_base_of_v<Manifest, First>,
273 ComponentBase<First, Rest...>,
274 ComponentBase<void, First, Rest...>
298 template<
typename M,
typename... Traits>
void onClick(std::function< void()> callback)
Register a no-argument callback invoked when this component is clicked.
Primary base class for all user-facing Malena components.
Virtual base class for all Malena framework objects.
Receiver trait that adds mouse-drag behavior to any Component.
static void subscribe(EnumType eventEnum, EventReceiver *component)
Register a component for an enum-keyed event.
Enum-keyed boolean flag store.
void toggleFlag(State state)
void disableFlag(State state)
void setFlag(State state, bool status)
bool checkFlag(State state) const
void enableFlag(State state)
void onHover(std::function< void()> callback)
Register a no-argument callback invoked when the mouse enters this component's bounds.
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
@ DRAG
Component is being dragged.
Flag
System-level boolean flags available on every ml::Core object.
Intermediate drawable layer — with manifest.
ml::ManifestResources< ComponentManifest > Resources
Internal non-drawable layer of the component hierarchy.
Collects all Flag enums from a component manifest and its traits.
Collects all State enums from a component manifest and its traits.
Unified manifest resource and config accessor.