23#include "guillaume/systems/floating_action_button.hpp"
33#include "guillaume/components/borders.hpp"
34#include "guillaume/components/bound.hpp"
35#include "guillaume/components/color.hpp"
36#include "guillaume/components/elevation.hpp"
37#include "guillaume/components/transform.hpp"
41#include "guillaume/systems/button.hpp"
42#include "guillaume/systems/layout.hpp"
43#include "guillaume/theme.hpp"
103 const bool visible = button.isVisible();
104 const auto mode = config.getMode();
105 const bool lowered = config.isLowered();
110 if (disabled || !visible || mode == Mode::Flat) {
112 }
else if (hovered && !pressed) {
114 static_cast<std::size_t
>(level) + 1);
117 .setElevationLevel(level);
133 const bool visible = button.isVisible();
134 const auto variant = config.getVariant();
135 const bool lowered = config.isLowered();
170 utility::graphic::Color32Bit containerColor = baseContainerColor;
175 }
else if (hovered) {
181 .setColor(containerColor);
203 const auto size = config.getSize();
204 const auto &customSize = config.getCustomSize();
205 const float iconSize =
iconFontSize(registry, identifier);
206 const float containerSize =
208 const float fontHeight = iconSize;
211 .setWidth(containerSize)
217 .setBorderRadius(customSize.has_value()
223 icon.setFontSize(fontHeight);
231 if (!icon && !label) {
235 const auto &buttonPose =
238 const float iconWidth = icon
242 const float iconHeight = icon
246 const float labelWidth = label
250 const float labelHeight = label
255 const float gap = (icon && label) ? 8.0f : 0.0f;
256 const float contentWidth = iconWidth + gap + labelWidth;
260 const float width = std::max(containerSize, contentWidth);
262 buttonPose.getPosition().x + (width - contentWidth) / 2.0f;
265 const float iconY = buttonPose.getPosition().y
266 - (containerSize - iconHeight) / 2.0f;
269 utility::graphic::PositionF(startX, iconY,
270 buttonPose.getPosition().z),
271 buttonPose.getOrientation(), layer);
278 const float labelX = startX + iconWidth + gap;
279 const float labelY = buttonPose.getPosition().y
280 - (containerSize - labelHeight) / 2.0f;
283 utility::graphic::PositionF(labelX, labelY,
284 buttonPose.getPosition().z),
285 buttonPose.getOrientation(), layer);
291 if (width > containerSize) {
Corner radii and outline stroke of a rectangular entity.
Size of an entity: the width and height, in dp, of the rectangle that starts at the position of its c...
Bound & setHeight(float height) noexcept
Set the height.
Main color of an entity: the fill of a shape, or the ink of a text or an icon.
Soft shadow drawn around an elevated surface.
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.
ComponentType & addComponent(const Entity::Identifier &entityIdentifier, Args &&...args)
Construct a component for an entity, replacing the one it already has, if any.
bool hasComponent(const Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component of a given type.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
SystemFiller(Phase phase)
ecs::ComponentRegistry & getComponentRegistry(void)
Get the component registry of the scene being processed.
bool requireComponent(const ecs::Entity::Identifier &entityIdentifier)
Tell whether an entity has a component, and log a warning naming the entity and the component when it...
Arranges the children of a container in a row or a column and sizes the container around them.
static const utility::graphic::PoseF contentLayerPose(const utility::graphic::PositionF &position, const utility::graphic::OrientationF &orientation, const std::uint32_t &containerLayer)
Compute the pose of content placed by hand on a container.
static std::uint32_t layerOf(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &identifier)
Get the layer of an entity: its depth in the entity tree.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
utility::graphic::Color32Bit getContentColor(VariantType variant)
Color of the icon and of the label of a FAB: Primary for the Surface variant, the "on container" role...
float getContainerSize(SizeType size)
Width and height of the container of a FAB at its default size: 40 dp for Small, 56 dp for Medium,...
utility::graphic::Color32Bit getContainerColor(VariantType variant, bool lowered)
Fill color of the container of a FAB.
float getBorderRadius(SizeType size)
Corner radius of the container: the Medium, Large and ExtraLarge shape of the active theme for a Smal...
float getIconFontSize(SizeType size)
Font size of the icon of a regular FAB: 24 dp for Small and Medium, 36 dp for Large.
utility::graphic::Color32Bit disabledContainerColor(void)
Fill color of the container of a disabled widget.
utility::graphic::Color32Bit transparentColor(void)
The color written to hide a fill or an outline without removing its component.
utility::graphic::Color32Bit stateLayer(const utility::graphic::Color32Bit &base, const utility::graphic::Color32Bit &overlay, std::uint8_t alpha)
Blend a translucent tint over a base color.
utility::graphic::Color32Bit disabledContentColor(void)
Color of the icon, label or outline of a disabled widget.
Rules. Every class here runs each frame on the entities that have the components it declares.
ElevationLevel
How far a surface is raised above the background, in six steps.
@ Level1
Lowest raised level.
@ Level3
Third raised level.
@ Level0
Flat: no shadow, no tint.
@ LabelLarge
14 / 20, medium weight.
@ Hovered
0.08 overlay of the content color.
@ Pressed
0.12 overlay of the content color.
Style tables of the floating action buttons (FAB): container size, font sizes, corner radius and colo...
Color helpers shared by the widget systems: scheme lookup, state layers and the disabled colors.