summaryrefslogtreecommitdiffstats
path: root/glow/src/renderer/widget/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-19 17:15:44 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-19 17:15:44 +0200
commit05af8d00d4c0f7b8e0ece85224fd90a92da86da8 (patch)
tree98e4774a2c0d4a2a0a01aff1d772f89c4cb0aa5e /glow/src/renderer/widget/text.rs
parentd4743183d40c6044ce6fa39e2a52919a32912cda (diff)
downloadiced-05af8d00d4c0f7b8e0ece85224fd90a92da86da8.tar.gz
iced-05af8d00d4c0f7b8e0ece85224fd90a92da86da8.tar.bz2
iced-05af8d00d4c0f7b8e0ece85224fd90a92da86da8.zip
Draft new `iced_graphics` crate :tada:
Diffstat (limited to 'glow/src/renderer/widget/text.rs')
-rw-r--r--glow/src/renderer/widget/text.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/glow/src/renderer/widget/text.rs b/glow/src/renderer/widget/text.rs
deleted file mode 100644
index 4605ed06..00000000
--- a/glow/src/renderer/widget/text.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-use crate::{Primitive, Renderer};
-use iced_native::{
- mouse, text, Color, Font, HorizontalAlignment, Rectangle, Size,
- VerticalAlignment,
-};
-
-use std::f32;
-
-impl text::Renderer for Renderer {
- type Font = Font;
-
- const DEFAULT_SIZE: u16 = 20;
-
- fn measure(
- &self,
- content: &str,
- size: u16,
- font: Font,
- bounds: Size,
- ) -> (f32, f32) {
- self.text_pipeline
- .measure(content, f32::from(size), font, bounds)
- }
-
- fn draw(
- &mut self,
- defaults: &Self::Defaults,
- bounds: Rectangle,
- content: &str,
- size: u16,
- font: Font,
- color: Option<Color>,
- horizontal_alignment: HorizontalAlignment,
- vertical_alignment: VerticalAlignment,
- ) -> Self::Output {
- let x = match horizontal_alignment {
- iced_native::HorizontalAlignment::Left => bounds.x,
- iced_native::HorizontalAlignment::Center => bounds.center_x(),
- iced_native::HorizontalAlignment::Right => bounds.x + bounds.width,
- };
-
- let y = match vertical_alignment {
- iced_native::VerticalAlignment::Top => bounds.y,
- iced_native::VerticalAlignment::Center => bounds.center_y(),
- iced_native::VerticalAlignment::Bottom => bounds.y + bounds.height,
- };
-
- (
- Primitive::Text {
- content: content.to_string(),
- size: f32::from(size),
- bounds: Rectangle { x, y, ..bounds },
- color: color.unwrap_or(defaults.text.color),
- font,
- horizontal_alignment,
- vertical_alignment,
- },
- mouse::Interaction::default(),
- )
- }
-}