8#ifndef MALENA_UICOMPONENTBASE_H
9#define MALENA_UICOMPONENTBASE_H
12#include <SFML/Graphics.hpp>
211 typename = std::enable_if_t<std::is_enum_v<E>>>
249 template<
typename... Children>
252 static_assert((std::is_base_of_v<Core, Children> && ...),
253 "addComponents() requires Core-derived arguments");
266 template<
typename... Children>
269 static_assert((std::is_base_of_v<Core, Children> && ...),
270 "addComponents() requires Core-derived arguments");
281 template<
typename E,
typename... Children,
282 typename = std::enable_if_t<std::is_enum_v<E>>>
285 static_assert((std::is_base_of_v<Core, Children> && ...),
286 "addComponents() requires Core-derived arguments");
306 const std::vector<Child>&
getChildren()
const {
return _children; }
323 bool _selfEnabled =
true;
324 bool _parentEnabled =
true;
326 void applyEnabled(
bool selfEnabled,
bool parentEnabled);
332 Core* _parent =
nullptr;
333 std::vector<Child> _children;
339 std::vector<std::function<void()>> _pendingOps;
341 void doRemoveChild(
Core* child);
342 void runPendingIfDepthZero();
348 void insertChildSorted(
Core& child,
int layer);
350 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)
bool isVisibilityIndependent() const
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.
void setVisibilityIndependent(bool independent)
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
void setFlag(State state, bool status)
bool checkFlag(State state) 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.
@ VISIBILITY_INDEPENDENT
This child opts OUT of a parent container's setVisible/setActive cascade (it manages its own visibili...
A registered child plus the layer key it draws/iterates under.