guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::systems::Backdrop Class Reference

Fades the backdrop of a modal widget in and keeps it behind its owner. More...

#include <headers/guillaume/systems/backdrop.hpp>

Inheritance diagram for guillaume::systems::Backdrop:
Collaboration diagram for guillaume::systems::Backdrop:

Public Member Functions

 Backdrop (void)
 Create the system in the Layout phase.
 ~Backdrop (void) override=default
 Destroy the system. It owns no resource.
void update (const ecs::Entity::Identifier &entityIdentifier) override
 Write the Scrim color of one backdrop for this frame, so a theme change is picked up without any call.
Public Member Functions inherited from guillaume::ecs::SystemFiller< components::Backdrop, components::Scrim >
 SystemFiller (Phase phase)
 Create the system and set its signature from ComponentTypes.
virtual ~SystemFiller (void)=default
 Virtual destructor.
Public Member Functions inherited from guillaume::ecs::System
 System (Phase phase)
 Create a system that runs in a given phase, with an empty signature.
virtual ~System (void)=default
 Virtual destructor.
Phase getPhase (void) const noexcept
 Get the phase of the frame in which the system runs.
Entity::Signature getSignature (void) const noexcept
 Get the component types an entity must declare to be visited by this system.
void routine (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry, const ecs::EntityTreeTraveler &traveler)
 Run the system once over a scene: prepare(), update() on each matching entity, cleanup().
void bindComponentRegistry (ecs::ComponentRegistry &componentRegistry)
 Bind a component registry so update() can be called directly, without routine().
void unbindComponentRegistry (void)
 Drop the binding made by bindComponentRegistry().
virtual void prepare (void)
 Called once per pass, before the first update().
virtual void cleanup (void)
 Called once per pass, after the last update().

Static Public Member Functions

static void apply (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
 Write the Scrim color that matches the current state of a backdrop.
static void setVisible (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, bool visible)
 Show or hide a backdrop.
static void follow (ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, const utility::graphic::PoseF &ownerPose, float ownerWidth, float ownerHeight)
 Center a backdrop on its owner and place it half a layer behind it.

Static Public Attributes

static constexpr float Extent = 8192.0f

Additional Inherited Members

Protected Member Functions inherited from guillaume::ecs::System
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.
ecs::EntityRegistry & getEntityRegistry (void)
 Get the entity registry of the scene being processed.
const ecs::EntityRegistry & getEntityRegistry (void) const
 Get the entity registry of the scene being processed, read-only.
ecs::ComponentRegistry & getComponentRegistry (void)
 Get the component registry of the scene being processed.
const ecs::ComponentRegistry & getComponentRegistry (void) const
 Get the component registry of the scene being processed, read-only.
template<InheritFromComponent ComponentType>
bool hasComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Tell whether an entity has a component, in the bound registry.
template<InheritFromComponent ComponentType>
ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier)
 Get a component of an entity from the bound registry, to read or modify it.
template<InheritFromComponent ComponentType>
const ComponentType & getComponent (const ecs::Entity::Identifier &entityIdentifier) const
 Get a component of an entity from the bound registry, read-only.
template<InheritFromComponent ComponentType>
bool requireComponent (const ecs::Entity::Identifier &entityIdentifier)
 Tell whether an entity has a component, and log a warning naming the entity and the component when it does not.

Detailed Description

Fades the backdrop of a modal widget in and keeps it behind its owner.

A backdrop is the dimmed layer shown behind a dialog or a modal navigation drawer. Its state is a components::Backdrop (shown or not, fade-in progress from 0 to 1); what is drawn is a components::Scrim.

Runs in the Layout phase on entities with Backdrop and Scrim. Each frame it reads the Backdrop and the Backdrop color of the active theme and writes the Scrim color: the theme color with its alpha multiplied by the progress, or fully transparent while the backdrop is hidden. systems::ScrimRender draws the result in the Render phase.

The progress itself is advanced by systems::Animation, through the sample handler that entities::Backdrop installs on its components::Animation.

The static functions are called by the system of the owner (systems::Dialog, systems::NavigationDrawer) when it opens, closes or moves:

systems::Backdrop::setVisible(registry, backdrop, true);
systems::Backdrop::follow(registry, backdrop, ownerPose, ownerWidth,
ownerHeight);
static void follow(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, const utility::graphic::PoseF &ownerPose, float ownerWidth, float ownerHeight)
Center a backdrop on its owner and place it half a layer behind it.
Definition backdrop.cpp:76
static void setVisible(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier, bool visible)
Show or hide a backdrop.
Definition backdrop.cpp:55

There is no fade-out: hiding a backdrop makes it transparent at once.

See also
components::Backdrop, components::Scrim
entities::Backdrop, systems::ScrimRender

Definition at line 68 of file backdrop.hpp.

Constructor & Destructor Documentation

◆ Backdrop()

guillaume::systems::Backdrop::Backdrop ( void )

Create the system in the Layout phase.

Definition at line 33 of file backdrop.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ apply()

void guillaume::systems::Backdrop::apply ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier )
static

Write the Scrim color that matches the current state of a backdrop.

Call it after changing components::Backdrop by hand when the new color must be in place before the next frame.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe backdrop entity. It must have Backdrop and Scrim.

Definition at line 39 of file backdrop.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ follow()

void guillaume::systems::Backdrop::follow ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier,
const utility::graphic::PoseF & ownerPose,
float ownerWidth,
float ownerHeight )
static

Center a backdrop on its owner and place it half a layer behind it.

Writes the backdrop's components::Transform, with the orientation of the owner. The computation assumes the backdrop is Extent wide and high. Call it whenever the owner moves or is resized.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe backdrop entity. It must have a Transform.
ownerPosePose of the top-left corner of the owner.
ownerWidthWidth of the owner, in dp.
ownerHeightHeight of the owner, in dp.

Definition at line 76 of file backdrop.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setVisible()

void guillaume::systems::Backdrop::setVisible ( ecs::ComponentRegistry & componentRegistry,
const ecs::Entity::Identifier & entityIdentifier,
bool visible )
static

Show or hide a backdrop.

Showing resets the progress to 0 and starts the fade-in animation from its beginning. Hiding resets the progress, stops the animation and makes the scrim transparent at once. Nothing happens when the backdrop is already in the requested state.

Parameters
componentRegistryThe registry holding the components.
entityIdentifierThe backdrop entity. It must have Backdrop, Scrim and components::Animation.
visibleTrue to show the backdrop, false to hide it.

Definition at line 55 of file backdrop.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void guillaume::systems::Backdrop::update ( const ecs::Entity::Identifier & entityIdentifier)
overridevirtual

Write the Scrim color of one backdrop for this frame, so a theme change is picked up without any call.

Parameters
entityIdentifierThe backdrop entity.

Implements guillaume::ecs::System.

Definition at line 92 of file backdrop.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ Extent

float guillaume::systems::Backdrop::Extent = 8192.0f
staticconstexpr

Width and height given to a backdrop, in dp: large enough to cover the view wherever its owner is.

Definition at line 74 of file backdrop.hpp.


The documentation for this class was generated from the following files: