1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 07:03:14 -04:00
Files
egui/scripts/check.sh
Emil Ernerfeldt 1571027556 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.
2023-11-18 19:27:53 +01:00

80 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# This scripts runs various CI-like checks in a convenient way.
set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
set -x
# Checks all tests, lints etc.
# Basically does what the CI does.
cargo install cargo-cranky # Uses lints defined in Cranky.toml. See https://github.com/ericseppanen/cargo-cranky
# web_sys_unstable_apis is required to enable the web_sys clipboard API which eframe web uses,
# as well as by the wasm32-backend of the wgpu crate.
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 test --all-targets --all-features
cargo test --doc # slow - checks all doc-tests
(cd crates/eframe && cargo check --no-default-features --features "glow")
(cd crates/eframe && cargo check --no-default-features --features "wgpu")
(cd crates/egui && cargo check --no-default-features --features "serde")
(cd crates/egui_demo_app && cargo check --no-default-features --features "glow")
(cd crates/egui_demo_app && cargo check --no-default-features --features "wgpu")
(cd crates/egui_demo_lib && cargo check --no-default-features)
(cd crates/egui_extras && cargo check --no-default-features)
(cd crates/egui_glow && cargo check --no-default-features)
(cd crates/egui-winit && cargo check --no-default-features --features "wayland")
(cd crates/egui-winit && cargo check --no-default-features --features "x11")
(cd crates/emath && cargo check --no-default-features)
(cd crates/epaint && cargo check --no-default-features --release)
(cd crates/epaint && cargo check --no-default-features)
(cd crates/eframe && cargo check --all-features)
(cd crates/egui && cargo check --all-features)
(cd crates/egui_demo_app && cargo check --all-features)
(cd crates/egui_extras && cargo check --all-features)
(cd crates/egui_glow && cargo check --all-features)
(cd crates/egui-winit && cargo check --all-features)
(cd crates/emath && cargo check --all-features)
(cd crates/epaint && cargo check --all-features)
./scripts/wasm_bindgen_check.sh
./scripts/cargo_deny.sh
# TODO(emilk): consider using https://github.com/taiki-e/cargo-hack or https://github.com/frewsxcv/cargo-all-features
# ------------------------------------------------------------
#
# For finding bloat:
# cargo bloat --release --bin egui_demo_app -n 200 | rg egui
# Also try https://github.com/google/bloaty
# what compiles slowly?
# cargo clean && time cargo build -p eframe --timings
# https://fasterthanli.me/articles/why-is-my-rust-build-so-slow
# what compiles slowly?
# cargo llvm-lines --lib -p egui | head -20
echo "All checks passed."