From dd9ae0e82e7f0ac383a0d37e76348d6b74baea5d Mon Sep 17 00:00:00 2001 From: Eamon Date: Thu, 23 Nov 2023 23:41:37 -0800 Subject: [PATCH] Add a tutorials folder with simple tutorials `tutorials.md` is the "home page" The other `md` files are different sections (layout, technical, miscellaneous, etc.) --- crates/eframe/tutorials/layout.md | 10 ++++++++++ crates/eframe/tutorials/miscellaneous.md | 1 + crates/eframe/tutorials/technical.md | 20 ++++++++++++++++++++ crates/eframe/tutorials/tutorials.md | 11 +++++++++++ 4 files changed, 42 insertions(+) create mode 100644 crates/eframe/tutorials/layout.md create mode 100644 crates/eframe/tutorials/miscellaneous.md create mode 100644 crates/eframe/tutorials/technical.md create mode 100644 crates/eframe/tutorials/tutorials.md diff --git a/crates/eframe/tutorials/layout.md b/crates/eframe/tutorials/layout.md new file mode 100644 index 00000000000..2727c1162c0 --- /dev/null +++ b/crates/eframe/tutorials/layout.md @@ -0,0 +1,10 @@ +# Layout tutorials + +## Make group fill full height of its parent + +```rust +ui.group(|ui| { + // Stuff blah blah blah + ui.set_height(ui.available_height()); +}); +``` diff --git a/crates/eframe/tutorials/miscellaneous.md b/crates/eframe/tutorials/miscellaneous.md new file mode 100644 index 00000000000..46ed46232f3 --- /dev/null +++ b/crates/eframe/tutorials/miscellaneous.md @@ -0,0 +1 @@ +# Miscellaneous tutorials diff --git a/crates/eframe/tutorials/technical.md b/crates/eframe/tutorials/technical.md new file mode 100644 index 00000000000..9d4c3227818 --- /dev/null +++ b/crates/eframe/tutorials/technical.md @@ -0,0 +1,20 @@ +# Technical tutorials + +## Press a button when a key is pressed + +If you want to have something that happens when either: + +- a button is clicked, or +- a key is pressed + +This is how you can do that: + +```rust +let my_button = ui.button("Press me"); + +if my_button.clicked() || ui.input(|i| i.key_pressed(egui::Key::Enter)) { + // Do awesome stuff +} +``` + +Now, whenever `my_button` is clicked _or_ the `Enter` key is pressed, they will do the same thing. diff --git a/crates/eframe/tutorials/tutorials.md b/crates/eframe/tutorials/tutorials.md new file mode 100644 index 00000000000..b5f95fd7d91 --- /dev/null +++ b/crates/eframe/tutorials/tutorials.md @@ -0,0 +1,11 @@ +# `eframe` Tutorials + +This is a list of tutorials to do small things using eframe + +- [Layout](./layout.md) +- [Technical](./technical.md) +- [Miscellaneous](./miscellaneous.md) + +--- + +These tutorials are a work in progress. You can contribute to them by submitting a PR on GitHub