From 6362ff9e4d37069253c2830977f3de9b2b1126c4 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Sat, 26 Aug 2023 03:42:05 +1000 Subject: [PATCH] capture typesetting overflow in ComposedType and pass thru to gam.post_textview() --- services/gam/src/lib.rs | 2 ++ services/gam/src/main.rs | 2 ++ services/graphics-server/src/lib.rs | 1 + services/graphics-server/src/main.rs | 1 + services/graphics-server/src/wordwrap.rs | 13 ++++++++++--- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/services/gam/src/lib.rs b/services/gam/src/lib.rs index cee1a732e..3d2ddff6a 100644 --- a/services/gam/src/lib.rs +++ b/services/gam/src/lib.rs @@ -151,6 +151,7 @@ impl Gam { api::Return::RenderReturn(tvr) => { tv.bounds_computed = tvr.bounds_computed; tv.cursor = tvr.cursor; + tv.overflow = tvr.overflow; } api::Return::NotCurrentlyDrawable => { tv.bounds_computed = None; @@ -172,6 +173,7 @@ impl Gam { api::Return::RenderReturn(tvr) => { tv.bounds_computed = tvr.bounds_computed; 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") } diff --git a/services/gam/src/main.rs b/services/gam/src/main.rs index 165d117b8..bf0bd19c9 100644 --- a/services/gam/src/main.rs +++ b/services/gam/src/main.rs @@ -245,6 +245,7 @@ fn wrapped_main() -> ! { // copy back the fields that we want to be mutable tv.cursor = tv_clone.cursor; tv.bounds_computed = tv_clone.bounds_computed; + tv.overflow = tv_clone.overflow; let ret = api::Return::RenderReturn(tv); 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); tv.cursor = tv_clone.cursor; tv.bounds_computed = tv_clone.bounds_computed; + tv.overflow = tv_clone.overflow; let ret = api::Return::RenderReturn(tv); buffer.replace(ret).unwrap(); diff --git a/services/graphics-server/src/lib.rs b/services/graphics-server/src/lib.rs index 344de9a33..416b7e352 100644 --- a/services/graphics-server/src/lib.rs +++ b/services/graphics-server/src/lib.rs @@ -156,6 +156,7 @@ impl Gfx { let tvr = buf.to_original::().unwrap(); tv.bounds_computed = tvr.bounds_computed; tv.cursor = tvr.cursor; + tv.overflow = tvr.overflow; Ok(()) } diff --git a/services/graphics-server/src/main.rs b/services/graphics-server/src/main.rs index 3623dcc16..57a451dd3 100644 --- a/services/graphics-server/src/main.rs +++ b/services/graphics-server/src/main.rs @@ -387,6 +387,7 @@ fn wrapped_main(main_thread_token: backend::MainThreadToken) -> ! { tv.cursor.pt.x = composition.final_cursor().pt.x; tv.cursor.pt.y = composition.final_cursor().pt.y; tv.cursor.line_height = composition.final_cursor().line_height; + tv.overflow = Some(composition.final_overflow()); tv.bounds_computed = Some( clear_rect diff --git a/services/graphics-server/src/wordwrap.rs b/services/graphics-server/src/wordwrap.rs index 0116146bf..0ffd14213 100644 --- a/services/graphics-server/src/wordwrap.rs +++ b/services/graphics-server/src/wordwrap.rs @@ -93,13 +93,15 @@ pub(crate) struct ComposedType { words: Vec::, bounding_box: ClipRect, cursor: Cursor, + overflow: bool, } impl ComposedType { - pub fn new(words: Vec::, bounds: ClipRect, cursor: Cursor) -> Self { + pub fn new(words: Vec::, bounds: ClipRect, cursor: Cursor, overflow: bool) -> Self { ComposedType { words, bounding_box: bounds, cursor, + overflow, } } pub fn bb_width(&self) -> i16 { @@ -177,6 +179,9 @@ impl ComposedType { pub fn final_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 /// 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."); return ComposedType::new(composition, ClipRect::new(self.bb.min.x, self.bb.min.y, self.bb.min.x, self.bb.min.y), - self.cursor + self.cursor, + true, ); } // algorithm: @@ -422,7 +428,8 @@ impl Typesetter { self.bb.min.x, self.bb.min.y, 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 match strat {