pub struct Theme {Show 21 fields
pub colors: ThemeColor,
pub tokens: ThemeTokens,
pub highlight_theme: Arc<HighlightTheme>,
pub light_theme: Rc<ThemeConfig>,
pub dark_theme: Rc<ThemeConfig>,
pub mode: ThemeMode,
pub font_family: SharedString,
pub font_size: Pixels,
pub mono_font_family: SharedString,
pub mono_font_size: Pixels,
pub radius: Pixels,
pub radius_lg: Pixels,
pub shadow: bool,
pub transparent: Hsla,
pub scrollbar_show: ScrollbarShow,
pub notification: NotificationSettings,
pub tile_grid_size: Pixels,
pub tile_shadow: bool,
pub tile_radius: Pixels,
pub list: ListSettings,
pub sheet: SheetSettings,
}Expand description
全局主题配置。
Fields§
§colors: ThemeColor主题颜色。
tokens: ThemeTokens主题令牌(颜色 + 背景)。
highlight_theme: Arc<HighlightTheme>代码高亮主题。
light_theme: Rc<ThemeConfig>亮色主题配置。
dark_theme: Rc<ThemeConfig>暗色主题配置。
mode: ThemeMode主题模式。
font_family: SharedString应用字体族,默认 .SystemUIFont。
font_size: Pixels基础字号,默认 16px。
mono_font_family: SharedString等宽字体族。
默认值:
- macOS:
Menlo - Windows:
Consolas - Linux:
DejaVu Sans Mono
mono_font_size: Pixels等宽字号,默认 13px。
radius: Pixels常规元素圆角。
radius_lg: Pixels大元素圆角(如 Dialog、Notification)。
shadow: bool是否启用阴影。
transparent: Hsla透明色。
scrollbar_show: ScrollbarShow滚动条显示模式,默认:Scrolling。
notification: NotificationSettings通知设置。
tile_grid_size: Pixels磁贴网格尺寸,默认 4px。
tile_shadow: bool磁贴面板阴影。
tile_radius: Pixels磁贴面板圆角,默认 0px。
list: ListSettingsList 设置。
sheet: SheetSettingsSheet 设置。
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn apply_config(&mut self, config: &Rc<ThemeConfig>)
pub fn apply_config(&mut self, config: &Rc<ThemeConfig>)
将给定的主题配置应用到当前主题。
Source§impl Theme
impl Theme
Sourcepub fn global_mut(cx: &mut App) -> &mut Theme
pub fn global_mut(cx: &mut App) -> &mut Theme
返回全局主题可变引用。
Sourcepub fn theme_name(&self) -> &SharedString
pub fn theme_name(&self) -> &SharedString
返回当前主题名称。
Sourcepub fn sync_system_appearance(window: Option<&mut Window>, cx: &mut App)
pub fn sync_system_appearance(window: Option<&mut Window>, cx: &mut App)
与系统外观同步主题。
Sourcepub fn sync_scrollbar_appearance(cx: &mut App)
pub fn sync_scrollbar_appearance(cx: &mut App)
与系统同步滚动条显示行为。
Sourcepub fn change(
mode: impl Into<ThemeMode>,
window: Option<&mut Window>,
cx: &mut App,
)
pub fn change( mode: impl Into<ThemeMode>, window: Option<&mut Window>, cx: &mut App, )
切换主题模式。
Sourcepub fn input_background(&self) -> Hsla
pub fn input_background(&self) -> Hsla
获取输入框背景色。
暗色模式下使用透明色与输入框边框混合:cx.theme().input,
亮色模式下使用 cx.theme().background 颜色。
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Theme
impl<'de> Deserialize<'de> for Theme
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&ThemeColor> for Theme
impl From<&ThemeColor> for Theme
Source§fn from(colors: &ThemeColor) -> Self
fn from(colors: &ThemeColor) -> Self
Converts to this type from the input type.
impl Global for Theme
Source§impl JsonSchema for Theme
impl JsonSchema for Theme
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl !Send for Theme
impl !Sync for Theme
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl UnwindSafe for Theme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReadGlobal for Twhere
T: Global,
impl<T> ReadGlobal for Twhere
T: Global,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> UpdateGlobal for Twhere
T: Global,
impl<T> UpdateGlobal for Twhere
T: Global,
Source§fn update_global<C, F, R>(cx: &mut C, update: F) -> R
fn update_global<C, F, R>(cx: &mut C, update: F) -> R
使用提供的闭包更新全局实例。 Read more
Source§fn set_global<C>(cx: &mut C, global: T)where
C: BorrowAppContext,
fn set_global<C>(cx: &mut C, global: T)where
C: BorrowAppContext,
设置全局实例。