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 d3dee84
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 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,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
};

(
Expand Down

0 comments on commit d3dee84

Please sign in to comment.