Skip to content

Commit bbc860c

Browse files
committed
Make resize-stroke sharper
1 parent 4588715 commit bbc860c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/egui/src/containers/window.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,16 @@ fn paint_frame_interaction(ui: &Ui, rect: Rect, interaction: ResizeInteraction)
10551055

10561056
let rounding = Roundingf::from(ui.visuals().window_rounding);
10571057

1058-
// Put the rect in the center of the stroke:
1058+
// Put the rect in the center of the fixed window stroke:
10591059
let rect = rect.shrink(interaction.window_frame.stroke.width / 2.0);
10601060

1061-
// TODO(emilk): the correct thing would be to round to pixel center only when the stroke width is an odd number of pixels.
1062-
let rect = rect.round_to_pixel_center(ui.pixels_per_point());
1061+
// Make sure the inner part of the stroke is at a pixel boundary:
1062+
let stroke = visuals.bg_stroke;
1063+
let half_stroke = stroke.width / 2.0;
1064+
let rect = rect
1065+
.shrink(half_stroke)
1066+
.round_to_pixels(ui.pixels_per_point())
1067+
.expand(half_stroke);
10631068

10641069
let Rect { min, max } = rect;
10651070

@@ -1118,7 +1123,7 @@ fn paint_frame_interaction(ui: &Ui, rect: Rect, interaction: ResizeInteraction)
11181123
points.push(pos2(max.x, max.y - rounding.se));
11191124
}
11201125

1121-
ui.painter().add(Shape::line(points, visuals.bg_stroke));
1126+
ui.painter().add(Shape::line(points, stroke));
11221127
}
11231128

11241129
// ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)