diff options
author | 2024-09-19 06:59:05 +0200 | |
---|---|---|
committer | 2024-09-19 06:59:05 +0200 | |
commit | ddbb8445bf60de7169727721a5cb57048ded3d82 (patch) | |
tree | 1f2b90d5f0e010be72e4bbd20da6c22e1478b573 /core/src/widget | |
parent | 1f8dc1f3dda25c699b94c653d5d569f4142e9b83 (diff) | |
parent | 31c42c1d02d6a76dedaa780e6832a23765c8aef2 (diff) | |
download | iced-ddbb8445bf60de7169727721a5cb57048ded3d82.tar.gz iced-ddbb8445bf60de7169727721a5cb57048ded3d82.tar.bz2 iced-ddbb8445bf60de7169727721a5cb57048ded3d82.zip |
Merge pull request #2587 from iced-rs/improve-api-reference
Add widget examples to API reference and update `README`
Diffstat (limited to 'core/src/widget')
-rw-r--r-- | core/src/widget/text.rs | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs index d8d6e4c6..8b02f8c2 100644 --- a/core/src/widget/text.rs +++ b/core/src/widget/text.rs @@ -1,4 +1,25 @@ -//! Write some text for your users to read. +//! Text widgets display information through writing. +//! +//! # Example +//! ```no_run +//! # mod iced { pub mod widget { pub fn text<T>(t: T) -> iced_core::widget::Text<'static, iced_core::Theme, ()> { unimplemented!() } } +//! # pub use iced_core::color; } +//! # pub type State = (); +//! # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>; +//! use iced::widget::text; +//! use iced::color; +//! +//! enum Message { +//! // ... +//! } +//! +//! fn view(state: &State) -> Element<'_, Message> { +//! text("Hello, this is iced!") +//! .size(20) +//! .color(color!(0x0000ff)) +//! .into() +//! } +//! ``` use crate::alignment; use crate::layout; use crate::mouse; @@ -13,7 +34,28 @@ use crate::{ pub use text::{LineHeight, Shaping, Wrapping}; -/// A paragraph of text. +/// A bunch of text. +/// +/// # Example +/// ```no_run +/// # mod iced { pub mod widget { pub fn text<T>(t: T) -> iced_core::widget::Text<'static, iced_core::Theme, ()> { unimplemented!() } } +/// # pub use iced_core::color; } +/// # pub type State = (); +/// # pub type Element<'a, Message> = iced_core::Element<'a, Message, iced_core::Theme, ()>; +/// use iced::widget::text; +/// use iced::color; +/// +/// enum Message { +/// // ... +/// } +/// +/// fn view(state: &State) -> Element<'_, Message> { +/// text("Hello, this is iced!") +/// .size(20) +/// .color(color!(0x0000ff)) +/// .into() +/// } +/// ``` #[allow(missing_debug_implementations)] pub struct Text<'a, Theme, Renderer> where |