fix(text_input): draw selected text in the theme's selected_text_color
This commit is contained in:
parent
eec2f7619d
commit
ff7c753302
1 changed files with 32 additions and 20 deletions
|
|
@ -2920,27 +2920,39 @@ pub fn draw<'a, Message>(
|
||||||
text_color
|
text_color
|
||||||
};
|
};
|
||||||
|
|
||||||
renderer.fill_text(
|
let text = Text {
|
||||||
Text {
|
content: if text.is_empty() {
|
||||||
content: if text.is_empty() {
|
placeholder.to_string()
|
||||||
placeholder.to_string()
|
} else {
|
||||||
} else {
|
text.clone()
|
||||||
text.clone()
|
|
||||||
},
|
|
||||||
font,
|
|
||||||
bounds: bounds.size(),
|
|
||||||
size: iced::Pixels(size),
|
|
||||||
align_x: text::Alignment::Default,
|
|
||||||
align_y: alignment::Vertical::Center,
|
|
||||||
line_height: text::LineHeight::default(),
|
|
||||||
shaping: text::Shaping::Advanced,
|
|
||||||
wrapping: text::Wrapping::None,
|
|
||||||
ellipsize: text::Ellipsize::None,
|
|
||||||
},
|
},
|
||||||
bounds.position(),
|
font,
|
||||||
color,
|
bounds: bounds.size(),
|
||||||
text_bounds,
|
size: iced::Pixels(size),
|
||||||
);
|
align_x: text::Alignment::Default,
|
||||||
|
align_y: alignment::Vertical::Center,
|
||||||
|
line_height: text::LineHeight::default(),
|
||||||
|
shaping: text::Shaping::Advanced,
|
||||||
|
wrapping: text::Wrapping::None,
|
||||||
|
ellipsize: text::Ellipsize::None,
|
||||||
|
};
|
||||||
|
renderer.fill_text(text.clone(), bounds.position(), color, text_bounds);
|
||||||
|
|
||||||
|
// Redraw the same text in the selected color, clipped to the selection quads,
|
||||||
|
// so glyph shaping and positioning stay identical to the unselected pass.
|
||||||
|
if is_selecting {
|
||||||
|
let shift = Vector::new(alignment_offset - offset, 0.0);
|
||||||
|
for (quad, _) in &cursors {
|
||||||
|
renderer.with_layer(quad.bounds + shift, |renderer| {
|
||||||
|
renderer.fill_text(
|
||||||
|
text.clone(),
|
||||||
|
bounds.position(),
|
||||||
|
appearance.selected_text_color,
|
||||||
|
text_bounds,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: we always must clip with a layer because of what appears to be a tiny-skia text clipping issue.
|
// FIXME: we always must clip with a layer because of what appears to be a tiny-skia text clipping issue.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue