mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Improve documentation
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
//! Color conversions and types.
|
||||
|
||||
use emath::clamp;
|
||||
|
||||
/// This format is used for space-efficient color representation (32 bits).
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
pub mod color;
|
||||
pub mod mutex;
|
||||
mod shadow;
|
||||
pub mod shape;
|
||||
mod shape;
|
||||
pub mod stats;
|
||||
mod stroke;
|
||||
pub mod tessellator;
|
||||
@@ -108,7 +108,7 @@ pub(crate) struct PaintRect {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ClippedShape(
|
||||
/// 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,
|
||||
/// The shape
|
||||
pub Shape,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use super::*;
|
||||
|
||||
/// A rectangular shadow with a soft penumbra.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Shadow {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! Collect statistics about what is being painted.
|
||||
|
||||
use crate::*;
|
||||
|
||||
/// Size of the elements in a vector/array.
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
enum ElementSize {
|
||||
Unknown,
|
||||
@@ -13,6 +16,7 @@ impl Default for ElementSize {
|
||||
}
|
||||
}
|
||||
|
||||
/// Aggregate information about a bunch of allocations.
|
||||
#[derive(Clone, Copy, Default, PartialEq)]
|
||||
pub struct AllocInfo {
|
||||
element_size: ElementSize,
|
||||
@@ -131,6 +135,7 @@ impl AllocInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/// Collected allocation statistics for shapes and meshes.
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct PaintStats {
|
||||
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.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// ``` ignore
|
||||
/// # let mut ctx = egui::CtxRef::default();
|
||||
/// let mut fonts = egui::FontDefinitions::default();
|
||||
/// ```
|
||||
/// let mut fonts = epaint::text::FontDefinitions::default();
|
||||
/// // Large button text:
|
||||
/// fonts.family_and_size.insert(
|
||||
/// egui::TextStyle::Button,
|
||||
/// (egui::FontFamily::Proportional, 32.0));
|
||||
/// ctx.set_fonts(fonts);
|
||||
/// epaint::text::TextStyle::Button,
|
||||
/// (epaint::text::FontFamily::Proportional, 32.0));
|
||||
/// ```
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
@@ -86,7 +82,7 @@ pub struct FontDefinitions {
|
||||
/// List of font names and their definitions.
|
||||
/// 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.
|
||||
#[cfg_attr(feature = "persistence", serde(skip))]
|
||||
pub font_data: BTreeMap<String, FontData>,
|
||||
@@ -94,7 +90,7 @@ pub struct FontDefinitions {
|
||||
/// Which fonts (names) to use for each [`FontFamily`].
|
||||
///
|
||||
/// 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.
|
||||
/// 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>>,
|
||||
@@ -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`).
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//! Everything related to text, fonts, text layout, cursors etc.
|
||||
|
||||
pub mod cursor;
|
||||
mod font;
|
||||
mod fonts;
|
||||
|
||||
Reference in New Issue
Block a user