diff options
author | 2023-12-01 16:04:27 +0100 | |
---|---|---|
committer | 2023-12-01 16:04:27 +0100 | |
commit | 936d480267578d7e80675e78ec1880aaaaab72d6 (patch) | |
tree | 70719766c67dd6a09630c5a4231e952a3200bea1 /wgpu/src/layer | |
parent | 99899d49cc93cdec3832f7b5ecad867fdd421e07 (diff) | |
download | iced-936d480267578d7e80675e78ec1880aaaaab72d6.tar.gz iced-936d480267578d7e80675e78ec1880aaaaab72d6.tar.bz2 iced-936d480267578d7e80675e78ec1880aaaaab72d6.zip |
Clip text to `viewport` bounds instead of layout bounds
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/layer.rs | 7 | ||||
-rw-r--r-- | wgpu/src/layer/text.rs | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs index 98e49f1a..60da3543 100644 --- a/wgpu/src/layer.rs +++ b/wgpu/src/layer.rs @@ -75,6 +75,7 @@ impl<'a> Layer<'a> { horizontal_alignment: alignment::Horizontal::Left, vertical_alignment: alignment::Vertical::Top, shaping: core::text::Shaping::Basic, + viewport: Rectangle::with_size(Size::INFINITY), }; overlay.text.push(Text::Cached(text.clone())); @@ -123,6 +124,7 @@ impl<'a> Layer<'a> { paragraph, position, color, + viewport, } => { let layer = &mut layers[current_layer]; @@ -130,12 +132,14 @@ impl<'a> Layer<'a> { paragraph: paragraph.clone(), position: *position + translation, color: *color, + viewport: *viewport + translation, }); } Primitive::Editor { editor, position, color, + viewport, } => { let layer = &mut layers[current_layer]; @@ -143,6 +147,7 @@ impl<'a> Layer<'a> { editor: editor.clone(), position: *position + translation, color: *color, + viewport: *viewport + translation, }); } Primitive::Text { @@ -155,6 +160,7 @@ impl<'a> Layer<'a> { horizontal_alignment, vertical_alignment, shaping, + viewport, } => { let layer = &mut layers[current_layer]; @@ -168,6 +174,7 @@ impl<'a> Layer<'a> { horizontal_alignment: *horizontal_alignment, vertical_alignment: *vertical_alignment, shaping: *shaping, + viewport: *viewport + translation, })); } Primitive::Quad { diff --git a/wgpu/src/layer/text.rs b/wgpu/src/layer/text.rs index 66417cec..c4ea9185 100644 --- a/wgpu/src/layer/text.rs +++ b/wgpu/src/layer/text.rs @@ -13,6 +13,7 @@ pub enum Text<'a> { paragraph: paragraph::Weak, position: Point, color: Color, + viewport: Rectangle, }, /// An editor. #[allow(missing_docs)] @@ -20,6 +21,7 @@ pub enum Text<'a> { editor: editor::Weak, position: Point, color: Color, + viewport: Rectangle, }, /// A cached text. Cached(Cached<'a>), @@ -53,4 +55,7 @@ pub struct Cached<'a> { /// The shaping strategy of the text. pub shaping: text::Shaping, + + /// The viewport of the text. + pub viewport: Rectangle, } |