egui/examples
Emil Ernerfeldt 63e48dc855
Introduce global `zoom_factor` (#3608)
* Closes https://github.com/emilk/egui/issues/3602

You can now zoom any egui app by pressing Cmd+Plus, Cmd+Minus or Cmd+0,
just like in a browser. This will change the current `zoom_factor`
(default 1.0) which is persisted in the egui memory, and is the same for
all viewports.
You can turn off the keyboard shortcuts with `ctx.options_mut(|o|
o.zoom_with_keyboard = false);`

`zoom_factor` can also be explicitly read/written with
`ctx.zoom_factor()` and `ctx.set_zoom_factor()`.

This redefines `pixels_per_point` as `zoom_factor *
native_pixels_per_point`, where `native_pixels_per_point` is whatever is
the native scale factor for the monitor that the current viewport is in.

This adds some complexity to the interaction with winit, since we need
to know the current `zoom_factor` in a lot of places, because all egui
IO is done in ui points. I'm pretty sure this PR fixes a bunch of subtle
bugs though that used to be in this code.

`egui::gui_zoom::zoom_with_keyboard_shortcuts` is now gone, and is no
longer needed, as this is now the default behavior.

`Context::set_pixels_per_point` is still there, but it is recommended
you use `Context::set_zoom_factor` instead.
2023-11-22 20:34:51 +01:00
..
confirm_exit Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
custom_3d_glow Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
custom_font Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
custom_font_style Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
custom_window_frame Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
file_dialog Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
hello_world Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
hello_world_par Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
hello_world_simple Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
images Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
keyboard_events Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
multiple_viewports Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
puffin_profiler Introduce global `zoom_factor` (#3608) 2023-11-22 20:34:51 +01:00
save_plot Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
screenshot Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
serial_windows Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
test_viewports Introduce global `zoom_factor` (#3608) 2023-11-22 20:34:51 +01:00
user_attention Update MSRV to Rust 1.72 (#3595) 2023-11-21 17:26:35 +01:00
README.md examples/README.md: explain that the examples are for master 2023-02-08 20:34:43 +01:00

README.md

egui and eframe examples

All the examples in this folder uses eframe to set up a window for 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.

Note that all the examples on master are for the latest master version of egui.

If you want to look for examples for a specific version of egui, go to that tag, e.g. https://github.com/emilk/egui/tree/latest/examples.