iced-yoda/graphics/src/widget/text.rs

52 lines
1.1 KiB
Rust
Raw Normal View History

2020-05-19 17:15:44 +02:00
//! Write some text for your users to read.
2020-05-19 21:00:40 +02:00
use crate::backend::{self, Backend};
use crate::Renderer;
2020-05-19 21:00:40 +02:00
use iced_native::text;
use iced_native::{Font, Point, Size};
2020-05-19 17:15:44 +02:00
/// A paragraph of text.
///
/// This is an alias of an `iced_native` text with an `iced_wgpu::Renderer`.
pub type Text<Backend> = iced_native::Text<Renderer<Backend>>;
2020-05-19 21:00:40 +02:00
use std::f32;
impl<B> text::Renderer for Renderer<B>
where
B: Backend + backend::Text,
{
fn default_size(&self) -> u16 {
self.backend().default_size()
}
2020-05-19 21:00:40 +02:00
fn measure(
&self,
content: &str,
size: u16,
font: Font,
bounds: Size,
) -> (f32, f32) {
self.backend()
.measure(content, f32::from(size), font, bounds)
}
2021-08-21 10:31:26 -07:00
fn hit_test(
&self,
content: &str,
size: f32,
font: Font,
bounds: Size,
point: Point,
nearest_only: bool,
) -> Option<text::Hit> {
2021-08-21 10:31:26 -07:00
self.backend().hit_test(
content,
size,
font,
bounds,
point,
nearest_only,
)
}
2020-05-19 21:00:40 +02:00
}