summaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-04-02 16:53:54 +0200
committerLibravatar GitHub <noreply@github.com>2020-04-02 16:53:54 +0200
commit3aafd2c1f7539806449b116fa98d6bf0fff94de8 (patch)
tree727eb202e24d66836065e89c279d400c053563c0 /native/src
parent2fa6edf7a8b2a6e06b42ff9879fe81cbd1a957c6 (diff)
parent4a498ed0e3d0526ce9f47b7eefa0b2716f9b27a8 (diff)
downloadiced-3aafd2c1f7539806449b116fa98d6bf0fff94de8.tar.gz
iced-3aafd2c1f7539806449b116fa98d6bf0fff94de8.tar.bz2
iced-3aafd2c1f7539806449b116fa98d6bf0fff94de8.zip
Merge pull request #252 from hecrj/improvement/documentation
Update and improve documentation
Diffstat (limited to '')
-rw-r--r--native/src/lib.rs4
-rw-r--r--native/src/user_interface.rs7
-rw-r--r--native/src/widget.rs20
-rw-r--r--native/src/widget/pane_grid.rs20
-rw-r--r--native/src/widget/text_input.rs2
5 files changed, 44 insertions, 9 deletions
diff --git a/native/src/lib.rs b/native/src/lib.rs
index d17dd918..89612391 100644
--- a/native/src/lib.rs
+++ b/native/src/lib.rs
@@ -14,7 +14,7 @@
//! - A [`Widget`] trait, which is used to implement new widgets: from layout
//! requirements to event and drawing logic.
//! - A bunch of `Renderer` traits, meant to keep the crate renderer-agnostic.
-//! - A [`window::Renderer`] trait, leveraging [`raw-window-handle`], which can be
+//! - A [`window::Backend`] trait, leveraging [`raw-window-handle`], which can be
//! implemented by graphical renderers that target _windows_. Window-based
//! shells (like [`iced_winit`]) can use this trait to stay renderer-agnostic.
//!
@@ -31,7 +31,7 @@
//! [`druid`]: https://github.com/xi-editor/druid
//! [`raw-window-handle`]: https://github.com/rust-windowing/raw-window-handle
//! [`Widget`]: widget/trait.Widget.html
-//! [`window::Renderer`]: window/trait.Renderer.html
+//! [`window::Backend`]: window/trait.Backend.html
//! [`UserInterface`]: struct.UserInterface.html
//! [renderer]: renderer/index.html
#![deny(missing_docs)]
diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs
index 08914bed..5d9221e9 100644
--- a/native/src/user_interface.rs
+++ b/native/src/user_interface.rs
@@ -12,6 +12,13 @@ use std::hash::Hasher;
/// charge of using this type in your system in any way you want.
///
/// [`Layout`]: struct.Layout.html
+///
+/// # Example
+/// The [`integration` example] uses a [`UserInterface`] to integrate Iced in
+/// an existing graphical application.
+///
+/// [`integration` example]: https://github.com/hecrj/iced/tree/0.1/examples/integration
+/// [`UserInterface`]: struct.UserInterface.html
#[allow(missing_debug_implementations)]
pub struct UserInterface<'a, Message, Renderer> {
hash: u64,
diff --git a/native/src/widget.rs b/native/src/widget.rs
index 88f819c9..4453145b 100644
--- a/native/src/widget.rs
+++ b/native/src/widget.rs
@@ -76,6 +76,24 @@ use crate::{layout, Clipboard, Event, Hasher, Layout, Length, Point};
///
/// [`Widget`]: trait.Widget.html
/// [`Element`]: ../struct.Element.html
+///
+/// # Examples
+/// The repository has some [examples] showcasing how to implement a custom
+/// widget:
+///
+/// - [`bezier_tool`], a Paint-like tool for drawing Bézier curves using
+/// [`lyon`].
+/// - [`custom_widget`], a demonstration of how to build a custom widget that
+/// draws a circle.
+/// - [`geometry`], a custom widget showcasing how to draw geometry with the
+/// `Mesh2D` primitive in [`iced_wgpu`].
+///
+/// [examples]: https://github.com/hecrj/iced/tree/0.1/examples
+/// [`bezier_tool`]: https://github.com/hecrj/iced/tree/0.1/examples/bezier_tool
+/// [`custom_widget`]: https://github.com/hecrj/iced/tree/0.1/examples/custom_widget
+/// [`geometry`]: https://github.com/hecrj/iced/tree/0.1/examples/geometry
+/// [`lyon`]: https://github.com/nical/lyon
+/// [`iced_wgpu`]: https://github.com/hecrj/iced/tree/0.1/wgpu
pub trait Widget<Message, Renderer>
where
Renderer: crate::Renderer,
@@ -139,12 +157,14 @@ where
/// * a mutable `Message` list, allowing the [`Widget`] to produce
/// new messages based on user interaction.
/// * the `Renderer`
+ /// * a [`Clipboard`], if available
///
/// By default, it does nothing.
///
/// [`Event`]: ../enum.Event.html
/// [`Widget`]: trait.Widget.html
/// [`Layout`]: ../layout/struct.Layout.html
+ /// [`Clipboard`]: ../trait.Clipboard.html
fn on_event(
&mut self,
_event: Event,
diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs
index 2eca68d3..f6dd328e 100644
--- a/native/src/widget/pane_grid.rs
+++ b/native/src/widget/pane_grid.rs
@@ -1,6 +1,13 @@
//! Let your users split regions of your application and organize layout dynamically.
//!
//! [![Pane grid - Iced](https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif)](https://gfycat.com/mixedflatjellyfish)
+//!
+//! # Example
+//! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,
+//! drag and drop, and hotkey support.
+//!
+//! [`pane_grid` example]: https://github.com/hecrj/iced/tree/0.1/examples/pane_grid
+//! [`PaneGrid`]: struct.PaneGrid.html
mod axis;
mod direction;
mod node;
@@ -59,12 +66,13 @@ use crate::{
///
/// let (mut state, _) = pane_grid::State::new(PaneState::SomePane);
///
-/// let pane_grid = PaneGrid::new(&mut state, |pane, state, focus| {
-/// match state {
-/// PaneState::SomePane => Text::new("This is some pane"),
-/// PaneState::AnotherKindOfPane => Text::new("This is another kind of pane"),
-/// }.into()
-/// })
+/// let pane_grid =
+/// PaneGrid::new(&mut state, |pane, state, focus| {
+/// match state {
+/// PaneState::SomePane => Text::new("This is some pane"),
+/// PaneState::AnotherKindOfPane => Text::new("This is another kind of pane"),
+/// }.into()
+/// })
/// .on_drag(Message::PaneDragged)
/// .on_resize(Message::PaneResized);
/// ```
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs
index b4ba5afa..1c07e252 100644
--- a/native/src/widget/text_input.rs
+++ b/native/src/widget/text_input.rs
@@ -562,7 +562,7 @@ pub trait Renderer: crate::Renderer + Sized {
/// Draws a [`TextInput`].
///
/// It receives:
- /// - its bounds of the [`TextInput`]
+ /// - the bounds of the [`TextInput`]
/// - the bounds of the text (i.e. the current value)
/// - the cursor position
/// - the placeholder to show when the value is empty