Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation comments #179

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Hsv {
}

impl Hsv {
/// Creates a [`Hsv`](Hsv) from its HSV components.
/// Creates a [`Hsv`] from its HSV components.
#[must_use]
pub const fn from_hsv(hue: u16, saturation: f32, value: f32) -> Self {
Self {
Expand Down
24 changes: 12 additions & 12 deletions src/native/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ where
width: Length,
/// The height of the [`Badge`].
height: Length,
/// The horizontal alignment of the [`Badge`](Badge).
/// The horizontal alignment of the [`Badge`].
horizontal_alignment: Alignment,
/// The vertical alignment of the [`Badge`](Badge).
/// The vertical alignment of the [`Badge`].
vertical_alignment: Alignment,
/// The style of the [`Badge`](Badge).
/// The style of the [`Badge`].
style: <Renderer::Theme as StyleSheet>::Style,
/// The content [`Element`] of the [`Badge`](Badge).
/// The content [`Element`] of the [`Badge`].
content: Element<'a, Message, Renderer>,
}

Expand All @@ -55,10 +55,10 @@ where
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`Badge`](Badge) with the given content.
/// Creates a new [`Badge`] with the given content.
///
/// It expects:
/// * the content [`Element`] to display in the [`Badge`](Badge).
/// * the content [`Element`] to display in the [`Badge`].
pub fn new<T>(content: T) -> Self
where
T: Into<Element<'a, Message, Renderer>>,
Expand All @@ -74,42 +74,42 @@ where
}
}

/// Sets the padding of the [`Badge`](Badge).
/// Sets the padding of the [`Badge`].
#[must_use]
pub fn padding(mut self, units: u16) -> Self {
self.padding = units;
self
}

/// Sets the width of the [`Badge`](Badge).
/// Sets the width of the [`Badge`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}

/// Sets the height of the [`Badge`](Badge).
/// Sets the height of the [`Badge`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}

/// Sets the horizontal alignment of the content of the [`Badge`](Badge).
/// Sets the horizontal alignment of the content of the [`Badge`].
#[must_use]
pub fn align_x(mut self, alignment: Alignment) -> Self {
self.horizontal_alignment = alignment;
self
}

/// Sets the vertical alignment of the content of the [`Badge`](Badge).
/// Sets the vertical alignment of the content of the [`Badge`].
#[must_use]
pub fn align_y(mut self, alignment: Alignment) -> Self {
self.vertical_alignment = alignment;
self
}

/// Sets the style of the [`Badge`](Badge).
/// Sets the style of the [`Badge`].
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
Expand Down
64 changes: 31 additions & 33 deletions src/native/card.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Displays a [`Card`](Card).
//! Displays a [`Card`].
//!
//! *This API requires the following crate features to be activated: card*

Expand All @@ -20,7 +20,7 @@ use iced_widget::{
use crate::graphics::icons::{Icon, ICON_FONT};
pub use crate::style::card::{Appearance, StyleSheet};

/// The default padding of a [`Card`](Card).
/// The default padding of a [`Card`].
const DEFAULT_PADDING: f32 = 10.0;

/// A card consisting of a head, body and optional foot.
Expand Down Expand Up @@ -49,31 +49,31 @@ where
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// The width of the [`Card`](Card).
/// The width of the [`Card`].
width: Length,
/// The height of the [`Card`](Card).
/// The height of the [`Card`].
height: Length,
/// The maximum width of the [`Card`](Card).
/// The maximum width of the [`Card`].
max_width: f32,
/// The maximum height of the [`Card`](Card).
/// The maximum height of the [`Card`].
max_height: f32,
/// The padding of the head of the [`Card`](Card).
/// The padding of the head of the [`Card`].
padding_head: f32,
/// The padding of the body of the [`Card`](Card).
/// The padding of the body of the [`Card`].
padding_body: f32,
/// The padding of the foot of the [`Card`](Card).
/// The padding of the foot of the [`Card`].
padding_foot: f32,
/// The optional size of the close icon of the [`Card`](Card).
/// The optional size of the close icon of the [`Card`].
close_size: Option<f32>,
/// The optional message that is send if the close icon of the [`Card`](Card) is pressed.
/// The optional message that is send if the close icon of the [`Card`] is pressed.
on_close: Option<Message>,
/// The head [`Element`] of the [`Card`](Card).
/// The head [`Element`] of the [`Card`].
head: Element<'a, Message, Renderer>,
/// The body [`Element`] of the [`Card`](Card).
/// The body [`Element`] of the [`Card`].
body: Element<'a, Message, Renderer>,
/// The optional foot [`Element`] of the [`Card`](Card).
/// The optional foot [`Element`] of the [`Card`].
foot: Option<Element<'a, Message, Renderer>>,
/// The style of the [`Card`](Card).
/// The style of the [`Card`].
style: <Renderer::Theme as StyleSheet>::Style,
}

