diff options
author | 2021-08-26 14:41:33 +0700 | |
---|---|---|
committer | 2021-08-26 14:41:33 +0700 | |
commit | 7614127d3641cf3224798c2f0ff07b6ae57d9a53 (patch) | |
tree | 413fc3a6f7a22bfaf00de05dfcc9acf5b40bdd26 /wgpu | |
parent | aa63841e2c80ca8130adf41d25e5d731409b92f4 (diff) | |
download | iced-7614127d3641cf3224798c2f0ff07b6ae57d9a53.tar.gz iced-7614127d3641cf3224798c2f0ff07b6ae57d9a53.tar.bz2 iced-7614127d3641cf3224798c2f0ff07b6ae57d9a53.zip |
Rename `HitTestResult` to `Hit`
... and also move it to a new `text` module in `iced_core`
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/backend.rs | 7 | ||||
-rw-r--r-- | wgpu/src/text.rs | 14 |
2 files changed, 10 insertions, 11 deletions
diff --git a/wgpu/src/backend.rs b/wgpu/src/backend.rs index fe8ed255..b31bf92c 100644 --- a/wgpu/src/backend.rs +++ b/wgpu/src/backend.rs @@ -2,14 +2,13 @@ use crate::quad; use crate::text; use crate::triangle; use crate::{Settings, Transformation}; + use iced_graphics::backend; use iced_graphics::font; use iced_graphics::layer::Layer; use iced_graphics::{Primitive, Viewport}; use iced_native::mouse; -use iced_native::{ - Font, HitTestResult, HorizontalAlignment, Size, VerticalAlignment, -}; +use iced_native::{Font, HorizontalAlignment, Size, VerticalAlignment}; #[cfg(any(feature = "image_rs", feature = "svg"))] use crate::image; @@ -285,7 +284,7 @@ impl backend::Text for Backend { bounds: Size, point: iced_native::Point, nearest_only: bool, - ) -> HitTestResult { + ) -> text::Hit { self.text_pipeline.hit_test( contents, size, diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index f227cb6f..ee49ee4b 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -1,9 +1,12 @@ use crate::Transformation; + use iced_graphics::font; -use iced_native::HitTestResult; + use std::{cell::RefCell, collections::HashMap}; use wgpu_glyph::ab_glyph; +pub use iced_native::text::Hit; + #[derive(Debug)] pub struct Pipeline { draw_brush: RefCell<wgpu_glyph::GlyphBrush<()>>, @@ -126,7 +129,7 @@ impl Pipeline { bounds: iced_native::Size, point: iced_native::Point, nearest_only: bool, - ) -> HitTestResult { + ) -> Hit { use wgpu_glyph::GlyphCruncher; let wgpu_glyph::FontId(font_id) = self.find_font(font); @@ -187,7 +190,7 @@ impl Pipeline { if !nearest_only { for (idx, bounds) in bounds.clone() { if bounds.contains(point) { - return HitTestResult::CharOffset(char_index(idx)); + return Hit::CharOffset(char_index(idx)); } } } @@ -203,10 +206,7 @@ impl Pipeline { }, ); - HitTestResult::NearestCharOffset( - char_index(idx), - (point - nearest).into(), - ) + Hit::NearestCharOffset(char_index(idx), (point - nearest).into()) } pub fn trim_measurement_cache(&mut self) { |