mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Slightly simplify paint_text_selection code
This commit is contained in:
@@ -31,27 +31,25 @@ pub fn paint_text_selection(
|
|||||||
let max = max.rcursor;
|
let max = max.rcursor;
|
||||||
|
|
||||||
for ri in min.row..=max.row {
|
for ri in min.row..=max.row {
|
||||||
let placed_row = &mut galley.rows[ri];
|
let row = Arc::make_mut(&mut galley.rows[ri].row);
|
||||||
|
|
||||||
let left = if ri == min.row {
|
let left = if ri == min.row {
|
||||||
placed_row.x_offset(min.column)
|
row.x_offset(min.column)
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
let right = if ri == max.row {
|
let right = if ri == max.row {
|
||||||
placed_row.x_offset(max.column)
|
row.x_offset(max.column)
|
||||||
} else {
|
} else {
|
||||||
let newline_size = if placed_row.ends_with_newline {
|
let newline_size = if row.ends_with_newline {
|
||||||
placed_row.height() / 2.0 // visualize that we select the newline
|
row.height() / 2.0 // visualize that we select the newline
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
placed_row.size.x + newline_size
|
row.size.x + newline_size
|
||||||
};
|
};
|
||||||
|
|
||||||
let rect = Rect::from_min_max(pos2(left, 0.0), pos2(right, placed_row.size.y));
|
let rect = Rect::from_min_max(pos2(left, 0.0), pos2(right, row.size.y));
|
||||||
|
|
||||||
let row = Arc::make_mut(&mut placed_row.row);
|
|
||||||
let mesh = &mut row.visuals.mesh;
|
let mesh = &mut row.visuals.mesh;
|
||||||
|
|
||||||
// Time to insert the selection rectangle into the row mesh.
|
// Time to insert the selection rectangle into the row mesh.
|
||||||
|
|||||||
Reference in New Issue
Block a user