ui/core/material/cfmaterial_radius_scale.h¶
Material Design 3 Radius Scale with EmbeddedTokenRegistry. More...
Namespaces¶
| Name |
|---|
| cf |
| cf::ui |
| cf::ui::core |
| cf::ui::core::tokens |
Classes¶
| Name | |
|---|---|
| class | cf::ui::core::MaterialRadiusScale Material Design 3 Radius Scale with EmbeddedTokenRegistry. |
Detailed Description¶
Material Design 3 Radius Scale with EmbeddedTokenRegistry.
Author: Charliechen114514 (chengh1922@mails.jlu.edu.cn)
Version: 0.1
Date: 2026-02-26
Copyright: Copyright © 2026
Implements the complete Material Design 3 corner radius system with 7 scales. Radii are stored in an embedded registry for independent radius scale instances.
Source code¶
#pragma once
#include <string>
#include <unordered_map>
#include "../export.h"
#include "base/hash/constexpr_fnv1a.hpp"
#include "radius_scale.h"
#include "token.hpp"
#include "token/radius_scale/cfmaterial_radius_scale_literals.h"
namespace cf::ui::core {
// =============================================================================
// Radius Scale Token Type Aliases - Material Radius Scale System
// =============================================================================
namespace tokens {
using namespace cf::ui::core::token::literals;
using CornerNoneToken = StaticToken<float, cf::hash::fnv1a64(CORNER_NONE)>;
using CornerExtraSmallToken = StaticToken<float, cf::hash::fnv1a64(CORNER_EXTRA_SMALL)>;
using CornerSmallToken = StaticToken<float, cf::hash::fnv1a64(CORNER_SMALL)>;
using CornerMediumToken = StaticToken<float, cf::hash::fnv1a64(CORNER_MEDIUM)>;
using CornerLargeToken = StaticToken<float, cf::hash::fnv1a64(CORNER_LARGE)>;
using CornerExtraLargeToken = StaticToken<float, cf::hash::fnv1a64(CORNER_EXTRA_LARGE)>;
using CornerExtraExtraLargeToken = StaticToken<float, cf::hash::fnv1a64(CORNER_EXTRA_EXTRA_LARGE)>;
} // namespace tokens
// =============================================================================
// Material Radius Scale - 实现 IRadiusScale 接口
// =============================================================================
class CF_UI_EXPORT MaterialRadiusScale : public IRadiusScale {
public:
MaterialRadiusScale();
~MaterialRadiusScale() override = default;
// Non-copyable, movable
MaterialRadiusScale(const MaterialRadiusScale&) = delete;
MaterialRadiusScale& operator=(const MaterialRadiusScale&) = delete;
MaterialRadiusScale(MaterialRadiusScale&&) noexcept = default;
MaterialRadiusScale& operator=(MaterialRadiusScale&&) noexcept = default;
float queryRadiusScale(const char* name) override;
EmbeddedTokenRegistry& registry() { return registry_; }
const EmbeddedTokenRegistry& registry() const { return registry_; }
private:
void registerDefaultCorners();
EmbeddedTokenRegistry registry_;
mutable std::unordered_map<std::string, float> radius_cache_;
};
} // namespace cf::ui::core
Updated on 2026-03-09 at 10:14:01 +0000