Improve documentation
This commit is contained in:
parent
67c0fbdd01
commit
1f2aebc25a
15 changed files with 48 additions and 26 deletions
|
@ -19,8 +19,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
### Changed 🔧
|
### Changed 🔧
|
||||||
|
|
||||||
* New simpler and sleeker look!
|
* New simpler and sleeker look!
|
||||||
* Center window titles.
|
|
||||||
* Tweak size and alignment of some emojis to match other text.
|
|
||||||
* Rename `PaintCmd` to `Shape`.
|
* Rename `PaintCmd` to `Shape`.
|
||||||
* Replace tuple `(Rect, Shape)` with tuple-struct `ClippedShape`.
|
* Replace tuple `(Rect, Shape)` with tuple-struct `ClippedShape`.
|
||||||
* Rename feature `"serde"` to `"persistence"`.
|
* Rename feature `"serde"` to `"persistence"`.
|
||||||
|
@ -31,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
* Fixed a bug that would sometimes trigger a "Mismatching panels" panic in debug builds.
|
* Fixed a bug that would sometimes trigger a "Mismatching panels" panic in debug builds.
|
||||||
* `Image` and `ImageButton` will no longer stretch to fill a justified layout.
|
* `Image` and `ImageButton` will no longer stretch to fill a justified layout.
|
||||||
|
|
||||||
|
|
||||||
## 0.7.0 - 2021-01-04
|
## 0.7.0 - 2021-01-04
|
||||||
|
|
||||||
### Added ⭐
|
### Added ⭐
|
||||||
|
|
|
@ -75,3 +75,5 @@
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
<!-- Powered by Egui: https://github.com/emilk/egui/ -->
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
//! eframe - the Egui Framework crate
|
//! eframe - the Egui Framework crate
|
||||||
//!
|
//!
|
||||||
//! You write your application code for [`epi`] (implementing [`epi::App`]) and then
|
//! If you are planning to write an app for web or native,
|
||||||
//! use eframe to either compile and run it natively, or compile it as a web app.
|
//! and are happy with just using Egui for all visuals,
|
||||||
|
//! Then `eframe` is for you!
|
||||||
//!
|
//!
|
||||||
//! To get started, look at <https://github.com/emilk/egui_template>.
|
//! To get started, look at <https://github.com/emilk/egui_template>.
|
||||||
//!
|
//!
|
||||||
//! eframe is implemented using [`egui_web`](https://docs.rs/egui_web) and [`egui_glium`](https://docs.rs/egui_glium).
|
//! 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`.
|
||||||
|
//!
|
||||||
|
//! `eframe` is implemented using [`egui_web`](https://docs.rs/egui_web) and [`egui_glium`](https://docs.rs/egui_glium).
|
||||||
|
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
#![cfg_attr(not(debug_assertions), deny(warnings))] // Forbid warnings in release builds
|
||||||
|
@ -23,7 +27,7 @@ pub use egui_web::wasm_bindgen;
|
||||||
/// and start running the given app.
|
/// and start running the given app.
|
||||||
///
|
///
|
||||||
/// Usage:
|
/// Usage:
|
||||||
/// ``` ignore
|
/// ``` no_run
|
||||||
/// #[cfg(target_arch = "wasm32")]
|
/// #[cfg(target_arch = "wasm32")]
|
||||||
/// use wasm_bindgen::prelude::*;
|
/// use wasm_bindgen::prelude::*;
|
||||||
///
|
///
|
||||||
|
|
|
@ -193,7 +193,7 @@ impl GridLayout {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// A simple `Grid` layout.
|
/// A simple grid layout.
|
||||||
///
|
///
|
||||||
/// The contents of each cell be aligned to the left and center.
|
/// The contents of each cell be aligned to the left and center.
|
||||||
/// If you want to add multiple widgets to a cell you need to group them with
|
/// If you want to add multiple widgets to a cell you need to group them with
|
||||||
|
@ -209,6 +209,11 @@ impl GridLayout {
|
||||||
/// ui.label("Second row, first column");
|
/// ui.label("Second row, first column");
|
||||||
/// ui.label("Second row, second column");
|
/// ui.label("Second row, second column");
|
||||||
/// ui.label("Second row, third column");
|
/// ui.label("Second row, third column");
|
||||||
|
/// ui.end_row();
|
||||||
|
///
|
||||||
|
/// ui.horizontal(|ui| { ui.label("Same"); ui.label("cell"); });
|
||||||
|
/// ui.label("Third row, second column");
|
||||||
|
/// ui.end_row();
|
||||||
/// });
|
/// });
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Grid {
|
pub struct Grid {
|
||||||
|
@ -220,6 +225,7 @@ pub struct Grid {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Grid {
|
impl Grid {
|
||||||
|
/// Create a new [`Grid`] with a locally unique identifier.
|
||||||
pub fn new(id_source: impl std::hash::Hash) -> Self {
|
pub fn new(id_source: impl std::hash::Hash) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id_source: Id::new(id_source),
|
id_source: Id::new(id_source),
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
//! Handles paint layers, i.e. how things
|
||||||
|
//! are sometimes painted behind or in front of other things.
|
||||||
|
|
||||||
use crate::{math::Rect, Id, *};
|
use crate::{math::Rect, Id, *};
|
||||||
use epaint::ahash::AHashMap;
|
use epaint::ahash::AHashMap;
|
||||||
use epaint::{ClippedShape, Shape};
|
use epaint::{ClippedShape, Shape};
|
||||||
|
|
|
@ -156,7 +156,7 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
/// Create a [`Hyperlink`](crate::Hyperlink) to this file (and line) on Github
|
/// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] (and line) on Github
|
||||||
///
|
///
|
||||||
/// Example: `ui.add(github_link_file_line!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));`
|
/// Example: `ui.add(github_link_file_line!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));`
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
@ -167,7 +167,7 @@ macro_rules! github_link_file_line {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a [`Hyperlink`](crate::Hyperlink) to this file on github.
|
/// Create a [`Hyperlink`](crate::Hyperlink) to the current [`file!()`] on github.
|
||||||
///
|
///
|
||||||
/// Example: `ui.add(github_link_file!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));`
|
/// Example: `ui.add(github_link_file!("https://github.com/YOUR/PROJECT/blob/master/", "(source code)"));`
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
/// left/center/right or top/center/bottom alignment for e.g. anchors and `Layout`s.
|
/// left/center/right or top/center/bottom alignment for e.g. anchors and layouts.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
//! Vectors, positions, rectangles etc.
|
//! Opinionated 2D math library for building GUIs.
|
||||||
|
//!
|
||||||
|
//! Includes vectors, positions, rectangles etc.
|
||||||
//!
|
//!
|
||||||
//! Conventions (unless otherwise specified):
|
//! Conventions (unless otherwise specified):
|
||||||
//!
|
//!
|
||||||
|
@ -127,7 +129,7 @@ where
|
||||||
lerp(to, t)
|
lerp(to, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `remap`, but also clamps the value so that the returned value is always in the `to` range.
|
/// Like [`remap`], but also clamps the value so that the returned value is always in the `to` range.
|
||||||
pub fn remap_clamp<T>(x: T, from: RangeInclusive<T>, to: RangeInclusive<T>) -> T
|
pub fn remap_clamp<T>(x: T, from: RangeInclusive<T>, to: RangeInclusive<T>) -> T
|
||||||
where
|
where
|
||||||
T: Real,
|
T: Real,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Color conversions and types.
|
||||||
|
|
||||||
use emath::clamp;
|
use emath::clamp;
|
||||||
|
|
||||||
/// This format is used for space-efficient color representation (32 bits).
|
/// This format is used for space-efficient color representation (32 bits).
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
pub mod color;
|
pub mod color;
|
||||||
pub mod mutex;
|
pub mod mutex;
|
||||||
mod shadow;
|
mod shadow;
|
||||||
pub mod shape;
|
mod shape;
|
||||||
pub mod stats;
|
pub mod stats;
|
||||||
mod stroke;
|
mod stroke;
|
||||||
pub mod tessellator;
|
pub mod tessellator;
|
||||||
|
@ -108,7 +108,7 @@ pub(crate) struct PaintRect {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ClippedShape(
|
pub struct ClippedShape(
|
||||||
/// Clip / scissor rectangle.
|
/// Clip / scissor rectangle.
|
||||||
/// Only show the part of the [`shape`] that falls within this.
|
/// Only show the part of the [`Shape`] that falls within this.
|
||||||
pub emath::Rect,
|
pub emath::Rect,
|
||||||
/// The shape
|
/// The shape
|
||||||
pub Shape,
|
pub Shape,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
/// A rectangular shadow with a soft penumbra.
|
||||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
pub struct Shadow {
|
pub struct Shadow {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
//! Collect statistics about what is being painted.
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
/// Size of the elements in a vector/array.
|
||||||
#[derive(Clone, Copy, PartialEq)]
|
#[derive(Clone, Copy, PartialEq)]
|
||||||
enum ElementSize {
|
enum ElementSize {
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -13,6 +16,7 @@ impl Default for ElementSize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Aggregate information about a bunch of allocations.
|
||||||
#[derive(Clone, Copy, Default, PartialEq)]
|
#[derive(Clone, Copy, Default, PartialEq)]
|
||||||
pub struct AllocInfo {
|
pub struct AllocInfo {
|
||||||
element_size: ElementSize,
|
element_size: ElementSize,
|
||||||
|
@ -131,6 +135,7 @@ impl AllocInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Collected allocation statistics for shapes and meshes.
|
||||||
#[derive(Clone, Copy, Default)]
|
#[derive(Clone, Copy, Default)]
|
||||||
pub struct PaintStats {
|
pub struct PaintStats {
|
||||||
pub shapes: AllocInfo,
|
pub shapes: AllocInfo,
|
||||||
|
|
|
@ -66,18 +66,14 @@ fn rusttype_font_from_font_data(name: &str, data: &FontData) -> rusttype::Font<'
|
||||||
|
|
||||||
/// Describes the font data and the sizes to use.
|
/// Describes the font data and the sizes to use.
|
||||||
///
|
///
|
||||||
/// This is how you can tell Egui which fonts and font sizes to use.
|
|
||||||
///
|
|
||||||
/// Often you would start with [`FontDefinitions::default()`] and then add/change the contents.
|
/// Often you would start with [`FontDefinitions::default()`] and then add/change the contents.
|
||||||
///
|
///
|
||||||
/// ``` ignore
|
/// ```
|
||||||
/// # let mut ctx = egui::CtxRef::default();
|
/// let mut fonts = epaint::text::FontDefinitions::default();
|
||||||
/// let mut fonts = egui::FontDefinitions::default();
|
|
||||||
/// // Large button text:
|
/// // Large button text:
|
||||||
/// fonts.family_and_size.insert(
|
/// fonts.family_and_size.insert(
|
||||||
/// egui::TextStyle::Button,
|
/// epaint::text::TextStyle::Button,
|
||||||
/// (egui::FontFamily::Proportional, 32.0));
|
/// (epaint::text::FontFamily::Proportional, 32.0));
|
||||||
/// ctx.set_fonts(fonts);
|
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||||
|
@ -86,7 +82,7 @@ pub struct FontDefinitions {
|
||||||
/// List of font names and their definitions.
|
/// List of font names and their definitions.
|
||||||
/// The definition must be the contents of either a `.ttf` or `.otf` font file.
|
/// The definition must be the contents of either a `.ttf` or `.otf` font file.
|
||||||
///
|
///
|
||||||
/// Egui has built-in-default for these,
|
/// `epaint` has built-in-default for these,
|
||||||
/// but you can override them if you like.
|
/// but you can override them if you like.
|
||||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||||
pub font_data: BTreeMap<String, FontData>,
|
pub font_data: BTreeMap<String, FontData>,
|
||||||
|
@ -94,7 +90,7 @@ pub struct FontDefinitions {
|
||||||
/// Which fonts (names) to use for each [`FontFamily`].
|
/// Which fonts (names) to use for each [`FontFamily`].
|
||||||
///
|
///
|
||||||
/// The list should be a list of keys into [`Self::font_data`].
|
/// The list should be a list of keys into [`Self::font_data`].
|
||||||
/// When looking for a character glyph Egui will start with
|
/// When looking for a character glyph `epaint` will start with
|
||||||
/// the first font and then move to the second, and so on.
|
/// the first font and then move to the second, and so on.
|
||||||
/// So the first font is the primary, and then comes a list of fallbacks in order of priority.
|
/// So the first font is the primary, and then comes a list of fallbacks in order of priority.
|
||||||
pub fonts_for_family: BTreeMap<FontFamily, Vec<String>>,
|
pub fonts_for_family: BTreeMap<FontFamily, Vec<String>>,
|
||||||
|
@ -175,7 +171,7 @@ impl Default for FontDefinitions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The collection of fonts used by Egui.
|
/// The collection of fonts used by `epaint`.
|
||||||
///
|
///
|
||||||
/// Note: `Fonts::default()` is invalid (missing `pixels_per_point`).
|
/// Note: `Fonts::default()` is invalid (missing `pixels_per_point`).
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Everything related to text, fonts, text layout, cursors etc.
|
||||||
|
|
||||||
pub mod cursor;
|
pub mod cursor;
|
||||||
mod font;
|
mod font;
|
||||||
mod fonts;
|
mod fonts;
|
||||||
|
|
|
@ -160,7 +160,7 @@ impl<'a> Frame<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Information about the web environment
|
/// Information about the web environment (if applicable).
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct WebInfo {
|
pub struct WebInfo {
|
||||||
/// e.g. "#fragment" part of "www.example.com/index.html#fragment".
|
/// e.g. "#fragment" part of "www.example.com/index.html#fragment".
|
||||||
|
|
Loading…
Reference in a new issue