guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
backdrop.cpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#include "guillaume/entities/backdrop.hpp"
24
25#include <cmath>
26
27#include "guillaume/systems/backdrop.hpp"
28#include "guillaume/theme.hpp"
29
30namespace guillaume::entities
31{
32 Backdrop::Backdrop(ecs::ComponentRegistry &registry)
33 : ecs::EntityFiller<components::Transform, components::Bound,
34 components::Scrim, components::Animation,
35 components::Backdrop>(registry)
36 {
37 // The fade-in handler outlives this constructor: capture the
38 // registry and the identifier, never the entity object.
39 const auto identifier = getIdentifier();
40
41 registry.getComponent<components::Bound>(identifier)
42 .setWidth(Extent)
43 .setHeight(Extent);
44 registry.getComponent<components::Animation>(identifier)
45 .setDuration(getMotionDuration(theme::MotionDuration::Medium2))
46 .setEasing(theme::MotionScale::enter())
47 .setOnSampleHandler([&registry, identifier](float progress) {
48 registry.getComponent<components::Backdrop>(identifier)
49 .setProgress(progress);
50 systems::Backdrop::apply(registry, identifier);
51 });
52 systems::Backdrop::apply(registry, identifier);
53 }
54
60
61 bool Backdrop::isVisible(void) const
62 {
64 .getComponent<components::Backdrop>(getIdentifier())
65 .isVisible();
66 }
67
68 void Backdrop::follow(const utility::graphic::PoseF &ownerPose,
69 float ownerWidth, float ownerHeight)
70 {
72 ownerPose, ownerWidth, ownerHeight);
73 }
74
75} // namespace guillaume::entities
State of a modal backdrop, the dimming layer behind a dialog or a drawer: whether it is shown and how...
Definition backdrop.hpp:52
Entity::Identifier getIdentifier(void) const noexcept
Get the identifier of the entity.
Definition entity.cpp:94
The translucent veil painted behind a dialog or a modal drawer to dim the rest of the scene.
Definition backdrop.hpp:82
bool isVisible(void) const
Check whether the backdrop is shown.
Definition backdrop.cpp:61
void follow(const utility::graphic::PoseF &ownerPose, float ownerWidth, float ownerHeight)
Centre the backdrop on its owner, half a layer behind it.
Definition backdrop.cpp:68
void setVisible(bool visible)
Show or hide the backdrop.
Definition backdrop.cpp:55
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
Widgets: the classes used to create entities with the right components and children.
Definition app_bar.hpp:46
float getMotionDuration(theme::MotionDuration duration)
Get the length the active theme gives to a duration token.