Position IME input according to where the selection is rendered

This commit is contained in:
Antonio Scandurra 2022-07-21 17:35:40 +02:00
parent 3c5d7e001e
commit 97ce3998ec
31 changed files with 563 additions and 27 deletions

View file

@ -1,6 +1,9 @@
use std::ops::Range;
use crate::{
geometry::{rect::RectF, vector::Vector2F},
json::{self, json, ToJson},
presenter::MeasurementContext,
DebugContext, Element, ElementBox, Event, EventContext, LayoutContext, PaintContext,
SizeConstraint,
};
@ -64,6 +67,21 @@ impl Element for Stack {
false
}
fn rect_for_text_range(
&self,
range_utf16: Range<usize>,
_: RectF,
_: RectF,
_: &Self::LayoutState,
_: &Self::PaintState,
cx: &MeasurementContext,
) -> Option<RectF> {
self.children
.iter()
.rev()
.find_map(|child| child.rect_for_text_range(range_utf16.clone(), cx))
}
fn debug(
&self,
bounds: RectF,