1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 06:40:06 -04:00

Add overline option for Table rows (#5637)

* Closes no issue, I just needed this for an app and figured it could be
useful.
* [x] I have followed the instructions in the PR template

This PR adds an `overline` option for `egui_extras::TableRow`, which is
useful for visually grouping rows. The overline consumes no layout
space.

A screenshot of the demo app, showing every 7th row getting an overline.

<img width="704" alt="Screenshot 2025-01-25 at 14 40 08"
src="https://github.com/user-attachments/assets/9ccbee3d-296d-4afd-9290-c669e4ede1c0"
/>

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Aarni Koskela
2025-04-08 12:36:43 +03:00
committed by GitHub
parent 565966b3c9
commit 36e007bd8c
4 changed files with 31 additions and 2 deletions

View File

@@ -33,6 +33,7 @@ pub(crate) struct StripLayoutFlags {
pub(crate) striped: bool,
pub(crate) hovered: bool,
pub(crate) selected: bool,
pub(crate) overline: bool,
/// Used when we want to accruately measure the size of this cell.
pub(crate) sizing_pass: bool,
@@ -232,6 +233,14 @@ impl<'l> StripLayout<'l> {
child_ui.style_mut().visuals.override_text_color = Some(stroke_color);
}
if flags.overline {
child_ui.painter().hline(
max_rect.x_range(),
max_rect.top(),
child_ui.visuals().widgets.noninteractive.bg_stroke,
);
}
add_cell_contents(&mut child_ui);
child_ui