diff options
author | 2019-08-24 03:55:07 +0200 | |
---|---|---|
committer | 2019-08-24 03:55:07 +0200 | |
commit | 36d18d979ffe713328de901005c8a5a78075357d (patch) | |
tree | d6724bf489e346d0506a8fe58d4464479ae2cd7f /src | |
parent | ec66e3fc1b6cc0d40025bf94d86263716d18657b (diff) | |
download | iced-36d18d979ffe713328de901005c8a5a78075357d.tar.gz iced-36d18d979ffe713328de901005c8a5a78075357d.tar.bz2 iced-36d18d979ffe713328de901005c8a5a78075357d.zip |
Fix details in documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/renderer.rs | 5 | ||||
-rw-r--r-- | src/user_interface.rs | 2 | ||||
-rw-r--r-- | src/widget.rs | 36 | ||||
-rw-r--r-- | src/widget/button.rs | 2 | ||||
-rw-r--r-- | src/widget/column.rs | 2 | ||||
-rw-r--r-- | src/widget/radio.rs | 2 | ||||
-rw-r--r-- | src/widget/row.rs | 2 | ||||
-rw-r--r-- | src/widget/text.rs | 9 |
8 files changed, 34 insertions, 26 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 86e93a06..79675793 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -6,7 +6,10 @@ pub trait Renderer { /// Explains the [`Layout`] of an [`Element`] for debugging purposes. /// /// This will be called when [`Element::explain`] has been used. It should - /// _explain_ the [`Layout`] graphically. + /// _explain_ the given [`Layout`] graphically. + /// + /// A common approach consists in recursively rendering the bounds of the + /// [`Layout`] and its children. /// /// [`Layout`]: struct.Layout.html /// [`Element`]: struct.Element.html diff --git a/src/user_interface.rs b/src/user_interface.rs index 5d02bf9a..0a36e151 100644 --- a/src/user_interface.rs +++ b/src/user_interface.rs @@ -37,7 +37,7 @@ impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> { pub fn update( &mut self, - events: std::vec::Drain<'_, Event>, + events: impl Iterator<Item = Event>, ) -> Vec<Message> { let mut messages = Vec::new(); diff --git a/src/widget.rs b/src/widget.rs index d1ad8123..6113b9ad 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -1,16 +1,18 @@ -//! Use the built-in widgets in your user interface. +//! Use the built-in widgets or create your own! //! //! # Customization //! Every drawable widget has its own module with a `Renderer` trait that must -//! be implemented by a custom renderer before being able to use the -//! widget. +//! be implemented by a renderer before being able to use it as a [`Widget`]. //! -//! The built-in [`Renderer`] supports all the widgets in this module! +//! # Re-exports +//! For convenience, the contents of this module are available at the root +//! module. Therefore, you can directly type: //! -//! [`ui` module]: ../index.html -//! [`Row`]: struct.Row.html -//! [`Column`]: struct.Column.html -//! [`Renderer`]: ../struct.Renderer.html +//! ``` +//! use iced::{button, Button, Widget}; +//! ``` +//! +//! [`Widget`]: trait.Widget.html mod column; mod row; @@ -30,24 +32,26 @@ pub use text::Text; use crate::{Event, Hasher, Layout, MouseCursor, Node, Point}; -/// A component that displays information or allows interaction. +/// A component that displays information and allows interaction. +/// +/// If you want to build your own widgets, you will need to implement this +/// trait. /// -/// If you want to build a custom widget, you will need to implement this trait. /// Additionally, remember to also provide [`Into<Element>`] so your users can -/// easily turn your [`Widget`] into a generic [`Element`] +/// easily turn your [`Widget`] into a generic [`Element`]. /// -/// [`Into<Element>`]: struct.Element.html +/// [`Into<Element>`]: ../struct.Element.html /// [`Widget`]: trait.Widget.html -/// [`Element`]: struct.Element.html +/// [`Element`]: ../struct.Element.html pub trait Widget<Message, Renderer>: std::fmt::Debug { /// Returns the [`Node`] of the [`Widget`]. /// /// This [`Node`] is used by the runtime to compute the [`Layout`] of the /// user interface. /// - /// [`Node`]: struct.Node.html + /// [`Node`]: ../struct.Node.html /// [`Widget`]: trait.Widget.html - /// [`Layout`]: struct.Layout.html + /// [`Layout`]: ../struct.Layout.html fn node(&self, renderer: &Renderer) -> Node; /// Draws the [`Widget`] using the associated `Renderer`. @@ -55,7 +59,7 @@ pub trait Widget<Message, Renderer>: std::fmt::Debug { /// It must return the [`MouseCursor`] state for the [`Widget`]. /// /// [`Widget`]: trait.Widget.html - /// [`MouseCursor`]: enum.MouseCursor.html + /// [`MouseCursor`]: ../enum.MouseCursor.html fn draw( &self, renderer: &mut Renderer, diff --git a/src/widget/button.rs b/src/widget/button.rs index 35fa6ca8..04573bd0 100644 --- a/src/widget/button.rs +++ b/src/widget/button.rs @@ -218,7 +218,7 @@ impl State { /// The type of a [`Button`]. /// -///  +///  /// /// [`Button`]: struct.Button.html #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/src/widget/column.rs b/src/widget/column.rs index 18a68f60..291019b2 100644 --- a/src/widget/column.rs +++ b/src/widget/column.rs @@ -43,7 +43,7 @@ impl<'a, Message, Renderer> Column<'a, Message, Renderer> { /// Sets the vertical spacing _between_ elements in pixels. /// - /// Custom margins per element do not exist in Coffee. You should use this + /// Custom margins per element do not exist in Iced. You should use this /// method instead! While less flexible, it helps you keep spacing between /// elements consistent. pub fn spacing(mut self, px: u16) -> Self { diff --git a/src/widget/radio.rs b/src/widget/radio.rs index 8a678ec8..75ddd35d 100644 --- a/src/widget/radio.rs +++ b/src/widget/radio.rs @@ -49,7 +49,7 @@ use std::hash::Hash; /// .label_color(Color::Black); /// ``` /// -///  +///  pub struct Radio<Color, Message> { is_selected: bool, on_click: Message, diff --git a/src/widget/row.rs b/src/widget/row.rs index 9e0f9d4c..6265739a 100644 --- a/src/widget/row.rs +++ b/src/widget/row.rs @@ -40,7 +40,7 @@ impl<'a, Message, Renderer> Row<'a, Message, Renderer> { /// Sets the horizontal spacing _between_ elements in pixels. /// - /// Custom margins per element do not exist in Coffee. You should use this + /// Custom margins per element do not exist in Iced. You should use this /// method instead! While less flexible, it helps you keep spacing between /// elements consistent. pub fn spacing(mut self, px: u16) -> Self { diff --git a/src/widget/text.rs b/src/widget/text.rs index e1ce8b16..bf5c1624 100644 --- a/src/widget/text.rs +++ b/src/widget/text.rs @@ -141,13 +141,14 @@ where } } -/// The renderer of a [`Text`] fragment. +/// The renderer of a [`Text`] fragment with a generic `Color`. /// -/// Your [`core::Renderer`] will need to implement this trait before being -/// able to use a [`Text`] in your user interface. +/// Your [`Renderer`] will need to implement this trait before being +/// able to use [`Text`] in your [`UserInterface`]. /// /// [`Text`]: struct.Text.html -/// [`core::Renderer`]: ../../core/trait.Renderer.html +/// [`Renderer`]: ../../trait.Renderer.html +/// [`UserInterface`]: ../../struct.UserInterface.html pub trait Renderer<Color> { /// Creates a [`Node`] with the given [`Style`] for the provided [`Text`] /// contents and size. |