Introduce text::Alignment with Justified support

This commit is contained in:
Héctor Ramón Jiménez 2025-03-11 02:25:44 +01:00
parent e45d4b5cb6
commit 0e4a392731
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
30 changed files with 227 additions and 195 deletions

View file

@ -150,12 +150,12 @@ impl<Message> canvas::Program<Message> for Clock {
-width * 2.0,
),
color: palette.secondary.strong.text,
horizontal_alignment: if rotate_factor > 0.0 {
align_x: if rotate_factor > 0.0 {
alignment::Horizontal::Right
} else {
alignment::Horizontal::Left
},
vertical_alignment: alignment::Vertical::Bottom,
align_y: alignment::Vertical::Bottom,
font: Font::MONOSPACE,
..canvas::Text::default()
});
@ -173,8 +173,8 @@ impl<Message> canvas::Program<Message> for Clock {
size: (radius / 5.0).into(),
position: Point::new(x * 0.82, y * 0.82),
color: palette.secondary.strong.text,
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Center,
align_x: alignment::Horizontal::Center,
align_y: alignment::Vertical::Center,
font: Font::MONOSPACE,
..canvas::Text::default()
});

View file

@ -170,8 +170,8 @@ impl Theme {
});
let mut text = canvas::Text {
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Top,
align_x: alignment::Horizontal::Center,
align_y: alignment::Vertical::Top,
size: Pixels(15.0),
color: text_color,
..canvas::Text::default()
@ -214,7 +214,7 @@ impl Theme {
});
}
text.vertical_alignment = alignment::Vertical::Bottom;
text.align_y = alignment::Vertical::Bottom;
let hsl = Hsl::from_color(Rgb::from(self.base));
for i in 0..self.len() {

View file

@ -580,8 +580,8 @@ mod grid {
color: Color::WHITE,
size: 14.0.into(),
position: Point::new(frame.width(), frame.height()),
horizontal_alignment: alignment::Horizontal::Right,
vertical_alignment: alignment::Vertical::Bottom,
align_x: alignment::Horizontal::Right,
align_y: alignment::Vertical::Bottom,
..Text::default()
};

View file

@ -194,8 +194,8 @@ impl Tour {
fn welcome(&self) -> Column<Message> {
Self::container("Welcome!")
.push(
"This is a simple tour meant to showcase a bunch of widgets \
that can be easily implemented on top of Iced.",
"This is a simple tour meant to showcase a bunch of \
widgets that can be easily implemented on top of Iced.",
)
.push(
"Iced is a cross-platform GUI library for Rust focused on \
@ -211,12 +211,12 @@ impl Tour {
Metal, DX11, and DX12.",
)
.push(
"Additionally, this tour can also run on WebAssembly thanks \
to dodrio, an experimental VDOM library for Rust.",
"Additionally, this tour can also run on WebAssembly \
thanks to dodrio, an experimental VDOM library for Rust.",
)
.push(
"You will need to interact with the UI in order to reach the \
end!",
"You will need to interact with the UI in order to reach \
the end!",
)
}

View file

@ -142,8 +142,8 @@ impl<Message> canvas::Program<Message> for State {
} else {
"Vectorial Text! 🎉"
}),
horizontal_alignment: alignment::Horizontal::Center,
vertical_alignment: alignment::Vertical::Center,
align_x: alignment::Horizontal::Center,
align_y: alignment::Vertical::Center,
shaping: text::Shaping::Advanced,
..canvas::Text::default()
});