29#include <utility/graphic/color.hpp>
30#include <utility/graphic/pose.hpp>
32#include "guillaume/ecs/component.hpp"
33#include "guillaume/ecs/component_registry.hpp"
34#include "guillaume/ecs/entity.hpp"
35#include "guillaume/ecs/parent_entity_filler.hpp"
37#include "guillaume/components/borders.hpp"
38#include "guillaume/components/bound.hpp"
39#include "guillaume/components/color.hpp"
40#include "guillaume/components/layout.hpp"
41#include "guillaume/components/transform.hpp"
72 utility::graphic::PoseF
74 utility::graphic::Color32Bit
color {
239 public std::enable_shared_from_this<SurfaceBase<ExtraComponents...>>,
241 components::Layout, components::Transform, components::Bound,
242 components::Color, components::Borders, ExtraComponents...>
246 std::vector<std::shared_ptr<ecs::Entity>>;
351#include "guillaume/entities/surface.tpp"
353#include "guillaume/components/elevation.hpp"
354#include "guillaume/components/surface_tone.hpp"
355#include "guillaume/entities/builder_base.hpp"
356#include "guillaume/theme/tokens.hpp"
388 public SurfaceBase<components::Elevation, components::SurfaceTone>
429 std::shared_ptr<Surface>
buildEntity(
void)
override;
437 void reset(
void)
override;
497 std::shared_ptr<Surface>
515 template<
typename... Arguments>
516 static std::shared_ptr<Surface>
create(Arguments &&...arguments)
518 std::shared_ptr<Surface> entity(
519 new Surface(std::forward<Arguments>(arguments)...));
CrossAxisAlignment
Where each child goes along the cross axis, inside the padding. In a container that wraps its childre...
MainAxisAlignment
Where the children go along the main axis when the container is larger than them.
@ Start
Packed at the left (row) or top (column).
Axis
Direction along which children are arranged.
@ Horizontal
Row: children placed left to right.
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.
The base class of a widget with children: an EntityFiller that is also a ParentEntity.
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
SurfaceConfig getSurfaceConfig(void) const
Read the current configuration back from the components.
std::vector< std::shared_ptr< ecs::Entity > > Children
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Create the entity with its components and apply a configuration.
SurfaceBase & setChildren(const Children &children)
Choose the children this surface arranges, in order.
std::vector< ecs::Entity::Identifier > getChildren(void) const
Get the children this surface arranges.
SurfaceBase & setPose(const utility::graphic::PoseF &pose)
Move the surface.
SurfaceBase & setColor(const utility::graphic::Color32Bit &color)
Set the fill color (Color component).
~SurfaceBase(void) override=default
Default destructor.
SurfaceBase & setBorderRadius(float radius)
Set the radius of the four corners (Borders component).
SurfaceBase & setSurfaceConfig(const SurfaceConfig &config)
Apply every field of a configuration at once.
void applyGeometry(void)
Arrange the layout children now with systems::Layout::apply.
Builder & withMode(Mode mode)
Choose whether the surface casts a shadow.
std::shared_ptr< Surface > makeSurface(std::shared_ptr< ecs::Entity > parent, theme::ElevationLevel elevation, Mode mode=Mode::Elevated)
Build a surface with the given elevation and register it under a parent.
Builder & withShape(theme::ShapeRole role)
Set the corner radius from a shape role of the theme.
Builder & withElevation(theme::ElevationLevel elevation)
Set the elevation level, which tints the background and sizes the shadow.
std::shared_ptr< Surface > buildEntity(void) override
Create a surface from the current configuration, without attaching nor registering it.
Builder & withConfig(const SurfaceConfig &config)
Replace the layout configuration: axis, alignment, spacing, padding, fixed size and corner radius.
void reset(void) override
Restore the defaults: elevation level 1, a shadow (Mode::Elevated), square corners,...
Builder & withPose(const utility::graphic::PoseF &pose)
Set where the surface is.
Builder(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
Construct a builder set to the defaults of reset().
Mode getMode(void) const
Tell whether the surface casts a shadow.
theme::ElevationLevel getElevation(void) const
Get the elevation level.
~Surface(void) override=default
Destructor.
Surface & setMode(Mode mode)
Turn the shadow on or off, and restyle at once.
static std::shared_ptr< Surface > create(Arguments &&...arguments)
Create a surface without registering it.
Surface & setElevation(theme::ElevationLevel elevation)
Change the elevation level.
Mode
Whether the surface casts a shadow.
@ Elevated
Tinted background and the shadow of the level.
@ Flat
Tinted background, no shadow.
Constrains a template parameter to a type derived from Component (or Component itself).
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.
@ Level1
Lowest raised level.
ShapeRole
The corner radii a widget can ask for, by name.
Everything needed to set up a surface in one value: where it is, how it looks and how it arranges its...
SurfaceConfig & setMainAxisAlignment(components::Layout::MainAxisAlignment value)
Set where the children go along the axis.
float padding
Gap between the edges and the children, in dp.
SurfaceConfig & setFixedHeight(float value)
Give the surface a height that does not depend on its children.
SurfaceConfig & setBorderRadius(float value)
Set the radius of the four corners.
utility::graphic::PoseF pose
Position and orientation of the surface.
SurfaceConfig & setAxis(components::Layout::Axis value)
Choose between a row and a column.
SurfaceConfig & setCrossAxisAlignment(components::Layout::CrossAxisAlignment value)
Set where the children go across the axis.
float spacing
Gap between two children, in dp.
SurfaceConfig & setPose(const utility::graphic::PoseF &value)
Set where the surface is.
bool hasFixedWidth
True when fixedWidth replaces the content width.
float fixedWidth
Width in dp, used only when hasFixedWidth.
SurfaceConfig & setPadding(float value)
Set the gap between the edges of the surface and its children.
components::Layout::MainAxisAlignment mainAxisAlignment
Where the children go along the axis.
utility::graphic::Color32Bit color
Fill color (transparent by default).
SurfaceConfig & setColor(const utility::graphic::Color32Bit &value)
Set the fill color.
components::Layout::Axis axis
Direction the children are arranged in.
static SurfaceConfig panel(float width, components::Layout::Axis axis, float spacing)
Get the configuration shared by dialog and picker panels.
bool hasFixedHeight
True when fixedHeight replaces the content height.
float fixedHeight
Height in dp, used only when hasFixedHeight.
components::Layout::CrossAxisAlignment crossAxisAlignment
Where the children go across the axis.
SurfaceConfig & setFixedWidth(float value)
Give the surface a width that does not depend on its children.
SurfaceConfig & setSpacing(float value)
Set the gap between two consecutive children.
float borderRadius
Radius of the four corners, in dp.