23#include "guillaume/theme.hpp"
24#include "guillaume/entities/surface.hpp"
25#include "guillaume/systems/surface_tone.hpp"
150 _elevation = elevation;
168 const auto pose = _config.pose;
174 std::shared_ptr<Surface>
179 return withElevation(elevation).withMode(mode).registerEntity(parent);
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.
@ Center
Packed in the middle.
Axis
Direction along which children are arranged.
@ Vertical
Column: children placed top to bottom.
State of a tonal surface: how high it sits above the background, and whether it casts a shadow.
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
ComponentRegistry & getComponentRegistry(void)
Get the registry in which the builder creates components.
Owns entities and gives the systems the list of entities to visit.
Entity::Identifier getIdentifier(void) const noexcept
Get the identifier of the entity.
ComponentRegistry & getComponentRegistry(void)
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
SurfaceBase(ecs::ComponentRegistry ®istry, const SurfaceConfig &config)
Configures and registers Surface widgets.
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 & 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.
static void apply(ecs::ComponentRegistry &componentRegistry, const ecs::Entity::Identifier &entityIdentifier)
Write the color and the shadow of one surface from its components::SurfaceTone.
State. Every class here is plain data attached to an entity.
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.
@ ExtraLarge
28 dp (dialogs, search bars, sheets).
@ None
0 dp: square corners.
float getShapeRadius(theme::ShapeRole role)
Get the corner radius the active theme gives to a shape role.
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.