Skip to main content

Module theme

Module theme 

Source
Expand description

阶段 4-A:Theme + Direction — 第一个 InheritedWidget 用例

设计文档 § 6 + § 19.Theme:全局视觉风格沿树向下传递。

ⓘ
ThemeWidget::new(ThemeData::dark())
    .direction(Direction::Ltr)
    .child(MyApp())

任何后代 widget 在 state.build(ctx) 中调 ctx.depend_on::<ThemeWidget>() 或 便捷的 ctx.theme() / ctx.direction() 拿当前主题。

Re-exports§

pub use tokens::define_theme;
pub use tokens::overlay;
pub use tokens::ColorToken;
pub use tokens::DurationToken;
pub use tokens::EasingToken;
pub use tokens::FocusTokens;
pub use tokens::FontFamilyToken;
pub use tokens::FontSizeToken;
pub use tokens::FontWeightToken;
pub use tokens::LengthToken;
pub use tokens::RadiusTokens;
pub use tokens::Shadow;
pub use tokens::ShadowLayer;
pub use tokens::ShadowToken;
pub use tokens::SizeTokens;
pub use tokens::SpacingStep;
pub use tokens::TextRole;
pub use tokens::TextRoleStyle;
pub use tokens::ThemeDefinition;
pub use tokens::TokenError;
pub use tokens::TokenOverrides;
pub use tokens::Tokens;
pub use tokens::Value as TokenValue;
pub use tokens::Variant;

Modules§

tokens
Design token 层 —— 按 Astryx(Meta 开源设计系统)的 token 命名与取值定义,让 mgui 的主题可以逐 token 修改,而不是一整套换掉。

Structs§

AvatarStyle
Avatar 样式(首字头像)。
ButtonStyle
Button style defaults.
ButtonVariantStyle
单个按钮变体的五态配色。
ButtonVariants
全部按钮变体。
ControlGeometry
表单控件的几何令牌(Checkbox / Radio 的指示器尺寸、描边、焦点环)。
ControlStyle
表单控件(Checkbox / Radio / Toggle / Slider)的控件令牌,由 Astryx token 推导(见 ThemeData::from_tokens)。
DialogStyle
Dialog 遮罩 + 对话框样式。
DirectionWidget
单独的 Direction 提供者,方便只想换方向不换主题的场景。
DropdownStyle
Dropdown 触发器 + 弹出面板样式。
FeedbackStyle
反馈类组件样式(进度条 / Toast 等)。
InputStyle
TextField / 输入框样式(描边输入框 + 主色焦点环,颜色全部来自 --color-*)。
ListStyle
ListView / 列表类样式。
LocaleSnapshot
应用级语言快照。只存 BCP-47 子集 tag,不依赖 i18n crate;mgui-i18n 负责解析/格式化。
LocaleWidget
语言提供者。切换语言时替换 LocaleWidget,后代通过 ctx.locale() 自动 dirty。
MenuStyle
菜单 / 右键 ContextMenu / 下拉列表样式。
NavStyle
NavigationMenu 样式。
ScrollbarStyle
SpacingScale
4pt 间距刻度 + 组件默认间距(由 --spacing-* 生成)。
TabStyle
TabBar / TabView / TabbedPane 样式。
TextStyleTheme
TextTheme
Text style defaults (theme-level). Individual TextWidget can override via TextStyle.
ThemeData
主题色板 + 子主题。
ThemeWidget
Theme 提供者 widget。挂到树中,所有后代可通过 ctx.theme() 访问。
TooltipStyle
Tooltip 浮层样式。

Enums§

ButtonVariant
按钮语义变体(对应组件侧 ButtonType)。
Direction

Constants§

MGUI_INDICATOR_SIZE
Checkbox / Radio 指示器边长。

Functions§

resolve_color
用户显式颜色优先,否则回退到主题/token 值。
resolve_f32
数值版 resolve_color:显式尺寸/宽度优先,否则用主题/回退值。