Show progress_bar doc example in multiple places
This commit is contained in:
parent
7b22b7e876
commit
c646ff5f1f
2 changed files with 56 additions and 7 deletions
|
|
@ -1112,11 +1112,31 @@ where
|
||||||
|
|
||||||
/// Creates a new [`ProgressBar`].
|
/// Creates a new [`ProgressBar`].
|
||||||
///
|
///
|
||||||
|
/// Progress bars visualize the progression of an extended computer operation, such as a download, file transfer, or installation.
|
||||||
|
///
|
||||||
/// It expects:
|
/// It expects:
|
||||||
/// * an inclusive range of possible values, and
|
/// * an inclusive range of possible values, and
|
||||||
/// * the current value of the [`ProgressBar`].
|
/// * the current value of the [`ProgressBar`].
|
||||||
///
|
///
|
||||||
/// [`ProgressBar`]: crate::ProgressBar
|
/// # Example
|
||||||
|
/// ```no_run
|
||||||
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::Renderer; pub use iced_widget::core::*; }
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
/// #
|
||||||
|
/// use iced::widget::progress_bar;
|
||||||
|
///
|
||||||
|
/// struct State {
|
||||||
|
/// progress: f32,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// progress_bar(0.0..=100.0, state.progress).into()
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
pub fn progress_bar<'a, Theme>(
|
pub fn progress_bar<'a, Theme>(
|
||||||
range: RangeInclusive<f32>,
|
range: RangeInclusive<f32>,
|
||||||
value: f32,
|
value: f32,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,24 @@
|
||||||
//! Provide progress feedback to your users.
|
//! Progress bars visualize the progression of an extended computer operation, such as a download, file transfer, or installation.
|
||||||
|
//!
|
||||||
|
//! # Example
|
||||||
|
//! ```no_run
|
||||||
|
//! # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::Renderer; pub use iced_widget::core::*; }
|
||||||
|
//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
|
//! #
|
||||||
|
//! use iced::widget::progress_bar;
|
||||||
|
//!
|
||||||
|
//! struct State {
|
||||||
|
//! progress: f32,
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! enum Message {
|
||||||
|
//! // ...
|
||||||
|
//! }
|
||||||
|
//!
|
||||||
|
//! fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
//! progress_bar(0.0..=100.0, state.progress).into()
|
||||||
|
//! }
|
||||||
|
//! ```
|
||||||
use crate::core::border::{self, Border};
|
use crate::core::border::{self, Border};
|
||||||
use crate::core::layout;
|
use crate::core::layout;
|
||||||
use crate::core::mouse;
|
use crate::core::mouse;
|
||||||
|
|
@ -15,14 +35,23 @@ use std::ops::RangeInclusive;
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # type ProgressBar<'a> = iced_widget::ProgressBar<'a>;
|
/// # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::Renderer; pub use iced_widget::core::*; }
|
||||||
|
/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
|
||||||
/// #
|
/// #
|
||||||
/// let value = 50.0;
|
/// use iced::widget::progress_bar;
|
||||||
///
|
///
|
||||||
/// ProgressBar::new(0.0..=100.0, value);
|
/// struct State {
|
||||||
|
/// progress: f32,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// enum Message {
|
||||||
|
/// // ...
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// fn view(state: &State) -> Element<'_, Message> {
|
||||||
|
/// progress_bar(0.0..=100.0, state.progress).into()
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
|
||||||
/// 
|
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct ProgressBar<'a, Theme = crate::Theme>
|
pub struct ProgressBar<'a, Theme = crate::Theme>
|
||||||
where
|
where
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue