Implement hit_test for text::Pipeline in iced_wgpu
This commit is contained in:
parent
c8e8b1a7ba
commit
0a324f0aeb
1 changed files with 18 additions and 6 deletions
|
|
@ -286,14 +286,26 @@ impl Pipeline {
|
||||||
|
|
||||||
pub fn hit_test(
|
pub fn hit_test(
|
||||||
&self,
|
&self,
|
||||||
_content: &str,
|
content: &str,
|
||||||
_size: f32,
|
size: f32,
|
||||||
_font: iced_native::Font,
|
font: iced_native::Font,
|
||||||
_bounds: iced_native::Size,
|
bounds: iced_native::Size,
|
||||||
_point: iced_native::Point,
|
point: iced_native::Point,
|
||||||
_nearest_only: bool,
|
_nearest_only: bool,
|
||||||
) -> Option<Hit> {
|
) -> Option<Hit> {
|
||||||
None
|
let mut measurement_cache = self.measurement_cache.borrow_mut();
|
||||||
|
|
||||||
|
let (_, paragraph) = measurement_cache.allocate(Key {
|
||||||
|
content,
|
||||||
|
size: size,
|
||||||
|
font,
|
||||||
|
bounds,
|
||||||
|
color: Color::BLACK,
|
||||||
|
});
|
||||||
|
|
||||||
|
let cursor = paragraph.hit(point.x as i32, point.y as i32)?;
|
||||||
|
|
||||||
|
Some(Hit::CharOffset(cursor.index))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trim_measurement_cache(&mut self) {
|
pub fn trim_measurement_cache(&mut self) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue