30#include <utility/graphic/color.hpp>
31#include <utility/graphic/pose.hpp>
33#include "guillaume/ecs/component_registry.hpp"
34#include "guillaume/ecs/entity_builder.hpp"
36#include "guillaume/components/accessibility.hpp"
37#include "guillaume/components/elevation.hpp"
38#include "guillaume/components/focus.hpp"
39#include "guillaume/components/line.hpp"
40#include "guillaume/components/overlay.hpp"
41#include "guillaume/components/search.hpp"
42#include "guillaume/components/text_field.hpp"
44#include "guillaume/entities/builder_base.hpp"
45#include "guillaume/entities/icon.hpp"
46#include "guillaume/entities/surface.hpp"
47#include "guillaume/entities/text.hpp"
99 public SurfaceBase<components::Overlay, components::TextField,
100 components::Elevation, components::Line,
101 components::Focus, components::Accessibility,
115 Variant _variant { Variant::SearchBar };
116 std::string _placeholder {};
117 std::string _text {};
135 std::shared_ptr<Search>
buildEntity(
void)
override;
145 void reset(
void)
override;
189 std::shared_ptr<Search>
191 const std::string &placeholder,
192 const std::string &text =
"");
208 template<
typename... Arguments>
209 static std::shared_ptr<Search>
create(Arguments &&...arguments)
211 std::shared_ptr<Search> entity(
212 new Search(std::forward<Arguments>(arguments)...));
262 std::string
getText(
void)
const;
309 std::function<
void(
void)> onPress = {});
416 void buildChildren(
void);
432 Variant variant,
const std::string &placeholder,
433 const std::string &text);
Variant
Shape of the search field.
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...
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Create a builder set to the defaults of reset().
std::shared_ptr< Search > makeSearch(std::shared_ptr< ecs::Entity > parent, Variant variant, const std::string &placeholder, const std::string &text="")
Build a search field, register it under parent and reset the builder.
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the search field is placed.
std::shared_ptr< Search > buildEntity(void) override
Build a search field and its children from the current configuration, without registering it or setti...
Builder & withText(const std::string &text)
Set the initial query.
void reset(void) override
Restore the defaults.
Builder & withVariant(Variant variant)
Set the variant.
Builder & withPlaceholder(const std::string &placeholder)
Set the placeholder: the hint shown while the query is empty.
A search field: a leading icon, an editable query with a placeholder, a clear button and an optional ...
Search & setLoading(bool loading)
Show the loading glyph in place of the clear button, or the reverse. Restyles at once.
Search & setOnIconPress(std::function< void(void)> onIconPress)
Set the handler called when the user presses the leading icon (Paper onIconPress).
Search & setPlaceholder(const std::string &placeholder)
Change the placeholder: the hint shown while the query is empty.
components::Search::Variant Variant
Search variant.
static std::shared_ptr< Search > create(Arguments &&...arguments)
Create a search field and its children, without registering it in an entity registry.
Search & hide(void)
Hide the search field: set its components::Overlay not visible.
Search & setElevation(theme::ElevationLevel level)
Set the elevation level (Paper elevation). Restyles at once.
Search & setIcon(const std::string &iconGlyph)
Change the glyph of the leading icon (Paper icon). Restyles at once.
~Search(void) override
Default destructor.
ecs::Entity::Identifier getTextIdentifier(void) const
Get the query text entity: the text the user edits.
ecs::Entity::Identifier getPlaceholderIdentifier(void) const
Get the placeholder text entity.
ecs::Entity::Identifier getIconIdentifier(void) const
Get the leading icon: a pressable icon entity.
Search & setOnClearIconPress(std::function< void(void)> onClearIconPress)
Set the handler called after the query was cleared, by the clear button or by clear() (Paper onClearI...
Search & open(void)
Open the search field. Same as show().
bool isVisible(void) const
Whether the search field is shown.
bool isLoading(void) const
Whether the loading glyph replaces the clear button.
ecs::Entity::Identifier getClearIdentifier(void) const
Get the clear button: a pressable icon entity.
Search & clear(void)
Empty the query, as the clear button does, then call the clear handler.
Search & show(void)
Show the search field: set its components::Overlay visible.
Search & close(void)
Close the search field. Same as hide().
Search & setText(const std::string &text)
Replace the query. Restyles at once.
Search & setTrailingIcon(const std::string &iconGlyph, std::function< void(void)> onPress={})
Set or hide the trailing icon (Paper right and traileringIcon).
Search & setVariant(Variant variant)
Change the variant. Restyles at once.
bool isOpen(void) const
Whether the search field is open. Same as isVisible().
Variant getVariant(void) const
Get the variant.
std::string getText(void) const
Get the query, including what the user typed.
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Widgets: the classes used to create entities with the right components and children.
ElevationLevel
How far a surface is raised above the background, in six steps.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...