summaryrefslogtreecommitdiffstats
path: root/wgpu/src/text.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-12-01 16:04:27 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-12-01 16:04:27 +0100
commit936d480267578d7e80675e78ec1880aaaaab72d6 (patch)
tree70719766c67dd6a09630c5a4231e952a3200bea1 /wgpu/src/text.rs
parent99899d49cc93cdec3832f7b5ecad867fdd421e07 (diff)
downloadiced-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/text.rs23
1 files changed, 14 insertions, 9 deletions
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index 08a8bea6..7d73c87b 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -120,9 +120,13 @@ impl Pipeline {
horizontal_alignment,
vertical_alignment,
color,
+ viewport,
) = match section {
Text::Paragraph {
- position, color, ..
+ position,
+ color,
+ viewport,
+ ..
} => {
use crate::core::text::Paragraph as _;
@@ -137,10 +141,14 @@ impl Pipeline {
paragraph.horizontal_alignment(),
paragraph.vertical_alignment(),
*color,
+ *viewport,
)
}
Text::Editor {
- position, color, ..
+ position,
+ color,
+ viewport,
+ ..
} => {
use crate::core::text::Editor as _;
@@ -155,6 +163,7 @@ impl Pipeline {
alignment::Horizontal::Left,
alignment::Vertical::Top,
*color,
+ *viewport,
)
}
Text::Cached(text) => {
@@ -173,6 +182,7 @@ impl Pipeline {
text.horizontal_alignment,
text.vertical_alignment,
text.color,
+ text.viewport,
)
}
};
@@ -195,13 +205,8 @@ impl Pipeline {
alignment::Vertical::Bottom => bounds.y - bounds.height,
};
- let section_bounds = Rectangle {
- x: left,
- y: top,
- ..bounds
- };
-
- let clip_bounds = layer_bounds.intersection(&section_bounds)?;
+ let clip_bounds =
+ layer_bounds.intersection(&(viewport * scale_factor))?;
Some(glyphon::TextArea {
buffer,