Make `Grid` take full width when `Self::num_columns` is `Some`
Hello!
This is a PR to address ticket #3928. This PR would close the issue.
I've made grid stripes take up the full width available to the Grid when Grid::num_rows is_some().
This change is being made to match the documentation, which states that: Setting this will allow the last column to expand to take up the rest of the space of the parent (Link to comment)
fn paint_row(&self, cursor: &Rect, painter: &Painter) {
// ...
- let rect = rect.expand2(2.0 * Vec2::X); // HACK: just looks better with some spacing on the sides
+ let mut rect = rect.expand2(2.0 * Vec2::X); // HACK: just looks better with some spacing on the sides
+
+ if self.num_columns.is_some() {
+ rect.set_width(cursor.width())
+ }
painter.rect_filled(rect, 2.0, row_color);
}
I'm a first time contributor to this repo, and I'm honestly not too familiar with how it works, so if there are any issues with this, please let me know and I'll investigate it ASAP!
Preview available at https://egui-pr-preview.github.io/pr/5870-fulllengthgridstripes Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.
Setting this will allow the last column to expand to take up the rest of the space of the parent
I think the keyword here is allow. It should not always expand to the full width, but only do so if there is content in the last column that is wide enough.
You have failing snapshot tests btw
You can see the what broke in the snapshot test:
Sorry - forgot about this PR. I'll go ahead and close this since I misunderstood the docs, per previous comments. Thanks :)