Expand All @@ -82,13 +82,11 @@ where
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`Card`](Card) containing the given head and body.
/// Creates a new [`Card`] containing the given head and body.
///
/// It expects:
/// * the head [`Element`] to display at the top of
/// the [`Card`](Card).
/// * the body [`Element`] to display at the middle
/// of the [`Card`](Card).
/// * the head [`Element`] to display at the top of the [`Card`].
/// * the body [`Element`] to display at the middle of the [`Card`].
pub fn new<H, B>(head: H, body: B) -> Self
where
H: Into<Element<'a, Message, Renderer>>,
Expand All @@ -111,7 +109,7 @@ where
}
}

/// Sets the [`Element`] of the foot of the [`Card`](Card).
/// Sets the [`Element`] of the foot of the [`Card`].
#[must_use]
pub fn foot<F>(mut self, foot: F) -> Self
where
Expand All @@ -121,35 +119,35 @@ where
self
}

/// Sets the width of the [`Card`](Card).
/// Sets the width of the [`Card`].
#[must_use]
pub fn width(mut self, width: Length) -> Self {
self.width = width;
self
}

/// Sets the height of the [`Card`](Card).
/// Sets the height of the [`Card`].
#[must_use]
pub fn height(mut self, height: Length) -> Self {
self.height = height;
self
}

/// Sets the maximum width of the [`Card`](Card).
/// Sets the maximum width of the [`Card`].
#[must_use]
pub fn max_width(mut self, width: f32) -> Self {
self.max_width = width;
self
}

/// Sets the maximum height of the [`Card`](Card).
/// Sets the maximum height of the [`Card`].
#[must_use]
pub fn max_height(mut self, height: f32) -> Self {
self.max_height = height;
self
}

/// Sets the padding of the [`Card`](Card).
/// Sets the padding of the [`Card`].
///
/// This will set the padding of the head, body and foot to the
/// same value.
Expand All @@ -161,45 +159,45 @@ where
self
}

/// Sets the padding of the head of the [`Card`](Card).
/// Sets the padding of the head of the [`Card`].
#[must_use]
pub fn padding_head(mut self, padding: f32) -> Self {
self.padding_head = padding;
self
}

/// Sets the padding of the body of the [`Card`](Card).
/// Sets the padding of the body of the [`Card`].
#[must_use]
pub fn padding_body(mut self, padding: f32) -> Self {
self.padding_body = padding;
self
}

/// Sets the padding of the foot of the [`Card`](Card).
/// Sets the padding of the foot of the [`Card`].
#[must_use]
pub fn padding_foot(mut self, padding: f32) -> Self {
self.padding_foot = padding;
self
}

/// Sets the size of the close icon of the [`Card`](Card).
/// Sets the size of the close icon of the [`Card`].
#[must_use]
pub fn close_size(mut self, size: f32) -> Self {
self.close_size = Some(size);
self
}

/// Sets the message that will be produced when the close icon of the
/// [`Card`](Card) is pressed.
/// [`Card`] is pressed.
///
/// Setting this enables the drawing of a close icon on the [`Card`](Card).
/// Setting this enables the drawing of a close icon on the [`Card`].
#[must_use]
pub fn on_close(mut self, msg: Message) -> Self {
self.on_close = Some(msg);
self
}

