跳转至

cf::ui::core::material

Namespaces

Name
cf::ui::core::material::detail

Classes

Name
struct cf::ui::core::material::MaterialSchemeError
Error type for material scheme operations.

Types

Name
using cf::expected< MaterialColorScheme, MaterialSchemeError > Result
Result type for factory functions.

Functions

Name
MaterialColorScheme light()
Creates Material Design 3 default light theme.
MaterialColorScheme dark()
Creates Material Design 3 default dark theme.
Result fromJson(constQByteArray & json, bool isDark =false)
Creates color scheme from Material Theme Builder JSON.
MaterialColorScheme fromKeyColor(cf::ui::base::CFColor keyColor, bool isDark =false)
Creates dynamic color scheme from a key color.
QByteArray toJson(constMaterialColorScheme & scheme)
Converts a MaterialColorScheme to JSON format.
MaterialTypography defaultTypography()
Creates default Material Design 3 typography scale.
MaterialRadiusScale defaultRadiusScale()
Creates default Material Design 3 radius scale.
MaterialMotionScheme motion()
Creates default Material Design 3 motion scheme.

Types Documentation

using Result

using cf::ui::core::material::Result = typedef cf::expected<MaterialColorScheme, MaterialSchemeError>;

Result type for factory functions.

Since: 0.1

Functions Documentation

function light

MaterialColorScheme light()

Creates Material Design 3 default light theme.

Return: MaterialColorScheme with light theme colors.

Since: 0.1

Uses the official Material Design 3 baseline purple color scheme.

auto lightScheme = cf::ui::core::material::light();
QColor primary = lightScheme.queryExpectedColor("md.primary");

function dark

MaterialColorScheme dark()

Creates Material Design 3 default dark theme.

Return: MaterialColorScheme with dark theme colors.

Since: 0.1

Uses the official Material Design 3 baseline purple color scheme adapted for dark mode.

function fromJson

Result fromJson(
    constQByteArray & json,
    bool isDark =false
)

Creates color scheme from Material Theme Builder JSON.

Parameters:

  • json JSON export from Material Theme Builder.
  • isDark Whether to use light or dark scheme from JSON (default: false).

Return: MaterialColorScheme parsed from JSON, or error.

Since: 0.1

Supports the Material Theme Builder export format with the following structure:

{
  "schemes": {
    "light": { "primary": "#6750A4", ... },
    "dark": { "primary": "#D0BCFF", ... }
  }
}

Also supports direct color values:

{
  "primary": "#6750A4",
  "onPrimary": "#FFFFFF",
  ...
}

function fromKeyColor

MaterialColorScheme fromKeyColor(
    cf::ui::base::CFColor keyColor,
    bool isDark =false
)

Creates dynamic color scheme from a key color.

Parameters:

  • keyColor Source color for generating the scheme.
  • isDark Whether to generate a dark scheme (default: false).

Return: MaterialColorScheme generated from the key color.

Since: 0.1

Implements Material You dynamic color generation using the HCT color space and tonal palette algorithm.

function toJson

QByteArray toJson(
    constMaterialColorScheme & scheme
)

Converts a MaterialColorScheme to JSON format.

Parameters:

  • scheme The color scheme to export.

Return: JSON representation of the color scheme.

Since: 0.1

Exports the scheme in Material Theme Builder compatible format.

function defaultTypography

MaterialTypography defaultTypography()

Creates default Material Design 3 typography scale.

Return: MaterialTypography with default configuration.

Since: 0.1

Uses system default sans-serif font with MD3 specified sizes and weights.

auto typography = cf::ui::core::material::defaultTypography();
QFont titleFont = typography.queryTargetFont("md.typography.titleLarge");

function defaultRadiusScale

MaterialRadiusScale defaultRadiusScale()

Creates default Material Design 3 radius scale.

Return: MaterialRadiusScale with default configuration.

Since: 0.1

Uses Material Design 3 specified corner radius values.

auto radiusScale = cf::ui::core::material::defaultRadiusScale();
float smallRadius = radiusScale.queryRadiusScale("md.shape.cornerSmall"); // 8.0f

function motion

MaterialMotionScheme motion()

Creates default Material Design 3 motion scheme.

Return: MaterialMotionScheme with default configuration.

Since: 0.1

Uses Material Design 3 specified duration and easing values for animations.

auto motionScheme = cf::ui::core::material::motion();
int duration = motionScheme.queryDuration("shortEnter"); // 200
auto spec = motionScheme.getMotionSpec("mediumExit");

Updated on 2026-03-09 at 10:14:00 +0000