summaryrefslogtreecommitdiffstats
path: root/native/src/widget/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-04 16:41:18 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-02-17 15:47:51 +0100
commit570600ce513e7e02b23c1da8322c68fbb876d1b0 (patch)
treecf0c03e34469ad9005288e627e37f69d75aad0e7 /native/src/widget/text.rs
parent7b8b01f560569ae18d9337a31ba94f6c1c2ba0dd (diff)
downloadiced-570600ce513e7e02b23c1da8322c68fbb876d1b0.tar.gz
iced-570600ce513e7e02b23c1da8322c68fbb876d1b0.tar.bz2
iced-570600ce513e7e02b23c1da8322c68fbb876d1b0.zip
Use `Pixels` for `Text::size`
Diffstat (limited to '')
-rw-r--r--native/src/widget/text.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs
index bac1adcf..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
}
@@ -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,