/// Sets the style of the [`Card`](Card).
/// Sets the style of the [`Card`].
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
Expand Down
20 changes: 10 additions & 10 deletions src/native/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ where
color: Color,
/// The underlying element.
underlay: Element<'a, Message, Renderer<Theme>>,
/// The message that is send if the cancel button of the [`ColorPickerOverlay`](ColorPickerOverlay) is pressed.
/// The message that is sent if the cancel button of the [`ColorPickerOverlay`] is pressed.
on_cancel: Message,
/// The function that produces a message when the submit button of the [`ColorPickerOverlay`](ColorPickerOverlay) is pressed.
/// The function that produces a message when the submit button of the [`ColorPickerOverlay`] is pressed.
on_submit: Box<dyn Fn(Color) -> Message>,
/// The style of the [`ColorPickerOverlay`](ColorPickerOverlay).
/// The style of the [`ColorPickerOverlay`].
style: <Theme as StyleSheet>::Style,
/// The buttons of the overlay.
overlay_state: Element<'a, Message, Renderer<Theme>>,
Expand All @@ -75,16 +75,16 @@ where
Message: 'a + Clone,
Theme: 'a + StyleSheet + button::StyleSheet + widget::text::StyleSheet,
{
/// Creates a new [`ColorPicker`](ColorPicker) wrapping around the given underlay.
/// Creates a new [`ColorPicker`] wrapping around the given underlay.
///
/// It expects:
/// * if the overlay of the color picker is visible.
/// * the initial color to show.
/// * the underlay [`Element`] on which this [`ColorPicker`](ColorPicker)
/// * the underlay [`Element`] on which this [`ColorPicker`]
/// will be wrapped around.
/// * a message that will be send when the cancel button of the [`ColorPicker`](ColorPicker)
/// * a message that will be send when the cancel button of the [`ColorPicker`]
/// is pressed.
/// * a function that will be called when the submit button of the [`ColorPicker`](ColorPicker)
/// * a function that will be called when the submit button of the [`ColorPicker`]
/// is pressed, which takes the picked [`Color`] value.
pub fn new<U, F>(
show_picker: bool,
Expand All @@ -108,23 +108,23 @@ where
}
}

/// Sets the style of the [`ColorPicker`](ColorPicker).
/// Sets the style of the [`ColorPicker`].
#[must_use]
pub fn style(mut self, style: <Theme as StyleSheet>::Style) -> Self {
self.style = style;
self
}
}

/// The state of the [`ColorPicker`](ColorPicker).
/// The state of the [`ColorPicker`].
#[derive(Debug, Default)]
pub struct State {
/// The state of the overlay.
pub(crate) overlay_state: color_picker::State,
}

impl State {
/// Creates a new [`State`](State).
/// Creates a new [`State`].
#[must_use]
pub fn new(color: Color) -> Self {
Self {
Expand Down
14 changes: 7 additions & 7 deletions src/native/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ where
{
/// The underlying element.
underlay: Element<'a, Message, Renderer>,
/// The content of [`ContextMenuOverlay`](ContextMenuOverlay).
/// The content of [`ContextMenuOverlay`].
overlay: Overlay,
/// The style of the [`ContextMenu`](ContextMenu).
/// The style of the [`ContextMenu`].
style: <Renderer::Theme as StyleSheet>::Style,
}

Expand All @@ -55,11 +55,11 @@ where
Renderer: core::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`ContextMenu`](ContextMenu)
/// Creates a new [`ContextMenu`]
///
/// `underlay`: The underlying element.
///
/// `overlay`: The content of [`ContextMenuOverlay`](ContextMenuOverlay) which will be displayed when `underlay` is clicked.
/// `overlay`: The content of [`ContextMenuOverlay`] which will be displayed when `underlay` is clicked.
pub fn new<U>(underlay: U, overlay: Overlay) -> Self
where
U: Into<Element<'a, Message, Renderer>>,
Expand All @@ -71,7 +71,7 @@ where
}
}

/// Sets the style of the [`ContextMenu`](ContextMenu).
/// Sets the style of the [`ContextMenu`].
#[must_use]
pub fn style(mut self, style: <Renderer::Theme as StyleSheet>::Style) -> Self {
self.style = style;
Expand Down Expand Up @@ -252,14 +252,14 @@ where
/// The state of the ``context_menu``.
#[derive(Debug, Default)]
pub(crate) struct State {
/// The visibility of the [`ContextMenu`](ContextMenu) overlay.
/// The visibility of the [`ContextMenu`] overlay.
pub show: bool,
/// Use for showing the overlay where the click was made.
pub cursor_position: Point,
}

impl State {
/// Creates a new [`State`](State) containing the given state data.
/// Creates a new [`State`] containing the given state data.
pub const fn new() -> Self {
Self {
show: false,
Expand Down
Loading