Add more doc-links in docstrings (#1419)

This commit is contained in:
4JX 2022-04-03 18:18:35 +02:00 committed by GitHub
parent 861b0e11ba
commit 6091370962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 257 additions and 257 deletions

View file

@ -1,4 +1,4 @@
//! Area is a `Ui` that has no parent, it floats on the background. //! Area is a [`Ui`] that has no parent, it floats on the background.
//! It has no frame or own size. It is potentially movable. //! It has no frame or own size. It is potentially movable.
//! It is the foundation for windows and popups. //! It is the foundation for windows and popups.

View file

@ -148,11 +148,11 @@ pub struct CollapsingHeader {
} }
impl CollapsingHeader { impl CollapsingHeader {
/// The `CollapsingHeader` starts out collapsed unless you call `default_open`. /// The [`CollapsingHeader`] starts out collapsed unless you call `default_open`.
/// ///
/// The label is used as an [`Id`] source. /// The label is used as an [`Id`] source.
/// If the label is unique and static this is fine, /// If the label is unique and static this is fine,
/// but if it changes or there are several `CollapsingHeader` with the same title /// but if it changes or there are several [`CollapsingHeader`] with the same title
/// you need to provide a unique id source with [`Self::id_source`]. /// you need to provide a unique id source with [`Self::id_source`].
pub fn new(text: impl Into<WidgetText>) -> Self { pub fn new(text: impl Into<WidgetText>) -> Self {
let text = text.into(); let text = text.into();
@ -170,7 +170,7 @@ impl CollapsingHeader {
} }
} }
/// By default, the `CollapsingHeader` is collapsed. /// By default, the [`CollapsingHeader`] is collapsed.
/// Call `.default_open(true)` to change this. /// Call `.default_open(true)` to change this.
pub fn default_open(mut self, open: bool) -> Self { pub fn default_open(mut self, open: bool) -> Self {
self.default_open = open; self.default_open = open;
@ -187,14 +187,14 @@ impl CollapsingHeader {
self self
} }
/// Explicitly set the source of the `Id` of this widget, instead of using title label. /// Explicitly set the source of the [`Id`] of this widget, instead of using title label.
/// This is useful if the title label is dynamic or not unique. /// This is useful if the title label is dynamic or not unique.
pub fn id_source(mut self, id_source: impl Hash) -> Self { pub fn id_source(mut self, id_source: impl Hash) -> Self {
self.id_source = Id::new(id_source); self.id_source = Id::new(id_source);
self self
} }
/// If you set this to `false`, the `CollapsingHeader` will be grayed out and un-clickable. /// If you set this to `false`, the [`CollapsingHeader`] will be grayed out and un-clickable.
/// ///
/// This is a convenience for [`Ui::set_enabled`]. /// This is a convenience for [`Ui::set_enabled`].
pub fn enabled(mut self, enabled: bool) -> Self { pub fn enabled(mut self, enabled: bool) -> Self {
@ -202,14 +202,14 @@ impl CollapsingHeader {
self self
} }
/// Can the `CollapsingHeader` be selected by clicking it? Default: `false`. /// Can the [`CollapsingHeader`] be selected by clicking it? Default: `false`.
/// ///
pub fn selectable(mut self, selectable: bool) -> Self { pub fn selectable(mut self, selectable: bool) -> Self {
self.selectable = selectable; self.selectable = selectable;
self self
} }
/// If you set this to 'true', the `CollapsingHeader` will be shown as selected. /// If you set this to 'true', the [`CollapsingHeader`] will be shown as selected.
/// ///
/// Example: /// Example:
/// ``` /// ```
@ -229,9 +229,9 @@ impl CollapsingHeader {
self self
} }
/// Should the `CollapsingHeader` show a background behind it? Default: `false`. /// Should the [`CollapsingHeader`] show a background behind it? Default: `false`.
/// ///
/// To show it behind all `CollapsingHeader` you can just use: /// To show it behind all [`CollapsingHeader`] you can just use:
/// ``` /// ```
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
/// ui.visuals_mut().collapsing_header_frame = true; /// ui.visuals_mut().collapsing_header_frame = true;
@ -242,8 +242,8 @@ impl CollapsingHeader {
self self
} }
/// Use the provided function to render a different `CollapsingHeader` icon. /// Use the provided function to render a different [`CollapsingHeader`] icon.
/// Defaults to a triangle that animates as the `CollapsingHeader` opens and closes. /// Defaults to a triangle that animates as the [`CollapsingHeader`] opens and closes.
/// ///
/// For example: /// For example:
/// ``` /// ```
@ -397,7 +397,7 @@ impl CollapsingHeader {
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>, add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
) -> CollapsingResponse<R> { ) -> CollapsingResponse<R> {
// Make sure contents are bellow header, // Make sure contents are bellow header,
// and make sure it is one unit (necessary for putting a `CollapsingHeader` in a grid). // and make sure it is one unit (necessary for putting a [`CollapsingHeader`] in a grid).
ui.vertical(|ui| { ui.vertical(|ui| {
ui.set_enabled(self.enabled); ui.set_enabled(self.enabled);

View file

@ -1,7 +1,7 @@
use crate::{style::WidgetVisuals, *}; use crate::{style::WidgetVisuals, *};
use epaint::Shape; use epaint::Shape;
/// A function that paints the `ComboBox` icon /// A function that paints the [`ComboBox`] icon
pub type IconPainter = Box<dyn FnOnce(&Ui, Rect, &WidgetVisuals, bool)>; pub type IconPainter = Box<dyn FnOnce(&Ui, Rect, &WidgetVisuals, bool)>;
/// A drop-down selection menu with a descriptive label. /// A drop-down selection menu with a descriptive label.
@ -31,7 +31,7 @@ pub struct ComboBox {
} }
impl ComboBox { impl ComboBox {
/// Create new `ComboBox` with id and label /// Create new [`ComboBox`] with id and label
pub fn new(id_source: impl std::hash::Hash, label: impl Into<WidgetText>) -> Self { pub fn new(id_source: impl std::hash::Hash, label: impl Into<WidgetText>) -> Self {
Self { Self {
id_source: Id::new(id_source), id_source: Id::new(id_source),
@ -77,8 +77,8 @@ impl ComboBox {
self self
} }
/// Use the provided function to render a different `ComboBox` icon. /// Use the provided function to render a different [`ComboBox`] icon.
/// Defaults to a triangle that expands when the cursor is hovering over the `ComboBox`. /// Defaults to a triangle that expands when the cursor is hovering over the [`ComboBox`].
/// ///
/// For example: /// For example:
/// ``` /// ```

View file

@ -37,7 +37,7 @@ impl PanelState {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// `Left` or `Right` /// [`Left`](Side::Left) or [`Right`](Side::Right)
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum Side { pub enum Side {
Left, Left,
@ -132,7 +132,7 @@ impl SidePanel {
self self
} }
/// The initial wrapping width of the `SidePanel`. /// The initial wrapping width of the [`SidePanel`].
pub fn default_width(mut self, default_width: f32) -> Self { pub fn default_width(mut self, default_width: f32) -> Self {
self.default_width = default_width; self.default_width = default_width;
self self
@ -162,7 +162,7 @@ impl SidePanel {
} }
impl SidePanel { impl SidePanel {
/// Show the panel inside a `Ui`. /// Show the panel inside a [`Ui`].
pub fn show_inside<R>( pub fn show_inside<R>(
self, self,
ui: &mut Ui, ui: &mut Ui,
@ -171,7 +171,7 @@ impl SidePanel {
self.show_inside_dyn(ui, Box::new(add_contents)) self.show_inside_dyn(ui, Box::new(add_contents))
} }
/// Show the panel inside a `Ui`. /// Show the panel inside a [`Ui`].
fn show_inside_dyn<'c, R>( fn show_inside_dyn<'c, R>(
self, self,
ui: &mut Ui, ui: &mut Ui,
@ -321,7 +321,7 @@ impl SidePanel {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// `Top` or `Bottom` /// [`Top`](TopBottomSide::Top) or [`Bottom`](TopBottomSide::Bottom)
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum TopBottomSide { pub enum TopBottomSide {
Top, Top,
@ -416,7 +416,7 @@ impl TopBottomPanel {
self self
} }
/// The initial height of the `SidePanel`. /// The initial height of the [`SidePanel`].
/// Defaults to [`style::Spacing::interact_size`].y. /// Defaults to [`style::Spacing::interact_size`].y.
pub fn default_height(mut self, default_height: f32) -> Self { pub fn default_height(mut self, default_height: f32) -> Self {
self.default_height = Some(default_height); self.default_height = Some(default_height);
@ -447,7 +447,7 @@ impl TopBottomPanel {
} }
impl TopBottomPanel { impl TopBottomPanel {
/// Show the panel inside a `Ui`. /// Show the panel inside a [`Ui`].
pub fn show_inside<R>( pub fn show_inside<R>(
self, self,
ui: &mut Ui, ui: &mut Ui,
@ -456,7 +456,7 @@ impl TopBottomPanel {
self.show_inside_dyn(ui, Box::new(add_contents)) self.show_inside_dyn(ui, Box::new(add_contents))
} }
/// Show the panel inside a `Ui`. /// Show the panel inside a [`Ui`].
fn show_inside_dyn<'c, R>( fn show_inside_dyn<'c, R>(
self, self,
ui: &mut Ui, ui: &mut Ui,
@ -615,9 +615,9 @@ impl TopBottomPanel {
/// A panel that covers the remainder of the screen, /// A panel that covers the remainder of the screen,
/// i.e. whatever area is left after adding other panels. /// i.e. whatever area is left after adding other panels.
/// ///
/// `CentralPanel` must be added after all other panels. /// [`CentralPanel`] must be added after all other panels.
/// ///
/// NOTE: Any [`Window`]s and [`Area`]s will cover the top-level `CentralPanel`. /// NOTE: Any [`Window`]s and [`Area`]s will cover the top-level [`CentralPanel`].
/// ///
/// See the [module level docs](crate::containers::panel) for more details. /// See the [module level docs](crate::containers::panel) for more details.
/// ///
@ -643,7 +643,7 @@ impl CentralPanel {
} }
impl CentralPanel { impl CentralPanel {
/// Show the panel inside a `Ui`. /// Show the panel inside a [`Ui`].
pub fn show_inside<R>( pub fn show_inside<R>(
self, self,
ui: &mut Ui, ui: &mut Ui,
@ -652,7 +652,7 @@ impl CentralPanel {
self.show_inside_dyn(ui, Box::new(add_contents)) self.show_inside_dyn(ui, Box::new(add_contents))
} }
/// Show the panel inside a `Ui`. /// Show the panel inside a [`Ui`].
fn show_inside_dyn<'c, R>( fn show_inside_dyn<'c, R>(
self, self,
ui: &mut Ui, ui: &mut Ui,

View file

@ -52,7 +52,7 @@ impl Default for Resize {
resizable: true, resizable: true,
min_size: Vec2::splat(16.0), min_size: Vec2::splat(16.0),
max_size: Vec2::splat(f32::INFINITY), max_size: Vec2::splat(f32::INFINITY),
default_size: vec2(320.0, 128.0), // TODO: preferred size of `Resize` area. default_size: vec2(320.0, 128.0), // TODO: preferred size of [`Resize`] area.
with_stroke: true, with_stroke: true,
} }
} }
@ -65,7 +65,7 @@ impl Resize {
self self
} }
/// A source for the unique `Id`, e.g. `.id_source("second_resize_area")` or `.id_source(loop_index)`. /// A source for the unique [`Id`], e.g. `.id_source("second_resize_area")` or `.id_source(loop_index)`.
pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self { pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self {
self.id_source = Some(Id::new(id_source)); self.id_source = Some(Id::new(id_source));
self self
@ -85,7 +85,7 @@ impl Resize {
/// Preferred / suggested height. Actual height will depend on contents. /// Preferred / suggested height. Actual height will depend on contents.
/// ///
/// Examples: /// Examples:
/// * if the contents is a `ScrollArea` then this decides the maximum size. /// * if the contents is a [`ScrollArea`] then this decides the maximum size.
/// * if the contents is a canvas, this decides the height of it, /// * if the contents is a canvas, this decides the height of it,
/// * if the contents is text and buttons, then the `default_height` is ignored /// * if the contents is text and buttons, then the `default_height` is ignored
/// and the height is picked automatically.. /// and the height is picked automatically..
@ -217,7 +217,7 @@ impl Resize {
} else { } else {
// We are not being actively resized, so auto-expand to include size of last frame. // We are not being actively resized, so auto-expand to include size of last frame.
// This prevents auto-shrinking if the contents contain width-filling widgets (separators etc) // This prevents auto-shrinking if the contents contain width-filling widgets (separators etc)
// but it makes a lot of interactions with `Window`s nicer. // but it makes a lot of interactions with [`Window`]s nicer.
state.desired_size = state.desired_size.max(state.last_content_size); state.desired_size = state.desired_size.max(state.last_content_size);
} }

View file

@ -55,7 +55,7 @@ pub struct ScrollAreaOutput<R> {
/// What the user closure returned. /// What the user closure returned.
pub inner: R, pub inner: R,
/// `Id` of the `ScrollArea`. /// [`Id`] of the [`ScrollArea`].
pub id: Id, pub id: Id,
/// The current state of the scroll area. /// The current state of the scroll area.
@ -136,7 +136,7 @@ impl ScrollArea {
/// The maximum width of the outer frame of the scroll area. /// The maximum width of the outer frame of the scroll area.
/// ///
/// Use `f32::INFINITY` if you want the scroll area to expand to fit the surrounding `Ui` (default). /// Use `f32::INFINITY` if you want the scroll area to expand to fit the surrounding [`Ui`] (default).
/// ///
/// See also [`Self::auto_shrink`]. /// See also [`Self::auto_shrink`].
pub fn max_width(mut self, max_width: f32) -> Self { pub fn max_width(mut self, max_width: f32) -> Self {
@ -146,7 +146,7 @@ impl ScrollArea {
/// The maximum height of the outer frame of the scroll area. /// The maximum height of the outer frame of the scroll area.
/// ///
/// Use `f32::INFINITY` if you want the scroll area to expand to fit the surrounding `Ui` (default). /// Use `f32::INFINITY` if you want the scroll area to expand to fit the surrounding [`Ui`] (default).
/// ///
/// See also [`Self::auto_shrink`]. /// See also [`Self::auto_shrink`].
pub fn max_height(mut self, max_height: f32) -> Self { pub fn max_height(mut self, max_height: f32) -> Self {
@ -156,7 +156,7 @@ impl ScrollArea {
/// The minimum width of a horizontal scroll area which requires scroll bars. /// The minimum width of a horizontal scroll area which requires scroll bars.
/// ///
/// The `ScrollArea` will only become smaller than this if the content is smaller than this /// The [`ScrollArea`] will only become smaller than this if the content is smaller than this
/// (and so we don't require scroll bars). /// (and so we don't require scroll bars).
/// ///
/// Default: `64.0`. /// Default: `64.0`.
@ -167,7 +167,7 @@ impl ScrollArea {
/// The minimum height of a vertical scroll area which requires scroll bars. /// The minimum height of a vertical scroll area which requires scroll bars.
/// ///
/// The `ScrollArea` will only become smaller than this if the content is smaller than this /// The [`ScrollArea`] will only become smaller than this if the content is smaller than this
/// (and so we don't require scroll bars). /// (and so we don't require scroll bars).
/// ///
/// Default: `64.0`. /// Default: `64.0`.
@ -183,7 +183,7 @@ impl ScrollArea {
self self
} }
/// A source for the unique `Id`, e.g. `.id_source("second_scroll_area")` or `.id_source(loop_index)`. /// A source for the unique [`Id`], e.g. `.id_source("second_scroll_area")` or `.id_source(loop_index)`.
pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self { pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self {
self.id_source = Some(Id::new(id_source)); self.id_source = Some(Id::new(id_source));
self self
@ -241,7 +241,7 @@ impl ScrollArea {
/// If `false`, the scroll area will not respond to user scrolling /// If `false`, the scroll area will not respond to user scrolling
/// ///
/// This can be used, for example, to optionally freeze scrolling while the user /// This can be used, for example, to optionally freeze scrolling while the user
/// is inputing text in a `TextEdit` widget contained within the scroll area. /// is inputing text in a [`TextEdit`] widget contained within the scroll area.
/// ///
/// This controls both scrolling directions. /// This controls both scrolling directions.
pub fn enable_scrolling(mut self, enable: bool) -> Self { pub fn enable_scrolling(mut self, enable: bool) -> Self {
@ -358,7 +358,7 @@ impl ScrollArea {
let mut inner_size = outer_size - current_bar_use; let mut inner_size = outer_size - current_bar_use;
// Don't go so far that we shrink to zero. // Don't go so far that we shrink to zero.
// In particular, if we put a `ScrollArea` inside of a `ScrollArea`, the inner // In particular, if we put a [`ScrollArea`] inside of a [`ScrollArea`], the inner
// one shouldn't collapse into nothingness. // one shouldn't collapse into nothingness.
// See https://github.com/emilk/egui/issues/1097 // See https://github.com/emilk/egui/issues/1097
for d in 0..2 { for d in 0..2 {
@ -414,7 +414,7 @@ impl ScrollArea {
} }
} }
/// Show the `ScrollArea`, and add the contents to the viewport. /// Show the [`ScrollArea`], and add the contents to the viewport.
/// ///
/// If the inner area can be very long, consider using [`Self::show_rows`] instead. /// If the inner area can be very long, consider using [`Self::show_rows`] instead.
pub fn show<R>( pub fn show<R>(

View file

@ -114,7 +114,7 @@ impl ContextImpl {
/// [`Context`] is cheap to clone, and any clones refers to the same mutable data /// [`Context`] is cheap to clone, and any clones refers to the same mutable data
/// ([`Context`] uses refcounting internally). /// ([`Context`] uses refcounting internally).
/// ///
/// All methods are marked `&self`; `Context` has interior mutability (protected by a mutex). /// All methods are marked `&self`; [`Context`] has interior mutability (protected by a mutex).
/// ///
/// ///
/// You can store /// You can store
@ -287,7 +287,7 @@ impl Context {
self.interact_with_hovered(layer_id, id, rect, sense, enabled, hovered) self.interact_with_hovered(layer_id, id, rect, sense, enabled, hovered)
} }
/// You specify if a thing is hovered, and the function gives a `Response`. /// You specify if a thing is hovered, and the function gives a [`Response`].
pub(crate) fn interact_with_hovered( pub(crate) fn interact_with_hovered(
&self, &self,
layer_id: LayerId, layer_id: LayerId,

View file

@ -163,7 +163,7 @@ pub enum Event {
Paste(String), Paste(String),
/// Text input, e.g. via keyboard. /// Text input, e.g. via keyboard.
/// ///
/// When the user presses enter/return, do not send a `Text` (just [`Key::Enter`]). /// When the user presses enter/return, do not send a [`Text`](Event::Text) (just [`Key::Enter`]).
Text(String), Text(String),
/// A key was pressed or released. /// A key was pressed or released.
Key { Key {
@ -255,7 +255,7 @@ pub const NUM_POINTER_BUTTONS: usize = 3;
/// State of the modifier keys. These must be fed to egui. /// State of the modifier keys. These must be fed to egui.
/// ///
/// The best way to compare `Modifiers` is by using [`Modifiers::matches`]. /// The best way to compare [`Modifiers`] is by using [`Modifiers::matches`].
#[derive(Clone, Copy, Debug, Default, PartialEq)] #[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct Modifiers { pub struct Modifiers {

View file

@ -66,7 +66,7 @@ pub struct PlatformOutput {
/// Events that may be useful to e.g. a screen reader. /// Events that may be useful to e.g. a screen reader.
pub events: Vec<OutputEvent>, pub events: Vec<OutputEvent>,
/// Is there a mutable `TextEdit` under the cursor? /// Is there a mutable [`TextEdit`](crate::TextEdit) under the cursor?
/// Use by `egui_web` to show/hide mobile keyboard and IME agent. /// Use by `egui_web` to show/hide mobile keyboard and IME agent.
pub mutable_text_under_cursor: bool, pub mutable_text_under_cursor: bool,
@ -321,7 +321,7 @@ pub struct WidgetInfo {
pub enabled: bool, pub enabled: bool,
/// The text on labels, buttons, checkboxes etc. /// The text on labels, buttons, checkboxes etc.
pub label: Option<String>, pub label: Option<String>,
/// The contents of some editable text (for `TextEdit` fields). /// The contents of some editable text (for [`TextEdit`](crate::TextEdit) fields).
pub current_text_value: Option<String>, pub current_text_value: Option<String>,
// The previous text value. // The previous text value.
pub prev_text_value: Option<String>, pub prev_text_value: Option<String>,

View file

@ -6,17 +6,17 @@ use crate::*;
/// Short-term (single frame) memory. /// Short-term (single frame) memory.
#[derive(Clone)] #[derive(Clone)]
pub(crate) struct FrameState { pub(crate) struct FrameState {
/// All `Id`s that were used this frame. /// All [`Id`]s that were used this frame.
/// Used to debug `Id` clashes of widgets. /// Used to debug [`Id`] clashes of widgets.
pub(crate) used_ids: IdMap<Rect>, pub(crate) used_ids: IdMap<Rect>,
/// Starts off as the screen_rect, shrinks as panels are added. /// Starts off as the screen_rect, shrinks as panels are added.
/// The `CentralPanel` does not change this. /// The [`CentralPanel`] does not change this.
/// This is the area available to Window's. /// This is the area available to Window's.
pub(crate) available_rect: Rect, pub(crate) available_rect: Rect,
/// Starts off as the screen_rect, shrinks as panels are added. /// Starts off as the screen_rect, shrinks as panels are added.
/// The `CentralPanel` retracts from this. /// The [`CentralPanel`] retracts from this.
pub(crate) unused_rect: Rect, pub(crate) unused_rect: Rect,
/// How much space is used by panels. /// How much space is used by panels.
@ -27,7 +27,7 @@ pub(crate) struct FrameState {
/// Initialized to `None` at the start of each frame. /// Initialized to `None` at the start of each frame.
pub(crate) tooltip_rect: Option<(Id, Rect, usize)>, pub(crate) tooltip_rect: Option<(Id, Rect, usize)>,
/// Cleared by the first `ScrollArea` that makes use of it. /// Cleared by the first [`ScrollArea`] that makes use of it.
pub(crate) scroll_delta: Vec2, // TODO: move to a Mutex inside of `InputState` ? pub(crate) scroll_delta: Vec2, // TODO: move to a Mutex inside of `InputState` ?
/// horizontal, vertical /// horizontal, vertical
pub(crate) scroll_target: [Option<(RangeInclusive<f32>, Option<Align>)>; 2], pub(crate) scroll_target: [Option<(RangeInclusive<f32>, Option<Align>)>; 2],

View file

@ -125,7 +125,7 @@ impl GridLayout {
// TODO: should probably heed `prev_state` here too // TODO: should probably heed `prev_state` here too
self.max_cell_size.x self.max_cell_size.x
} else { } else {
// If we want to allow width-filling widgets like `Separator` in one of the first cells // If we want to allow width-filling widgets like [`Separator`] in one of the first cells
// then we need to make sure they don't spill out of the first cell: // then we need to make sure they don't spill out of the first cell:
self.prev_state self.prev_state
.col_width(self.col) .col_width(self.col)
@ -325,7 +325,7 @@ impl Grid {
} }
/// Change which row number the grid starts on. /// Change which row number the grid starts on.
/// This can be useful when you have a large `Grid` inside of [`ScrollArea::show_rows`]. /// This can be useful when you have a large [`Grid`] inside of [`ScrollArea::show_rows`].
pub fn start_row(mut self, start_row: usize) -> Self { pub fn start_row(mut self, start_row: usize) -> Self {
self.start_row = start_row; self.start_row = start_row;
self self

View file

@ -1,16 +1,16 @@
// TODO: have separate types `PositionId` and `UniqueId`. ? // TODO: have separate types `PositionId` and `UniqueId`. ?
/// egui tracks widgets frame-to-frame using `Id`s. /// egui tracks widgets frame-to-frame using [`Id`]s.
/// ///
/// For instance, if you start dragging a slider one frame, egui stores /// For instance, if you start dragging a slider one frame, egui stores
/// the sliders `Id` as the current active id so that next frame when /// the sliders [`Id`] as the current active id so that next frame when
/// you move the mouse the same slider changes, even if the mouse has /// you move the mouse the same slider changes, even if the mouse has
/// moved outside the slider. /// moved outside the slider.
/// ///
/// For some widgets `Id`s are also used to persist some state about the /// For some widgets [`Id`]s are also used to persist some state about the
/// widgets, such as Window position or whether not a collapsing header region is open. /// widgets, such as Window position or whether not a collapsing header region is open.
/// ///
/// This implies that the `Id`s must be unique. /// This implies that the [`Id`]s must be unique.
/// ///
/// For simple things like sliders and buttons that don't have any memory and /// For simple things like sliders and buttons that don't have any memory and
/// doesn't move we can use the location of the widget as a source of identity. /// doesn't move we can use the location of the widget as a source of identity.
@ -30,10 +30,10 @@
pub struct Id(u64); pub struct Id(u64);
impl Id { impl Id {
/// A special `Id`, in particular as a key to [`crate::Memory::data`] /// A special [`Id`], in particular as a key to [`crate::Memory::data`]
/// for when there is no particular widget to attach the data. /// for when there is no particular widget to attach the data.
/// ///
/// The null `Id` is still a valid id to use in all circumstances, /// The null [`Id`] is still a valid id to use in all circumstances,
/// though obviously it will lead to a lot of collisions if you do use it! /// though obviously it will lead to a lot of collisions if you do use it!
pub fn null() -> Self { pub fn null() -> Self {
Self(0) Self(0)
@ -43,7 +43,7 @@ impl Id {
Self(1) Self(1)
} }
/// Generate a new `Id` by hashing some source (e.g. a string or integer). /// Generate a new [`Id`] by hashing some source (e.g. a string or integer).
pub fn new(source: impl std::hash::Hash) -> Id { pub fn new(source: impl std::hash::Hash) -> Id {
use std::hash::Hasher; use std::hash::Hasher;
let mut hasher = epaint::ahash::AHasher::new_with_keys(123, 456); let mut hasher = epaint::ahash::AHasher::new_with_keys(123, 456);
@ -51,7 +51,7 @@ impl Id {
Id(hasher.finish()) Id(hasher.finish())
} }
/// Generate a new `Id` by hashing the parent `Id` and the given argument. /// Generate a new [`Id`] by hashing the parent [`Id`] and the given argument.
pub fn with(self, child: impl std::hash::Hash) -> Id { pub fn with(self, child: impl std::hash::Hash) -> Id {
use std::hash::Hasher; use std::hash::Hasher;
let mut hasher = epaint::ahash::AHasher::new_with_keys(123, 456); let mut hasher = epaint::ahash::AHasher::new_with_keys(123, 456);
@ -142,5 +142,5 @@ impl std::hash::BuildHasher for BuilIdHasher {
} }
} }
/// `IdMap<V>` is a `HashMap<Id, V>` optimized by knowing that `Id` has good entropy, and doesn't need more hashing. /// `IdMap<V>` is a `HashMap<Id, V>` optimized by knowing that [`Id`] has good entropy, and doesn't need more hashing.
pub type IdMap<V> = std::collections::HashMap<Id, V, BuilIdHasher>; pub type IdMap<V> = std::collections::HashMap<Id, V, BuilIdHasher>;

View file

@ -30,7 +30,7 @@ pub struct InputState {
pub pointer: PointerState, pub pointer: PointerState,
/// State of touches, except those covered by PointerState (like clicks and drags). /// State of touches, except those covered by PointerState (like clicks and drags).
/// (We keep a separate `TouchState` for each encountered touch device.) /// (We keep a separate [`TouchState`] for each encountered touch device.)
touch_states: BTreeMap<TouchDeviceId, TouchState>, touch_states: BTreeMap<TouchDeviceId, TouchState>,
/// How many pixels the user scrolled. /// How many pixels the user scrolled.
@ -324,7 +324,7 @@ impl InputState {
} }
/// Scans `events` for device IDs of touch devices we have not seen before, /// Scans `events` for device IDs of touch devices we have not seen before,
/// and creates a new `TouchState` for each such device. /// and creates a new [`TouchState`] for each such device.
fn create_touch_states_for_new_devices(&mut self, events: &[Event]) { fn create_touch_states_for_new_devices(&mut self, events: &[Event]) {
for event in events { for event in events {
if let Event::Touch { device_id, .. } = event { if let Event::Touch { device_id, .. } = event {

View file

@ -16,7 +16,7 @@ pub struct MultiTouchInfo {
pub start_pos: Pos2, pub start_pos: Pos2,
/// Number of touches (fingers) on the surface. Value is ≥ 2 since for a single touch no /// Number of touches (fingers) on the surface. Value is ≥ 2 since for a single touch no
/// `MultiTouchInfo` is created. /// [`MultiTouchInfo`] is created.
pub num_touches: usize, pub num_touches: usize,
/// Proportional zoom factor (pinch gesture). /// Proportional zoom factor (pinch gesture).
@ -66,7 +66,7 @@ pub struct MultiTouchInfo {
#[derive(Clone)] #[derive(Clone)]
pub(crate) struct TouchState { pub(crate) struct TouchState {
/// Technical identifier of the touch device. This is used to identify relevant touch events /// Technical identifier of the touch device. This is used to identify relevant touch events
/// for this `TouchState` instance. /// for this [`TouchState`] instance.
device_id: TouchDeviceId, device_id: TouchDeviceId,
/// Active touches, if any. /// Active touches, if any.
/// ///

View file

@ -133,9 +133,9 @@ impl PaintList {
/// Modify an existing [`Shape`]. /// Modify an existing [`Shape`].
/// ///
/// Sometimes you want to paint a frame behind some contents, but don't know how large the frame needs to be /// Sometimes you want to paint a frame behind some contents, but don't know how large the frame needs to be
/// until the contents have been added, and therefor also painted to the `PaintList`. /// until the contents have been added, and therefor also painted to the [`PaintList`].
/// ///
/// The solution is to allocate a `Shape` using `let idx = paint_list.add(cr, Shape::Noop);` /// The solution is to allocate a [`Shape`] using `let idx = paint_list.add(cr, Shape::Noop);`
/// and then later setting it using `paint_list.set(idx, cr, frame);`. /// and then later setting it using `paint_list.set(idx, cr, frame);`.
#[inline(always)] #[inline(always)]
pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) { pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) {

View file

@ -7,16 +7,16 @@ use std::f32::INFINITY;
/// It is what is used and updated by [`Layout`] when adding new widgets. /// It is what is used and updated by [`Layout`] when adding new widgets.
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub(crate) struct Region { pub(crate) struct Region {
/// This is the minimal size of the `Ui`. /// This is the minimal size of the [`Ui`](crate::Ui).
/// When adding new widgets, this will generally expand. /// When adding new widgets, this will generally expand.
/// ///
/// Always finite. /// Always finite.
/// ///
/// The bounding box of all child widgets, but not necessarily a tight bounding box /// The bounding box of all child widgets, but not necessarily a tight bounding box
/// since `Ui` can start with a non-zero min_rect size. /// since [`Ui`](crate::Ui) can start with a non-zero min_rect size.
pub min_rect: Rect, pub min_rect: Rect,
/// The maximum size of this `Ui`. This is a *soft max* /// The maximum size of this [`Ui`](crate::Ui). This is a *soft max*
/// meaning new widgets will *try* not to expand beyond it, /// meaning new widgets will *try* not to expand beyond it,
/// but if they have to, they will. /// but if they have to, they will.
/// ///
@ -74,7 +74,7 @@ impl Region {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// Layout direction, one of `LeftToRight`, `RightToLeft`, `TopDown`, `BottomUp`. /// Layout direction, one of [`LeftToRight`](Direction::LeftToRight), [`RightToLeft`](Direction::RightToLeft), [`TopDown`](Direction::TopDown), [`BottomUp`](Direction::BottomUp).
#[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))]
pub enum Direction { pub enum Direction {
@ -473,7 +473,7 @@ impl Layout {
} }
/// Returns where to put the next widget that is of the given size. /// Returns where to put the next widget that is of the given size.
/// The returned `frame_rect` `Rect` will always be justified along the cross axis. /// The returned `frame_rect` [`Rect`] will always be justified along the cross axis.
/// This is what you then pass to `advance_after_rects`. /// This is what you then pass to `advance_after_rects`.
/// Use `justify_and_align` to get the inner `widget_rect`. /// Use `justify_and_align` to get the inner `widget_rect`.
pub(crate) fn next_frame(&self, region: &Region, child_size: Vec2, spacing: Vec2) -> Rect { pub(crate) fn next_frame(&self, region: &Region, child_size: Vec2, spacing: Vec2) -> Rect {

View file

@ -7,9 +7,9 @@ use crate::{area, window, Id, IdMap, InputState, LayerId, Pos2, Rect, Style};
/// The data that egui persists between frames. /// The data that egui persists between frames.
/// ///
/// This includes window positions and sizes, /// This includes window positions and sizes,
/// how far the user has scrolled in a `ScrollArea` etc. /// how far the user has scrolled in a [`ScrollArea`](crate::ScrollArea) etc.
/// ///
/// If you want this to persist when closing your app you should serialize `Memory` and store it. /// If you want this to persist when closing your app you should serialize [`Memory`] and store it.
/// For this you need to enable the `persistence`. /// For this you need to enable the `persistence`.
/// ///
/// If you want to store data for your widgets, you should look at [`Memory::data`] /// If you want to store data for your widgets, you should look at [`Memory::data`]
@ -19,7 +19,7 @@ use crate::{area, window, Id, IdMap, InputState, LayerId, Pos2, Rect, Style};
pub struct Memory { pub struct Memory {
pub options: Options, pub options: Options,
/// This map stores some superficial state for all widgets with custom `Id`s. /// This map stores some superficial state for all widgets with custom [`Id`]s.
/// ///
/// This includes storing if a [`crate::CollapsingHeader`] is open, how far scrolled a /// This includes storing if a [`crate::CollapsingHeader`] is open, how far scrolled a
/// [`crate::ScrollArea`] is, where the cursor in a [`crate::TextEdit`] is, etc. /// [`crate::ScrollArea`] is, where the cursor in a [`crate::TextEdit`] is, etc.
@ -97,7 +97,7 @@ pub struct Memory {
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))] #[cfg_attr(feature = "serde", serde(default))]
pub struct Options { pub struct Options {
/// The default style for new `Ui`:s. /// The default style for new [`Ui`](crate::Ui):s.
#[cfg_attr(feature = "serde", serde(skip))] #[cfg_attr(feature = "serde", serde(skip))]
pub(crate) style: epaint::mutex::Arc<Style>, pub(crate) style: epaint::mutex::Arc<Style>,
@ -402,7 +402,7 @@ impl Memory {
self.interaction.focus.interested_in_focus(id); self.interaction.focus.interested_in_focus(id);
} }
/// Stop editing of active `TextEdit` (if any). /// Stop editing of active [`TextEdit`](crate::TextEdit) (if any).
#[inline(always)] #[inline(always)]
pub fn stop_text_input(&mut self) { pub fn stop_text_input(&mut self) {
self.interaction.focus.id = None; self.interaction.focus.id = None;
@ -476,8 +476,8 @@ impl Memory {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// Keeps track of `Area`s, which are free-floating `Ui`s. /// Keeps track of [`Area`](crate::containers::area::Area)s, which are free-floating [`Ui`](crate::Ui)s.
/// These `Area`s can be in any `Order`. /// These [`Area`](crate::containers::area::Area)s can be in any [`Order`](crate::Order).
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))] #[cfg_attr(feature = "serde", serde(default))]

View file

@ -61,8 +61,8 @@ impl std::ops::DerefMut for BarState {
} }
/// The menu bar goes well in a [`TopBottomPanel::top`], /// The menu bar goes well in a [`TopBottomPanel::top`],
/// but can also be placed in a `Window`. /// but can also be placed in a [`Window`].
/// In the latter case you may want to wrap it in `Frame`. /// In the latter case you may want to wrap it in [`Frame`].
pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> { pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
ui.horizontal(|ui| { ui.horizontal(|ui| {
let mut style = (**ui.style()).clone(); let mut style = (**ui.style()).clone();
@ -480,13 +480,13 @@ impl SubMenu {
} }
} }
pub(crate) struct MenuState { pub(crate) struct MenuState {
/// The opened sub-menu and its `Id` /// The opened sub-menu and its [`Id`]
sub_menu: Option<(Id, Arc<RwLock<MenuState>>)>, sub_menu: Option<(Id, Arc<RwLock<MenuState>>)>,
/// Bounding box of this menu (without the sub-menu) /// Bounding box of this menu (without the sub-menu)
pub rect: Rect, pub rect: Rect,
/// Used to check if any menu in the tree wants to close /// Used to check if any menu in the tree wants to close
pub response: MenuResponse, pub response: MenuResponse,
/// Used to hash different `Id`s for sub-menus /// Used to hash different [`Id`]s for sub-menus
entry_count: usize, entry_count: usize,
} }
impl MenuState { impl MenuState {

View file

@ -20,7 +20,7 @@ pub struct Painter {
/// Where we paint /// Where we paint
layer_id: LayerId, layer_id: LayerId,
/// Everything painted in this `Painter` will be clipped against this. /// Everything painted in this [`Painter`] will be clipped against this.
/// This means nothing outside of this rectangle will be visible on screen. /// This means nothing outside of this rectangle will be visible on screen.
clip_rect: Rect, clip_rect: Rect,
@ -70,10 +70,10 @@ impl Painter {
self.fade_to_color = Some(Color32::TRANSPARENT); self.fade_to_color = Some(Color32::TRANSPARENT);
} }
/// Create a painter for a sub-region of this `Painter`. /// Create a painter for a sub-region of this [`Painter`].
/// ///
/// The clip-rect of the returned `Painter` will be the intersection /// The clip-rect of the returned [`Painter`] will be the intersection
/// of the given rectangle and the `clip_rect()` of this `Painter`. /// of the given rectangle and the `clip_rect()` of this [`Painter`].
pub fn sub_region(&self, rect: Rect) -> Self { pub fn sub_region(&self, rect: Rect) -> Self {
Self { Self {
ctx: self.ctx.clone(), ctx: self.ctx.clone(),
@ -104,14 +104,14 @@ impl Painter {
self.layer_id self.layer_id
} }
/// Everything painted in this `Painter` will be clipped against this. /// Everything painted in this [`Painter`] will be clipped against this.
/// This means nothing outside of this rectangle will be visible on screen. /// This means nothing outside of this rectangle will be visible on screen.
#[inline(always)] #[inline(always)]
pub fn clip_rect(&self) -> Rect { pub fn clip_rect(&self) -> Rect {
self.clip_rect self.clip_rect
} }
/// Everything painted in this `Painter` will be clipped against this. /// Everything painted in this [`Painter`] will be clipped against this.
/// This means nothing outside of this rectangle will be visible on screen. /// This means nothing outside of this rectangle will be visible on screen.
#[inline(always)] #[inline(always)]
pub fn set_clip_rect(&mut self, clip_rect: Rect) { pub fn set_clip_rect(&mut self, clip_rect: Rect) {
@ -385,7 +385,7 @@ impl Painter {
/// Paint text that has already been layed out in a [`Galley`]. /// Paint text that has already been layed out in a [`Galley`].
/// ///
/// You can create the `Galley` with [`Self::layout`]. /// You can create the [`Galley`] with [`Self::layout`].
/// ///
/// If you want to change the color of the text, use [`Self::galley_with_color`]. /// If you want to change the color of the text, use [`Self::galley_with_color`].
#[inline(always)] #[inline(always)]
@ -397,7 +397,7 @@ impl Painter {
/// Paint text that has already been layed out in a [`Galley`]. /// Paint text that has already been layed out in a [`Galley`].
/// ///
/// You can create the `Galley` with [`Self::layout`]. /// You can create the [`Galley`] with [`Self::layout`].
/// ///
/// The text color in the [`Galley`] will be replaced with the given color. /// The text color in the [`Galley`] will be replaced with the given color.
#[inline(always)] #[inline(always)]

View file

@ -8,11 +8,11 @@ use crate::{
/// The result of adding a widget to a [`Ui`]. /// The result of adding a widget to a [`Ui`].
/// ///
/// A `Response` lets you know whether or not a widget is being hovered, clicked or dragged. /// A [`Response`] lets you know whether or not a widget is being hovered, clicked or dragged.
/// It also lets you easily show a tooltip on hover. /// It also lets you easily show a tooltip on hover.
/// ///
/// Whenever something gets added to a `Ui`, a `Response` object is returned. /// Whenever something gets added to a [`Ui`], a [`Response`] object is returned.
/// [`ui.add`] returns a `Response`, as does [`ui.button`], and all similar shortcuts. /// [`ui.add`] returns a [`Response`], as does [`ui.button`], and all similar shortcuts.
#[derive(Clone)] #[derive(Clone)]
pub struct Response { pub struct Response {
// CONTEXT: // CONTEXT:
@ -23,7 +23,7 @@ pub struct Response {
/// Which layer the widget is part of. /// Which layer the widget is part of.
pub layer_id: LayerId, pub layer_id: LayerId,
/// The `Id` of the widget/area this response pertains. /// The [`Id`] of the widget/area this response pertains.
pub id: Id, pub id: Id,
/// The area of the screen we are talking about. /// The area of the screen we are talking about.
@ -62,8 +62,8 @@ pub struct Response {
pub(crate) interact_pointer_pos: Option<Pos2>, pub(crate) interact_pointer_pos: Option<Pos2>,
/// What the underlying data changed? /// What the underlying data changed?
/// e.g. the slider was dragged, text was entered in a `TextEdit` etc. /// e.g. the slider was dragged, text was entered in a [`TextEdit`](crate::TextEdit) etc.
/// Always `false` for something like a `Button`. /// Always `false` for something like a [`Button`](crate::Button).
pub(crate) changed: bool, pub(crate) changed: bool,
} }
@ -286,14 +286,14 @@ impl Response {
/// What the underlying data changed? /// What the underlying data changed?
/// ///
/// e.g. the slider was dragged, text was entered in a `TextEdit` etc. /// e.g. the slider was dragged, text was entered in a [`TextEdit`](crate::TextEdit) etc.
/// Always `false` for something like a `Button`. /// Always `false` for something like a [`Button`](crate::Button).
/// ///
/// Can sometimes be `true` even though the data didn't changed /// Can sometimes be `true` even though the data didn't changed
/// (e.g. if the user entered a character and erased it the same frame). /// (e.g. if the user entered a character and erased it the same frame).
/// ///
/// This is not set if the *view* of the data was changed. /// This is not set if the *view* of the data was changed.
/// For instance, moving the cursor in a `TextEdit` does not set this to `true`. /// For instance, moving the cursor in a [`TextEdit`](crate::TextEdit) does not set this to `true`.
#[inline(always)] #[inline(always)]
pub fn changed(&self) -> bool { pub fn changed(&self) -> bool {
self.changed self.changed
@ -419,10 +419,10 @@ impl Response {
self self
} }
/// Check for more interactions (e.g. sense clicks on a `Response` returned from a label). /// Check for more interactions (e.g. sense clicks on a [`Response`] returned from a label).
/// ///
/// Note that this call will not add any hover-effects to the widget, so when possible /// Note that this call will not add any hover-effects to the widget, so when possible
/// it is better to give the widget a `Sense` instead, e.g. using [`crate::Label::sense`]. /// it is better to give the widget a [`Sense`] instead, e.g. using [`crate::Label::sense`].
/// ///
/// ``` /// ```
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
@ -555,7 +555,7 @@ impl Response {
/// } /// }
/// ``` /// ```
/// ///
/// Now `draw_vec2(ui, foo).hovered` is true if either `DragValue` were hovered. /// Now `draw_vec2(ui, foo).hovered` is true if either [`DragValue`](crate::DragValue) were hovered.
impl std::ops::BitOr for Response { impl std::ops::BitOr for Response {
type Output = Self; type Output = Self;
fn bitor(self, rhs: Self) -> Self { fn bitor(self, rhs: Self) -> Self {

View file

@ -61,7 +61,7 @@ impl Sense {
} }
} }
/// The logical "or" of two `Sense`s. /// The logical "or" of two [`Sense`]s.
#[must_use] #[must_use]
pub fn union(self, other: Self) -> Self { pub fn union(self, other: Self) -> Self {
Self { Self {

View file

@ -148,7 +148,7 @@ pub struct Style {
pub text_styles: BTreeMap<TextStyle, FontId>, pub text_styles: BTreeMap<TextStyle, FontId>,
/// If set, labels buttons wtc will use this to determine whether or not /// If set, labels buttons wtc will use this to determine whether or not
/// to wrap the text at the right edge of the `Ui` they are in. /// to wrap the text at the right edge of the [`Ui`] they are in.
/// By default this is `None`. /// By default this is `None`.
/// ///
/// * `None`: follow layout /// * `None`: follow layout
@ -171,7 +171,7 @@ pub struct Style {
/// Options to help debug why egui behaves strangely. /// Options to help debug why egui behaves strangely.
pub debug: DebugOptions, pub debug: DebugOptions,
/// Show tooltips explaining `DragValue`:s etc when hovered. /// Show tooltips explaining [`DragValue`]:s etc when hovered.
/// ///
/// This only affects a few egui widgets. /// This only affects a few egui widgets.
pub explanation_tooltips: bool, pub explanation_tooltips: bool,
@ -229,15 +229,15 @@ pub struct Spacing {
/// Indent collapsing regions etc by this much. /// Indent collapsing regions etc by this much.
pub indent: f32, pub indent: f32,
/// Minimum size of a `DragValue`, color picker button, and other small widgets. /// Minimum size of a [`DragValue`], color picker button, and other small widgets.
/// `interact_size.y` is the default height of button, slider, etc. /// `interact_size.y` is the default height of button, slider, etc.
/// Anything clickable should be (at least) this size. /// Anything clickable should be (at least) this size.
pub interact_size: Vec2, // TODO: rename min_interact_size ? pub interact_size: Vec2, // TODO: rename min_interact_size ?
/// Default width of a `Slider` and `ComboBox`. /// Default width of a [`Slider`] and [`ComboBox`](crate::ComboBox).
pub slider_width: f32, // TODO: rename big_interact_size ? pub slider_width: f32, // TODO: rename big_interact_size ?
/// Default width of a `TextEdit`. /// Default width of a [`TextEdit`].
pub text_edit_width: f32, pub text_edit_width: f32,
/// Checkboxes, radio button and collapsing headers have an icon at the start. /// Checkboxes, radio button and collapsing headers have an icon at the start.
@ -402,7 +402,7 @@ pub struct Visuals {
pub selection: Selection, pub selection: Selection,
/// The color used for `Hyperlink`, /// The color used for [`Hyperlink`],
pub hyperlink_color: Color32, pub hyperlink_color: Color32,
/// Something just barely different from the background color. /// Something just barely different from the background color.

View file

@ -42,15 +42,15 @@ pub struct Ui {
/// They are therefore only good for Id:s that has no state. /// They are therefore only good for Id:s that has no state.
next_auto_id_source: u64, next_auto_id_source: u64,
/// Specifies paint layer, clip rectangle and a reference to `Context`. /// Specifies paint layer, clip rectangle and a reference to [`Context`].
painter: Painter, painter: Painter,
/// The `Style` (visuals, spacing, etc) of this ui. /// The [`Style`] (visuals, spacing, etc) of this ui.
/// Commonly many `Ui`:s share the same `Style`. /// Commonly many [`Ui`]:s share the same [`Style`].
/// The `Ui` implements copy-on-write for this. /// The [`Ui`] implements copy-on-write for this.
style: Arc<Style>, style: Arc<Style>,
/// Handles the `Ui` size and the placement of new widgets. /// Handles the [`Ui`] size and the placement of new widgets.
placer: Placer, placer: Placer,
/// If false we are unresponsive to input, /// If false we are unresponsive to input,
@ -65,7 +65,7 @@ impl Ui {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
// Creation: // Creation:
/// Create a new `Ui`. /// Create a new [`Ui`].
/// ///
/// Normally you would not use this directly, but instead use /// Normally you would not use this directly, but instead use
/// [`SidePanel`], [`TopBottomPanel`], [`CentralPanel`], [`Window`] or [`Area`]. /// [`SidePanel`], [`TopBottomPanel`], [`CentralPanel`], [`Window`] or [`Area`].
@ -82,12 +82,12 @@ impl Ui {
} }
} }
/// Create a new `Ui` at a specific region. /// Create a new [`Ui`] at a specific region.
pub fn child_ui(&mut self, max_rect: Rect, layout: Layout) -> Self { pub fn child_ui(&mut self, max_rect: Rect, layout: Layout) -> Self {
self.child_ui_with_id_source(max_rect, layout, "child") self.child_ui_with_id_source(max_rect, layout, "child")
} }
/// Create a new `Ui` at a specific region with a specific id. /// Create a new [`Ui`] at a specific region with a specific id.
pub fn child_ui_with_id_source( pub fn child_ui_with_id_source(
&mut self, &mut self,
max_rect: Rect, max_rect: Rect,
@ -111,13 +111,13 @@ impl Ui {
// ------------------------------------------------- // -------------------------------------------------
/// A unique identity of this `Ui`. /// A unique identity of this [`Ui`].
#[inline] #[inline]
pub fn id(&self) -> Id { pub fn id(&self) -> Id {
self.id self.id
} }
/// Style options for this `Ui` and its children. /// Style options for this [`Ui`] and its children.
/// ///
/// Note that this may be a different [`Style`] than that of [`Context::style`]. /// Note that this may be a different [`Style`] than that of [`Context::style`].
#[inline] #[inline]
@ -125,10 +125,10 @@ impl Ui {
&self.style &self.style
} }
/// Mutably borrow internal `Style`. /// Mutably borrow internal [`Style`].
/// Changes apply to this `Ui` and its subsequent children. /// Changes apply to this [`Ui`] and its subsequent children.
/// ///
/// To set the style of all `Ui`:s, use [`Context::set_style`]. /// To set the style of all [`Ui`]:s, use [`Context::set_style`].
/// ///
/// Example: /// Example:
/// ``` /// ```
@ -140,9 +140,9 @@ impl Ui {
Arc::make_mut(&mut self.style) // clone-on-write Arc::make_mut(&mut self.style) // clone-on-write
} }
/// Changes apply to this `Ui` and its subsequent children. /// Changes apply to this [`Ui`] and its subsequent children.
/// ///
/// To set the visuals of all `Ui`:s, use [`Context::set_visuals`]. /// To set the visuals of all [`Ui`]:s, use [`Context::set_visuals`].
pub fn set_style(&mut self, style: impl Into<Arc<Style>>) { pub fn set_style(&mut self, style: impl Into<Arc<Style>>) {
self.style = style.into(); self.style = style.into();
} }
@ -152,15 +152,15 @@ impl Ui {
self.style = self.ctx().style(); self.style = self.ctx().style();
} }
/// The current spacing options for this `Ui`. /// The current spacing options for this [`Ui`].
/// Short for `ui.style().spacing`. /// Short for `ui.style().spacing`.
#[inline] #[inline]
pub fn spacing(&self) -> &crate::style::Spacing { pub fn spacing(&self) -> &crate::style::Spacing {
&self.style.spacing &self.style.spacing
} }
/// Mutably borrow internal `Spacing`. /// Mutably borrow internal [`Spacing`](crate::style::Spacing).
/// Changes apply to this `Ui` and its subsequent children. /// Changes apply to this [`Ui`] and its subsequent children.
/// ///
/// Example: /// Example:
/// ``` /// ```
@ -172,7 +172,7 @@ impl Ui {
&mut self.style_mut().spacing &mut self.style_mut().spacing
} }
/// The current visuals settings of this `Ui`. /// The current visuals settings of this [`Ui`].
/// Short for `ui.style().visuals`. /// Short for `ui.style().visuals`.
#[inline] #[inline]
pub fn visuals(&self) -> &crate::Visuals { pub fn visuals(&self) -> &crate::Visuals {
@ -180,9 +180,9 @@ impl Ui {
} }
/// Mutably borrow internal `visuals`. /// Mutably borrow internal `visuals`.
/// Changes apply to this `Ui` and its subsequent children. /// Changes apply to this [`Ui`] and its subsequent children.
/// ///
/// To set the visuals of all `Ui`:s, use [`Context::set_visuals`]. /// To set the visuals of all [`Ui`]:s, use [`Context::set_visuals`].
/// ///
/// Example: /// Example:
/// ``` /// ```
@ -200,25 +200,25 @@ impl Ui {
self.painter.ctx() self.painter.ctx()
} }
/// Use this to paint stuff within this `Ui`. /// Use this to paint stuff within this [`Ui`].
#[inline] #[inline]
pub fn painter(&self) -> &Painter { pub fn painter(&self) -> &Painter {
&self.painter &self.painter
} }
/// If `false`, the `Ui` does not allow any interaction and /// If `false`, the [`Ui`] does not allow any interaction and
/// the widgets in it will draw with a gray look. /// the widgets in it will draw with a gray look.
#[inline] #[inline]
pub fn is_enabled(&self) -> bool { pub fn is_enabled(&self) -> bool {
self.enabled self.enabled
} }
/// Calling `set_enabled(false)` will cause the `Ui` to deny all future interaction /// Calling `set_enabled(false)` will cause the [`Ui`] to deny all future interaction
/// and all the widgets will draw with a gray look. /// and all the widgets will draw with a gray look.
/// ///
/// Usually it is more convenient to use [`Self::add_enabled_ui`] or [`Self::add_enabled`]. /// Usually it is more convenient to use [`Self::add_enabled_ui`] or [`Self::add_enabled`].
/// ///
/// Calling `set_enabled(true)` has no effect - it will NOT re-enable the `Ui` once disabled. /// Calling `set_enabled(true)` has no effect - it will NOT re-enable the [`Ui`] once disabled.
/// ///
/// ### Example /// ### Example
/// ``` /// ```
@ -241,7 +241,7 @@ impl Ui {
} }
} }
/// If `false`, any widgets added to the `Ui` will be invisible and non-interactive. /// If `false`, any widgets added to the [`Ui`] will be invisible and non-interactive.
#[inline] #[inline]
pub fn is_visible(&self) -> bool { pub fn is_visible(&self) -> bool {
self.painter.is_visible() self.painter.is_visible()
@ -284,9 +284,9 @@ impl Ui {
self.placer.layout() self.placer.layout()
} }
/// Should text wrap in this `Ui`? /// Should text wrap in this [`Ui`]?
/// ///
/// This is determined first by [`Style::wrap`], and then by the layout of this `Ui`. /// This is determined first by [`Style::wrap`], and then by the layout of this [`Ui`].
pub fn wrap_text(&self) -> bool { pub fn wrap_text(&self) -> bool {
if let Some(wrap) = self.style.wrap { if let Some(wrap) = self.style.wrap {
wrap wrap
@ -300,13 +300,13 @@ impl Ui {
/// Create a painter for a sub-region of this Ui. /// Create a painter for a sub-region of this Ui.
/// ///
/// The clip-rect of the returned `Painter` will be the intersection /// The clip-rect of the returned [`Painter`] will be the intersection
/// of the given rectangle and the `clip_rect()` of this `Ui`. /// of the given rectangle and the `clip_rect()` of this [`Ui`].
pub fn painter_at(&self, rect: Rect) -> Painter { pub fn painter_at(&self, rect: Rect) -> Painter {
self.painter().sub_region(rect) self.painter().sub_region(rect)
} }
/// Use this to paint stuff within this `Ui`. /// Use this to paint stuff within this [`Ui`].
#[inline] #[inline]
pub fn layer_id(&self) -> LayerId { pub fn layer_id(&self) -> LayerId {
self.painter().layer_id() self.painter().layer_id()
@ -408,8 +408,8 @@ impl Ui {
/// # Sizes etc /// # Sizes etc
impl Ui { impl Ui {
/// Where and how large the `Ui` is already. /// Where and how large the [`Ui`] is already.
/// All widgets that have been added ot this `Ui` fits within this rectangle. /// All widgets that have been added ot this [`Ui`] fits within this rectangle.
/// ///
/// No matter what, the final Ui will be at least this large. /// No matter what, the final Ui will be at least this large.
/// ///
@ -429,7 +429,7 @@ impl Ui {
/// Separator lines will span the `max_rect`. /// Separator lines will span the `max_rect`.
/// ///
/// If a new widget doesn't fit within the `max_rect` then the /// If a new widget doesn't fit within the `max_rect` then the
/// `Ui` will make room for it by expanding both `min_rect` and `max_rect`. /// [`Ui`] will make room for it by expanding both `min_rect` and `max_rect`.
pub fn max_rect(&self) -> Rect { pub fn max_rect(&self) -> Rect {
self.placer.max_rect() self.placer.max_rect()
} }
@ -567,9 +567,9 @@ impl Ui {
} }
} }
/// # `Id` creation /// # [`Id`] creation
impl Ui { impl Ui {
/// Use this to generate widget ids for widgets that have persistent state in `Memory`. /// Use this to generate widget ids for widgets that have persistent state in [`Memory`].
pub fn make_persistent_id<IdSource>(&self, id_source: IdSource) -> Id pub fn make_persistent_id<IdSource>(&self, id_source: IdSource) -> Id
where where
IdSource: Hash + std::fmt::Debug, IdSource: Hash + std::fmt::Debug,
@ -595,7 +595,7 @@ impl Ui {
/// # Interaction /// # Interaction
impl Ui { impl Ui {
/// Check for clicks, drags and/or hover on a specific region of this `Ui`. /// Check for clicks, drags and/or hover on a specific region of this [`Ui`].
pub fn interact(&self, rect: Rect, id: Id, sense: Sense) -> Response { pub fn interact(&self, rect: Rect, id: Id, sense: Sense) -> Response {
self.ctx().interact( self.ctx().interact(
self.clip_rect(), self.clip_rect(),
@ -608,16 +608,16 @@ impl Ui {
) )
} }
/// Is the pointer (mouse/touch) above this rectangle in this `Ui`? /// Is the pointer (mouse/touch) above this rectangle in this [`Ui`]?
/// ///
/// The `clip_rect` and layer of this `Ui` will be respected, so, for instance, /// The `clip_rect` and layer of this [`Ui`] will be respected, so, for instance,
/// if this `Ui` is behind some other window, this will always return `false`. /// if this [`Ui`] is behind some other window, this will always return `false`.
pub fn rect_contains_pointer(&self, rect: Rect) -> bool { pub fn rect_contains_pointer(&self, rect: Rect) -> bool {
self.ctx() self.ctx()
.rect_contains_pointer(self.layer_id(), self.clip_rect().intersect(rect)) .rect_contains_pointer(self.layer_id(), self.clip_rect().intersect(rect))
} }
/// Is the pointer (mouse/touch) above this `Ui`? /// Is the pointer (mouse/touch) above this [`Ui`]?
/// Equivalent to `ui.rect_contains_pointer(ui.min_rect())` /// Equivalent to `ui.rect_contains_pointer(ui.min_rect())`
pub fn ui_contains_pointer(&self) -> bool { pub fn ui_contains_pointer(&self) -> bool {
self.rect_contains_pointer(self.min_rect()) self.rect_contains_pointer(self.min_rect())
@ -627,7 +627,7 @@ impl Ui {
/// # Allocating space: where do I put my widgets? /// # Allocating space: where do I put my widgets?
impl Ui { impl Ui {
/// Allocate space for a widget and check for interaction in the space. /// Allocate space for a widget and check for interaction in the space.
/// Returns a `Response` which contains a rectangle, id, and interaction info. /// Returns a [`Response`] which contains a rectangle, id, and interaction info.
/// ///
/// ## How sizes are negotiated /// ## How sizes are negotiated
/// Each widget should have a *minimum desired size* and a *desired size*. /// Each widget should have a *minimum desired size* and a *desired size*.
@ -651,11 +651,11 @@ impl Ui {
self.interact(rect, id, sense) self.interact(rect, id, sense)
} }
/// Returns a `Rect` with exactly what you asked for. /// Returns a [`Rect`] with exactly what you asked for.
/// ///
/// The response rect will be larger if this is part of a justified layout or similar. /// The response rect will be larger if this is part of a justified layout or similar.
/// This means that if this is a narrow widget in a wide justified layout, then /// This means that if this is a narrow widget in a wide justified layout, then
/// the widget will react to interactions outside the returned `Rect`. /// the widget will react to interactions outside the returned [`Rect`].
pub fn allocate_exact_size(&mut self, desired_size: Vec2, sense: Sense) -> (Rect, Response) { pub fn allocate_exact_size(&mut self, desired_size: Vec2, sense: Sense) -> (Rect, Response) {
let response = self.allocate_response(desired_size, sense); let response = self.allocate_response(desired_size, sense);
let rect = self let rect = self
@ -666,7 +666,7 @@ impl Ui {
/// Allocate at least as much space as needed, and interact with that rect. /// Allocate at least as much space as needed, and interact with that rect.
/// ///
/// The returned `Rect` will be the same size as `Response::rect`. /// The returned [`Rect`] will be the same size as `Response::rect`.
pub fn allocate_at_least(&mut self, desired_size: Vec2, sense: Sense) -> (Rect, Response) { pub fn allocate_at_least(&mut self, desired_size: Vec2, sense: Sense) -> (Rect, Response) {
let response = self.allocate_response(desired_size, sense); let response = self.allocate_response(desired_size, sense);
(response.rect, response) (response.rect, response)
@ -685,7 +685,7 @@ impl Ui {
/// ///
/// You will never get a rectangle that is smaller than the amount of space you asked for. /// You will never get a rectangle that is smaller than the amount of space you asked for.
/// ///
/// Returns an automatic `Id` (which you can use for interaction) and the `Rect` of where to put your widget. /// Returns an automatic [`Id`] (which you can use for interaction) and the [`Rect`] of where to put your widget.
/// ///
/// ``` /// ```
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
@ -754,9 +754,9 @@ impl Ui {
widget_rect widget_rect
} }
/// Allocate a specific part of the `Ui`. /// Allocate a specific part of the [`Ui`].
/// ///
/// Ignore the layout of the `Ui`: just put my widget here! /// Ignore the layout of the [`Ui`]: just put my widget here!
/// The layout cursor will advance to past this `rect`. /// The layout cursor will advance to past this `rect`.
pub fn allocate_rect(&mut self, rect: Rect, sense: Sense) -> Response { pub fn allocate_rect(&mut self, rect: Rect, sense: Sense) -> Response {
let id = self.advance_cursor_after_rect(rect); let id = self.advance_cursor_after_rect(rect);
@ -914,7 +914,7 @@ impl Ui {
(response, painter) (response, painter)
} }
/// Adjust the scroll position of any parent [`ScrollArea`] so that the given `Rect` becomes visible. /// Adjust the scroll position of any parent [`ScrollArea`] so that the given [`Rect`] becomes visible.
/// ///
/// If `align` is `None`, it'll scroll enough to bring the cursor into view. /// If `align` is `None`, it'll scroll enough to bring the cursor into view.
/// ///
@ -971,7 +971,7 @@ impl Ui {
/// # Adding widgets /// # Adding widgets
impl Ui { impl Ui {
/// Add a [`Widget`] to this `Ui` at a location dependent on the current [`Layout`]. /// Add a [`Widget`] to this [`Ui`] at a location dependent on the current [`Layout`].
/// ///
/// The returned [`Response`] can be used to check for interactions, /// The returned [`Response`] can be used to check for interactions,
/// as well as adding tooltips using [`Response::on_hover_text`]. /// as well as adding tooltips using [`Response::on_hover_text`].
@ -990,7 +990,7 @@ impl Ui {
widget.ui(self) widget.ui(self)
} }
/// Add a [`Widget`] to this `Ui` with a given size. /// Add a [`Widget`] to this [`Ui`] with a given size.
/// The widget will attempt to fit within the given size, but some widgets may overflow. /// The widget will attempt to fit within the given size, but some widgets may overflow.
/// ///
/// To fill all remaining area, use `ui.add_sized(ui.available_size(), widget);` /// To fill all remaining area, use `ui.add_sized(ui.available_size(), widget);`
@ -1014,7 +1014,7 @@ impl Ui {
.inner .inner
} }
/// Add a [`Widget`] to this `Ui` at a specific location (manual layout). /// Add a [`Widget`] to this [`Ui`] at a specific location (manual layout).
/// ///
/// See also [`Self::add`] and [`Self::add_sized`]. /// See also [`Self::add`] and [`Self::add_sized`].
pub fn put(&mut self, max_rect: Rect, widget: impl Widget) -> Response { pub fn put(&mut self, max_rect: Rect, widget: impl Widget) -> Response {
@ -1026,7 +1026,7 @@ impl Ui {
/// Add a single [`Widget`] that is possibly disabled, i.e. greyed out and non-interactive. /// Add a single [`Widget`] that is possibly disabled, i.e. greyed out and non-interactive.
/// ///
/// If you call `add_enabled` from within an already disabled `Ui`, /// If you call `add_enabled` from within an already disabled [`Ui`],
/// the widget will always be disabled, even if the `enabled` argument is true. /// the widget will always be disabled, even if the `enabled` argument is true.
/// ///
/// See also [`Self::add_enabled_ui`] and [`Self::is_enabled`]. /// See also [`Self::add_enabled_ui`] and [`Self::is_enabled`].
@ -1051,7 +1051,7 @@ impl Ui {
/// Add a section that is possibly disabled, i.e. greyed out and non-interactive. /// Add a section that is possibly disabled, i.e. greyed out and non-interactive.
/// ///
/// If you call `add_enabled_ui` from within an already disabled `Ui`, /// If you call `add_enabled_ui` from within an already disabled [`Ui`],
/// the result will always be disabled, even if the `enabled` argument is true. /// the result will always be disabled, even if the `enabled` argument is true.
/// ///
/// See also [`Self::add_enabled`] and [`Self::is_enabled`]. /// See also [`Self::add_enabled`] and [`Self::is_enabled`].
@ -1083,7 +1083,7 @@ impl Ui {
/// ///
/// An invisible widget still takes up the same space as if it were visible. /// An invisible widget still takes up the same space as if it were visible.
/// ///
/// If you call `add_visible` from within an already invisible `Ui`, /// If you call `add_visible` from within an already invisible [`Ui`],
/// the widget will always be invisible, even if the `visible` argument is true. /// the widget will always be invisible, even if the `visible` argument is true.
/// ///
/// See also [`Self::add_visible_ui`], [`Self::set_visible`] and [`Self::is_visible`]. /// See also [`Self::add_visible_ui`], [`Self::set_visible`] and [`Self::is_visible`].
@ -1110,7 +1110,7 @@ impl Ui {
/// ///
/// An invisible ui still takes up the same space as if it were visible. /// An invisible ui still takes up the same space as if it were visible.
/// ///
/// If you call `add_visible_ui` from within an already invisible `Ui`, /// If you call `add_visible_ui` from within an already invisible [`Ui`],
/// the result will always be invisible, even if the `visible` argument is true. /// the result will always be invisible, even if the `visible` argument is true.
/// ///
/// See also [`Self::add_visible`], [`Self::set_visible`] and [`Self::is_visible`]. /// See also [`Self::add_visible`], [`Self::set_visible`] and [`Self::is_visible`].
@ -1240,7 +1240,7 @@ impl Ui {
Hyperlink::from_label_and_url(label, url).ui(self) Hyperlink::from_label_and_url(label, url).ui(self)
} }
/// No newlines (`\n`) allowed. Pressing enter key will result in the `TextEdit` losing focus (`response.lost_focus`). /// No newlines (`\n`) allowed. Pressing enter key will result in the [`TextEdit`] losing focus (`response.lost_focus`).
/// ///
/// See also [`TextEdit`]. /// See also [`TextEdit`].
pub fn text_edit_singleline<S: widgets::text_edit::TextBuffer>( pub fn text_edit_singleline<S: widgets::text_edit::TextBuffer>(
@ -1250,7 +1250,7 @@ impl Ui {
TextEdit::singleline(text).ui(self) TextEdit::singleline(text).ui(self)
} }
/// A `TextEdit` for multiple lines. Pressing enter key will create a new line. /// A [`TextEdit`] for multiple lines. Pressing enter key will create a new line.
/// ///
/// See also [`TextEdit`]. /// See also [`TextEdit`].
pub fn text_edit_multiline<S: widgets::text_edit::TextBuffer>( pub fn text_edit_multiline<S: widgets::text_edit::TextBuffer>(
@ -1260,7 +1260,7 @@ impl Ui {
TextEdit::multiline(text).ui(self) TextEdit::multiline(text).ui(self)
} }
/// A `TextEdit` for code editing. /// A [`TextEdit`] for code editing.
/// ///
/// This will be multiline, monospace, and will insert tabs instead of moving focus. /// This will be multiline, monospace, and will insert tabs instead of moving focus.
/// ///
@ -1696,9 +1696,9 @@ impl Ui {
/// ///
/// If you don't want the contents to be centered, use [`Self::horizontal_top`] instead. /// If you don't want the contents to be centered, use [`Self::horizontal_top`] instead.
/// ///
/// The returned `Response` will only have checked for mouse hover /// The returned [`Response`] will only have checked for mouse hover
/// but can be used for tooltips (`on_hover_text`). /// but can be used for tooltips (`on_hover_text`).
/// It also contains the `Rect` used by the horizontal layout. /// It also contains the [`Rect`] used by the horizontal layout.
/// ///
/// ``` /// ```
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
@ -1740,9 +1740,9 @@ impl Ui {
/// Centering is almost always what you want if you are /// Centering is almost always what you want if you are
/// planning to to mix widgets or use different types of text. /// planning to to mix widgets or use different types of text.
/// ///
/// The returned `Response` will only have checked for mouse hover /// The returned [`Response`] will only have checked for mouse hover
/// but can be used for tooltips (`on_hover_text`). /// but can be used for tooltips (`on_hover_text`).
/// It also contains the `Rect` used by the horizontal layout. /// It also contains the [`Rect`] used by the horizontal layout.
/// ///
/// See also [`Self::with_layout`] for more options. /// See also [`Self::with_layout`] for more options.
pub fn horizontal_wrapped<R>( pub fn horizontal_wrapped<R>(

View file

@ -97,7 +97,7 @@ where
self.values.back_mut().map(|(_, value)| value) self.values.back_mut().map(|(_, value)| value)
} }
/// Amount of time contained from start to end in this `History`. /// Amount of time contained from start to end in this [`History`].
pub fn duration(&self) -> f32 { pub fn duration(&self) -> f32 {
if let (Some(front), Some(back)) = (self.values.front(), self.values.back()) { if let (Some(front), Some(back)) = (self.values.front(), self.values.back()) {
(back.0 - front.0) as f32 (back.0 - front.0) as f32
@ -132,7 +132,7 @@ where
self.flush(now); self.flush(now);
} }
/// Mean time difference between values in this `History`. /// Mean time difference between values in this [`History`].
pub fn mean_time_interval(&self) -> Option<f32> { pub fn mean_time_interval(&self) -> Option<f32> {
if let (Some(first), Some(last)) = (self.values.front(), self.values.back()) { if let (Some(first), Some(last)) = (self.values.front(), self.values.back()) {
let n = self.len(); let n = self.len();

View file

@ -36,10 +36,10 @@ impl Default for Settings {
/// Automatic undo system. /// Automatic undo system.
/// ///
/// Every frame you feed it the most recent state. /// Every frame you feed it the most recent state.
/// The `Undoer` compares it with the latest undo point /// The [`Undoer`] compares it with the latest undo point
/// and if there is a change it may create a new undo point. /// and if there is a change it may create a new undo point.
/// ///
/// `Undoer` follows two simple rules: /// [`Undoer`] follows two simple rules:
/// ///
/// 1) If the state has changed since the latest undo point, but has /// 1) If the state has changed since the latest undo point, but has
/// remained stable for `stable_time` seconds, an new undo point is created. /// remained stable for `stable_time` seconds, an new undo point is created.
@ -125,7 +125,7 @@ where
} }
/// Call this as often as you want (e.g. every frame) /// Call this as often as you want (e.g. every frame)
/// and `Undoer` will determine if a new undo point should be created. /// and [`Undoer`] will determine if a new undo point should be created.
/// ///
/// * `current_time`: current time in seconds. /// * `current_time`: current time in seconds.
pub fn feed_state(&mut self, current_time: f64, current_state: &State) { pub fn feed_state(&mut self, current_time: f64, current_state: &State) {

View file

@ -10,7 +10,7 @@ use crate::{
/// The style choices (font, color) are applied to the entire text. /// The style choices (font, color) are applied to the entire text.
/// For more detailed control, use [`crate::text::LayoutJob`] instead. /// For more detailed control, use [`crate::text::LayoutJob`] instead.
/// ///
/// A `RichText` can be used in most widgets and helper functions, e.g. [`Ui::label`] and [`Ui::button`]. /// A [`RichText`] can be used in most widgets and helper functions, e.g. [`Ui::label`] and [`Ui::button`].
/// ///
/// ### Example /// ### Example
/// ``` /// ```
@ -348,7 +348,7 @@ pub enum WidgetText {
/// [`LayoutJob::wrap_width`], [`LayoutJob::halign`], [`LayoutJob::justify`] /// [`LayoutJob::wrap_width`], [`LayoutJob::halign`], [`LayoutJob::justify`]
/// and [`LayoutJob::first_row_min_height`] will likely be determined by the [`crate::Layout`] /// and [`LayoutJob::first_row_min_height`] will likely be determined by the [`crate::Layout`]
/// of the [`Ui`] the widget is placed in. /// of the [`Ui`] the widget is placed in.
/// If you want all parts of the `LayoutJob` respected, then convert it to a /// If you want all parts of the [`LayoutJob`] respected, then convert it to a
/// [`Galley`] and use [`Self::Galley`] instead. /// [`Galley`] and use [`Self::Galley`] instead.
LayoutJob(LayoutJob), LayoutJob(LayoutJob),
@ -546,7 +546,7 @@ impl WidgetText {
} }
} }
/// Layout with wrap mode based on the containing `Ui`. /// Layout with wrap mode based on the containing [`Ui`].
/// ///
/// wrap: override for [`Ui::wrap_text`]. /// wrap: override for [`Ui::wrap_text`].
pub fn into_galley( pub fn into_galley(

View file

@ -67,7 +67,7 @@ impl Button {
} }
} }
/// If `true`, the text will wrap to stay within the max width of the `Ui`. /// If `true`, the text will wrap to stay within the max width of the [`Ui`].
/// ///
/// By default [`Self::wrap`] will be true in vertical layouts /// By default [`Self::wrap`] will be true in vertical layouts
/// and horizontal layouts with wrapping, /// and horizontal layouts with wrapping,

View file

@ -421,19 +421,19 @@ pub fn color_edit_button_rgb(ui: &mut Ui, rgb: &mut [f32; 3]) -> Response {
response response
} }
// To ensure we keep hue slider when `srgba` is gray we store the full `Hsva` in a cache: // To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
fn color_cache_get(ctx: &Context, rgba: impl Into<Rgba>) -> Hsva { fn color_cache_get(ctx: &Context, rgba: impl Into<Rgba>) -> Hsva {
let rgba = rgba.into(); let rgba = rgba.into();
use_color_cache(ctx, |cc| cc.get(&rgba).cloned()).unwrap_or_else(|| Hsva::from(rgba)) use_color_cache(ctx, |cc| cc.get(&rgba).cloned()).unwrap_or_else(|| Hsva::from(rgba))
} }
// To ensure we keep hue slider when `srgba` is gray we store the full `Hsva` in a cache: // To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
fn color_cache_set(ctx: &Context, rgba: impl Into<Rgba>, hsva: Hsva) { fn color_cache_set(ctx: &Context, rgba: impl Into<Rgba>, hsva: Hsva) {
let rgba = rgba.into(); let rgba = rgba.into();
use_color_cache(ctx, |cc| cc.set(rgba, hsva)); use_color_cache(ctx, |cc| cc.set(rgba, hsva));
} }
// To ensure we keep hue slider when `srgba` is gray we store the full `Hsva` in a cache: // To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
fn use_color_cache<R>(ctx: &Context, f: impl FnOnce(&mut FixedCache<Rgba, Hsva>) -> R) -> R { fn use_color_cache<R>(ctx: &Context, f: impl FnOnce(&mut FixedCache<Rgba, Hsva>) -> R) -> R {
f(ctx.data().get_temp_mut_or_default(Id::null())) f(ctx.data().get_temp_mut_or_default(Id::null()))
} }

View file

@ -11,7 +11,7 @@ use crate::*;
pub(crate) struct MonoState { pub(crate) struct MonoState {
last_dragged_id: Option<Id>, last_dragged_id: Option<Id>,
last_dragged_value: Option<f64>, last_dragged_value: Option<f64>,
/// For temporary edit of a `DragValue` value. /// For temporary edit of a [`DragValue`] value.
/// Couples with the current focus id. /// Couples with the current focus id.
edit_string: Option<String>, edit_string: Option<String>,
} }

View file

@ -32,7 +32,7 @@ impl Label {
self.text.text() self.text.text()
} }
/// If `true`, the text will wrap to stay within the max width of the `Ui`. /// If `true`, the text will wrap to stay within the max width of the [`Ui`].
/// ///
/// By default [`Self::wrap`] will be true in vertical layouts /// By default [`Self::wrap`] will be true in vertical layouts
/// and horizontal layouts with wrapping, /// and horizontal layouts with wrapping,

View file

@ -36,15 +36,15 @@ pub use text_edit::{TextBuffer, TextEdit};
/// Anything implementing Widget can be added to a [`Ui`] with [`Ui::add`]. /// Anything implementing Widget can be added to a [`Ui`] with [`Ui::add`].
/// ///
/// [`Button`], [`Label`], [`Slider`], etc all implement the `Widget` trait. /// [`Button`], [`Label`], [`Slider`], etc all implement the [`Widget`] trait.
/// ///
/// Note that the widgets (`Button`, `TextEdit` etc) are /// Note that the widgets ([`Button`], [`TextEdit`] etc) are
/// [builders](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html), /// [builders](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html),
/// and not objects that hold state. /// and not objects that hold state.
/// ///
/// Tip: you can `impl Widget for &mut YourThing { }`. /// Tip: you can `impl Widget for &mut YourThing { }`.
/// ///
/// `|ui: &mut Ui| -> Response { … }` also implements `Widget`. /// `|ui: &mut Ui| -> Response { … }` also implements [`Widget`].
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] #[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
pub trait Widget { pub trait Widget {
/// Allocate space, interact, paint, and return a [`Response`]. /// Allocate space, interact, paint, and return a [`Response`].

View file

@ -145,7 +145,7 @@ impl LinkedAxisGroup {
/// A 2D plot, e.g. a graph of a function. /// A 2D plot, e.g. a graph of a function.
/// ///
/// `Plot` supports multiple lines and points. /// [`Plot`] supports multiple lines and points.
/// ///
/// ``` /// ```
/// # egui::__run_test_ui(|ui| { /// # egui::__run_test_ui(|ui| {
@ -189,7 +189,7 @@ pub struct Plot {
} }
impl Plot { impl Plot {
/// Give a unique id for each plot within the same `Ui`. /// Give a unique id for each plot within the same [`Ui`].
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),
@ -312,7 +312,7 @@ impl Plot {
self self
} }
/// Config the button pointer to use for boxed zooming. Default: `Secondary` /// Config the button pointer to use for boxed zooming. Default: [`Secondary`](PointerButton::Secondary)
pub fn boxed_zoom_pointer_button(mut self, boxed_zoom_pointer_button: PointerButton) -> Self { pub fn boxed_zoom_pointer_button(mut self, boxed_zoom_pointer_button: PointerButton) -> Self {
self.boxed_zoom_pointer_button = boxed_zoom_pointer_button; self.boxed_zoom_pointer_button = boxed_zoom_pointer_button;
self self
@ -413,7 +413,7 @@ impl Plot {
self self
} }
/// Whether or not to show the background `Rect`. /// Whether or not to show the background [`Rect`].
/// Can be useful to disable if the plot is overlaid over existing content. /// Can be useful to disable if the plot is overlaid over existing content.
/// Default: `true`. /// Default: `true`.
pub fn show_background(mut self, show: bool) -> Self { pub fn show_background(mut self, show: bool) -> Self {

View file

@ -57,7 +57,7 @@ pub enum SliderOrientation {
/// # }); /// # });
/// ``` /// ```
/// ///
/// The default `Slider` size is set by [`crate::style::Spacing::slider_width`]. /// The default [`Slider`] size is set by [`crate::style::Spacing::slider_width`].
#[must_use = "You should put this widget in an ui with `ui.add(widget);`"] #[must_use = "You should put this widget in an ui with `ui.add(widget);`"]
pub struct Slider<'a> { pub struct Slider<'a> {
get_set_value: GetSetValue<'a>, get_set_value: GetSetValue<'a>,
@ -454,7 +454,7 @@ impl<'a> Slider<'a> {
} }
fn value_ui(&mut self, ui: &mut Ui, position_range: RangeInclusive<f32>) -> Response { fn value_ui(&mut self, ui: &mut Ui, position_range: RangeInclusive<f32>) -> Response {
// If `DragValue` is controlled from the keyboard and `step` is defined, set speed to `step` // If [`DragValue`] is controlled from the keyboard and `step` is defined, set speed to `step`
let change = { let change = {
// Hold one lock rather than 4 (see https://github.com/emilk/egui/pull/1380). // Hold one lock rather than 4 (see https://github.com/emilk/egui/pull/1380).
let input = ui.input(); let input = ui.input();
@ -509,7 +509,7 @@ impl<'a> Slider<'a> {
|| value_response.has_focus() || value_response.has_focus()
|| value_response.lost_focus() || value_response.lost_focus()
{ {
// Use the `DragValue` id as the id of the whole widget, // Use the [`DragValue`] id as the id of the whole widget,
// so that the focus events work as expected. // so that the focus events work as expected.
response = value_response.union(response); response = value_response.union(response);
} else { } else {

View file

@ -81,7 +81,7 @@ impl<'t> TextEdit<'t> {
} }
impl<'t> TextEdit<'t> { impl<'t> TextEdit<'t> {
/// No newlines (`\n`) allowed. Pressing enter key will result in the `TextEdit` losing focus (`response.lost_focus`). /// No newlines (`\n`) allowed. Pressing enter key will result in the [`TextEdit`] losing focus (`response.lost_focus`).
pub fn singleline(text: &'t mut dyn TextBuffer) -> Self { pub fn singleline(text: &'t mut dyn TextBuffer) -> Self {
Self { Self {
desired_height_rows: 1, desired_height_rows: 1,
@ -90,7 +90,7 @@ impl<'t> TextEdit<'t> {
} }
} }
/// A `TextEdit` for multiple lines. Pressing enter key will create a new line. /// A [`TextEdit`] for multiple lines. Pressing enter key will create a new line.
pub fn multiline(text: &'t mut dyn TextBuffer) -> Self { pub fn multiline(text: &'t mut dyn TextBuffer) -> Self {
Self { Self {
text, text,
@ -112,7 +112,7 @@ impl<'t> TextEdit<'t> {
} }
} }
/// Build a `TextEdit` focused on code editing. /// Build a [`TextEdit`] focused on code editing.
/// By default it comes with: /// By default it comes with:
/// - monospaced font /// - monospaced font
/// - focus lock /// - focus lock
@ -120,13 +120,13 @@ impl<'t> TextEdit<'t> {
self.font(TextStyle::Monospace).lock_focus(true) self.font(TextStyle::Monospace).lock_focus(true)
} }
/// Use if you want to set an explicit `Id` for this widget. /// Use if you want to set an explicit [`Id`] for this widget.
pub fn id(mut self, id: Id) -> Self { pub fn id(mut self, id: Id) -> Self {
self.id = Some(id); self.id = Some(id);
self self
} }
/// A source for the unique `Id`, e.g. `.id_source("second_text_edit_field")` or `.id_source(loop_index)`. /// A source for the unique [`Id`], e.g. `.id_source("second_text_edit_field")` or `.id_source(loop_index)`.
pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self { pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self {
self.id_source = Some(Id::new(id_source)); self.id_source = Some(Id::new(id_source));
self self
@ -165,7 +165,7 @@ impl<'t> TextEdit<'t> {
self self
} }
/// Override how text is being shown inside the `TextEdit`. /// Override how text is being shown inside the [`TextEdit`].
/// ///
/// This can be used to implement things like syntax highlighting. /// This can be used to implement things like syntax highlighting.
/// ///
@ -196,7 +196,7 @@ impl<'t> TextEdit<'t> {
/// Default is `true`. If set to `false` then you cannot interact with the text (neither edit or select it). /// Default is `true`. If set to `false` then you cannot interact with the text (neither edit or select it).
/// ///
/// Consider using [`Ui::add_enabled`] instead to also give the `TextEdit` a greyed out look. /// Consider using [`Ui::add_enabled`] instead to also give the [`TextEdit`] a greyed out look.
pub fn interactive(mut self, interactive: bool) -> Self { pub fn interactive(mut self, interactive: bool) -> Self {
self.interactive = interactive; self.interactive = interactive;
self self
@ -359,7 +359,7 @@ impl<'t> TextEdit<'t> {
let font_id = font_selection.resolve(ui.style()); let font_id = font_selection.resolve(ui.style());
let row_height = ui.fonts().row_height(&font_id); let row_height = ui.fonts().row_height(&font_id);
const MIN_WIDTH: f32 = 24.0; // Never make a `TextEdit` more narrow than this. const MIN_WIDTH: f32 = 24.0; // Never make a [`TextEdit`] more narrow than this.
let available_width = ui.available_width().at_least(MIN_WIDTH); let available_width = ui.available_width().at_least(MIN_WIDTH);
let desired_width = desired_width.unwrap_or_else(|| ui.spacing().text_edit_width); let desired_width = desired_width.unwrap_or_else(|| ui.spacing().text_edit_width);
let wrap_width = if ui.layout().horizontal_justify() { let wrap_width = if ui.layout().horizontal_justify() {
@ -402,7 +402,7 @@ impl<'t> TextEdit<'t> {
let mut state = TextEditState::load(ui.ctx(), id).unwrap_or_default(); let mut state = TextEditState::load(ui.ctx(), id).unwrap_or_default();
// On touch screens (e.g. mobile in egui_web), should // On touch screens (e.g. mobile in egui_web), should
// dragging select text, or scroll the enclosing `ScrollArea` (if any)? // dragging select text, or scroll the enclosing [`ScrollArea`] (if any)?
// Since currently copying selected text in not supported on `egui_web`, // Since currently copying selected text in not supported on `egui_web`,
// we prioritize touch-scrolling: // we prioritize touch-scrolling:
let any_touches = ui.input().any_touches(); // separate line to avoid double-locking the same mutex let any_touches = ui.input().any_touches(); // separate line to avoid double-locking the same mutex

View file

@ -1,6 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
/// The output from a `TextEdit`. /// The output from a [`TextEdit`](crate::TextEdit).
pub struct TextEditOutput { pub struct TextEditOutput {
/// The interaction response. /// The interaction response.
pub response: crate::Response, pub response: crate::Response,

View file

@ -64,7 +64,7 @@ impl TextEditState {
self.cursor_range self.cursor_range
.map(|cursor_range| { .map(|cursor_range| {
// We only use the PCursor (paragraph number, and character offset within that paragraph). // We only use the PCursor (paragraph number, and character offset within that paragraph).
// This is so that if we resize the `TextEdit` region, and text wrapping changes, // This is so that if we resize the [`TextEdit`] region, and text wrapping changes,
// we keep the same byte character offset from the beginning of the text, // we keep the same byte character offset from the beginning of the text,
// even though the number of rows changes // even though the number of rows changes
// (each paragraph can be several rows, due to word wrapping). // (each paragraph can be several rows, due to word wrapping).

View file

@ -3,7 +3,7 @@ use std::ops::Range;
/// Trait constraining what types [`crate::TextEdit`] may use as /// Trait constraining what types [`crate::TextEdit`] may use as
/// an underlying buffer. /// an underlying buffer.
/// ///
/// Most likely you will use a `String` which implements `TextBuffer`. /// Most likely you will use a [`String`] which implements [`TextBuffer`].
pub trait TextBuffer: AsRef<str> { pub trait TextBuffer: AsRef<str> {
/// Can this text be edited? /// Can this text be edited?
fn is_mutable(&self) -> bool; fn is_mutable(&self) -> bool;

View file

@ -22,7 +22,7 @@ pub fn drag_source(ui: &mut Ui, id: Id, body: impl FnOnce(&mut Ui)) {
// Normally you need to decide a location for a widget first, // Normally you need to decide a location for a widget first,
// because otherwise that widget cannot interact with the mouse. // because otherwise that widget cannot interact with the mouse.
// However, a dragged component cannot be interacted with anyway // However, a dragged component cannot be interacted with anyway
// (anything with `Order::Tooltip` always gets an empty `Response`) // (anything with `Order::Tooltip` always gets an empty [`Response`])
// So this is fine! // So this is fine!
if let Some(pointer_pos) = ui.ctx().pointer_interact_pos() { if let Some(pointer_pos) = ui.ctx().pointer_interact_pos() {

View file

@ -18,7 +18,7 @@ pub fn password_ui(ui: &mut egui::Ui, password: &mut String) -> egui::Response {
let state_id = ui.id().with("show_plaintext"); let state_id = ui.id().with("show_plaintext");
// Get state for this widget. // Get state for this widget.
// You should get state by value, not by reference to avoid borrowing of `Memory`. // You should get state by value, not by reference to avoid borrowing of [`Memory`].
let mut show_plaintext = ui.data().get_temp::<bool>(state_id).unwrap_or(false); let mut show_plaintext = ui.data().get_temp::<bool>(state_id).unwrap_or(false);
// Process ui, change a local copy of the state // Process ui, change a local copy of the state

View file

@ -159,7 +159,7 @@ impl super::View for ManualLayoutTest {
ui.add(crate::__egui_github_link_file!()); ui.add(crate::__egui_github_link_file!());
// Showing how to place a widget anywhere in the `Ui`: // Showing how to place a widget anywhere in the [`Ui`]:
match *widget_type { match *widget_type {
WidgetType::Button => { WidgetType::Button => {
ui.put(widget_rect, egui::Button::new("Example button")); ui.put(widget_rect, egui::Button::new("Example button"));

View file

@ -93,7 +93,7 @@ impl super::View for TextEdit {
let ccursor = egui::text::CCursor::new(0); let ccursor = egui::text::CCursor::new(0);
state.set_ccursor_range(Some(egui::text::CCursorRange::one(ccursor))); state.set_ccursor_range(Some(egui::text::CCursorRange::one(ccursor)));
state.store(ui.ctx(), text_edit_id); state.store(ui.ctx(), text_edit_id);
ui.ctx().memory().request_focus(text_edit_id); // give focus back to the `TextEdit`. ui.ctx().memory().request_focus(text_edit_id); // give focus back to the [`TextEdit`].
} }
} }
@ -103,7 +103,7 @@ impl super::View for TextEdit {
let ccursor = egui::text::CCursor::new(text.chars().count()); let ccursor = egui::text::CCursor::new(text.chars().count());
state.set_ccursor_range(Some(egui::text::CCursorRange::one(ccursor))); state.set_ccursor_range(Some(egui::text::CCursorRange::one(ccursor)));
state.store(ui.ctx(), text_edit_id); state.store(ui.ctx(), text_edit_id);
ui.ctx().memory().request_focus(text_edit_id); // give focus back to the `TextEdit`. ui.ctx().memory().request_focus(text_edit_id); // give focus back to the [`TextEdit`].
} }
} }
}); });

View file

@ -12,7 +12,7 @@ enum RunMode {
/// For instance, a GUI for a thermostat need to repaint each time the temperature changes. /// For instance, a GUI for a thermostat need to repaint each time the temperature changes.
/// To ensure the UI is up to date you need to call `egui::Context::request_repaint()` each /// To ensure the UI is up to date you need to call `egui::Context::request_repaint()` each
/// time such an event happens. You can also chose to call `request_repaint()` once every second /// time such an event happens. You can also chose to call `request_repaint()` once every second
/// or after every single frame - this is called "Continuous" mode, /// or after every single frame - this is called [`Continuous`](RunMode::Continuous) mode,
/// and for games and interactive tools that need repainting every frame anyway, this should be the default. /// and for games and interactive tools that need repainting every frame anyway, this should be the default.
Reactive, Reactive,
@ -47,7 +47,7 @@ pub struct BackendPanel {
pub open: bool, pub open: bool,
#[cfg_attr(feature = "serde", serde(skip))] #[cfg_attr(feature = "serde", serde(skip))]
// go back to `Reactive` mode each time we start // go back to [`Reactive`] mode each time we start
run_mode: RunMode, run_mode: RunMode,
/// current slider value for current gui scale /// current slider value for current gui scale

View file

@ -66,7 +66,7 @@ impl epi::App for WrapApp {
} }
fn clear_color(&self) -> egui::Rgba { fn clear_color(&self) -> egui::Rgba {
egui::Rgba::TRANSPARENT // we set a `CentralPanel` fill color in `demo_windows.rs` egui::Rgba::TRANSPARENT // we set a [`CentralPanel`] fill color in `demo_windows.rs`
} }
fn update(&mut self, ctx: &egui::Context, frame: &mut epi::Frame) { fn update(&mut self, ctx: &egui::Context, frame: &mut epi::Frame) {

View file

@ -117,7 +117,7 @@ impl<'l> StripLayout<'l> {
self.add(width, height, add_contents) self.add(width, height, add_contents)
} }
/// only needed for layouts with multiple lines, like [`Table`]. /// only needed for layouts with multiple lines, like [`Table`](crate::Table).
pub fn end_line(&mut self) { pub fn end_line(&mut self) {
match self.direction { match self.direction {
CellDirection::Horizontal => { CellDirection::Horizontal => {

View file

@ -66,7 +66,7 @@ impl Size {
self self
} }
/// Allowed range of movement (in points), if in a resizable [`Table`]. /// Allowed range of movement (in points), if in a resizable [`Table`](crate::table::Table).
pub fn range(self) -> (f32, f32) { pub fn range(self) -> (f32, f32) {
match self { match self {
Self::Absolute { range, .. } Self::Absolute { range, .. }

View file

@ -133,11 +133,11 @@ impl Painter {
let vertices: &[Vertex] = bytemuck::cast_slice(&mesh.vertices); let vertices: &[Vertex] = bytemuck::cast_slice(&mesh.vertices);
// TODO: we should probably reuse the `VertexBuffer` instead of allocating a new one each frame. // TODO: we should probably reuse the [`VertexBuffer`] instead of allocating a new one each frame.
glium::VertexBuffer::new(display, vertices).unwrap() glium::VertexBuffer::new(display, vertices).unwrap()
}; };
// TODO: we should probably reuse the `IndexBuffer` instead of allocating a new one each frame. // TODO: we should probably reuse the [`IndexBuffer`] instead of allocating a new one each frame.
let index_buffer = let index_buffer =
glium::IndexBuffer::new(display, PrimitiveType::TrianglesList, &mesh.indices).unwrap(); glium::IndexBuffer::new(display, PrimitiveType::TrianglesList, &mesh.indices).unwrap();

View file

@ -338,7 +338,7 @@ pub fn start(canvas_id: &str, app_creator: epi::AppCreator) -> Result<AppRunnerR
} }
/// Install event listeners to register different input events /// Install event listeners to register different input events
/// and starts running the given `AppRunner`. /// and starts running the given [`AppRunner`].
fn start_runner(app_runner: AppRunner) -> Result<AppRunnerRef, JsValue> { fn start_runner(app_runner: AppRunner) -> Result<AppRunnerRef, JsValue> {
let runner_container = AppRunnerContainer { let runner_container = AppRunnerContainer {
runner: Arc::new(Mutex::new(app_runner)), runner: Arc::new(Mutex::new(app_runner)),

View file

@ -22,7 +22,7 @@ pub fn button_from_mouse_event(event: &web_sys::MouseEvent) -> Option<egui::Poin
/// should not jump to a different position. Therefore, we do not calculate the average position /// should not jump to a different position. Therefore, we do not calculate the average position
/// of all touches, but we keep using the same touch as long as it is available. /// of all touches, but we keep using the same touch as long as it is available.
/// ///
/// `touch_id_for_pos` is the `TouchId` of the `Touch` we previously used to determine the /// `touch_id_for_pos` is the [`TouchId`](egui::TouchId) of the [`Touch`](web_sys::Touch) we previously used to determine the
/// pointer position. /// pointer position.
pub fn pos_from_touch_event( pub fn pos_from_touch_event(
canvas_id: &str, canvas_id: &str,

View file

@ -757,7 +757,7 @@ fn install_canvas_events(runner_container: &AppRunnerContainer) -> Result<(), Js
// Report a zoom event in case CTRL (on Windows or Linux) or CMD (on Mac) is pressed. // Report a zoom event in case CTRL (on Windows or Linux) or CMD (on Mac) is pressed.
// This if-statement is equivalent to how `Modifiers.command` is determined in // This if-statement is equivalent to how `Modifiers.command` is determined in
// `modifiers_from_event()`, but we cannot directly use that fn for a `WheelEvent`. // `modifiers_from_event()`, but we cannot directly use that fn for a [`WheelEvent`].
if event.ctrl_key() || event.meta_key() { if event.ctrl_key() || event.meta_key() {
let factor = (delta.y / 200.0).exp(); let factor = (delta.y / 200.0).exp();
runner_lock.input.raw.events.push(egui::Event::Zoom(factor)); runner_lock.input.raw.events.push(egui::Event::Zoom(factor));

View file

@ -231,7 +231,7 @@ fn test_remap() {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// Extends `f32`, `Vec2` etc with `at_least` and `at_most` as aliases for `max` and `min`. /// Extends `f32`, [`Vec2`] etc with `at_least` and `at_most` as aliases for `max` and `min`.
pub trait NumExt { pub trait NumExt {
/// More readable version of `self.max(lower_limit)` /// More readable version of `self.max(lower_limit)`
fn at_least(self, lower_limit: Self) -> Self; fn at_least(self, lower_limit: Self) -> Self;

View file

@ -5,7 +5,7 @@ use crate::*;
/// A rectangular region of space. /// A rectangular region of space.
/// ///
/// Usually a `Rect` has a positive (or zero) size, /// Usually a [`Rect`] has a positive (or zero) size,
/// and then [`Self::min`] `<=` [`Self::max`]. /// and then [`Self::min`] `<=` [`Self::max`].
/// In these cases [`Self::min`] is the left-top corner /// In these cases [`Self::min`] is the left-top corner
/// and [`Self::max`] is the right-bottom corner. /// and [`Self::max`] is the right-bottom corner.
@ -53,7 +53,7 @@ impl Rect {
max: pos2(-INFINITY, -INFINITY), max: pos2(-INFINITY, -INFINITY),
}; };
/// An invalid `Rect` filled with [`f32::NAN`]; /// An invalid [`Rect`] filled with [`f32::NAN`];
pub const NAN: Self = Self { pub const NAN: Self = Self {
min: pos2(f32::NAN, f32::NAN), min: pos2(f32::NAN, f32::NAN),
max: pos2(f32::NAN, f32::NAN), max: pos2(f32::NAN, f32::NAN),
@ -107,7 +107,7 @@ impl Rect {
rect rect
} }
/// A `Rect` that contains every point to the right of the given X coordinate. /// A [`Rect`] that contains every point to the right of the given X coordinate.
#[inline] #[inline]
pub fn everything_right_of(left_x: f32) -> Self { pub fn everything_right_of(left_x: f32) -> Self {
let mut rect = Self::EVERYTHING; let mut rect = Self::EVERYTHING;
@ -115,7 +115,7 @@ impl Rect {
rect rect
} }
/// A `Rect` that contains every point to the left of the given X coordinate. /// A [`Rect`] that contains every point to the left of the given X coordinate.
#[inline] #[inline]
pub fn everything_left_of(right_x: f32) -> Self { pub fn everything_left_of(right_x: f32) -> Self {
let mut rect = Self::EVERYTHING; let mut rect = Self::EVERYTHING;
@ -123,7 +123,7 @@ impl Rect {
rect rect
} }
/// A `Rect` that contains every point below a certain y coordinate /// A [`Rect`] that contains every point below a certain y coordinate
#[inline] #[inline]
pub fn everything_below(top_y: f32) -> Self { pub fn everything_below(top_y: f32) -> Self {
let mut rect = Self::EVERYTHING; let mut rect = Self::EVERYTHING;
@ -131,7 +131,7 @@ impl Rect {
rect rect
} }
/// A `Rect` that contains every point above a certain y coordinate /// A [`Rect`] that contains every point above a certain y coordinate
#[inline] #[inline]
pub fn everything_above(bottom_y: f32) -> Self { pub fn everything_above(bottom_y: f32) -> Self {
let mut rect = Self::EVERYTHING; let mut rect = Self::EVERYTHING;
@ -169,7 +169,7 @@ impl Rect {
Rect::from_min_size(self.min + amnt, self.size()) Rect::from_min_size(self.min + amnt, self.size())
} }
/// Rotate the bounds (will expand the `Rect`) /// Rotate the bounds (will expand the [`Rect`])
#[must_use] #[must_use]
#[inline] #[inline]
pub fn rotate_bb(self, rot: crate::Rot2) -> Self { pub fn rotate_bb(self, rot: crate::Rot2) -> Self {
@ -246,7 +246,7 @@ impl Rect {
self.max.y = self.max.y.max(y); self.max.y = self.max.y.max(y);
} }
/// The union of two bounding rectangle, i.e. the minimum `Rect` /// The union of two bounding rectangle, i.e. the minimum [`Rect`]
/// that contains both input rectangles. /// that contains both input rectangles.
#[inline(always)] #[inline(always)]
#[must_use] #[must_use]
@ -257,7 +257,7 @@ impl Rect {
} }
} }
/// The intersection of two `Rect`, i.e. the area covered by both. /// The intersection of two [`Rect`], i.e. the area covered by both.
#[inline] #[inline]
#[must_use] #[must_use]
pub fn intersect(self, other: Rect) -> Self { pub fn intersect(self, other: Rect) -> Self {

View file

@ -2,7 +2,7 @@ use crate::*;
/// Linearly transforms positions from one [`Rect`] to another. /// Linearly transforms positions from one [`Rect`] to another.
/// ///
/// `RectTransform` stores the rectangles, and therefore supports clamping and culling. /// [`RectTransform`] stores the rectangles, and therefore supports clamping and culling.
#[repr(C)] #[repr(C)]
#[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))]

View file

@ -11,7 +11,7 @@ use super::Vec2;
// //
/// A rotation of 𝞃/4 = 90° rotates the X axis to the Y axis. /// A rotation of 𝞃/4 = 90° rotates the X axis to the Y axis.
// //
/// Normally a `Rot2` is normalized (unit-length). /// Normally a [`Rot2`] is normalized (unit-length).
/// If not, it will also scale vectors. /// If not, it will also scale vectors.
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq)]

View file

@ -54,7 +54,7 @@ impl CubicBezierShape {
} }
} }
/// Convert the cubic Bézier curve to one or two `PathShapes`. /// Convert the cubic Bézier curve to one or two [`PathShape`]'s.
/// When the curve is closed and it has to intersect with the base line, it will be converted into two shapes. /// When the curve is closed and it has to intersect with the base line, it will be converted into two shapes.
/// Otherwise, it will be converted into one shape. /// Otherwise, it will be converted into one shape.
/// The `tolerance` will be used to control the max distance between the curve and the base line. /// The `tolerance` will be used to control the max distance between the curve and the base line.
@ -418,7 +418,7 @@ impl QuadraticBezierShape {
} }
} }
/// Convert the quadratic Bézier curve to one `PathShape`. /// Convert the quadratic Bézier curve to one [`PathShape`].
/// The `tolerance` will be used to control the max distance between the curve and the base line. /// The `tolerance` will be used to control the max distance between the curve and the base line.
pub fn to_path_shape(&self, tolerance: Option<f32>) -> PathShape { pub fn to_path_shape(&self, tolerance: Option<f32>) -> PathShape {
let points = self.flatten(tolerance); let points = self.flatten(tolerance);

View file

@ -60,7 +60,7 @@ impl ColorImage {
} }
} }
/// Create an `Image` from flat un-multiplied RGBA data. /// Create a [`ColorImage`] from flat un-multiplied RGBA data.
/// ///
/// This is usually what you want to use after having loaded an image file. /// This is usually what you want to use after having loaded an image file.
/// ///

View file

@ -645,7 +645,7 @@ fn mul_color(color: Color32, factor: f32) -> Color32 {
/// Converts [`Shape`]s into triangles ([`Mesh`]). /// Converts [`Shape`]s into triangles ([`Mesh`]).
/// ///
/// For performance reasons it is smart to reuse the same `Tessellator`. /// For performance reasons it is smart to reuse the same [`Tessellator`].
/// ///
/// Se also [`tessellate_shapes`], a convenient wrapper around [`Tessellator`]. /// Se also [`tessellate_shapes`], a convenient wrapper around [`Tessellator`].
pub struct Tessellator { pub struct Tessellator {
@ -686,7 +686,7 @@ impl Tessellator {
} }
} }
/// Set the `Rect` to use for culling. /// Set the [`Rect`] to use for culling.
pub fn set_clip_rect(&mut self, clip_rect: Rect) { pub fn set_clip_rect(&mut self, clip_rect: Rect) {
self.clip_rect = clip_rect; self.clip_rect = clip_rect;
} }

View file

@ -212,7 +212,7 @@ impl FontImpl {
type FontIndex = usize; type FontIndex = usize;
// TODO: rename? // TODO: rename?
/// Wrapper over multiple `FontImpl` (e.g. a primary + fallbacks for emojis) /// Wrapper over multiple [`FontImpl`] (e.g. a primary + fallbacks for emojis)
pub struct Font { pub struct Font {
fonts: Vec<Arc<FontImpl>>, fonts: Vec<Arc<FontImpl>>,
/// Lazily calculated. /// Lazily calculated.

View file

@ -658,7 +658,7 @@ struct FontImplCache {
pixels_per_point: f32, pixels_per_point: f32,
ab_glyph_fonts: BTreeMap<String, (FontTweak, ab_glyph::FontArc)>, ab_glyph_fonts: BTreeMap<String, (FontTweak, ab_glyph::FontArc)>,
/// Map font pixel sizes and names to the cached `FontImpl`. /// Map font pixel sizes and names to the cached [`FontImpl`].
cache: ahash::AHashMap<(u32, String), Arc<FontImpl>>, cache: ahash::AHashMap<(u32, String), Arc<FontImpl>>,
} }

View file

@ -37,12 +37,12 @@ use emath::*;
/// ); /// );
/// ``` /// ```
/// ///
/// As you can see, constructing a `LayoutJob` is currently a lot of work. /// As you can see, constructing a [`LayoutJob`] is currently a lot of work.
/// It would be nice to have a helper macro for it! /// It would be nice to have a helper macro for it!
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct LayoutJob { pub struct LayoutJob {
/// The complete text of this job, referenced by `LayoutSection`. /// The complete text of this job, referenced by [`LayoutSection`].
pub text: String, pub text: String,
/// The different section, which can have different fonts, colors, etc. /// The different section, which can have different fonts, colors, etc.
@ -140,7 +140,7 @@ impl LayoutJob {
self.sections.is_empty() self.sections.is_empty()
} }
/// Helper for adding a new section when building a `LayoutJob`. /// Helper for adding a new section when building a [`LayoutJob`].
pub fn append(&mut self, text: &str, leading_space: f32, format: TextFormat) { pub fn append(&mut self, text: &str, leading_space: f32, format: TextFormat) {
let start = self.text.len(); let start = self.text.len();
self.text += text; self.text += text;
@ -308,11 +308,11 @@ pub struct Row {
/// The mesh, ready to be rendered. /// The mesh, ready to be rendered.
pub visuals: RowVisuals, pub visuals: RowVisuals,
/// If true, this `Row` came from a paragraph ending with a `\n`. /// If true, this [`Row`] came from a paragraph ending with a `\n`.
/// The `\n` itself is omitted from [`Self::glyphs`]. /// The `\n` itself is omitted from [`Self::glyphs`].
/// A `\n` in the input text always creates a new `Row` below it, /// A `\n` in the input text always creates a new [`Row`] below it,
/// so that text that ends with `\n` has an empty `Row` last. /// so that text that ends with `\n` has an empty [`Row`] last.
/// This also implies that the last `Row` in a `Galley` always has `ends_with_newline == false`. /// This also implies that the last [`Row`] in a [`Galley`] always has `ends_with_newline == false`.
pub ends_with_newline: bool, pub ends_with_newline: bool,
} }
@ -373,13 +373,13 @@ impl Glyph {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
impl Row { impl Row {
/// Excludes the implicit `\n` after the `Row`, if any. /// Excludes the implicit `\n` after the [`Row`], if any.
#[inline] #[inline]
pub fn char_count_excluding_newline(&self) -> usize { pub fn char_count_excluding_newline(&self) -> usize {
self.glyphs.len() self.glyphs.len()
} }
/// Includes the implicit `\n` after the `Row`, if any. /// Includes the implicit `\n` after the [`Row`], if any.
#[inline] #[inline]
pub fn char_count_including_newline(&self) -> usize { pub fn char_count_including_newline(&self) -> usize {
self.glyphs.len() + (self.ends_with_newline as usize) self.glyphs.len() + (self.ends_with_newline as usize)

View file

@ -94,7 +94,7 @@ where
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/// Alternative to `FileStorage` /// Alternative to [`FileStorage`]
pub fn read_memory(ctx: &egui::Context, memory_file_path: impl AsRef<std::path::Path>) { pub fn read_memory(ctx: &egui::Context, memory_file_path: impl AsRef<std::path::Path>) {
let memory: Option<egui::Memory> = read_ron(memory_file_path); let memory: Option<egui::Memory> = read_ron(memory_file_path);
if let Some(memory) = memory { if let Some(memory) = memory {
@ -102,7 +102,7 @@ pub fn read_memory(ctx: &egui::Context, memory_file_path: impl AsRef<std::path::
} }
} }
/// Alternative to `FileStorage` /// Alternative to [`FileStorage`]
/// ///
/// # Errors /// # Errors
/// When failing to serialize or create the file. /// When failing to serialize or create the file.