mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Replace eframe::Frame commands and WindowInfo with egui (#3564)
* Part of https://github.com/emilk/egui/issues/3556 ## In short You now almost never need to use `eframe::Frame` - instead use `ui.input(|i| i.viewport())` for information about the current viewport (native window), and use `ctx.send_viewport_cmd` to modify it. ## In detail This PR removes most commands from `eframe::Frame`, and replaces them with `ViewportCommand`. So `frame.close()` becomes `ctx.send_viewport_cmd(ViewportCommand::Close)`, etc. `frame.info().window_info` is now also gone, replaced with `ui.input(|i| i.viewport())`. `frame.info().native_pixels_per_point` is replaced with `ui.input(|i| i.raw.native_pixels_per_point)`. `RawInput` now contains one `ViewportInfo` for each viewport. Screenshots are taken with `ctx.send_viewport_cmd(ViewportCommand::Screenshots)` and are returned in `egui::Event` which you can check with: ``` ust ui.input(|i| { for event in &i.raw.events { if let egui::Event::Screenshot { viewport_id, image } = event { // handle it here } } }); ``` ### Motivation You no longer need to pass around the `&eframe::Frame` everywhere. This also opens the door for other integrations to use the same API of `ViewportCommand`s.
This commit is contained in:
@@ -16,17 +16,22 @@ cargo install cargo-cranky # Uses lints defined in Cranky.toml. See https://gith
|
||||
export RUSTFLAGS="--cfg=web_sys_unstable_apis -D warnings"
|
||||
export RUSTDOCFLAGS="-D warnings" # https://github.com/emilk/egui/pull/1454
|
||||
|
||||
# Fast checks first:
|
||||
typos
|
||||
./scripts/lint.py
|
||||
cargo fmt --all -- --check
|
||||
cargo doc --lib --no-deps --all-features
|
||||
cargo doc --document-private-items --no-deps --all-features
|
||||
|
||||
cargo cranky --all-targets --all-features -- -D warnings
|
||||
./scripts/clippy_wasm.sh
|
||||
|
||||
cargo check --all-targets
|
||||
cargo check --all-targets --all-features
|
||||
cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown
|
||||
cargo check -p egui_demo_app --lib --target wasm32-unknown-unknown --all-features
|
||||
cargo cranky --all-targets --all-features -- -D warnings
|
||||
cargo test --all-targets --all-features
|
||||
cargo test --doc # slow - checks all doc-tests
|
||||
cargo fmt --all -- --check
|
||||
|
||||
cargo doc --lib --no-deps --all-features
|
||||
cargo doc --document-private-items --no-deps --all-features
|
||||
|
||||
(cd crates/eframe && cargo check --no-default-features --features "glow")
|
||||
(cd crates/eframe && cargo check --no-default-features --features "wgpu")
|
||||
@@ -53,8 +58,6 @@ cargo doc --document-private-items --no-deps --all-features
|
||||
|
||||
./scripts/wasm_bindgen_check.sh
|
||||
|
||||
cargo cranky --target wasm32-unknown-unknown --all-features -p egui_demo_app --lib -- -D warnings
|
||||
|
||||
./scripts/cargo_deny.sh
|
||||
|
||||
# TODO(emilk): consider using https://github.com/taiki-e/cargo-hack or https://github.com/frewsxcv/cargo-all-features
|
||||
|
||||
Reference in New Issue
Block a user