28#include "guillaume/ecs/component.hpp"
29#include "guillaume/ecs/entity.hpp"
83 std::function<void(
void)>
88 using Handler = std::function<void(
void)>;
105 bool _interactive {
false };
106 bool _pressed {
false };
107 float _pressProgress { 0.0f };
108 float _pressFrom { 0.0f };
109 std::string _coverPath {};
110 std::string _title {};
111 std::string _subtitle {};
112 std::string _contentText {};
137 std::vector<Action> _actions {};
252 const std::string &
getTitle(
void)
const noexcept;
268 const std::string &
getSubtitle(
void)
const noexcept;
390 const std::vector<Action> &
getActions(
void)
const noexcept;
const std::vector< Action > & getActions(void) const noexcept
Get the actions the card was asked to show.
bool isInteractive(void) const noexcept
Check whether the card reacts to hover and press.
Card & setPressed(bool pressed)
Record the pressed state the press motion heads to.
const std::string & getCoverPath(void) const noexcept
Get the path of the cover texture.
bool isPressed(void) const noexcept
Check whether the press motion is heading to the raised state.
static constexpr float CoverHeight
Height of the cover image, in dp.
ecs::Entity::Identifier getActionsSection(void) const noexcept
Get the child entity that contains the action buttons.
ecs::Entity::Identifier getCover(void) const noexcept
Get the child entity that draws the cover image.
Card & setInteractive(bool interactive)
Record that the card reacts to hover and press.
ecs::Entity::Identifier getTitleSection(void) const noexcept
Get the child entity that contains the title and the subtitle.
const Identifiers & getActionButtons(void) const noexcept
Get the entities of the action buttons.
static constexpr float TitleMinHeight
Minimum height of the title section, in dp.
Card & setSubtitle(const std::string &subtitle)
Set the subtitle text.
float getPressFrom(void) const noexcept
Get the press progress at which the running motion began.
Card(void)=default
Create the state of an empty, elevated card that cannot be pressed.
Card & setTitleText(ecs::Entity::Identifier identifier)
Record which entity draws the title text.
std::function< void(void)> Handler
Callback run when the card is pressed.
Card & setActionButtons(const Identifiers &identifiers)
Record which entities are the action buttons.
const Handler & getOnPress(void) const noexcept
Get the callback run when the card is pressed.
float getPressProgress(void) const noexcept
Get how far the card is raised by a press.
Card & setContentText(const std::string &contentText)
Set the content text.
~Card(void)=default
Default destructor.
Card & setPressProgress(float pressProgress)
Set how far the card is raised by a press.
const std::string & getTitle(void) const noexcept
Get the title text.
Card & setVariant(Variant variant)
Choose the look of the card surface.
const std::string & getContentText(void) const noexcept
Get the content text.
Card & setTitle(const std::string &title)
Set the title text.
Card & setActionsSection(ecs::Entity::Identifier identifier)
Record which child entity contains the action buttons.
Variant
Look of the card surface.
@ Outlined
Surface fill with a 1 dp outline-variant stroke.
@ Filled
Surface-variant fill, no shadow, no outline.
Card & setCover(ecs::Entity::Identifier identifier)
Record which child entity draws the cover image.
Card & setSubtitleText(ecs::Entity::Identifier identifier)
Record which entity draws the subtitle text.
std::vector< ecs::Entity::Identifier > Identifiers
List of child entity identifiers.
ecs::Entity::Identifier getTitleText(void) const noexcept
Get the entity that draws the title text.
const std::string & getSubtitle(void) const noexcept
Get the subtitle text.
Card & setOnPress(Handler handler)
Store the callback run when the card is pressed.
ecs::Entity::Identifier getContentEntity(void) const noexcept
Get the child entity that draws the content text.
Card & setTitleSection(ecs::Entity::Identifier identifier)
Record which child entity contains the title and the subtitle.
Card & setCoverPath(const std::string &coverPath)
Set the path of the cover texture.
ecs::Entity::Identifier getSubtitleText(void) const noexcept
Get the entity that draws the subtitle text.
Card & addAction(Action action)
Append an action to the actions row.
Card & setContentEntity(ecs::Entity::Identifier identifier)
Record which child entity draws the content text.
Card & setPressFrom(float pressFrom)
Record the press progress at which a motion begins.
Variant getVariant(void) const noexcept
Get the look of the card surface.
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.
One button of the actions row: its label and what it does.
std::function< void(void)> onPress
Called when the button is clicked.
std::string label
Button label.