mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
capture typesetting overflow in ComposedType and pass thru to gam.post_textview()
This commit is contained in:
parent
77f25bc416
commit
6362ff9e4d
5 changed files with 16 additions and 3 deletions
|
|
@ -151,6 +151,7 @@ impl Gam {
|
||||||
api::Return::RenderReturn(tvr) => {
|
api::Return::RenderReturn(tvr) => {
|
||||||
tv.bounds_computed = tvr.bounds_computed;
|
tv.bounds_computed = tvr.bounds_computed;
|
||||||
tv.cursor = tvr.cursor;
|
tv.cursor = tvr.cursor;
|
||||||
|
tv.overflow = tvr.overflow;
|
||||||
}
|
}
|
||||||
api::Return::NotCurrentlyDrawable => {
|
api::Return::NotCurrentlyDrawable => {
|
||||||
tv.bounds_computed = None;
|
tv.bounds_computed = None;
|
||||||
|
|
@ -172,6 +173,7 @@ impl Gam {
|
||||||
api::Return::RenderReturn(tvr) => {
|
api::Return::RenderReturn(tvr) => {
|
||||||
tv.bounds_computed = tvr.bounds_computed;
|
tv.bounds_computed = tvr.bounds_computed;
|
||||||
tv.cursor = tvr.cursor;
|
tv.cursor = tvr.cursor;
|
||||||
|
tv.overflow = tvr.overflow;
|
||||||
}
|
}
|
||||||
_ => panic!("GAM_API: bounds_compute_textview got a return value from the server that isn't expected or handled")
|
_ => panic!("GAM_API: bounds_compute_textview got a return value from the server that isn't expected or handled")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@ fn wrapped_main() -> ! {
|
||||||
// copy back the fields that we want to be mutable
|
// copy back the fields that we want to be mutable
|
||||||
tv.cursor = tv_clone.cursor;
|
tv.cursor = tv_clone.cursor;
|
||||||
tv.bounds_computed = tv_clone.bounds_computed;
|
tv.bounds_computed = tv_clone.bounds_computed;
|
||||||
|
tv.overflow = tv_clone.overflow;
|
||||||
|
|
||||||
let ret = api::Return::RenderReturn(tv);
|
let ret = api::Return::RenderReturn(tv);
|
||||||
buffer.replace(ret).unwrap();
|
buffer.replace(ret).unwrap();
|
||||||
|
|
@ -285,6 +286,7 @@ fn wrapped_main() -> ! {
|
||||||
log::trace!("got computed cursor of {:?}, bounds {:?}", tv_clone.cursor, tv_clone.bounds_computed);
|
log::trace!("got computed cursor of {:?}, bounds {:?}", tv_clone.cursor, tv_clone.bounds_computed);
|
||||||
tv.cursor = tv_clone.cursor;
|
tv.cursor = tv_clone.cursor;
|
||||||
tv.bounds_computed = tv_clone.bounds_computed;
|
tv.bounds_computed = tv_clone.bounds_computed;
|
||||||
|
tv.overflow = tv_clone.overflow;
|
||||||
|
|
||||||
let ret = api::Return::RenderReturn(tv);
|
let ret = api::Return::RenderReturn(tv);
|
||||||
buffer.replace(ret).unwrap();
|
buffer.replace(ret).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ impl Gfx {
|
||||||
let tvr = buf.to_original::<TextView, _>().unwrap();
|
let tvr = buf.to_original::<TextView, _>().unwrap();
|
||||||
tv.bounds_computed = tvr.bounds_computed;
|
tv.bounds_computed = tvr.bounds_computed;
|
||||||
tv.cursor = tvr.cursor;
|
tv.cursor = tvr.cursor;
|
||||||
|
tv.overflow = tvr.overflow;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -387,6 +387,7 @@ fn wrapped_main(main_thread_token: backend::MainThreadToken) -> ! {
|
||||||
tv.cursor.pt.x = composition.final_cursor().pt.x;
|
tv.cursor.pt.x = composition.final_cursor().pt.x;
|
||||||
tv.cursor.pt.y = composition.final_cursor().pt.y;
|
tv.cursor.pt.y = composition.final_cursor().pt.y;
|
||||||
tv.cursor.line_height = composition.final_cursor().line_height;
|
tv.cursor.line_height = composition.final_cursor().line_height;
|
||||||
|
tv.overflow = Some(composition.final_overflow());
|
||||||
|
|
||||||
tv.bounds_computed = Some(
|
tv.bounds_computed = Some(
|
||||||
clear_rect
|
clear_rect
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,15 @@ pub(crate) struct ComposedType {
|
||||||
words: Vec::<TypesetWord>,
|
words: Vec::<TypesetWord>,
|
||||||
bounding_box: ClipRect,
|
bounding_box: ClipRect,
|
||||||
cursor: Cursor,
|
cursor: Cursor,
|
||||||
|
overflow: bool,
|
||||||
}
|
}
|
||||||
impl ComposedType {
|
impl ComposedType {
|
||||||
pub fn new(words: Vec::<TypesetWord>, bounds: ClipRect, cursor: Cursor) -> Self {
|
pub fn new(words: Vec::<TypesetWord>, bounds: ClipRect, cursor: Cursor, overflow: bool) -> Self {
|
||||||
ComposedType {
|
ComposedType {
|
||||||
words,
|
words,
|
||||||
bounding_box: bounds,
|
bounding_box: bounds,
|
||||||
cursor,
|
cursor,
|
||||||
|
overflow,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn bb_width(&self) -> i16 {
|
pub fn bb_width(&self) -> i16 {
|
||||||
|
|
@ -177,6 +179,9 @@ impl ComposedType {
|
||||||
pub fn final_cursor(&self) -> Cursor {
|
pub fn final_cursor(&self) -> Cursor {
|
||||||
self.cursor
|
self.cursor
|
||||||
}
|
}
|
||||||
|
pub fn final_overflow(&self) -> bool {
|
||||||
|
self.overflow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// Typesetter takes a string and attempts to lay it out within a region defined by
|
/// Typesetter takes a string and attempts to lay it out within a region defined by
|
||||||
/// a single point known as the "Extent". This is the maximum extent allowable for
|
/// a single point known as the "Extent". This is the maximum extent allowable for
|
||||||
|
|
@ -267,7 +272,8 @@ impl Typesetter {
|
||||||
log::error!("Words cannot be typset because the width of the typset region is too narrow.");
|
log::error!("Words cannot be typset because the width of the typset region is too narrow.");
|
||||||
return ComposedType::new(composition,
|
return ComposedType::new(composition,
|
||||||
ClipRect::new(self.bb.min.x, self.bb.min.y, self.bb.min.x, self.bb.min.y),
|
ClipRect::new(self.bb.min.x, self.bb.min.y, self.bb.min.x, self.bb.min.y),
|
||||||
self.cursor
|
self.cursor,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// algorithm:
|
// algorithm:
|
||||||
|
|
@ -422,7 +428,8 @@ impl Typesetter {
|
||||||
self.bb.min.x, self.bb.min.y,
|
self.bb.min.x, self.bb.min.y,
|
||||||
self.max_width as i16, self.cursor.pt.y + self.last_line_height as i16,
|
self.max_width as i16, self.cursor.pt.y + self.last_line_height as i16,
|
||||||
),
|
),
|
||||||
self.cursor
|
self.cursor,
|
||||||
|
self.overflow,
|
||||||
);
|
);
|
||||||
// cleanup any state based on the overflow strategy
|
// cleanup any state based on the overflow strategy
|
||||||
match strat {
|
match strat {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue