27#include "guillaume/ecs/component.hpp"
28#include "guillaume/ecs/entity.hpp"
70 enum class Variant { Assist, Filter, Input, Suggestion };
77 enum class Mode { Flat, Outlined };
80 using Handler = std::function<void(
void)>;
101 Variant _variant { Variant::Assist };
102 Mode _mode { Mode::Flat };
103 std::string _label {};
104 std::string _iconGlyph {};
121 bool _compact {
false };
122 bool _elevated {
false };
123 bool _showSelectedOverlay {
false };
124 bool _showSelectedCheck {
true };
172 const std::string &
getLabel(
void)
const noexcept;
Chip & setCompact(bool compact)
Choose between the regular and the compact padding.
static constexpr float Padding
Padding around the content, in dp.
Chip & setShowSelectedOverlay(bool show)
Choose whether a selected chip is darkened by a state layer.
ecs::Entity::Identifier getCheckIcon(void) const noexcept
Get the child entity that draws the selected check.
Chip & setShowSelectedCheck(bool show)
Choose whether a selected chip shows its check.
static constexpr const char * DefaultAssistGlyph
Glyph of the leading icon of an Assist chip without one.
const std::string & getLabel(void) const noexcept
Get the label text.
ecs::Entity::Identifier getLeadingIcon(void) const noexcept
Get the child entity that draws the leading icon.
Variant getVariant(void) const noexcept
Get the kind of chip.
Chip & setMode(Mode mode)
Choose the container style.
const std::string & getIconGlyph(void) const noexcept
Get the name of the leading icon glyph.
Mode
Container style: Flat is filled with the secondary container color; Outlined is transparent with an o...
bool isShowSelectedCheck(void) const noexcept
Check whether a selected chip shows its check.
Chip & setOnPress(Handler handler)
Set the callback run when the chip is pressed.
static constexpr float IconSize
Font size of the icons, in dp.
ecs::Entity::Identifier getLabelEntity(void) const noexcept
Get the child entity that draws the label.
Chip & setCheckIcon(ecs::Entity::Identifier identifier)
Record which child entity draws the selected check.
Chip & setLeadingIcon(ecs::Entity::Identifier identifier)
Record which child entity draws the leading icon.
bool isElevated(void) const noexcept
Check whether the chip casts a shadow.
~Chip(void)=default
Default destructor.
static constexpr const char * CloseGlyph
Glyph of the trailing close icon.
Chip & setLabelEntity(ecs::Entity::Identifier identifier)
Record which child entity draws the label.
Chip & setOnClose(Handler handler)
Set the callback run when the close icon is pressed.
Chip & setLabel(const std::string &label)
Set the label text.
const Handler & getOnPress(void) const noexcept
Get the callback run when the chip is pressed.
bool isCompact(void) const noexcept
Check whether the chip uses the compact padding.
Chip & setTrailingIcon(ecs::Entity::Identifier identifier)
Record which child entity draws the trailing close icon.
const Handler & getOnClose(void) const noexcept
Get the callback run when the close icon is pressed.
Mode getMode(void) const noexcept
Get the container style.
static constexpr float CompactPadding
Padding around the content of a compact chip, in dp.
Chip & setElevated(bool elevated)
Choose whether the chip casts a shadow.
std::function< void(void)> Handler
Callback run when the chip, or its close icon, is activated.
ecs::Entity::Identifier getTrailingIcon(void) const noexcept
Get the child entity that draws the trailing close icon.
Chip & setVariant(Variant variant)
Choose the kind of chip.
bool isShowSelectedOverlay(void) const noexcept
Check whether a selected chip is darkened by a state layer.
Chip(void)=default
Create the configuration of a flat Assist chip with no label.
static constexpr const char * CheckGlyph
Glyph of the selected check.
Chip & setIconGlyph(const std::string &iconGlyph)
Set the name of the leading icon glyph.
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.