28#include "guillaume/ecs/component.hpp"
29#include "guillaume/ecs/entity.hpp"
62 enum class Variant { SingleLine, MultiLine, WithAction };
66 using Handler = std::function<void(
void)>;
78 Variant _variant { Variant::SingleLine };
79 std::string _message {};
80 std::string _action {};
89 bool _visible {
true };
125 const std::string &
getMessage(
void)
const noexcept;
141 const std::string &
getAction(
void)
const noexcept;
static constexpr float DurationLong
Long display time, in seconds.
Snackbar & setMessage(const std::string &message)
Set the message shown in the bar.
Snackbar & setAction(const std::string &action)
Set the label of the action, such as "Undo".
Snackbar & setActionEntity(ecs::Entity::Identifier identifier)
Record the pressable child that draws the action label.
Snackbar & setDuration(float seconds)
Set how long the snackbar stays on screen once shown.
Variant getVariant(void) const noexcept
Get the kind of snackbar.
float getDuration(void) const noexcept
Get how long the snackbar stays on screen.
const Handler & getOnAction(void) const noexcept
Get the callback run when the action is pressed.
std::function< void(void)> Handler
static constexpr float DurationMedium
Medium display time, in seconds. This is the default.
Snackbar & setMessageEntity(ecs::Entity::Identifier identifier)
Record the child that draws the message.
Snackbar & setOnDismiss(Handler handler)
Set the callback run when the snackbar is dismissed.
Snackbar & setOnAction(Handler handler)
Set the callback run when the action is pressed.
ecs::Entity::Identifier getActionEntity(void) const noexcept
Get the pressable child that draws the action label.
Snackbar(void)=default
Create the configuration of a visible, empty single-line snackbar that lasts DurationMedium.
bool isVisible(void) const noexcept
Tell whether the snackbar is shown.
Snackbar & setVariant(Variant variant)
Set the kind of snackbar, which decides its height.
const Handler & getOnDismiss(void) const noexcept
Get the callback run when the snackbar is dismissed.
~Snackbar(void)=default
Default destructor.
static constexpr float DurationShort
Short display time, in seconds.
Snackbar & setVisible(bool visible)
Record whether the snackbar is shown.
ecs::Entity::Identifier getMessageEntity(void) const noexcept
Get the child that draws the message.
const std::string & getAction(void) const noexcept
Get the label of the action.
const std::string & getMessage(void) const noexcept
Get the message shown in the bar.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
State. Every class here is plain data attached to an entity.