pub struct Text<'a> {
pub content: StrRef<'a>,
pub font_size: u8,
pub flags: u8,
pub color: Color,
}Expand description
文本原语节点。
Fields§
§content: StrRef<'a>§font_size: u8§flags: u8位域:align(2b: 0=Left, 1=Center, 2=Right) | ellipsis(1b: 0x04) | nowrap(1b: 0x08) | explicit_size(1b: 0x10) | explicit_color(1b: 0x20)。
color: ColorImplementations§
Source§impl<'a> Text<'a>
impl<'a> Text<'a>
pub const fn text_xs(self) -> Self
pub const fn text_sm(self) -> Self
pub const fn text_base(self) -> Self
pub const fn text_lg(self) -> Self
pub const fn text_xl(self) -> Self
pub const fn text_2xl(self) -> Self
pub const fn text_3xl(self) -> Self
Sourcepub const fn text_color(self, color: Color) -> Self
pub const fn text_color(self, color: Color) -> Self
设置文本颜色(与 GPUI .text_color(...) 对齐的别名)。
Sourcepub const fn has_explicit_size(&self) -> bool
pub const fn has_explicit_size(&self) -> bool
是否显式覆盖了字号(否则继承父 Div 的 text_size)。
Sourcepub const fn has_explicit_color(&self) -> bool
pub const fn has_explicit_color(&self) -> bool
是否显式覆盖了颜色(否则继承父 Div 的 text_color)。
Sourcepub const fn text_center(self) -> Self
pub const fn text_center(self) -> Self
设置文本水平居中对齐。
Sourcepub const fn text_right(self) -> Self
pub const fn text_right(self) -> Self
设置文本右对齐。
Sourcepub fn text_start(self, cx: &FrameScope) -> Self
pub fn text_start(self, cx: &FrameScope) -> Self
按当前语言的书写方向自动设置“逻辑起始端对齐”(LTR 为左对齐,RTL 如阿拉伯语/希伯来语自动镜像为右对齐)。
Sourcepub fn text_end(self, cx: &FrameScope) -> Self
pub fn text_end(self, cx: &FrameScope) -> Self
按当前语言的书写方向自动设置“逻辑末端对齐”(LTR 为右对齐,RTL 自动镜像为左对齐)。
Sourcepub const fn text_align(&self) -> TextAlign
pub const fn text_align(&self) -> TextAlign
读取水平对齐方式。
Sourcepub const fn is_ellipsis(&self) -> bool
pub const fn is_ellipsis(&self) -> bool
是否启用省略号截断。
Trait Implementations§
impl<'a> Copy for Text<'a>
Source§impl<'a> IntoElement<'a> for Text<'a>
impl<'a> IntoElement<'a> for Text<'a>
fn into_element(self, _cx: &'a FrameScope) -> Element<'a>
Source§fn into_any_element(self, cx: &'a FrameScope) -> Element<'a>
fn into_any_element(self, cx: &'a FrameScope) -> Element<'a>
与 GPUI
.into_any_element() 对应的语义别名(零堆分配返回闭合枚举 Element<'a>)。Auto Trait Implementations§
impl<'a> Forget for Text<'a>
impl<'a> Freeze for Text<'a>
impl<'a> Move for Text<'a>
impl<'a> RefUnwindSafe for Text<'a>
impl<'a> Send for Text<'a>
impl<'a> Sync for Text<'a>
impl<'a> Unpin for Text<'a>
impl<'a> UnsafeUnpin for Text<'a>
impl<'a> UnwindSafe for Text<'a>
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,
Source§impl<T> FluentBuilder for T
impl<T> FluentBuilder for T
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
当
condition 为 true 时执行闭包修饰自身,否则原样返回。Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Self
fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
根据
condition 在两个修饰分支之间二选一。Source§fn when_some<O>(
self,
option: Option<O>,
then: impl FnOnce(Self, O) -> Self,
) -> Self
fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self
当
option 为 Some(value) 时执行闭包修饰自身,否则原样返回。