1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-28 07:23:13 -04:00

Simplify Galley bounding rect calulcation

This commit is contained in:
Emil Ernerfeldt
2025-03-30 17:23:21 +02:00
parent 9e44490b31
commit 1b1f0726ce

View File

@@ -611,8 +611,7 @@ fn galley_from_rows(
) -> Galley {
let mut first_row_min_height = job.first_row_min_height;
let mut cursor_y = 0.0;
let mut min_x: f32 = 0.0;
let mut max_x: f32 = 0.0;
for placed_row in &mut rows {
let mut max_row_height = first_row_min_height.max(placed_row.rect().height());
let row = Arc::make_mut(&mut placed_row.row);
@@ -640,21 +639,23 @@ fn galley_from_rows(
placed_row.pos.y = cursor_y;
row.size.y = max_row_height;
min_x = min_x.min(placed_row.rect().min.x);
max_x = max_x.max(placed_row.rect().max.x);
cursor_y += max_row_height;
cursor_y = point_scale.round_to_pixel(cursor_y); // TODO(emilk): it would be better to do the calculations in pixels instead.
}
let format_summary = format_summary(&job);
let mut rect = Rect::ZERO;
let mut mesh_bounds = Rect::NOTHING;
let mut num_vertices = 0;
let mut num_indices = 0;
for placed_row in &mut rows {
rect = rect.union(placed_row.rect());
let row = Arc::make_mut(&mut placed_row.row);
row.visuals = tessellate_row(point_scale, &job, &format_summary, row);
mesh_bounds =
mesh_bounds.union(row.visuals.mesh_bounds.translate(placed_row.pos.to_vec2()));
num_vertices += row.visuals.mesh.vertices.len();
@@ -669,8 +670,6 @@ fn galley_from_rows(
}
}
let rect = Rect::from_min_max(pos2(min_x, 0.0), pos2(max_x, cursor_y));
let mut galley = Galley {
job,
rows,