Skip to content

Commit b34f47f

Browse files
committed
Ensure list_item2::ListItem background is painted on rounded pixels
1 parent 048b3a4 commit b34f47f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

crates/re_ui/src/list_item2/list_item.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,20 @@ impl<'a> ListItem<'a> {
307307
};
308308
content.ui(re_ui, ui, &content_ctx);
309309

310+
// Ensure the background highlight is drawn over round pixel coordinates. Otherwise,
311+
// there could be artifact between consecutive highlighted items when drawn on
312+
// fractional pixels.
313+
let bg_rect_to_paint = ui.painter().round_rect_to_pixels(bg_rect);
314+
310315
// Draw background on interaction.
311316
if drag_target {
312317
ui.painter().set(
313318
background_frame,
314-
Shape::rect_stroke(bg_rect, 0.0, (1.0, ui.visuals().selection.bg_fill)),
319+
Shape::rect_stroke(
320+
bg_rect_to_paint,
321+
0.0,
322+
(1.0, ui.visuals().selection.bg_fill),
323+
),
315324
);
316325
} else {
317326
let bg_fill = if !response.hovered() && ui.rect_contains_pointer(bg_rect) {
@@ -329,8 +338,10 @@ impl<'a> ListItem<'a> {
329338
};
330339

331340
if let Some(bg_fill) = bg_fill {
332-
ui.painter()
333-
.set(background_frame, Shape::rect_filled(bg_rect, 0.0, bg_fill));
341+
ui.painter().set(
342+
background_frame,
343+
Shape::rect_filled(bg_rect_to_paint, 0.0, bg_fill),
344+
);
334345
}
335346
}
336347
}

0 commit comments

Comments
 (0)