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."
167 template<
typename ComponentManifest,
typename... Traits>
175 using _AllManifests = std::tuple<
177 typename extract_manifest_or_void<Traits>::type...
184 typename extract_manifest_or_void<Traits>::type...
186 "[Malena] Images alias is ambiguous — two or more manifests in "
187 "this component's inheritance chain both declare an Images enum. "
188 "Use MyManifest::Images::VALUE syntax to qualify explicitly."
195 typename extract_manifest_or_void<Traits>::type...
197 "[Malena] Fonts alias is ambiguous — two or more manifests in "
198 "this component's inheritance chain both declare a Fonts enum. "
199 "Use MyManifest::Fonts::VALUE syntax to qualify explicitly."
206 typename extract_manifest_or_void<Traits>::type...
208 "[Malena] Sounds alias is ambiguous — two or more manifests in "
209 "this component's inheritance chain both declare a Sounds enum. "
210 "Use MyManifest::Sounds::VALUE syntax to qualify explicitly."
217 typename extract_manifest_or_void<Traits>::type...
219 "[Malena] Text alias is ambiguous — two or more manifests in "
220 "this component's inheritance chain both declare a Text enum. "
221 "Use MyManifest::Text::VALUE syntax to qualify explicitly."
245 template<
typename... Traits>
246 struct ComponentBase<void, Traits...> :
public sf::Drawable,
247 public ComponentCore<void, Traits...>
287 template<
typename First = void,
typename... Rest>
289 std::is_base_of_v<Manifest, First>,
290 ComponentBase<First, Rest...>,
291 ComponentBase<void, First, Rest...>
315 template<
typename M,
typename... Traits>
void onClick(std::function< void()> callback, bool overwrite=true)
Register a no-argument callback invoked when this component is clicked.
Primary base class for all user-facing Malena components.
void drawChildren(sf::RenderTarget &target, sf::RenderStates states) const
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, bool overwrite=true)
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.
void draw(sf::RenderTarget &target, sf::RenderStates states) const override
ml::ManifestResources< ComponentManifest > Resources
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.