guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::theme::ShapeScale Class Reference

Turns a ShapeRole into a corner radius in dp, scaled by one "roundness" value. More...

#include <headers/guillaume/theme/tokens.hpp>

Public Member Functions

 ShapeScale (void)=default
 Create a scale with DefaultRoundness.
float getRoundness (void) const
 Get the roundness of the scale.
void setRoundness (float roundness)
 Change the roundness, which rescales every role except None and Full.
float getRadius (ShapeRole role) const
 Get the corner radius of a role for the current roundness.

Static Public Attributes

static constexpr float FullRadius = 10000.0f
 Radius returned for ShapeRole::Full, in dp. Renderers clamp radii to half the smallest extent, which yields a pill or a circle.
static constexpr float DefaultRoundness = 4.0f
 The roundness for which each role has the radius listed in ShapeRole.

Detailed Description

Turns a ShapeRole into a corner radius in dp, scaled by one "roundness" value.

The roundness is the single knob of the scale (the name comes from react-native-paper, whose Material 3 themes use 4). Every role scales linearly with it: radius = base * roundness / 4, where base is the value listed in ShapeRole. None stays 0 and Full stays FullRadius whatever the roundness.

Read it through guillaume::getShapeRadius. To make the whole UI squarer or rounder, change the roundness in a copy of the theme:

theme.getShapes().setRoundness(8.0f); // Medium becomes 24 dp
Every design token of the UI in one object: colors, type scale, corner shapes, elevation,...
Definition theme.hpp:535
Design tokens: colors, type scale, shapes, elevation, motion and spacing. Read them through guillaume...
const Theme & getActiveTheme(void)
Get the theme every widget and system reads its tokens from.
void setActiveTheme(const Theme &theme)
Replace the active theme by a copy of another theme.
See also
guillaume::Theme::getShapes

Definition at line 73 of file tokens.hpp.

Member Function Documentation

◆ getRadius()

float guillaume::theme::ShapeScale::getRadius ( ShapeRole role) const

Get the corner radius of a role for the current roundness.

Parameters
roleThe shape role to resolve.
Returns
The corner radius, in dp.
Exceptions
std::out_of_rangeWhen role is ShapeRole::Count.

Definition at line 55 of file tokens.cpp.

◆ getRoundness()

float guillaume::theme::ShapeScale::getRoundness ( void ) const

Get the roundness of the scale.

Returns
The roundness; 4 by default, 0 for square corners everywhere except Full.

Definition at line 42 of file tokens.cpp.

◆ setRoundness()

void guillaume::theme::ShapeScale::setRoundness ( float roundness)

Change the roundness, which rescales every role except None and Full.

Parameters
roundnessThe new roundness. 4 gives the Material 3 radii, 8 doubles them, 0 makes corners square.
Exceptions
std::invalid_argumentWhen roundness is negative.

Definition at line 47 of file tokens.cpp.

Member Data Documentation

◆ DefaultRoundness

float guillaume::theme::ShapeScale::DefaultRoundness = 4.0f
staticconstexpr

The roundness for which each role has the radius listed in ShapeRole.

Definition at line 86 of file tokens.hpp.

◆ FullRadius

float guillaume::theme::ShapeScale::FullRadius = 10000.0f
staticconstexpr

Radius returned for ShapeRole::Full, in dp. Renderers clamp radii to half the smallest extent, which yields a pill or a circle.

Definition at line 80 of file tokens.hpp.


The documentation for this class was generated from the following files: