mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 12:50:04 -04:00
Finish WidgetLayout prototype
This commit is contained in:
committed by
lucasmerlin
parent
fa81ae049e
commit
4dbf20d107
@@ -20,3 +20,5 @@ env_logger = { version = "0.10", default-features = false, features = [
|
||||
"auto-color",
|
||||
"humantime",
|
||||
] }
|
||||
egui_extras = {workspace = true, features = ["image", "all_loaders"]}
|
||||
image = {workspace = true, features = ["png"]}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#![allow(rustdoc::missing_crate_level_docs)] // it's an example
|
||||
|
||||
use eframe::egui;
|
||||
use eframe::egui::{
|
||||
include_image, Image, Key, KeyboardShortcut, ModifierNames, Modifiers, Popup, RichText,
|
||||
WLButton, Widget,
|
||||
};
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||
@@ -17,6 +21,7 @@ fn main() -> eframe::Result {
|
||||
|
||||
eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
egui_extras::install_image_loaders(ctx);
|
||||
ui.heading("My egui Application");
|
||||
ui.horizontal(|ui| {
|
||||
let name_label = ui.label("Your name: ");
|
||||
@@ -28,6 +33,34 @@ fn main() -> eframe::Result {
|
||||
age += 1;
|
||||
}
|
||||
ui.label(format!("Hello '{name}', age {age}"));
|
||||
|
||||
if WLButton::new("WL Button").ui(ui).clicked() {
|
||||
age += 1;
|
||||
};
|
||||
|
||||
let source = include_image!("../../../crates/eframe/data/icon.png");
|
||||
let response = WLButton::image_and_text(source, "Hello World").ui(ui);
|
||||
|
||||
Popup::menu(&response).show(|ui| {
|
||||
WLButton::new("Print")
|
||||
.right_text(
|
||||
RichText::new(
|
||||
KeyboardShortcut::new(Modifiers::COMMAND, Key::P)
|
||||
.format(&ModifierNames::SYMBOLS, true),
|
||||
)
|
||||
.weak(),
|
||||
)
|
||||
.ui(ui);
|
||||
WLButton::new("A very long button")
|
||||
.right_text(
|
||||
RichText::new(
|
||||
KeyboardShortcut::new(Modifiers::COMMAND, Key::O)
|
||||
.format(&ModifierNames::SYMBOLS, true),
|
||||
)
|
||||
.weak(),
|
||||
)
|
||||
.ui(ui);
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user