23#include "guillaume/components/snackbar.hpp"
37 if (_variant != variant) {
51 if (_message != message) {
65 if (_action != action) {
74 return _messageEntity;
79 if (_messageEntity != identifier) {
80 _messageEntity = identifier;
93 if (_actionEntity != identifier) {
94 _actionEntity = identifier;
107 if (_visible != visible) {
121 if (seconds < 0.0f) {
122 throw std::invalid_argument(
"Snackbar duration must be >= 0");
124 if (_duration != seconds) {
138 _onDismiss = std::move(handler);
149 _onAction = std::move(handler);
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
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 & 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.
void setHasChanged(bool hasChanged)
Raise or lower the changed flag.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
State. Every class here is plain data attached to an entity.