Fix clipping of TextInput selection
This commit is contained in:
parent
a5ae442819
commit
5315e04a26
1 changed files with 32 additions and 24 deletions
|
|
@ -1194,31 +1194,39 @@ pub fn draw<Renderer>(
|
||||||
(None, 0.0)
|
(None, 0.0)
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((cursor, color)) = cursor {
|
let draw = |renderer: &mut Renderer, viewport| {
|
||||||
renderer.with_translation(Vector::new(-offset, 0.0), |renderer| {
|
if let Some((cursor, color)) = cursor {
|
||||||
renderer.fill_quad(cursor, color);
|
renderer.with_translation(Vector::new(-offset, 0.0), |renderer| {
|
||||||
});
|
renderer.fill_quad(cursor, color);
|
||||||
} else {
|
});
|
||||||
renderer.with_translation(Vector::ZERO, |_| {});
|
} else {
|
||||||
}
|
renderer.with_translation(Vector::ZERO, |_| {});
|
||||||
|
}
|
||||||
|
|
||||||
renderer.fill_paragraph(
|
renderer.fill_paragraph(
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
&state.placeholder
|
&state.placeholder
|
||||||
} else {
|
} else {
|
||||||
&state.value
|
&state.value
|
||||||
},
|
},
|
||||||
Point::new(text_bounds.x, text_bounds.center_y())
|
Point::new(text_bounds.x, text_bounds.center_y())
|
||||||
- Vector::new(offset, 0.0),
|
- Vector::new(offset, 0.0),
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
theme.placeholder_color(style)
|
theme.placeholder_color(style)
|
||||||
} else if is_disabled {
|
} else if is_disabled {
|
||||||
theme.disabled_color(style)
|
theme.disabled_color(style)
|
||||||
} else {
|
} else {
|
||||||
theme.value_color(style)
|
theme.value_color(style)
|
||||||
},
|
},
|
||||||
text_bounds,
|
viewport,
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if cursor.is_some() {
|
||||||
|
renderer.with_layer(text_bounds, |renderer| draw(renderer, *viewport));
|
||||||
|
} else {
|
||||||
|
draw(renderer, text_bounds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the current [`mouse::Interaction`] of the [`TextInput`].
|
/// Computes the current [`mouse::Interaction`] of the [`TextInput`].
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue