28#include "guillaume/ecs/component.hpp"
29#include "guillaume/ecs/entity.hpp"
94 std::string _placeholder {};
97 std::string _trailingGlyph {};
98 bool _loading {
false };
99 std::function<void(
void)> _onIconPress {};
100 std::function<void(
void)> _onClearIconPress {};
101 std::function<void(
void)>
102 _onTrailingIconPress {};
177 const std::string &
getText(
void)
const noexcept;
246 const std::function<void(
void)> &
getOnIconPress(
void)
const noexcept;
261 const std::function<void(
void)> &
278 const std::function<void(
void)> &
399 template<
typename Type>
Search &assign(Type &field,
const Type &value)
401 if (!(field == value)) {
Search & setTextEntity(ecs::Entity::Identifier identifier)
Record the child the user types the query in.
ecs::Entity::Identifier getLoadingIcon(void) const noexcept
Get the child that draws the loading glyph.
const std::function< void(void)> & getOnIconPress(void) const noexcept
Get the callback run when the leading icon is pressed.
Variant getVariant(void) const noexcept
Get the shape of the field.
const std::string & getIconGlyph(void) const noexcept
Get the icon at the leading edge of the field.
ecs::Entity::Identifier getClearIcon(void) const noexcept
Get the pressable child that draws the clear button.
static constexpr float DefaultWidth
Width given to a search field that has no fixed width, in dp.
~Search(void)=default
Default destructor.
Search & setLoadingIcon(ecs::Entity::Identifier identifier)
Record the child that draws the loading glyph.
Search & setClearIcon(ecs::Entity::Identifier identifier)
Record the pressable child that draws the clear button.
Variant
Shape of the search field.
@ SearchBar
Pill-shaped bar, 56 dp high.
@ View
Another name for FullScreen.
const std::string & getText(void) const noexcept
Get the query.
ecs::Entity::Identifier getSearchIcon(void) const noexcept
Get the pressable child that draws the leading icon.
Search & setLoading(bool loading)
Show or hide the loading glyph.
const std::function< void(void)> & getOnTrailingIconPress(void) const noexcept
Get the callback run when the trailing icon is pressed.
static constexpr float IconSize
Size of the icons, in dp.
Search & setText(const std::string &text)
Store the query.
Search & setPlaceholderEntity(ecs::Entity::Identifier identifier)
Record the child that draws the placeholder.
static constexpr const char * SearchGlyph
Glyph name of the default leading icon.
Search & setTrailingIcon(ecs::Entity::Identifier identifier)
Record the pressable child that draws the trailing icon.
const std::string & getPlaceholder(void) const noexcept
Get the hint shown while the query is empty.
static constexpr const char * LoadingGlyph
Glyph name of the icon shown while loading.
Search & setOnIconPress(std::function< void(void)> handler)
Set the callback run when the leading icon is pressed.
static constexpr float ViewHeight
Height of the FullScreen variant, in dp.
Search & setIconGlyph(const std::string &glyph)
Set the icon at the leading edge of the field, such as "arrow_back".
Search & setOnTrailingIconPress(std::function< void(void)> handler)
Set the callback run when the trailing icon is pressed.
static constexpr const char * ClearGlyph
Glyph name of the clear button.
const std::string & getTrailingGlyph(void) const noexcept
Get the icon at the trailing edge of the field.
Search & setSearchIcon(ecs::Entity::Identifier identifier)
Record the pressable child that draws the leading icon.
ecs::Entity::Identifier getTrailingIcon(void) const noexcept
Get the pressable child that draws the trailing icon.
ecs::Entity::Identifier getPlaceholderEntity(void) const noexcept
Get the child that draws the placeholder.
ecs::Entity::Identifier getTextEntity(void) const noexcept
Get the child the user types the query in.
static constexpr float BarHeight
Height of the SearchBar variant, in dp.
Search & setPlaceholder(const std::string &placeholder)
Set the hint shown while the query is empty, such as "Search".
Search(void)=default
Create the configuration of an empty search bar with the "search" leading icon.
Search & setTrailingGlyph(const std::string &glyph)
Set the icon at the trailing edge of the field, such as "mic".
Search & setVariant(Variant variant)
Set the shape of the field.
bool isLoading(void) const noexcept
Tell whether the field shows its loading glyph.
const std::function< void(void)> & getOnClearIconPress(void) const noexcept
Get the callback run when the clear button is pressed.
Search & setOnClearIconPress(std::function< void(void)> handler)
Set the callback run when the clear button is pressed.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
void setHasChanged(bool hasChanged)
Raise or lower the 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.