mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Change text color of selected text (#7691)
Selected text now gets the color of `visuals.selection.stroke.color`. This means you can have inverted colors for selected text, like in the new test: <img width="154" height="46" alt="image" src="https://github.com/user-attachments/assets/2666361d-d7e2-4d50-8e4d-2fcc128f1a81" /> It also means the color of selected text in labels matches that of the text color of selected buttons.
This commit is contained in:
@@ -230,6 +230,7 @@ fn layout_section(
|
||||
font_ascent: font_metrics.ascent,
|
||||
uv_rect: glyph_alloc.uv_rect,
|
||||
section_index,
|
||||
first_vertex: 0, // filled in later
|
||||
});
|
||||
|
||||
paragraph.cursor_x_px += glyph_alloc.advance_width_px;
|
||||
@@ -531,6 +532,7 @@ fn replace_last_glyph_with_overflow_character(
|
||||
font_ascent: font_metrics.ascent,
|
||||
uv_rect: replacement_glyph_alloc.uv_rect,
|
||||
section_index,
|
||||
first_vertex: 0, // filled in later
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -748,7 +750,7 @@ fn tessellate_row(
|
||||
point_scale: PointScale,
|
||||
job: &LayoutJob,
|
||||
format_summary: &FormatSummary,
|
||||
row: &Row,
|
||||
row: &mut Row,
|
||||
) -> RowVisuals {
|
||||
if row.glyphs.is_empty() {
|
||||
return Default::default();
|
||||
@@ -843,8 +845,9 @@ fn add_row_backgrounds(point_scale: PointScale, job: &LayoutJob, row: &Row, mesh
|
||||
end_run(run_start.take(), last_rect.right());
|
||||
}
|
||||
|
||||
fn tessellate_glyphs(point_scale: PointScale, job: &LayoutJob, row: &Row, mesh: &mut Mesh) {
|
||||
for glyph in &row.glyphs {
|
||||
fn tessellate_glyphs(point_scale: PointScale, job: &LayoutJob, row: &mut Row, mesh: &mut Mesh) {
|
||||
for glyph in &mut row.glyphs {
|
||||
glyph.first_vertex = mesh.vertices.len() as u32;
|
||||
let uv_rect = glyph.uv_rect;
|
||||
if !uv_rect.is_nothing() {
|
||||
let mut left_top = glyph.pos + uv_rect.offset;
|
||||
|
||||
@@ -701,6 +701,9 @@ pub struct Glyph {
|
||||
/// enable the paragraph-concat optimization path without having to
|
||||
/// adjust `section_index` when concatting.
|
||||
pub(crate) section_index: u32,
|
||||
|
||||
/// Which is our first vertex in [`RowVisuals::mesh`].
|
||||
pub first_vertex: u32,
|
||||
}
|
||||
|
||||
impl Glyph {
|
||||
|
||||
Reference in New Issue
Block a user