27#include "guillaume/ecs/component_registry.hpp"
28#include "guillaume/entities/builder_base.hpp"
29#include "guillaume/ecs/entity_builder.hpp"
30#include "guillaume/ecs/entity_filler.hpp"
32#include "guillaume/components/accessibility.hpp"
33#include "guillaume/components/image.hpp"
34#include "guillaume/components/bound.hpp"
35#include "guillaume/components/transform.hpp"
76 components::Image, components::Accessibility>
86 std::string _texturePath;
87 std::string _fallbackPath;
89 float _width { 0.0f };
91 float _height { 0.0f };
119 void reset(
void)
override;
161 std::shared_ptr<Image>
makeImage(std::shared_ptr<Entity> parent,
162 const std::string &texturePath);
176 template<
typename... Arguments>
177 static std::shared_ptr<Image>
create(Arguments &&...arguments)
179 std::shared_ptr<Image> entity(
180 new Image(std::forward<Arguments>(arguments)...));
LoadState
Whether the texture could be loaded, as recorded by systems::ImageRender.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
The base class of a widget without children: an Entity that creates its components when it is constru...
Owns entities and gives the systems the list of entities to visit.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Builder & withFallbackPath(const std::string &fallbackPath)
Set the texture drawn when the main one fails to load.
std::shared_ptr< Image > makeImage(std::shared_ptr< Entity > parent, const std::string &texturePath)
Build an image, register it under parent and reset the builder.
std::shared_ptr< Image > buildEntity(void) override
Build an image from the current configuration, without registering it or giving it a parent.
Builder & withTexturePath(const std::string &texturePath)
Choose the texture to draw.
Builder & withSize(float width, float height)
Set the displayed size.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder holding the defaults of reset().
void reset(void) override
Restore the defaults: empty texture path, no fallback texture, and no size (width and height 0).
A picture loaded from a texture file and stretched over a rectangle.
Image & setAccessibilityLabel(const std::string &label)
Describe the picture for assistive technologies.
Image & setSize(float width, float height)
Set the displayed size, written to components::Bound.
Image & setAspectRatio(float width, float aspectRatio)
Set the displayed size from a width and an aspect ratio.
Image & setTexturePath(const std::string &texturePath)
Change the texture to draw.
Image & setFallbackPath(const std::string &fallbackPath)
Set the texture drawn when the main one fails to load.
components::Image::LoadState getLoadState(void) const
Tell whether the texture could be loaded.
const std::string & getTexturePath(void) const
Get the path of the texture the image was asked to draw.
static std::shared_ptr< Image > create(Arguments &&...arguments)
Build an image without registering it in an entity registry.
Widgets: the classes used to create entities with the right components and children.