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

hierarchy & example

This commit is contained in:
adrien
2026-01-27 02:31:29 +01:00
parent 3bca8bfb19
commit f954abcbdf
11 changed files with 234 additions and 29 deletions

View File

@@ -0,0 +1,19 @@
[package]
name = "styling_engine"
version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0"
edition = "2024"
rust-version = "1.92"
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 = { workspace = true, features = ["auto-color", "humantime"] }

View File

@@ -0,0 +1,7 @@
Example showing how the style engine work.
```sh
cargo run -p styling_engine
```
![](screenshot.png)

View File

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

View File

@@ -0,0 +1,44 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
#![expect(rustdoc::missing_crate_level_docs)] // it's an example
use eframe::egui::{self, Button, Frame, Grid, Margin, Panel, widget_style::HasModifiers as _};
fn main() -> eframe::Result {
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 400.0]),
..Default::default()
};
let mut style_code = "// future style code live editor".to_owned();
eframe::run_ui_native("My egui App", options, move |ui, _frame| {
// Add a modifier to this ui
ui.add_modifier("body");
ui.label("body");
egui::CentralPanel::default().show_inside(ui, |ui| {
// Add a modifier to this ui
ui.add_modifier("central panel");
ui.label("central panel");
Panel::left("style_code").show_inside(ui, |ui| {
ui.add_modifier("style code editor");
ui.label("style code editor");
ui.text_edit_multiline(&mut style_code);
});
Grid::new("grid").show(ui, |ui| {
ui.add_modifier("grid");
Frame::new().inner_margin(Margin::same(10)).show(ui, |ui| {
ui.add_modifier("frame1");
ui.add(Button::new("button1").with_modifier("button1"));
ui.add(Button::new("button2").with_modifier("button2"));
})
});
});
})
}