31#include <utility/graphic/color.hpp>
32#include <utility/graphic/pose.hpp>
34#include "guillaume/ecs/component_registry.hpp"
35#include "guillaume/ecs/entity_builder.hpp"
37#include "guillaume/components/animation.hpp"
38#include "guillaume/components/card.hpp"
39#include "guillaume/components/elevation.hpp"
40#include "guillaume/entities/builder_base.hpp"
41#include "guillaume/entities/surface.hpp"
103 public SurfaceBase<components::Elevation, components::Animation,
131 Variant _variant { Variant::Elevated };
132 std::function<void(
void)>
134 bool _disabled {
false };
161 void reset(
void)
override;
233 std::shared_ptr<Card>
makeCard(std::shared_ptr<ecs::Entity> parent,
249 template<
typename... Arguments>
250 static std::shared_ptr<Card>
create(Arguments &&...arguments)
252 std::shared_ptr<Card> entity(
253 new Card(std::forward<Arguments>(arguments)...));
261 ~Card(
void)
override;
340 const std::string &subtitle =
"");
366 std::function<
void(
void)> onPress);
372 std::shared_ptr<Image>
getCover(
void)
const;
402 std::vector<std::shared_ptr<Button>>
getActions(
void)
const;
420 void buildComposition(
void);
static constexpr float CoverHeight
Height of the cover image, in dp.
static constexpr float TitleMinHeight
Minimum height of the title section, in dp.
Variant
Look of the card surface.
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.
Builder & withWidth(float width)
Set the width of the card.
void reset(void) override
Restore the defaults: default pose, the Elevated variant, no press handler, enabled,...
std::shared_ptr< Card > makeCard(std::shared_ptr< ecs::Entity > parent, Variant variant)
Build an empty card, register it under parent and reset the builder.
Builder & withDisabled(bool disabled)
Build the card disabled or enabled.
Builder & withOnPress(std::function< void(void)> onPress)
Make the built card pressable.
Builder & withBorderRadius(float radius)
Set the corner radius.
std::shared_ptr< Card > buildEntity(void) override
Build an empty card from the current configuration, without registering it or giving it a parent.
Builder & withHeight(float height)
Force the height of the card.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder holding the defaults of reset().
Builder & withVariant(Variant variant)
Choose the look of the card.
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the card is.
A rounded panel grouping a cover image, a title, a text and action buttons about one subject (react-n...
static constexpr float CoverHeight
Height given to the cover image, in dp (Paper Card.Cover: 195).
Card & setOnPress(std::function< void(void)> onPress)
Make the card pressable and set what a press does (Paper onPress).
static std::shared_ptr< Card > create(Arguments &&...arguments)
Build a card without registering it in an entity registry.
Card & addAction(const std::string &label, std::function< void(void)> onPress)
Append a text button to the row at the bottom of the card (Paper Card.Actions).
Card & setContent(const std::string &content)
Show a text under the title (Paper Card.Content).
Card & setDisabled(bool disabled)
Disable or enable the card (Paper disabled). Restyles at once.
Card & setCover(const std::string &texturePath)
Show an image at the top of the card (Paper Card.Cover).
bool isInteractive(void) const
Check whether the card reacts to input.
std::shared_ptr< ecs::Entity > getActionsSection(void) const
Get the row holding the action buttons.
Variant getVariant(void) const
Get the look of the card.
Card & setVariant(Variant variant)
Change the look of the card. Restyles at once.
static constexpr float TitleMinHeight
Height given to the title section, in dp (the minimum height of Paper Card.Title: 72).
float getPressProgress(void) const
Get how far the press elevation has progressed.
std::shared_ptr< Image > getCover(void) const
Get the cover image.
bool isDisabled(void) const
Check whether the card ignores presses.
std::shared_ptr< Text > getContent(void) const
Get the content text.
components::Card::Variant Variant
Look of the card: Elevated, Filled or Outlined.
std::vector< std::shared_ptr< Button > > getActions(void) const
Get the action buttons.
~Card(void) override
Destructor.
Card & setTitle(const std::string &title, const std::string &subtitle="")
Show a title, and optionally a subtitle under it (Paper Card.Title).
std::shared_ptr< ecs::Entity > getTitleSection(void) const
Get the section holding the title and subtitle texts.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
A picture loaded from a texture file and stretched over a rectangle.
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
A single run of text drawn with a typescale role, a color and an optional explicit font size.
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...