1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Add AtomLayout::direction (#8221)

* To be merged after #8219 

Adds support for vertical atom layout. Together with #8219 this
basically creates a minimal flex layout engine
This commit is contained in:
Lucas Meurer
2026-06-24 13:56:54 +02:00
committed by GitHub
parent 3c11c7b1b1
commit 080ce81c8b
3 changed files with 181 additions and 48 deletions

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e43b410ab0a06b40da5ad9c7fd105d11201d44a3afd63fd213429cc39013c0d4
size 6964

View File

@@ -1,4 +1,6 @@
use egui::{Align, AtomExt as _, Button, Layout, TextWrapMode, Ui, Vec2};
use egui::{
Align, Atom, AtomExt as _, AtomLayout, Button, Direction, Frame, Layout, TextWrapMode, Ui, Vec2,
};
use egui_kittest::{HarnessBuilder, SnapshotResult, SnapshotResults};
#[test]
@@ -120,6 +122,50 @@ fn test_button_shortcut_text() {
harness.snapshot("button_shortcut");
}
/// Test atom nesting and [`egui::AtomLayout::direction`].
#[test]
fn test_atom_layout_nesting_and_direction() {
let mut harness = HarnessBuilder::default().build_ui(|ui| {
let style = ui.style();
let canvas_frame = Frame::canvas(style);
let button_frame = style
.button_style(
&egui::widget_style::Classes::default(),
egui::widget_style::WidgetState::Inactive,
)
.frame;
let row = |direction: Direction| {
Atom::layout(
AtomLayout::new(("one", "two", "three"))
.direction(direction)
.frame(button_frame),
)
};
AtomLayout::new((
Atom::layout(
AtomLayout::new((
row(Direction::LeftToRight).atom_grow(true),
row(Direction::RightToLeft).atom_grow(true),
))
.direction(Direction::TopDown),
)
.atom_grow(true),
row(Direction::TopDown),
row(Direction::BottomUp),
))
.direction(Direction::LeftToRight)
.frame(canvas_frame)
.show(ui);
});
harness.fit_contents();
harness.snapshot("atom_layout_nesting");
}
/// Tests the spacing between galleys.
/// All of these should look the same.
#[test]