23#include "guillaume/systems/common_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"
79 utility::graphic::Color32Bit
88 config.getColorStyle(), button.
isToggle(), button.isSelected());
103 const bool toggle = button.isToggle();
104 const bool selected = button.isSelected();
105 const auto colorStyle = config.getColorStyle();
109 if (colorStyle == Color::Elevated && !disabled) {
114 .setElevationLevel(level);
169 const bool toggle = button.isToggle();
170 const bool selected = button.isSelected();
171 const bool morph = button.isMorph();
172 const bool trailingIcon = button.isTrailingIcon();
174 const auto shape = config.getShape();
175 const auto size = config.getSize();
176 const bool compact = config.isCompact();
177 const float minWidth = config.getMinWidth();
178 const bool uppercase = config.isUppercase();
179 const float iconSize =
iconFontSize(registry, identifier);
187 if (
const auto &corners = config.getCorners()) {
188 borders.setTopLeftRadius(corners->topLeft)
189 .setTopRightRadius(corners->topRight)
190 .setBottomRightRadius(corners->bottomRight)
191 .setBottomLeftRadius(corners->bottomLeft);
193 borders.setBorderRadius(radius);
196 if (!icon && !label) {
200 const float fontHeight = iconSize;
203 icon.setFontSize(fontHeight);
208 std::string content = button.getLabelContent();
210 std::transform(content.begin(), content.end(), content.begin(),
211 [](
unsigned char character) {
212 return static_cast<char>(
213 std::toupper(character));
219 const auto &buttonPose =
222 const bool hasIcon =
static_cast<bool>(icon);
223 const bool hasLabel =
static_cast<bool>(label);
225 const float iconWidth = hasIcon
229 const float iconHeight = hasIcon
233 const float labelWidth = hasLabel
237 const float labelHeight = hasLabel
242 const float gap = (!button.getIconGlyphName().empty()
243 && !button.getLabelContent().empty())
246 const float contentWidth = iconWidth + gap + labelWidth;
247 const float contentHeight = std::max(iconHeight, labelHeight);
251 const float minHeight = (size == Size::ExtraSmall)
254 const float buttonWidth = std::max(
258 const float buttonHeight = std::max(
264 const float y = (buttonHeight - childHeight) / 2.0f;
267 utility::graphic::PositionF(buttonPose.getPosition().x + x,
268 buttonPose.getPosition().y - y,
269 buttonPose.getPosition().z),
270 buttonPose.getOrientation(), layer));
273 float cursor = (buttonWidth - contentWidth) / 2.0f;
276 place(label, cursor, labelHeight);
277 cursor += labelWidth + gap;
280 place(icon, cursor, iconHeight);
284 place(icon, cursor, iconHeight);
285 cursor += iconWidth + gap;
288 place(label, cursor, labelHeight);
293 .setWidth(buttonWidth)
Corner radii and outline stroke of a rectangular entity.
Borders & setWidth(float width)
Set the width of the stroke painted by systems::RectangleRender.
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 disabledContainerColor(void)
Fill color of the container of a disabled widget.
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.
@ Level2
Second raised level.
@ Level1
Lowest raised level.
@ Level0
Flat: no shadow, no tint.
@ LabelLarge
14 / 20, medium weight.
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.