30#include <utility/graphic/color.hpp>
31#include <utility/graphic/pose.hpp>
33#include "guillaume/ecs/component_registry.hpp"
34#include "guillaume/ecs/entity_builder.hpp"
36#include "guillaume/components/accessibility.hpp"
37#include "guillaume/components/elevation.hpp"
38#include "guillaume/components/overlay.hpp"
39#include "guillaume/components/snackbar.hpp"
41#include "guillaume/entities/builder_base.hpp"
42#include "guillaume/entities/surface.hpp"
43#include "guillaume/entities/text.hpp"
99 public SurfaceBase<components::Overlay, components::Elevation,
100 components::Accessibility, components::Snackbar>
135 Variant _variant { Variant::SingleLine };
136 std::string _message {};
137 std::string _action {};
138 bool _visible {
true };
140 std::function<void(
void)> _onDismiss {};
141 std::function<void(
void)> _onAction {};
161 std::shared_ptr<Snackbar>
buildEntity(
void)
override;
168 void reset(
void)
override;
250 std::shared_ptr<Snackbar>
252 Variant variant,
const std::string &message,
253 const std::string &action =
"");
269 template<
typename... Arguments>
270 static std::shared_ptr<Snackbar>
create(Arguments &&...arguments)
272 std::shared_ptr<Snackbar> entity(
273 new Snackbar(std::forward<Arguments>(arguments)...));
308 Snackbar &
setMessage(
const std::string &message);
326 Snackbar &
show(
void);
333 Snackbar &
hide(
void);
369 Snackbar &
setOnDismiss(std::function<
void(
void)> onDismiss);
377 Snackbar &
setOnAction(std::function<
void(
void)> onAction);
403 void buildContent(
void);
418 Variant variant,
const std::string &message,
419 const std::string &action);
static constexpr float DurationLong
Long display time, in seconds.
static constexpr float DurationMedium
Medium display time, in seconds. This is the default.
static constexpr float DurationShort
Short display time, in seconds.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Builder & withOnAction(std::function< void(void)> onAction)
Set the handler called when the action is pressed (Paper action.onPress).
Builder & withAction(const std::string &action)
Set the label of the action.
Builder & withVariant(Variant variant)
Set the snackbar variant.
Builder & withMessage(const std::string &message)
Set the message.
Builder & withDuration(float seconds)
Set how long the snackbar stays shown (Paper duration).
Builder & withPose(const utility::graphic::PoseF &pose)
Set the pose the snackbar is created with.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
Builder & withOnDismiss(std::function< void(void)> onDismiss)
Set the handler called when the snackbar dismisses itself (see Snackbar::setOnDismiss()).
void reset(void) override
Restore the defaults: SingleLine variant, no message, no action label, shown, DurationMedium (7 secon...
std::shared_ptr< Snackbar > buildEntity(void) override
Build a snackbar and its children from the current configuration, without registering it or setting i...
std::shared_ptr< Snackbar > makeSnackbar(std::shared_ptr< ecs::Entity > parent, Variant variant, const std::string &message, const std::string &action="")
Build a snackbar, register it under parent and reset the builder.
Builder & withVisible(bool visible)
Choose whether the snackbar is shown once built.
bool isVisible(void) const
Check whether the snackbar is shown.
float getDuration(void) const
Get how long the snackbar stays shown.
~Snackbar(void) override=default
Default destructor.
Snackbar & setVisible(bool visible)
Show or hide the snackbar (Paper visible).
Snackbar & show(void)
Show the snackbar; same as setVisible(true).
Snackbar & pressAction(void)
Activate the action as a press on its label would: call the action handler, then hide the snackbar an...
Snackbar & setDuration(float seconds)
Set how long the snackbar stays shown (Paper duration).
Snackbar & setOnAction(std::function< void(void)> onAction)
Set the handler called when the action is pressed (Paper action.onPress).
static std::shared_ptr< Snackbar > create(Arguments &&...arguments)
Create a snackbar and its children, without registering it in an entity registry.
components::Snackbar::Variant Variant
Look of the snackbar: SingleLine, MultiLine or WithAction.
Snackbar & hide(void)
Hide the snackbar without calling the dismiss handler; same as setVisible(false).
Snackbar & setMessage(const std::string &message)
Change the message text.
std::shared_ptr< Text > getActionEntity(void) const
Get the text entity that shows the action label.
Snackbar & setVariant(Variant variant)
Change the snackbar variant.
static constexpr float DurationLong
Long display time: 10 seconds (Paper Snackbar.DURATION_LONG).
Variant getVariant(void) const
Get the snackbar variant.
Snackbar & setOnDismiss(std::function< void(void)> onDismiss)
Set the handler called when the snackbar dismisses itself (Paper onDismiss).
static constexpr float DurationMedium
Default display time: 7 seconds (Paper Snackbar.DURATION_MEDIUM).
static constexpr float DurationShort
Short display time: 4 seconds (Paper Snackbar.DURATION_SHORT).
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Widgets: the classes used to create entities with the right components and children.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...