8#ifndef MALENA_UICOMPONENTBASE_H
9#define MALENA_UICOMPONENTBASE_H
12#include <SFML/Graphics.hpp>
204 typename = std::enable_if_t<std::is_enum_v<E>>>
242 template<
typename... Children>
245 static_assert((std::is_base_of_v<Core, Children> && ...),
246 "addComponents() requires Core-derived arguments");
259 template<
typename... Children>
262 static_assert((std::is_base_of_v<Core, Children> && ...),
263 "addComponents() requires Core-derived arguments");
274 template<
typename E,
typename... Children,
275 typename = std::enable_if_t<std::is_enum_v<E>>>
278 static_assert((std::is_base_of_v<Core, Children> && ...),
279 "addComponents() requires Core-derived arguments");
299 const std::vector<Child>&
getChildren()
const {
return _children; }
316 bool _selfEnabled =
true;
317 bool _parentEnabled =
true;
319 void applyEnabled(
bool selfEnabled,
bool parentEnabled);
325 Core* _parent =
nullptr;
326 std::vector<Child> _children;
332 std::vector<std::function<void()>> _pendingOps;
334 void doRemoveChild(
Core* child);
335 void runPendingIfDepthZero();
341 void insertChildSorted(
Core& child,
int layer);
343 static bool isDescendantOf(
Core* ancestor,
Core* component);
void addComponents(int layer, Children &... children)
Register multiple child components at a shared layer.
bool isEffectivelyVisible() const
True only if this component and every ancestor are visible.
virtual void setVisible(bool visible)
void addComponents(E layer, Children &... children)
Variadic shared-layer registration with an enum layer key.
Core * topmostMatching(const std::function< bool(Core &)> &accept)
Find the front-most (last-painted) node in this subtree that satisfies accept, searching topmost-firs...
void setEnabled(bool enabled)
virtual void setActive(bool active)
void removeComponent(Core &child)
virtual void onEnabledChanged(bool enabled)
void addComponent(Core &child, E layer)
Register a child at a layer identified by any enum value.
virtual sf::RenderStates getRenderStates() const
void setParentEnabled(bool enabled)
static void linkChild(Core *parent, Core *child)
virtual void onWindowResize(unsigned int, unsigned int)
void addComponents(Children &... children)
Register multiple child components at the default layer.
static void unlinkAll(Core *core)
static constexpr int DefaultLayer
void addComponent(Core &child, int layer)
void addComponent(Core &child)
void drawChildren(sf::RenderTarget &target, sf::RenderStates states) const
const std::vector< Child > & getChildren() const
Trait that provides system-level boolean flag management.
Trait that adds keyboard-focus and blur callbacks to any Core object.
Trait that adds mouse-hover and mouse-leave callbacks to any Core object.
Trait that adds keyboard-input callbacks to any Core object.
Trait that provides position, bounds, and animated movement.
Trait that allows a component to subscribe to and publish framework events.
Trait that gives components the ability to unsubscribe from events.
Trait that adds per-frame update and window lifecycle callbacks to any Core object.
Layer
Framework-provided default layer enum.
A registered child plus the layer key it draws/iterates under.