1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Experiment with a new Group container

This commit is contained in:
Emil Ernerfeldt
2024-06-06 13:58:45 +02:00
parent 29b12e1760
commit e799c2ad70
5 changed files with 223 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
[package]
name = "group_layout"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.76"
publish = false
[lints]
workspace = true
[dependencies]
eframe = { workspace = true, features = [
"default",
"__screenshot", # __screenshot is so we can dump a screenshot using EFRAME_SCREENSHOT_TO
] }
env_logger = { version = "0.10", default-features = false, features = [
"auto-color",
"humantime",
] }

View File

@@ -0,0 +1,32 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui;
fn main() -> Result<(), eframe::Error> {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 480.0]),
..Default::default()
};
eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
egui::CentralPanel::default().show(ctx, |ui| {
ui.vertical_centered(|ui| {
egui::Group::new("my_group")
.frame(egui::Frame::group(ui.style()))
.show(ui, |ui| {
ui.horizontal(|ui| {
ui.label("Hello");
ui.code("world!");
});
if ui.button("Reset egui").clicked() {
ui.memory_mut(|mem| *mem = Default::default());
}
});
});
});
})
}