1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

remove padding, use egui item spacing

This commit is contained in:
René Rössler
2022-02-09 16:00:25 +01:00
parent 6261380180
commit 63a70ab00d
9 changed files with 81 additions and 118 deletions

View File

@@ -1,5 +1,5 @@
use egui::Color32;
use egui_extras::{GridBuilder, Padding, Size};
use egui_extras::{GridBuilder, Size};
/// Shows off a table with dynamic layout
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@@ -25,14 +25,14 @@ impl super::Demo for GridDemo {
impl super::View for GridDemo {
fn ui(&mut self, ui: &mut egui::Ui) {
GridBuilder::new(ui, Padding::new(0.0, 0.0))
GridBuilder::new(ui)
.size(Size::Absolute(50.0))
.size(Size::Remainder)
.size(Size::RelativeMinimum {
relative: 0.5,
minimum: 60.0,
})
.size(Size::Absolute(14.0))
.size(Size::Absolute(10.0))
.vertical(|mut grid| {
grid.cell(|ui| {
ui.painter()

View File

@@ -1,5 +1,5 @@
use egui::Label;
use egui_extras::{GridBuilder, Padding, Size, TableBuilder};
use egui::{Label, Vec2};
use egui_extras::{GridBuilder, Size, TableBuilder};
/// Shows off a table with dynamic layout
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@@ -30,13 +30,15 @@ impl super::View for TableDemo {
ui.checkbox(&mut self.virtual_scrool, "Virtual scroll demo");
// The table is inside a grid as its container would otherwise grow slowly as it takes all available height
GridBuilder::new(ui, Padding::new(0.0, 0.0))
ui.spacing_mut().item_spacing = Vec2::splat(4.0);
GridBuilder::new(ui)
.size(Size::Remainder)
.size(Size::Absolute(14.0))
.size(Size::Absolute(10.0))
.vertical(|mut grid| {
grid.cell(|ui| {
// TODO: Fix table as a padding smaller than 16 grows the window
TableBuilder::new(ui, Padding::new(3.0, 16.0))
grid.cell_clip(|ui| {
ui.spacing_mut().item_spacing = Vec2::splat(3.0);
TableBuilder::new(ui)
.striped(true)
.column(Size::Absolute(120.0))
.column(Size::RemainderMinimum(180.0))
@@ -58,7 +60,7 @@ impl super::View for TableDemo {
row.col(|ui| {
ui.label(index.to_string());
});
row.col(|ui| {
row.col_clip(|ui| {
ui.add(
Label::new("virtual scroll, easily with thousands of rows!")
.wrap(false),
@@ -79,7 +81,7 @@ impl super::View for TableDemo {
row.col(|ui| {
ui.label(i.to_string());
});
row.col(|ui| {
row.col_clip(|ui| {
ui.add(
Label::new(
format!("Normal scroll, each row can have a different height. Height: {}", height),