32#include <utility/graphic/color.hpp>
33#include <utility/graphic/pose.hpp>
35#include "guillaume/ecs/component_registry.hpp"
36#include "guillaume/ecs/entity_builder.hpp"
38#include "guillaume/components/accessibility.hpp"
39#include "guillaume/components/dialog.hpp"
40#include "guillaume/components/elevation.hpp"
41#include "guillaume/components/overlay.hpp"
43#include "guillaume/entities/backdrop.hpp"
44#include "guillaume/entities/button.hpp"
45#include "guillaume/entities/icon.hpp"
46#include "guillaume/entities/view.hpp"
47#include "guillaume/entities/builder_base.hpp"
48#include "guillaume/entities/surface.hpp"
49#include "guillaume/entities/text.hpp"
110 public SurfaceBase<components::Overlay, components::Elevation,
111 components::Accessibility, components::Dialog>
129 Variant _variant { Variant::Alert };
130 std::string _title {};
131 std::string _message {};
132 std::vector<Action> _actions {};
133 std::string _icon {};
134 std::function<void(
void)> _onDismiss {};
152 std::shared_ptr<Dialog>
buildEntity(
void)
override;
159 void reset(
void)
override;
202 std::function<
void(
void)> onPress = {});
237 std::shared_ptr<Dialog>
239 const std::string &title,
const std::string &message,
240 const std::vector<std::string> &actions = {});
264 Variant variant,
const std::string &title,
265 const std::string &message,
const std::vector<Action> &actions,
266 const std::string &icon,
267 std::function<
void(
void)> onDismiss = {});
282 template<
typename... Arguments>
283 static std::shared_ptr<Dialog>
create(Arguments &&...arguments)
285 std::shared_ptr<Dialog> entity(
286 new Dialog(std::forward<Arguments>(arguments)...));
445 void buildContent(
void);
451 void buildActionRow(
void);
466 Variant variant,
const std::string &title,
467 const std::string &message,
468 const std::vector<std::string> &actions);
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.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
Builder & withTitle(const std::string &title)
Set the title, shown above the message.
Builder & withPose(const utility::graphic::PoseF &pose)
Set the pose the dialog is created with.
Builder & addAction(const std::string &label, std::function< void(void)> onPress={})
Append an action, shown as a text button at the end of the action row.
void reset(void) override
Restore the defaults: Alert variant, no title, no message, no action, no icon, no dismiss handler,...
std::shared_ptr< Dialog > makeDialog(std::shared_ptr< ecs::Entity > parent, Variant variant, const std::string &title, const std::string &message, const std::vector< std::string > &actions={})
Build a dialog, register it under parent and reset the builder.
Builder & withVariant(Variant variant)
Set the dialog variant.
Builder & withMessage(const std::string &message)
Set the message, shown under the title.
std::shared_ptr< Dialog > buildEntity(void) override
Build a dialog and its children from the current configuration, without registering it or setting its...
Builder & withIcon(const std::string &iconGlyph)
Set the icon shown above the title.
Builder & withOnDismiss(std::function< void(void)> onDismiss)
Set the handler called when the dialog is dismissed (see Dialog::setOnDismiss()).
Dialog & close(void)
Hide the dialog; same as hide().
Dialog & show(void)
Show the dialog and, except for the FullScreen variant, its backdrop.
bool isOpen(void) const
Check whether the dialog is shown; same as isVisible().
ecs::Entity::Identifier getIconIdentifier(void) const
Get the identifier of the icon shown above the title.
Dialog(ecs::ComponentRegistry ®istry, const SurfaceConfig &config, Variant variant, const std::string &title, const std::string &message, const std::vector< Action > &actions, const std::string &icon, std::function< void(void)> onDismiss={})
Construct a dialog with pressable actions and an icon.
Dialog & open(void)
Show the dialog; same as show().
bool isVisible(void) const
Check whether the dialog is shown.
static std::shared_ptr< Dialog > create(Arguments &&...arguments)
Create a dialog and its children, without registering it in an entity registry.
Dialog & setVariant(Variant variant)
Change the dialog variant.
Variant getVariant(void) const
Get the dialog variant.
Dialog & dismiss(void)
Dismiss the dialog as the user would: hide it, then call the dismiss handler.
ecs::Entity::Identifier getBackdropIdentifier(void) const
Get the identifier of the backdrop drawn behind the panel.
~Dialog(void) override=default
Default destructor.
components::Dialog::Action Action
ecs::Entity::Identifier getActionRowIdentifier(void) const
Get the identifier of the row that holds the action buttons.
Dialog & setMessage(const std::string &message)
Change the message text.
ecs::Entity::Identifier getActionIdentifier(std::size_t index) const
Get the identifier of an action button.
Dialog & setOnDismiss(std::function< void(void)> onDismiss)
Set the handler called when the dialog is dismissed (Paper onDismiss).
Dialog & setTitle(const std::string &title)
Change the title text.
Dialog & hide(void)
Hide the dialog and its backdrop.
std::size_t getActionCount(void) const
Get the number of action buttons.
components::Dialog::Variant Variant
Look of the dialog: Alert, Simple, Confirmation or FullScreen.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Widgets: the classes used to create entities with the right components and children.
One action of the dialog, drawn as a text button in the action row.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...