Move examples out of eframe/examples
into examples/
(#1486)
* Move examples out of eframe/examples into examples/ Give each example a `Cargo.toml` and `src/main.rs`. This makes it easier for people to use as templates. * Update README.md with more deps needed on vanilla Ubuntu * Install libgtk-3-dev on CI, hoping that will fix something
This commit is contained in:
parent
170b21b63e
commit
2ae93c40ab
46 changed files with 317 additions and 71 deletions
4
.github/workflows/rust.yml
vendored
4
.github/workflows/rust.yml
vendored
|
@ -20,7 +20,7 @@ jobs:
|
|||
profile: minimal
|
||||
toolchain: 1.60.0
|
||||
override: true
|
||||
- run: sudo apt-get update && sudo apt-get install libspeechd-dev
|
||||
- run: sudo apt-get update && sudo apt-get install libspeechd-dev libgtk-3-dev
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
@ -35,7 +35,7 @@ jobs:
|
|||
profile: minimal
|
||||
toolchain: 1.60.0
|
||||
override: true
|
||||
- run: sudo apt-get update && sudo apt-get install libspeechd-dev
|
||||
- run: sudo apt-get update && sudo apt-get install libspeechd-dev libgtk-3-dev
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
|
|
@ -7,7 +7,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
|
|||
## Unreleased
|
||||
|
||||
### Added ⭐
|
||||
* Added `Shape::Callback` for backend-specific painting, [with an example](https://github.com/emilk/egui/blob/master/eframe/examples/custom_3d_three-d.rs) ([#1351](https://github.com/emilk/egui/pull/1351)).
|
||||
* Added `Shape::Callback` for backend-specific painting, [with an example](https://github.com/emilk/egui/blob/master/examples/custom_3d_three/) ([#1351](https://github.com/emilk/egui/pull/1351)).
|
||||
* Added `Frame::canvas` ([#1362](https://github.com/emilk/egui/pull/1362)).
|
||||
* `Context::request_repaint` will wake up UI thread, if integrations has called `Context::set_request_repaint_callback` ([#1366](https://github.com/emilk/egui/pull/1366)).
|
||||
* Added `Plot::allow_scroll`, `Plot::allow_zoom` no longer affects scrolling ([#1382](https://github.com/emilk/egui/pull/1382)).
|
||||
|
|
92
Cargo.lock
generated
92
Cargo.lock
generated
|
@ -608,6 +608,13 @@ dependencies = [
|
|||
"cache-padded",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "confirm_exit"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.7"
|
||||
|
@ -817,6 +824,39 @@ version = "0.2.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
||||
|
||||
[[package]]
|
||||
name = "custom_3d_glow"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"egui_glow",
|
||||
"glow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "custom_3d_three-d"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"egui_glow",
|
||||
"glow",
|
||||
"three-d",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "custom_font"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "custom_window_frame"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dark-light"
|
||||
version = "0.2.1"
|
||||
|
@ -980,6 +1020,17 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "download_image"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"egui_extras",
|
||||
"ehttp",
|
||||
"image",
|
||||
"poll-promise",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dyn-clonable"
|
||||
version = "0.9.0"
|
||||
|
@ -1019,18 +1070,9 @@ version = "0.17.0"
|
|||
dependencies = [
|
||||
"egui",
|
||||
"egui-winit",
|
||||
"egui_extras",
|
||||
"egui_glow",
|
||||
"egui_web",
|
||||
"ehttp",
|
||||
"epi",
|
||||
"glow",
|
||||
"image",
|
||||
"poll-promise",
|
||||
"puffin",
|
||||
"puffin_http",
|
||||
"rfd",
|
||||
"three-d",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1301,6 +1343,14 @@ dependencies = [
|
|||
"instant",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "file_dialog"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"rfd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.22"
|
||||
|
@ -1702,6 +1752,13 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hello_world"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
|
@ -2727,6 +2784,15 @@ dependencies = [
|
|||
"usvg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "retained_image"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"egui_extras",
|
||||
"image",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rfd"
|
||||
version = "0.8.0"
|
||||
|
@ -3128,6 +3194,14 @@ version = "0.10.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "svg"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"eframe",
|
||||
"egui_extras",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "svgfilters"
|
||||
version = "0.4.0"
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -13,7 +13,17 @@ members = [
|
|||
"epaint",
|
||||
"epi",
|
||||
|
||||
"examples/confirm_exit",
|
||||
"examples/custom_3d_glow",
|
||||
"examples/custom_3d_three-d",
|
||||
"examples/custom_font",
|
||||
"examples/custom_window_frame",
|
||||
"examples/download_image",
|
||||
"examples/file_dialog",
|
||||
"examples/hello_world",
|
||||
"examples/puffin_profiler",
|
||||
"examples/retained_image",
|
||||
"examples/svg",
|
||||
]
|
||||
|
||||
[profile.dev]
|
||||
|
|
10
README.md
10
README.md
|
@ -50,7 +50,7 @@ ui.label(format!("Hello '{}', age {}", name, age));
|
|||
|
||||
## Quick start
|
||||
|
||||
If you just want to write a GUI application in Rust (for the web or for native), go to <https://github.com/emilk/eframe_template/> and follow the instructions there! The official docs are at <https://docs.rs/egui>. For inspiration, check out the [the egui web demo](https://www.egui.rs/#demo) and follow the links in it to its source code. There is also an excellent tutorial video at <https://www.youtube.com/watch?v=NtUkr_z7l84>.
|
||||
There are simple examples in [the `examples/` folder](https://github.com/emilk/egui/blob/master/examples/). If you want to write a web app, then go to <https://github.com/emilk/eframe_template/> and follow the instructions. The official docs are at <https://docs.rs/egui>. For inspiration and more examples, check out the [the egui web demo](https://www.egui.rs/#demo) and follow the links in it to its source code.
|
||||
|
||||
If you want to integrate egui into an existing engine, go to the [Integrations](#integrations) section.
|
||||
|
||||
|
@ -64,7 +64,7 @@ To test the demo app locally, run `cargo run --release -p egui_demo_app`.
|
|||
|
||||
The native backend is [`egui_glow`](https://github.com/emilk/egui/tree/master/egui_glow) (using [`glow`](https://crates.io/crates/glow)) and should work out-of-the-box on Mac and Windows, but on Linux you need to first run:
|
||||
|
||||
`sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev`
|
||||
`sudo apt-get install -y libclang-dev libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev`
|
||||
|
||||
On Fedora Rawhide you need to run:
|
||||
|
||||
|
@ -312,7 +312,7 @@ Here is an example (from https://github.com/AlexxxRu/TinyPomodoro):
|
|||
If you call `.await` in your GUI code, the UI will freeze, with is very bad UX. Instead, keep the GUI thread non-blocking and communicate with any concurrent tasks (`async` tasks or other threads) with something like:
|
||||
* Channels (e.g. [`std::sync::mpsc::channel`](https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html)). Make sure to use [`try_recv`](https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.try_recv) so you don't block the gui thread!
|
||||
* `Arc<Mutex<Value>>` (background thread sets a value; GUI thread reads it)
|
||||
* [`poll_promise::Promise`](https://docs.rs/poll-promise) (example: [`eframe/examples/download_image.rs`](https://github.com/emilk/egui/blob/master/eframe/examples/download_image.rs))
|
||||
* [`poll_promise::Promise`](https://docs.rs/poll-promise) (example: [`examples/download_image/`](https://github.com/emilk/egui/blob/master/examples/download_image/))
|
||||
* [`eventuals::Eventual`](https://docs.rs/eventuals/latest/eventuals/struct.Eventual.html)
|
||||
* [`tokio::sync::watch::channel`](https://docs.rs/tokio/latest/tokio/sync/watch/fn.channel.html)
|
||||
|
||||
|
@ -338,8 +338,8 @@ If you want to embed 3D into an egui view there are two options.
|
|||
|
||||
#### `Shape::Callback`
|
||||
Examples:
|
||||
* <https://github.com/emilk/egui/blob/master/eframe/examples/custom_3d_three-d.rs>
|
||||
* <https://github.com/emilk/egui/blob/master/eframe/examples/custom_3d_glow.rs>
|
||||
* <https://github.com/emilk/egui/blob/master/examples/custom_3d_three-d.rs>
|
||||
* <https://github.com/emilk/egui/blob/master/examples/custom_3d_glow.rs>
|
||||
|
||||
`Shape::Callback` will call your code when egui gets painted, to show anything using whatever the background rendering context is. When using [`eframe`](https://github.com/emilk/egui/tree/master/eframe) this will be [`glow`](https://github.com/grovesNL/glow). Other integrations will give you other rendering contexts, if they support `Shape::Callback` at all.
|
||||
|
||||
|
|
|
@ -67,19 +67,3 @@ egui-winit = { version = "0.17.0", path = "../egui-winit", default-features = fa
|
|||
# web:
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
egui_web = { version = "0.17.0", path = "../egui_web", default-features = false }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
# For examples:
|
||||
egui_extras = { path = "../egui_extras", features = ["image", "svg"] }
|
||||
ehttp = "0.2"
|
||||
glow = "0.11"
|
||||
image = { version = "0.24", default-features = false, features = [
|
||||
"jpeg",
|
||||
"png",
|
||||
] }
|
||||
poll-promise = "0.1"
|
||||
puffin = "0.13"
|
||||
puffin_http = "0.10"
|
||||
rfd = "0.8"
|
||||
three-d = { version = "0.11", default-features = false }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
`eframe` is the official framework library for writing apps using [`egui`](https://github.com/emilk/egui). The app can be compiled both to run natively (cross platform) or be compiled to a web app (using WASM).
|
||||
|
||||
To get started, see the [crate examples](https://github.com/emilk/egui/tree/master/examples) and [single-file examples](https://github.com/emilk/egui/tree/master/eframe/examples).
|
||||
To get started, see the [examples](https://github.com/emilk/egui/tree/master/examples).
|
||||
To learn how to set up `eframe` for web and native, go to <https://github.com/emilk/eframe_template/> and follow the instructions there!
|
||||
|
||||
There is also a tutorial video at <https://www.youtube.com/watch?v=NtUkr_z7l84>.
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
//! and are happy with just using egui for all visuals,
|
||||
//! Then `eframe` is for you!
|
||||
//!
|
||||
//! To get started, see the [crate examples](https://github.com/emilk/egui/tree/master/examples) and [single-file examples](https://github.com/emilk/egui/tree/master/eframe/examples).
|
||||
//! To get started, see the [examples](https://github.com/emilk/egui/tree/master/examples).
|
||||
//! To learn how to set up `eframe` for web and native, go to <https://github.com/emilk/eframe_template/> and follow the instructions there!
|
||||
//!
|
||||
//! You write your application code for [`epi`] (implementing [`epi::App`]) and then
|
||||
//! call from [`crate::run_native`] your `main.rs`, and/or call `eframe::start_web` from your `lib.rs`.
|
||||
//! In short, you implement [`App`] and then
|
||||
//! call [`crate::run_native`] from your `main.rs`, and/or call `eframe::start_web` from your `lib.rs`.
|
||||
//!
|
||||
//! `eframe` is implemented using [`egui_web`](https://github.com/emilk/egui/tree/master/egui_web) for web and
|
||||
//! [`egui_glium`](https://github.com/emilk/egui/tree/master/egui_glium) or [`egui_glow`](https://github.com/emilk/egui/tree/master/egui_glow) for native.
|
||||
//! [`egui_glow`](https://github.com/emilk/egui/tree/master/egui_glow) for native.
|
||||
//!
|
||||
//! ## Usage, native:
|
||||
//! ``` no_run
|
||||
|
@ -100,7 +100,7 @@ pub fn start_web(canvas_id: &str, app_creator: AppCreator) -> Result<(), wasm_bi
|
|||
/// This is how you start a native (desktop) app.
|
||||
///
|
||||
/// The first argument is name of your app, used for the title bar of the native window
|
||||
/// and the save location of persistence (see [`epi::App::save`]).
|
||||
/// and the save location of persistence (see [`App::save`]).
|
||||
///
|
||||
/// Call from `fn main` like this:
|
||||
/// ``` no_run
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
There are no stand-alone egui examples, because egui is not stand-alone!
|
||||
|
||||
There are plenty of examples in [the online demo](https://www.egui.rs/#demo). You can find the source code for it at <https://github.com/emilk/egui/tree/master/egui_demo_lib>.
|
||||
See the top-level [examples](https://github.com/emilk/egui/tree/master/examples/) folder instead.
|
||||
|
||||
There are also plenty of examples in [the online demo](https://www.egui.rs/#demo). You can find the source code for it at <https://github.com/emilk/egui/tree/master/egui_demo_lib>.
|
||||
|
||||
If you are using `eframe`, the [crate examples](https://github.com/emilk/egui/tree/master/examples) and [single-file examples](https://github.com/emilk/egui/tree/master/eframe/examples).
|
||||
To learn how to set up `eframe` for web and native, go to <https://github.com/emilk/eframe_template/> and follow the instructions there!
|
||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
|||
|
||||
let mut egui_glium = egui_glium::EguiGlium::new(&display);
|
||||
|
||||
let png_data = include_bytes!("../../eframe/examples/rust-logo-256x256.png");
|
||||
let png_data = include_bytes!("../../examples/retained_image/src/rust-logo-256x256.png");
|
||||
let image = load_glium_image(png_data);
|
||||
let image_size = egui::Vec2::new(image.width as f32, image.height as f32);
|
||||
// Load to gpu memory
|
||||
|
|
|
@ -72,7 +72,7 @@ pub trait App {
|
|||
///
|
||||
/// A scenario where this method will be run is after pressing the close button on a native
|
||||
/// window, which allows you to ask the user whether they want to do something before exiting.
|
||||
/// See the example `eframe/examples/confirm_exit.rs` for practical usage.
|
||||
/// See the example at <https://github.com/emilk/egui/blob/master/examples/confirm_exit/> for practical usage.
|
||||
///
|
||||
/// It will _not_ be called on the web or when the window is forcefully closed.
|
||||
fn on_exit_event(&mut self) -> bool {
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
Examples of how to use [`eframe`](https://github.com/emilk/egui/tree/master/eframe) and [`egui`](https://github.com/emilk/egui/).
|
||||
# `egui` and `eframe` examples
|
||||
All the examples in this folder uses [`eframe`](https://github.com/emilk/egui/tree/master/eframe) to set up a window for [`egui`](https://github.com/emilk/egui/). Some examples are specific to `eframe`, but many are applicable to any `egui` integration.
|
||||
|
||||
There are a lot more examples at <https://www.egui.rs>, and it has links to the source code of each example.
|
||||
|
||||
Also check out the official docs at <https://docs.rs/egui> and <https://docs.rs/eframe>.
|
||||
|
|
12
examples/confirm_exit/Cargo.toml
Normal file
12
examples/confirm_exit/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "confirm_exit"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
3
examples/confirm_exit/README.md
Normal file
3
examples/confirm_exit/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
```sh
|
||||
cargo run -p confirm_exit
|
||||
```
|
|
@ -34,14 +34,14 @@ impl eframe::App for MyApp {
|
|||
.resizable(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Not yet").clicked() {
|
||||
self.is_exiting = false;
|
||||
}
|
||||
|
||||
if ui.button("Yes!").clicked() {
|
||||
self.can_exit = true;
|
||||
frame.quit();
|
||||
}
|
||||
|
||||
if ui.button("Not yet").clicked() {
|
||||
self.is_exiting = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
14
examples/custom_3d_glow/Cargo.toml
Normal file
14
examples/custom_3d_glow/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "custom_3d_glow"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
||||
egui_glow = { path = "../../egui_glow" }
|
||||
glow = "0.11"
|
15
examples/custom_3d_glow/README.md
Normal file
15
examples/custom_3d_glow/README.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
This demo shows how to embed 3D rendering using [`glow`](https://github.com/grovesNL/glow) in `eframe`.
|
||||
|
||||
This is very advanced usage, and you need to be careful.
|
||||
|
||||
If you want an easier way to show 3D graphics with egui, take a look at the `custom_3d_three-d.rs` example.
|
||||
|
||||
If you are content of having egui sit on top of a 3D background, take a look at:
|
||||
|
||||
* [`bevy_egui`](https://github.com/mvlabat/bevy_egui)
|
||||
* [`three-d`](https://github.com/asny/three-d)
|
||||
|
||||
|
||||
```sh
|
||||
cargo run -p custom_3d_glow
|
||||
```
|
|
@ -1,14 +1,3 @@
|
|||
//! This demo shows how to embed 3D rendering using [`glow`](https://github.com/grovesNL/glow) in `eframe`.
|
||||
//!
|
||||
//! This is very advanced usage, and you need to be careful.
|
||||
//!
|
||||
//! If you want an easier way to show 3D graphics with egui, take a look at the `custom_3d_three-d.rs` example.
|
||||
//!
|
||||
//! If you are content of having egui sit on top of a 3D background, take a look at:
|
||||
//!
|
||||
//! * [`bevy_egui`](https://github.com/mvlabat/bevy_egui)
|
||||
//! * [`three-d`](https://github.com/asny/three-d)
|
||||
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
#![allow(unsafe_code)]
|
||||
|
15
examples/custom_3d_three-d/Cargo.toml
Normal file
15
examples/custom_3d_three-d/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[package]
|
||||
name = "custom_3d_three-d"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
||||
egui_glow = { path = "../../egui_glow" }
|
||||
glow = "0.11"
|
||||
three-d = { version = "0.11", default-features = false }
|
16
examples/custom_3d_three-d/README.md
Normal file
16
examples/custom_3d_three-d/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
This demo shows how to embed 3D rendering using [`three-d`](https://github.com/asny/three-d) in `eframe`.
|
||||
|
||||
Any 3D library built on top of [`glow`](https://github.com/grovesNL/glow) can be used in `eframe`.
|
||||
|
||||
Alternatively you can render 3D stuff to a texture and display it using [`egui::Ui::image`].
|
||||
|
||||
If you are content of having egui sit on top of a 3D background, take a look at:
|
||||
|
||||
* [`bevy_egui`](https://github.com/mvlabat/bevy_egui)
|
||||
* [`three-d`](https://github.com/asny/three-d)
|
||||
|
||||
|
||||
|
||||
```sh
|
||||
cargo run -p custom_3d_three-d
|
||||
```
|
|
@ -1,14 +1,3 @@
|
|||
//! This demo shows how to embed 3D rendering using [`three-d`](https://github.com/asny/three-d) in `eframe`.
|
||||
//!
|
||||
//! Any 3D library built on top of [`glow`](https://github.com/grovesNL/glow) can be used in `eframe`.
|
||||
//!
|
||||
//! Alternatively you can render 3D stuff to a texture and display it using [`egui::Ui::image`].
|
||||
//!
|
||||
//! If you are content of having egui sit on top of a 3D background, take a look at:
|
||||
//!
|
||||
//! * [`bevy_egui`](https://github.com/mvlabat/bevy_egui)
|
||||
//! * [`three-d`](https://github.com/asny/three-d)
|
||||
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
|
||||
use eframe::egui;
|
12
examples/custom_font/Cargo.toml
Normal file
12
examples/custom_font/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "custom_font"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
3
examples/custom_font/README.md
Normal file
3
examples/custom_font/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
```sh
|
||||
cargo run -p custom_font
|
||||
```
|
|
@ -19,7 +19,7 @@ fn setup_custom_fonts(ctx: &egui::Context) {
|
|||
// .ttf and .otf files supported.
|
||||
fonts.font_data.insert(
|
||||
"my_font".to_owned(),
|
||||
egui::FontData::from_static(include_bytes!("../../epaint/fonts/Hack-Regular.ttf")),
|
||||
egui::FontData::from_static(include_bytes!("../../../epaint/fonts/Hack-Regular.ttf")),
|
||||
);
|
||||
|
||||
// Put my font first (highest priority) for proportional text:
|
12
examples/custom_window_frame/Cargo.toml
Normal file
12
examples/custom_window_frame/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "custom_window_frame"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
3
examples/custom_window_frame/README.md
Normal file
3
examples/custom_window_frame/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
```sh
|
||||
cargo run -p custom_window_frame
|
||||
```
|
16
examples/download_image/Cargo.toml
Normal file
16
examples/download_image/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[package]
|
||||
name = "download_image"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
||||
egui_extras = { path = "../../egui_extras", features = ["image"] }
|
||||
ehttp = "0.2"
|
||||
image = { version = "0.24", default-features = false, features = ["jpeg"] }
|
||||
poll-promise = "0.1"
|
3
examples/download_image/README.md
Normal file
3
examples/download_image/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
```sh
|
||||
cargo run -p download_image
|
||||
```
|
13
examples/file_dialog/Cargo.toml
Normal file
13
examples/file_dialog/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "file_dialog"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
||||
rfd = "0.8"
|
5
examples/file_dialog/README.md
Normal file
5
examples/file_dialog/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
How to show a file dialog using [`rfd`](https://github.com/PolyMeilex/rfd).
|
||||
|
||||
```sh
|
||||
cargo run -p file_dialog
|
||||
```
|
12
examples/hello_world/Cargo.toml
Normal file
12
examples/hello_world/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "hello_world"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
3
examples/hello_world/README.md
Normal file
3
examples/hello_world/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
```sh
|
||||
cargo run -p hello_world
|
||||
```
|
14
examples/retained_image/Cargo.toml
Normal file
14
examples/retained_image/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "retained_image"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
||||
egui_extras = { path = "../../egui_extras", features = ["image"] }
|
||||
image = { version = "0.24", default-features = false, features = ["png"] }
|
3
examples/retained_image/README.md
Normal file
3
examples/retained_image/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
```sh
|
||||
cargo run -p retained_image
|
||||
```
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
13
examples/svg/Cargo.toml
Normal file
13
examples/svg/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "svg"
|
||||
version = "0.1.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.60"
|
||||
publish = false
|
||||
|
||||
|
||||
[dependencies]
|
||||
eframe = { path = "../../eframe" }
|
||||
egui_extras = { path = "../../egui_extras", features = ["svg"] }
|
6
examples/svg/README.md
Normal file
6
examples/svg/README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
Example how to show an SVG image.
|
||||
|
||||
|
||||
```sh
|
||||
cargo run -p svg
|
||||
```
|
1
examples/svg/src/rust-logo-license.txt
Normal file
1
examples/svg/src/rust-logo-license.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Rust logo by Mozilla, from https://github.com/rust-lang/rust-artwork
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.3 KiB |
Loading…
Reference in a new issue