Skip to content

Commit

Permalink
Fix unnecessary clip of text input in iced_wgpu
Browse files Browse the repository at this point in the history
It should only produce a `Clip` primitive when the contents overflow the
input now.
  • Loading branch information
hecrj committed Apr 9, 2020
1 parent 9afa318 commit 1a7f097
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions wgpu/src/renderer/widget/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,16 @@ 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(&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
};

(
Expand Down

0 comments on commit 1a7f097

Please sign in to comment.