summaryrefslogtreecommitdiffstats
path: root/pure/src/helpers.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-05-02 21:21:24 +0200
committerLibravatar GitHub <noreply@github.com>2022-05-02 21:21:24 +0200
commit5acba65c1135d8ebbda94efc74ea0bebb29c438a (patch)
tree88673403313ad90cec226ee92d4ebf4ef0a24bdc /pure/src/helpers.rs
parenta17a7103d382f02c64e7b271d953ea6babffac97 (diff)
parent7e111f273fb22a6ffc7a4fd24bea5e838d276758 (diff)
downloadiced-5acba65c1135d8ebbda94efc74ea0bebb29c438a.tar.gz
iced-5acba65c1135d8ebbda94efc74ea0bebb29c438a.tar.bz2
iced-5acba65c1135d8ebbda94efc74ea0bebb29c438a.zip
Merge pull request #1327 from iced-rs/update-docs
Update documentation
Diffstat (limited to 'pure/src/helpers.rs')
-rw-r--r--pure/src/helpers.rs60
1 files changed, 58 insertions, 2 deletions
diff --git a/pure/src/helpers.rs b/pure/src/helpers.rs
index 2ddab3ae..2c4a37be 100644
--- a/pure/src/helpers.rs
+++ b/pure/src/helpers.rs
@@ -1,3 +1,4 @@
+//! Helper functions to create pure widgets.
use crate::widget;
use crate::Element;
@@ -5,6 +6,9 @@ use iced_native::Length;
use std::borrow::Cow;
use std::ops::RangeInclusive;
+/// Creates a new [`Container`] with the provided content.
+///
+/// [`Container`]: widget::Container
pub fn container<'a, Message, Renderer>(
content: impl Into<Element<'a, Message, Renderer>>,
) -> widget::Container<'a, Message, Renderer>
@@ -14,15 +18,24 @@ where
widget::Container::new(content)
}
+/// Creates a new [`Column`].
+///
+/// [`Column`]: widget::Column
pub fn column<'a, Message, Renderer>() -> widget::Column<'a, Message, Renderer>
{
widget::Column::new()
}
+/// Creates a new [`Row`].
+///
+/// [`Row`]: widget::Row
pub fn row<'a, Message, Renderer>() -> widget::Row<'a, Message, Renderer> {
widget::Row::new()
}
+/// Creates a new [`Scrollable`] with the provided content.
+///
+/// [`Scrollable`]: widget::Scrollable
pub fn scrollable<'a, Message, Renderer>(
content: impl Into<Element<'a, Message, Renderer>>,
) -> widget::Scrollable<'a, Message, Renderer>
@@ -32,12 +45,19 @@ where
widget::Scrollable::new(content)
}
+/// Creates a new [`Button`] with the provided content.
+///
+/// [`Button`]: widget::Button
pub fn button<'a, Message, Renderer>(
content: impl Into<Element<'a, Message, Renderer>>,
) -> widget::Button<'a, Message, Renderer> {
widget::Button::new(content)
}
+/// Creates a new [`Tooltip`] with the provided content, tooltip text, and [`tooltip::Position`].
+///
+/// [`Tooltip`]: widget::Tooltip
+/// [`tooltip::Position`]: widget::tooltip::Position
pub fn tooltip<'a, Message, Renderer>(
content: impl Into<Element<'a, Message, Renderer>>,
tooltip: impl ToString,
@@ -49,6 +69,9 @@ where
widget::Tooltip::new(content, tooltip, position)
}
+/// Creates a new [`Text`] widget with the provided content.
+///
+/// [`Text`]: widget::Text
pub fn text<Renderer>(text: impl Into<String>) -> widget::Text<Renderer>
where
Renderer: iced_native::text::Renderer,
@@ -56,6 +79,9 @@ where
widget::Text::new(text)
}
+/// Creates a new [`Checkbox`].
+///
+/// [`Checkbox`]: widget::Checkbox
pub fn checkbox<'a, Message, Renderer>(
label: impl Into<String>,
is_checked: bool,
@@ -67,6 +93,9 @@ where
widget::Checkbox::new(is_checked, label, f)
}
+/// Creates a new [`Radio`].
+///
+/// [`Radio`]: widget::Radio
pub fn radio<'a, Message, Renderer, V>(
label: impl Into<String>,
value: V,
@@ -81,6 +110,9 @@ where
widget::Radio::new(value, label, selected, on_click)
}
+/// Creates a new [`Toggler`].
+///
+/// [`Toggler`]: widget::Toggler
pub fn toggler<'a, Message, Renderer>(
label: impl Into<Option<String>>,
is_checked: bool,
@@ -92,6 +124,9 @@ where
widget::Toggler::new(is_checked, label, f)
}
+/// Creates a new [`TextInput`].
+///
+/// [`TextInput`]: widget::TextInput
pub fn text_input<'a, Message, Renderer>(
placeholder: &str,
value: &str,
@@ -104,6 +139,9 @@ where
widget::TextInput::new(placeholder, value, on_change)
}
+/// Creates a new [`Slider`].
+///
+/// [`Slider`]: widget::Slider
pub fn slider<'a, Message, T>(
range: std::ops::RangeInclusive<T>,
value: T,
@@ -116,6 +154,9 @@ where
widget::Slider::new(range, value, on_change)
}
+/// Creates a new [`PickList`].
+///
+/// [`PickList`]: widget::PickList
pub fn pick_list<'a, Message, Renderer, T>(
options: impl Into<Cow<'a, [T]>>,
selected: Option<T>,
@@ -129,24 +170,37 @@ where
widget::PickList::new(options, selected, on_selected)
}
+/// Creates a new [`Image`].
+///
+/// [`Image`]: widget::Image
pub fn image<Handle>(handle: impl Into<Handle>) -> widget::Image<Handle> {
widget::Image::new(handle.into())
}
+/// Creates a new horizontal [`Space`] with the given [`Length`].
+///
+/// [`Space`]: widget::Space
pub fn horizontal_space(width: Length) -> widget::Space {
widget::Space::with_width(width)
}
+/// Creates a new vertical [`Space`] with the given [`Length`].
+///
+/// [`Space`]: widget::Space
pub fn vertical_space(height: Length) -> widget::Space {
widget::Space::with_height(height)
}
/// Creates a horizontal [`Rule`] with the given height.
+///
+/// [`Rule`]: widget::Rule
pub fn horizontal_rule<'a>(height: u16) -> widget::Rule<'a> {
widget::Rule::horizontal(height)
}
/// Creates a vertical [`Rule`] with the given width.
+///
+/// [`Rule`]: widget::Rule
pub fn vertical_rule<'a>(width: u16) -> widget::Rule<'a> {
widget::Rule::horizontal(width)
}
@@ -154,8 +208,10 @@ pub fn vertical_rule<'a>(width: u16) -> widget::Rule<'a> {
/// Creates a new [`ProgressBar`].
///
/// It expects:
-/// * an inclusive range of possible values
-/// * the current value of the [`ProgressBar`]
+/// * an inclusive range of possible values, and
+/// * the current value of the [`ProgressBar`].
+///
+/// [`ProgressBar`]: widget::ProgressBar
pub fn progress_bar<'a>(
range: RangeInclusive<f32>,
value: f32,