Move the text_input_byte_offset_for_position from the FontMetrics to the Window

In preparation of having mutiple-lines TextInput, we will need to give more
data to this function so it no longer belong in FontMetrics

Also remove the unused FontMetric::line_height()
This commit is contained in:
Olivier Goffart 2021-08-31 11:55:32 +02:00 committed by Olivier Goffart
parent e1be599bc0
commit c1fc242a9a
7 changed files with 77 additions and 64 deletions

View file

@ -66,6 +66,16 @@ pub trait PlatformWindow {
reference_text: Pin<&crate::properties::Property<SharedString>>,
) -> Box<dyn crate::graphics::FontMetrics>;
/// Returns the (UTF-8) byte offset in the text property that refers to the character that contributed to
/// the glyph cluster that's visually nearest to the given coordinate. This is used for hit-testing,
/// for example when receiving a mouse click into a text field. Then this function returns the "cursor"
/// position.
fn text_input_byte_offset_for_position(
&self,
text_input: Pin<&crate::items::TextInput>,
pos: Point,
) -> usize;
/// Return self as any so the backend can upcast
fn as_any(&self) -> &dyn core::any::Any;
}