summaryrefslogtreecommitdiffstats
path: root/glow
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-08-26 14:41:33 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-08-26 14:41:33 +0700
commit7614127d3641cf3224798c2f0ff07b6ae57d9a53 (patch)
tree413fc3a6f7a22bfaf00de05dfcc9acf5b40bdd26 /glow
parentaa63841e2c80ca8130adf41d25e5d731409b92f4 (diff)
downloadiced-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 'glow')
-rw-r--r--glow/src/backend.rs7
-rw-r--r--glow/src/text.rs16
2 files changed, 11 insertions, 12 deletions
diff --git a/glow/src/backend.rs b/glow/src/backend.rs
index d97cbceb..37c0ac9d 100644
--- a/glow/src/backend.rs
+++ b/glow/src/backend.rs
@@ -2,14 +2,13 @@ use crate::quad;
use crate::text;
use crate::triangle;
use crate::{Settings, Transformation, Viewport};
+
use iced_graphics::backend;
use iced_graphics::font;
use iced_graphics::Layer;
use iced_graphics::Primitive;
use iced_native::mouse;
-use iced_native::{
- Font, HitTestResult, HorizontalAlignment, Size, VerticalAlignment,
-};
+use iced_native::{Font, HorizontalAlignment, Size, VerticalAlignment};
/// A [`glow`] graphics backend for [`iced`].
///
@@ -222,7 +221,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/glow/src/text.rs b/glow/src/text.rs
index bb882594..d6915d92 100644
--- a/glow/src/text.rs
+++ b/glow/src/text.rs
@@ -1,9 +1,12 @@
use crate::Transformation;
-use glow_glyph::ab_glyph;
+
use iced_graphics::font;
-use iced_native::HitTestResult;
+
+use glow_glyph::ab_glyph;
use std::{cell::RefCell, collections::HashMap};
+pub use iced_native::text::Hit;
+
#[derive(Debug)]
pub struct Pipeline {
draw_brush: RefCell<glow_glyph::GlyphBrush>,
@@ -118,7 +121,7 @@ impl Pipeline {
bounds: iced_native::Size,
point: iced_native::Point,
nearest_only: bool,
- ) -> HitTestResult {
+ ) -> Hit {
use glow_glyph::GlyphCruncher;
let glow_glyph::FontId(font_id) = self.find_font(font);
@@ -179,7 +182,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));
}
}
}
@@ -195,10 +198,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) {