summaryrefslogtreecommitdiffstats
path: root/native/src/widget/text.rs
diff options
context:
space:
mode:
authorLibravatar Giuliano Bellini <100347457+GyulyVGC@users.noreply.github.com>2023-02-22 21:23:04 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-22 21:23:04 +0100
commit4f41927155e7d4bc38497b0e298a0b23ccea6ca1 (patch)
tree70b7dbc1afdc62dfeaf42f0c62e8f4c01e407729 /native/src/widget/text.rs
parenta35d6d2e4d59f71309f31c87ea5150959d639185 (diff)
parent666f3cd143047e49a010f0c97eabc7136f92aa35 (diff)
downloadiced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.tar.gz
iced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.tar.bz2
iced-4f41927155e7d4bc38497b0e298a0b23ccea6ca1.zip
Merge branch 'iced-rs:master' into master
Diffstat (limited to 'native/src/widget/text.rs')
-rw-r--r--native/src/widget/text.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs
index be9e775e..3fee48f2 100644
--- a/native/src/widget/text.rs
+++ b/native/src/widget/text.rs
@@ -4,7 +4,7 @@ use crate::layout;
use crate::renderer;
use crate::text;
use crate::widget::Tree;
-use crate::{Element, Layout, Length, Point, Rectangle, Size, Widget};
+use crate::{Element, Layout, Length, Pixels, Point, Rectangle, Size, Widget};
use std::borrow::Cow;
@@ -32,7 +32,7 @@ where
Renderer::Theme: StyleSheet,
{
content: Cow<'a, str>,
- size: Option<u16>,
+ size: Option<f32>,
width: Length,
height: Length,
horizontal_alignment: alignment::Horizontal,
@@ -61,8 +61,8 @@ where
}
/// Sets the size of the [`Text`].
- pub fn size(mut self, size: u16) -> Self {
- self.size = Some(size);
+ pub fn size(mut self, size: impl Into<Pixels>) -> Self {
+ self.size = Some(size.into().0);
self
}
@@ -84,14 +84,14 @@ where
}
/// Sets the width of the [`Text`] boundaries.
- pub fn width(mut self, width: Length) -> Self {
- self.width = width;
+ pub fn width(mut self, width: impl Into<Length>) -> Self {
+ self.width = width.into();
self
}
/// Sets the height of the [`Text`] boundaries.
- pub fn height(mut self, height: Length) -> Self {
- self.height = height;
+ pub fn height(mut self, height: impl Into<Length>) -> Self {
+ self.height = height.into();
self
}
@@ -185,7 +185,7 @@ pub fn draw<Renderer>(
style: &renderer::Style,
layout: Layout<'_>,
content: &str,
- size: Option<u16>,
+ size: Option<f32>,
font: Renderer::Font,
appearance: Appearance,
horizontal_alignment: alignment::Horizontal,
@@ -209,7 +209,7 @@ pub fn draw<Renderer>(
renderer.fill_text(crate::text::Text {
content,
- size: f32::from(size.unwrap_or_else(|| renderer.default_size())),
+ size: size.unwrap_or_else(|| renderer.default_size()),
bounds: Rectangle { x, y, ..bounds },
color: appearance.color.unwrap_or(style.text_color),
font,