Misc doc improvements

This commit is contained in:
Emil Ernerfeldt 2022-04-13 22:05:19 +02:00
parent 2ae93c40ab
commit a7b6334784
14 changed files with 48 additions and 16 deletions

View file

@ -160,7 +160,7 @@ jobs:
toolchain: 1.60.0
override: true
- run: sudo apt-get update && sudo apt-get install libspeechd-dev
- run: cargo doc -p emath -p epaint -p egui -p eframe -p epi -p egui_web -p egui-winit -p egui_extras -p egui_glium -p egui_glow --lib --no-deps --all-features
- run: cargo doc -p eframe -p egui -p egui_extras -p egui_glium -p egui_glow -p egui_web -p egui-winit -p emath -p epaint -p epi --lib --no-deps --all-features
doc_web:
name: cargo doc web

View file

@ -165,7 +165,7 @@ If you're making an app, your best bet is using [`eframe`](https://github.com/em
These are the official egui integrations:
* [`egui_glium`](https://github.com/emilk/egui/tree/master/egui_glium) for compiling native apps with [Glium](https://github.com/glium/glium).
* [`egui_glow`](https://github.com/emilk/egui/tree/master/egui_glow) for compiling native apps with [glow](https://github.com/grovesNL/glow).
* [`egui_glow`](https://github.com/emilk/egui/tree/master/egui_glow) for rendering egui with [glow](https://github.com/grovesNL/glow) on native and web, and for making native apps.
* [`egui_web`](https://github.com/emilk/egui/tree/master/egui_web) for making a web app. Compiles to WASM, renders with WebGL. [Click to run the egui demo](https://www.egui.rs/#demo). Uses `egui_glow`.
* [`egui-winit`](https://github.com/emilk/egui/tree/master/egui-winit) for integrating with [winit](https://github.com/rust-windowing/winit). `egui-winit` is used by `egui_glium` and `egui_glow`.

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<head>
<title>egui An experimental immediate mode GUI written in Rust</title>
<title>egui An immediate mode GUI written in Rust</title>
<style>
html {
/* Remove touch delay: */

View file

@ -27,6 +27,8 @@ To use on Linux, first run:
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
```
You need to either use `edition = "2021"`, or set `resolver = "2"` in the `[workspace`] section of your to-level `Cargo.toml`. See [this link](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) for more info.
## Alternatives
`eframe` is not the only way to write an app using `egui`! You can also try [`egui-miniquad`](https://github.com/not-fl3/egui-miniquad), [`bevy_egui`](https://github.com/mvlabat/bevy_egui), [`egui_sdl2_gl`](https://github.com/ArjunNair/egui_sdl2_gl), and others.
@ -36,7 +38,7 @@ sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev lib
Not all rust crates work when compiled to WASM, but here are some useful crates have been designed to work well both natively and as WASM:
* Audio: [`cpal`](https://github.com/RustAudio/cpal).
* HTTP client: [`ehttp`](https://github.com/emilk/ehttp).
* HTTP client: [`ehttp`](https://github.com/emilk/ehttp) and [`reqwest`](https://github.com/seanmonstar/reqwest).
* Time: [`chrono`](https://github.com/chronotope/chrono).
* WebSockets: [`ewebsock`](https://github.com/rerun-io/ewebsock).

View file

@ -122,7 +122,6 @@ pub type IconPainter = Box<dyn FnOnce(&mut Ui, f32, &Response)>;
/// A header which can be collapsed/expanded, revealing a contained [`Ui`] region.
///
///
/// ```
/// # egui::__run_test_ui(|ui| {
/// egui::CollapsingHeader::new("Heading")

View file

@ -3,7 +3,17 @@
use crate::{layers::ShapeIdx, style::Margin, *};
use epaint::*;
/// Color and margin of a rectangular background of a [`Ui`].
/// Add a background, frame and/or margin to a rectangular background of a [`Ui`].
///
/// ```
/// # egui::__run_test_ui(|ui| {
/// egui::Frame::none()
/// .fill(egui::Color32::RED)
/// .show(ui, |ui| {
/// ui.label("Label with red background");
/// });
/// # });
/// ```
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[must_use = "You should call .show()"]
pub struct Frame {

View file

@ -74,6 +74,8 @@ pub struct ScrollAreaOutput<R> {
/// });
/// # });
/// ```
///
/// You can scroll to an element using [`Response::scroll_to_me`], [`Ui::scroll_to_cursor`] and [`Ui::scroll_to_rect`].
#[derive(Clone, Debug)]
#[must_use = "You should call .show()"]
pub struct ScrollArea {

View file

@ -176,6 +176,9 @@
//! by how much the slider has been dragged in the previous few milliseconds.
//! This means it is responsibility of the egui user to store the state (`value`) so that it persists between frames.
//!
//! It can be useful to read the code for the toggle switch example widget to get a better understanding
//! of how egui works: <https://github.com/emilk/egui/blob/master/egui_demo_lib/src/apps/demo/toggle_switch.rs>.
//!
//! Read more about the pros and cons of immediate mode at <https://github.com/emilk/egui#why-immediate-mode>.
//!
//! # Misc

View file

@ -918,7 +918,7 @@ impl Ui {
///
/// If `align` is `None`, it'll scroll enough to bring the cursor into view.
///
/// See also: [`Response::scroll_to_me`], [`Ui::scroll_to_rect`].
/// See also: [`Response::scroll_to_me`], [`Ui::scroll_to_cursor`].
///
/// ```
/// # use egui::Align;

View file

@ -46,6 +46,9 @@ use super::{CCursorRange, CursorRange, TextEditOutput, TextEditState};
///
/// ## Advanced usage
/// See [`TextEdit::show`].
///
/// ## Other
/// The background color of a [`TextEdit`] is [`Visuals::extreme_bg_color`].
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
pub struct TextEdit<'t> {
text: &'t mut dyn TextBuffer,

View file

@ -31,8 +31,12 @@ eframe = { version = "0.17.0", path = "../eframe" }
egui_demo_lib = { version = "0.17.0", path = "../egui_demo_lib", features = [
"extra_debug_asserts",
] }
# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tracing-subscriber = "0.3"
# web:
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
tracing-wasm = "0.2"

View file

@ -5,7 +5,11 @@
![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
![Apache](https://img.shields.io/badge/license-Apache-blue.svg)
This crates provides bindings between [`egui`](https://github.com/emilk/egui) and [glow](https://crates.io/crates/glow) which allows you to write GUI code using egui and compile it and run it natively, cross platform.
This crates provides bindings between [`egui`](https://github.com/emilk/egui) and [glow](https://crates.io/crates/glow) which allows you to:
* Render egui using glow on both native and web.
* Write cross platform native egui apps (with the `winit` feature).
To write web apps using `glow` you should use either [`eframe`](https://github.com/emilk/egui/tree/master/eframe) or [`egui_web`](https://github.com/emilk/egui/tree/master/egui_web) (both uses `egui_glow` for rendering, by default).
To use on Linux, first run:
@ -13,4 +17,4 @@ To use on Linux, first run:
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
```
This crate depends on [`egui-winit`](https://github.com/emilk/egui/tree/master/egui-winit).
This crate optionally depends on [`egui-winit`](https://github.com/emilk/egui/tree/master/egui-winit).

View file

@ -260,17 +260,21 @@ fn fast_round(r: f32) -> u8 {
/// A change to an image.
///
/// Either a whole new image,
/// or an update to a rectangular region of it.
/// Either a whole new image, or an update to a rectangular region of it.
#[derive(Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[must_use = "The painter must take care of this"]
pub struct ImageDelta {
/// What to set the texture to.
///
/// If [`Self::pos`] is `None`, this describes the whole texture.
///
/// If [`Self::pos`] is `Some`, this describes a patch of the whole image starting at [`Self::pos`].
pub image: ImageData,
/// If `None`, set the whole texture to [`Self::image`].
/// If `Some(pos)`, update a sub-region of an already allocated texture.
///
/// If `Some(pos)`, update a sub-region of an already allocated texture with the patch in [`Self::image`].
pub pos: Option<[usize; 2]>,
}

View file

@ -315,12 +315,13 @@ impl Default for FontDefinitions {
/// The collection of fonts used by `epaint`.
///
/// Required in order to paint text.
/// Create one and reuse. Cheap to clone.
/// Required in order to paint text. Create one and reuse. Cheap to clone.
///
/// Each [`Fonts`] comes with a font atlas textures that needs to be used when painting.
///
/// If you are using `egui`, use `egui::Context::set_fonts` and `egui::Context::fonts`.
///
/// You need to call [`Self::begin_frame`] and [`Self::font_image_delta`] once every frame.
///
/// Wrapper for `Arc<Mutex<FontsAndCache>>`.
pub struct Fonts(Arc<Mutex<FontsAndCache>>);
impl Fonts {