From adb82687cb85f4190c96e125e493597d8952ad1d Mon Sep 17 00:00:00 2001 From: 4JX <4JXcYvmyu3Hz8fV@protonmail.com> Date: Fri, 25 Mar 2022 22:47:29 +0100 Subject: [PATCH 1/9] Add missing [] to struct names in comments This allows them to be clicked when viewed through a code editor --- egui/src/containers/area.rs | 2 +- egui/src/containers/collapsing_header.rs | 24 ++-- egui/src/containers/combo_box.rs | 8 +- egui/src/containers/panel.rs | 24 ++-- egui/src/containers/resize.rs | 8 +- egui/src/containers/scroll_area.rs | 18 +-- egui/src/context.rs | 4 +- egui/src/data/input.rs | 6 +- egui/src/data/output.rs | 4 +- egui/src/frame_state.rs | 10 +- egui/src/grid.rs | 4 +- egui/src/id.rs | 18 +-- egui/src/input_state.rs | 4 +- egui/src/input_state/touch_state.rs | 4 +- egui/src/layers.rs | 4 +- egui/src/layout.rs | 10 +- egui/src/memory.rs | 14 +-- egui/src/menu.rs | 8 +- egui/src/painter.rs | 16 +-- egui/src/response.rs | 24 ++-- egui/src/sense.rs | 2 +- egui/src/style.rs | 12 +- egui/src/ui.rs | 126 +++++++++---------- egui/src/util/history.rs | 4 +- egui/src/util/undoer.rs | 6 +- egui/src/widget_text.rs | 6 +- egui/src/widgets/button.rs | 2 +- egui/src/widgets/color_picker.rs | 6 +- egui/src/widgets/drag_value.rs | 2 +- egui/src/widgets/label.rs | 2 +- egui/src/widgets/mod.rs | 6 +- egui/src/widgets/plot/mod.rs | 8 +- egui/src/widgets/slider.rs | 6 +- egui/src/widgets/text_edit/builder.rs | 18 +-- egui/src/widgets/text_edit/output.rs | 2 +- egui/src/widgets/text_edit/state.rs | 2 +- egui/src/widgets/text_edit/text_buffer.rs | 2 +- egui_demo_lib/src/apps/demo/drag_and_drop.rs | 2 +- egui_demo_lib/src/apps/demo/password.rs | 2 +- egui_demo_lib/src/apps/demo/tests.rs | 2 +- egui_demo_lib/src/apps/demo/text_edit.rs | 4 +- egui_demo_lib/src/backend_panel.rs | 4 +- egui_demo_lib/src/wrap_app.rs | 2 +- egui_glium/src/painter.rs | 4 +- egui_web/src/backend.rs | 2 +- egui_web/src/input.rs | 2 +- egui_web/src/lib.rs | 2 +- emath/src/lib.rs | 2 +- emath/src/rect.rs | 18 +-- emath/src/rect_transform.rs | 2 +- emath/src/rot2.rs | 2 +- epaint/src/bezier.rs | 4 +- epaint/src/color.rs | 2 +- epaint/src/image.rs | 2 +- epaint/src/tessellator.rs | 4 +- epaint/src/text/font.rs | 2 +- epaint/src/text/fonts.rs | 2 +- epaint/src/text/text_layout_types.rs | 18 +-- epi/src/file_storage.rs | 4 +- 59 files changed, 257 insertions(+), 257 deletions(-) diff --git a/egui/src/containers/area.rs b/egui/src/containers/area.rs index 6501a1d780a..391a414002c 100644 --- a/egui/src/containers/area.rs +++ b/egui/src/containers/area.rs @@ -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 is the foundation for windows and popups. diff --git a/egui/src/containers/collapsing_header.rs b/egui/src/containers/collapsing_header.rs index d0df08956e1..6ade3285f44 100644 --- a/egui/src/containers/collapsing_header.rs +++ b/egui/src/containers/collapsing_header.rs @@ -148,11 +148,11 @@ pub struct 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. /// 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`]. pub fn new(text: impl Into) -> Self { 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. pub fn default_open(mut self, open: bool) -> Self { self.default_open = open; @@ -187,14 +187,14 @@ impl CollapsingHeader { 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. pub fn id_source(mut self, id_source: impl Hash) -> Self { self.id_source = Id::new(id_source); 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`]. pub fn enabled(mut self, enabled: bool) -> Self { @@ -202,14 +202,14 @@ impl CollapsingHeader { 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 { self.selectable = selectable; 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: /// ``` @@ -229,9 +229,9 @@ impl CollapsingHeader { 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| { /// ui.visuals_mut().collapsing_header_frame = true; @@ -242,8 +242,8 @@ impl CollapsingHeader { self } - /// Use the provided function to render a different `CollapsingHeader` icon. - /// Defaults to a triangle that animates as the `CollapsingHeader` opens and closes. + /// Use the provided function to render a different [`CollapsingHeader`] icon. + /// Defaults to a triangle that animates as the [`CollapsingHeader`] opens and closes. /// /// For example: /// ``` @@ -397,7 +397,7 @@ impl CollapsingHeader { add_contents: Box R + 'c>, ) -> CollapsingResponse { // 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.set_enabled(self.enabled); diff --git a/egui/src/containers/combo_box.rs b/egui/src/containers/combo_box.rs index fa90d86ac4d..b34c87e32e1 100644 --- a/egui/src/containers/combo_box.rs +++ b/egui/src/containers/combo_box.rs @@ -1,7 +1,7 @@ use crate::{style::WidgetVisuals, *}; use epaint::Shape; -/// A function that paints the `ComboBox` icon +/// A function that paints the [`ComboBox`] icon pub type IconPainter = Box; /// A drop-down selection menu with a descriptive label. @@ -31,7 +31,7 @@ pub struct 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) -> Self { Self { id_source: Id::new(id_source), @@ -77,8 +77,8 @@ impl ComboBox { self } - /// Use the provided function to render a different `ComboBox` icon. - /// Defaults to a triangle that expands when the cursor is hovering over the `ComboBox`. + /// Use the provided function to render a different [`ComboBox`] icon. + /// Defaults to a triangle that expands when the cursor is hovering over the [`ComboBox`]. /// /// For example: /// ``` diff --git a/egui/src/containers/panel.rs b/egui/src/containers/panel.rs index ea17aa17563..4298a2a9d51 100644 --- a/egui/src/containers/panel.rs +++ b/egui/src/containers/panel.rs @@ -37,7 +37,7 @@ impl PanelState { // ---------------------------------------------------------------------------- -/// `Left` or `Right` +/// [`Left`] or [`Right`] #[derive(Clone, Copy, Debug, PartialEq)] pub enum Side { Left, @@ -132,7 +132,7 @@ impl SidePanel { 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 { self.default_width = default_width; self @@ -162,7 +162,7 @@ impl SidePanel { } impl SidePanel { - /// Show the panel inside a `Ui`. + /// Show the panel inside a [`Ui`]. pub fn show_inside( self, ui: &mut Ui, @@ -171,7 +171,7 @@ impl SidePanel { 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>( self, ui: &mut Ui, @@ -321,7 +321,7 @@ impl SidePanel { // ---------------------------------------------------------------------------- -/// `Top` or `Bottom` +/// [`Top`] or [`Bottom`] #[derive(Clone, Copy, Debug, PartialEq)] pub enum TopBottomSide { Top, @@ -416,7 +416,7 @@ impl TopBottomPanel { self } - /// The initial height of the `SidePanel`. + /// The initial height of the [`SidePanel`]. /// Defaults to [`style::Spacing::interact_size`].y. pub fn default_height(mut self, default_height: f32) -> Self { self.default_height = Some(default_height); @@ -447,7 +447,7 @@ impl TopBottomPanel { } impl TopBottomPanel { - /// Show the panel inside a `Ui`. + /// Show the panel inside a [`Ui`]. pub fn show_inside( self, ui: &mut Ui, @@ -456,7 +456,7 @@ impl TopBottomPanel { 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>( self, ui: &mut Ui, @@ -615,9 +615,9 @@ impl TopBottomPanel { /// A panel that covers the remainder of the screen, /// 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. /// @@ -643,7 +643,7 @@ impl CentralPanel { } impl CentralPanel { - /// Show the panel inside a `Ui`. + /// Show the panel inside a [`Ui`]. pub fn show_inside( self, ui: &mut Ui, @@ -652,7 +652,7 @@ impl CentralPanel { 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>( self, ui: &mut Ui, diff --git a/egui/src/containers/resize.rs b/egui/src/containers/resize.rs index 2f31ff0544f..a764970e7c8 100644 --- a/egui/src/containers/resize.rs +++ b/egui/src/containers/resize.rs @@ -52,7 +52,7 @@ impl Default for Resize { resizable: true, min_size: Vec2::splat(16.0), 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, } } @@ -65,7 +65,7 @@ impl Resize { 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 { self.id_source = Some(Id::new(id_source)); self @@ -85,7 +85,7 @@ impl Resize { /// Preferred / suggested height. Actual height will depend on contents. /// /// 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 text and buttons, then the `default_height` is ignored /// and the height is picked automatically.. @@ -217,7 +217,7 @@ impl Resize { } else { // 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) - // 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); } diff --git a/egui/src/containers/scroll_area.rs b/egui/src/containers/scroll_area.rs index 3d9254ae9ab..8b6ab960134 100644 --- a/egui/src/containers/scroll_area.rs +++ b/egui/src/containers/scroll_area.rs @@ -55,7 +55,7 @@ pub struct ScrollAreaOutput { /// What the user closure returned. pub inner: R, - /// `Id` of the `ScrollArea`. + /// [`Id`] of the [`ScrollArea`]. pub id: Id, /// The current state of the scroll area. @@ -136,7 +136,7 @@ impl ScrollArea { /// 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`]. 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. /// - /// 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`]. 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 `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). /// /// Default: `64.0`. @@ -167,7 +167,7 @@ impl ScrollArea { /// 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). /// /// Default: `64.0`. @@ -183,7 +183,7 @@ impl ScrollArea { 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 { self.id_source = Some(Id::new(id_source)); self @@ -241,7 +241,7 @@ impl ScrollArea { /// If `false`, the scroll area will not respond to user scrolling /// /// 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. pub fn enable_scrolling(mut self, enable: bool) -> Self { @@ -358,7 +358,7 @@ impl ScrollArea { let mut inner_size = outer_size - current_bar_use; // 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. // See https://github.com/emilk/egui/issues/1097 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. pub fn show( diff --git a/egui/src/context.rs b/egui/src/context.rs index bb4fe88024c..1171f05ff9d 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -114,7 +114,7 @@ impl ContextImpl { /// [`Context`] is cheap to clone, and any clones refers to the same mutable data /// ([`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 @@ -287,7 +287,7 @@ impl Context { 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( &self, layer_id: LayerId, diff --git a/egui/src/data/input.rs b/egui/src/data/input.rs index 832a1ee673d..1dc036af677 100644 --- a/egui/src/data/input.rs +++ b/egui/src/data/input.rs @@ -163,7 +163,7 @@ pub enum Event { Paste(String), /// 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`] (just [`Key::Enter`]). Text(String), /// A key was pressed or released. Key { @@ -192,7 +192,7 @@ pub enum Event { /// /// This means there is no longer a cursor on the screen for hovering etc. /// - /// On touch-up first send `PointerButton{pressed: false, …}` followed by `PointerLeft`. + /// On touch-up first send `PointerButton{pressed: false, …}` followed by [`PointerLeft`]. PointerGone, /// How many points (logical pixels) the user scrolled. @@ -255,7 +255,7 @@ pub const NUM_POINTER_BUTTONS: usize = 3; /// 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)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct Modifiers { diff --git a/egui/src/data/output.rs b/egui/src/data/output.rs index e3f8dc37655..f425dab65a4 100644 --- a/egui/src/data/output.rs +++ b/egui/src/data/output.rs @@ -66,7 +66,7 @@ pub struct PlatformOutput { /// Events that may be useful to e.g. a screen reader. pub events: Vec, - /// Is there a mutable `TextEdit` under the cursor? + /// Is there a mutable [`TextEdit`] under the cursor? /// Use by `egui_web` to show/hide mobile keyboard and IME agent. pub mutable_text_under_cursor: bool, @@ -321,7 +321,7 @@ pub struct WidgetInfo { pub enabled: bool, /// The text on labels, buttons, checkboxes etc. pub label: Option, - /// The contents of some editable text (for `TextEdit` fields). + /// The contents of some editable text (for [`TextEdit`] fields). pub current_text_value: Option, // The previous text value. pub prev_text_value: Option, diff --git a/egui/src/frame_state.rs b/egui/src/frame_state.rs index e522eef65b2..d949606fec0 100644 --- a/egui/src/frame_state.rs +++ b/egui/src/frame_state.rs @@ -6,17 +6,17 @@ use crate::*; /// Short-term (single frame) memory. #[derive(Clone)] pub(crate) struct FrameState { - /// All `Id`s that were used this frame. - /// Used to debug `Id` clashes of widgets. + /// All [`Id`]s that were used this frame. + /// Used to debug [`Id`] clashes of widgets. pub(crate) used_ids: IdMap, /// 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. pub(crate) available_rect: Rect, /// 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, /// How much space is used by panels. @@ -27,7 +27,7 @@ pub(crate) struct FrameState { /// Initialized to `None` at the start of each frame. 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` ? /// horizontal, vertical pub(crate) scroll_target: [Option<(RangeInclusive, Option)>; 2], diff --git a/egui/src/grid.rs b/egui/src/grid.rs index fe37337f18c..7b6267346ee 100644 --- a/egui/src/grid.rs +++ b/egui/src/grid.rs @@ -125,7 +125,7 @@ impl GridLayout { // TODO: should probably heed `prev_state` here too self.max_cell_size.x } 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: self.prev_state .col_width(self.col) @@ -325,7 +325,7 @@ impl Grid { } /// 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 { self.start_row = start_row; self diff --git a/egui/src/id.rs b/egui/src/id.rs index 1b4883ff3ad..d0f09f20ea6 100644 --- a/egui/src/id.rs +++ b/egui/src/id.rs @@ -1,16 +1,16 @@ // 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 -/// 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 /// 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. /// -/// 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 /// doesn't move we can use the location of the widget as a source of identity. @@ -30,10 +30,10 @@ pub struct Id(u64); 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. /// - /// 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! pub fn null() -> Self { Self(0) @@ -43,7 +43,7 @@ impl Id { 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 { use std::hash::Hasher; let mut hasher = epaint::ahash::AHasher::new_with_keys(123, 456); @@ -51,7 +51,7 @@ impl Id { 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 { use std::hash::Hasher; let mut hasher = epaint::ahash::AHasher::new_with_keys(123, 456); @@ -142,5 +142,5 @@ impl std::hash::BuildHasher for BuilIdHasher { } } -/// `IdMap` is a `HashMap` optimized by knowing that `Id` has good entropy, and doesn't need more hashing. +/// `IdMap` is a `HashMap` optimized by knowing that [`Id`] has good entropy, and doesn't need more hashing. pub type IdMap = std::collections::HashMap; diff --git a/egui/src/input_state.rs b/egui/src/input_state.rs index 1c1e4703c40..61f576a4cea 100644 --- a/egui/src/input_state.rs +++ b/egui/src/input_state.rs @@ -30,7 +30,7 @@ pub struct InputState { pub pointer: PointerState, /// 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, /// 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, - /// 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]) { for event in events { if let Event::Touch { device_id, .. } = event { diff --git a/egui/src/input_state/touch_state.rs b/egui/src/input_state/touch_state.rs index 82df96b50f8..2f3d6a05204 100644 --- a/egui/src/input_state/touch_state.rs +++ b/egui/src/input_state/touch_state.rs @@ -16,7 +16,7 @@ pub struct MultiTouchInfo { pub start_pos: Pos2, /// 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, /// Proportional zoom factor (pinch gesture). @@ -66,7 +66,7 @@ pub struct MultiTouchInfo { #[derive(Clone)] pub(crate) struct TouchState { /// 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, /// Active touches, if any. /// diff --git a/egui/src/layers.rs b/egui/src/layers.rs index 76c8dfe3258..bd0090463a8 100644 --- a/egui/src/layers.rs +++ b/egui/src/layers.rs @@ -133,9 +133,9 @@ impl PaintList { /// 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 - /// 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);`. #[inline(always)] pub fn set(&mut self, idx: ShapeIdx, clip_rect: Rect, shape: Shape) { diff --git a/egui/src/layout.rs b/egui/src/layout.rs index a9642c86d3c..fe569e571ce 100644 --- a/egui/src/layout.rs +++ b/egui/src/layout.rs @@ -7,16 +7,16 @@ use std::f32::INFINITY; /// It is what is used and updated by [`Layout`] when adding new widgets. #[derive(Clone, Copy, Debug)] pub(crate) struct Region { - /// This is the minimal size of the `Ui`. + /// This is the minimal size of the [`Ui`]. /// When adding new widgets, this will generally expand. /// /// Always finite. /// /// 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`] can start with a non-zero min_rect size. pub min_rect: Rect, - /// The maximum size of this `Ui`. This is a *soft max* + /// The maximum size of this [`Ui`]. This is a *soft max* /// meaning new widgets will *try* not to expand beyond it, /// 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`], [`RightToLeft`], [`TopDown`], [`BottomUp`]. #[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum Direction { @@ -473,7 +473,7 @@ impl Layout { } /// 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`. /// Use `justify_and_align` to get the inner `widget_rect`. pub(crate) fn next_frame(&self, region: &Region, child_size: Vec2, spacing: Vec2) -> Rect { diff --git a/egui/src/memory.rs b/egui/src/memory.rs index 0ccc36ae70f..2b94d27e66c 100644 --- a/egui/src/memory.rs +++ b/egui/src/memory.rs @@ -7,9 +7,9 @@ use crate::{area, window, Id, IdMap, InputState, LayerId, Pos2, Rect, Style}; /// The data that egui persists between frames. /// /// 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`] 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`. /// /// 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 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 /// [`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", serde(default))] pub struct Options { - /// The default style for new `Ui`:s. + /// The default style for new [`Ui`]:s. #[cfg_attr(feature = "serde", serde(skip))] pub(crate) style: epaint::mutex::Arc