Converted txt_align to use Align.
This commit is contained in:
parent
9ba619944e
commit
e6024fa6f5
|
@ -230,7 +230,7 @@ fn delayed_focus() -> impl UiNode {
|
|||
corner_radius = 4;
|
||||
txt = "delayed target";
|
||||
font_style = FontStyle::Italic;
|
||||
txt_align = TextAlign::CENTER_MIDDLE;
|
||||
txt_align = Align::CENTER;
|
||||
background_color = color_scheme_map(rgb(30, 30, 30), rgb(225, 225, 225));
|
||||
|
||||
focusable = true;
|
||||
|
|
|
@ -233,7 +233,7 @@ fn title(title: Text) -> impl UiNode {
|
|||
text! {
|
||||
txt = title;
|
||||
font_size = 24;
|
||||
txt_align = TextAlign::CENTER;
|
||||
txt_align = Align::CENTER;
|
||||
}
|
||||
}
|
||||
fn sub_title(title: impl Into<Text>) -> impl UiNode {
|
||||
|
@ -246,6 +246,6 @@ fn size_label(size: Text) -> impl UiNode {
|
|||
text! {
|
||||
txt = size;
|
||||
font_size = 10;
|
||||
txt_align = TextAlign::CENTER;
|
||||
txt_align = Align::CENTER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ pub struct ShapedText {
|
|||
/// vertical align offset applied.
|
||||
y_offset: f32,
|
||||
align_box: PxRect,
|
||||
align: TextAlign,
|
||||
align: Align,
|
||||
}
|
||||
impl ShapedText {
|
||||
/// New empty text.
|
||||
|
@ -410,7 +410,7 @@ impl ShapedText {
|
|||
}
|
||||
|
||||
/// Last applied alignment.
|
||||
pub fn align(&self) -> TextAlign {
|
||||
pub fn align(&self) -> Align {
|
||||
self.align
|
||||
}
|
||||
|
||||
|
@ -429,7 +429,7 @@ impl ShapedText {
|
|||
line_height: Px,
|
||||
line_spacing: Px,
|
||||
align_box: impl FnOnce(PxSize) -> PxRect,
|
||||
align: TextAlign,
|
||||
align: Align,
|
||||
) {
|
||||
//
|
||||
// Line Height & Spacing
|
||||
|
@ -527,7 +527,7 @@ impl ShapedText {
|
|||
self.og_line_height,
|
||||
self.og_line_spacing,
|
||||
|_| PxRect::zero(),
|
||||
TextAlign::LEFT,
|
||||
Align::START,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -625,7 +625,7 @@ impl ShapedText {
|
|||
underline_descent: self.underline_descent,
|
||||
y_offset: 0.0,
|
||||
align_box: PxRect::zero(),
|
||||
align: TextAlign::LEFT,
|
||||
align: Align::START,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,7 +669,7 @@ impl ShapedText {
|
|||
underline_descent: self.underline_descent,
|
||||
y_offset: 0.0,
|
||||
align_box: PxRect::zero(),
|
||||
align: TextAlign::LEFT,
|
||||
align: Align::START,
|
||||
};
|
||||
|
||||
if self.lines.0.is_empty() || self.lines.last().end <= self.segments.0.len() {
|
||||
|
@ -808,7 +808,7 @@ impl ShapedText {
|
|||
self.line_height,
|
||||
self.line_spacing,
|
||||
|_| PxRect::zero(),
|
||||
TextAlign::LEFT,
|
||||
Align::START,
|
||||
);
|
||||
|
||||
if self.is_empty() {
|
||||
|
@ -917,7 +917,7 @@ impl ShapedTextBuilder {
|
|||
underline_descent: Default::default(),
|
||||
y_offset: 0.0,
|
||||
align_box: PxRect::zero(),
|
||||
align: TextAlign::LEFT,
|
||||
align: Align::START,
|
||||
},
|
||||
|
||||
line_height: 0.0,
|
||||
|
|
|
@ -933,8 +933,8 @@ pub mod prelude {
|
|||
CapsVariant, CharVariant, CnVariant, EastAsianWidth, FontPosition, FontStyleSet, JpVariant, NumFraction, NumSpacing,
|
||||
NumVariant,
|
||||
},
|
||||
formatx, lang, FontFeatures, FontName, FontNames, FontStretch, FontStyle, FontWeight, Fonts, Hyphens, LineBreak, Text,
|
||||
TextAlign, TextTransformFn, ToText, UnderlinePosition, UnderlineSkip, WhiteSpace, WordBreak,
|
||||
formatx, lang, FontFeatures, FontName, FontNames, FontStretch, FontStyle, FontWeight, Fonts, Hyphens, Justify, LineBreak, Text,
|
||||
TextTransformFn, ToText, UnderlinePosition, UnderlineSkip, WhiteSpace, WordBreak,
|
||||
},
|
||||
units::{
|
||||
rotate, scale, scale_x, scale_xy, scale_y, skew, skew_x, skew_y, translate, translate_x, translate_y, Align, AngleUnits,
|
||||
|
|
|
@ -50,8 +50,11 @@ context_var! {
|
|||
/// Configuration of line breaks in Chinese, Japanese, or Korean text.
|
||||
pub static LINE_BREAK_VAR: LineBreak = LineBreak::Auto;
|
||||
|
||||
/// Text line alignment in a text block.
|
||||
pub static TEXT_ALIGN_VAR: TextAlign = TextAlign::START;
|
||||
/// Text line alignment inside a text block.
|
||||
pub static TEXT_ALIGN_VAR: Align = Align::START;
|
||||
|
||||
/// Text justify mode when text align is fill.
|
||||
pub static JUSTIFY_VAR: Option<Justify> = None;
|
||||
|
||||
/// Length of the `TAB` space.
|
||||
pub static TAB_LENGTH_VAR: TabLength = 400.pct();
|
||||
|
@ -287,10 +290,16 @@ pub fn line_break(child: impl UiNode, mode: impl IntoVar<LineBreak>) -> impl UiN
|
|||
|
||||
/// Sets the [`TEXT_ALIGN_VAR`] context var.
|
||||
#[property(CONTEXT, default(TEXT_ALIGN_VAR))]
|
||||
pub fn txt_align(child: impl UiNode, mode: impl IntoVar<TextAlign>) -> impl UiNode {
|
||||
pub fn txt_align(child: impl UiNode, mode: impl IntoVar<Align>) -> impl UiNode {
|
||||
with_context_var(child, TEXT_ALIGN_VAR, mode)
|
||||
}
|
||||
|
||||
/// Sets the [`JUSTIFY_VAR`] context var.
|
||||
#[property(CONTEXT, default(JUSTIFY_VAR))]
|
||||
pub fn justify(child: impl UiNode, mode: impl IntoVar<Option<Justify>>) -> impl UiNode {
|
||||
with_context_var(child, JUSTIFY_VAR, mode)
|
||||
}
|
||||
|
||||
/// Sets the [`TAB_LENGTH_VAR`] context var.
|
||||
#[property(CONTEXT, default(TAB_LENGTH_VAR))]
|
||||
pub fn tab_length(child: impl UiNode, length: impl IntoVar<TabLength>) -> impl UiNode {
|
||||
|
|
Loading…
Reference in New Issue