summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-09 05:03:43 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-04-09 05:17:06 +0200
commitd3dee849b70e52dceddf83c46a8c83837b80094d (patch)
tree62ed925e0c6557af1bbf175134167f0d46aa39e3 /wgpu
parent9afa31899f9daa4523cb23db75e736d7d652da13 (diff)
downloadiced-d3dee849b70e52dceddf83c46a8c83837b80094d.tar.gz
iced-d3dee849b70e52dceddf83c46a8c83837b80094d.tar.bz2
iced-d3dee849b70e52dceddf83c46a8c83837b80094d.zip
Fix unnecessary clip of text input in `iced_wgpu`
It should only produce a `Clip` primitive when the contents overflow the input now.
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/renderer/widget/text_input.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/wgpu/src/renderer/widget/text_input.rs b/wgpu/src/renderer/widget/text_input.rs
index ab0ba363..1f804a1a 100644
--- a/wgpu/src/renderer/widget/text_input.rs
+++ b/wgpu/src/renderer/widget/text_input.rs
@@ -210,10 +210,20 @@ impl text_input::Renderer for Renderer {
(text_value, Vector::new(0, 0))
};
- let contents = Primitive::Clip {
- bounds: text_bounds,
- offset,
- content: Box::new(contents_primitive),
+ let text_width = self.measure_value(
+ if text.is_empty() { placeholder } else { &text },
+ size,
+ font,
+ );
+
+ let contents = if text_width > text_bounds.width {
+ Primitive::Clip {
+ bounds: text_bounds,
+ offset,
+ content: Box::new(contents_primitive),
+ }
+ } else {
+ contents_primitive
};
(