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:
22
examples/group_layout/Cargo.toml
Normal file
22
examples/group_layout/Cargo.toml
Normal 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",
|
||||
] }
|
||||
32
examples/group_layout/src/main.rs
Normal file
32
examples/group_layout/src/main.rs
Normal 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());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user