Use recently stabilized intra-doc links
See RFC: https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
This commit is contained in:
parent
d612bf5678
commit
01322f69a4
135 changed files with 135 additions and 1769 deletions
|
|
@ -5,7 +5,7 @@ use std::rc::Rc;
|
|||
///
|
||||
/// It can be used to route messages back to the [`Application`].
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
/// [`Application`]: crate::Application
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Bus<Message> {
|
||||
publish: Rc<Box<dyn Fn(Message) -> ()>>,
|
||||
|
|
@ -33,15 +33,13 @@ where
|
|||
|
||||
/// Publishes a new message for the [`Application`].
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
/// [`Application`]: crate::Application
|
||||
pub fn publish(&self, message: Message) {
|
||||
(self.publish)(message)
|
||||
}
|
||||
|
||||
/// Creates a new [`Bus`] that applies the given function to the messages
|
||||
/// before publishing.
|
||||
///
|
||||
/// [`Bus`]: struct.Bus.html
|
||||
pub fn map<B>(&self, mapper: Rc<Box<dyn Fn(B) -> Message>>) -> Bus<B>
|
||||
where
|
||||
B: 'static,
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ pub enum Rule {
|
|||
}
|
||||
|
||||
impl Rule {
|
||||
/// Returns the class name of the [`Style`].
|
||||
///
|
||||
/// [`Style`]: enum.Style.html
|
||||
/// Returns the class name of the [`Rule`].
|
||||
pub fn class<'a>(&self) -> String {
|
||||
match self {
|
||||
Rule::Column => String::from("c"),
|
||||
|
|
@ -32,9 +30,7 @@ impl Rule {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the declaration of the [`Style`].
|
||||
///
|
||||
/// [`Style`]: enum.Style.html
|
||||
/// Returns the declaration of the [`Rule`].
|
||||
pub fn declaration<'a>(&self, bump: &'a bumpalo::Bump) -> &'a str {
|
||||
let class = self.class();
|
||||
|
||||
|
|
@ -81,22 +77,17 @@ pub struct Css<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Css<'a> {
|
||||
/// Creates an empty style [`Sheet`].
|
||||
///
|
||||
/// [`Sheet`]: struct.Sheet.html
|
||||
/// Creates an empty [`Css`].
|
||||
pub fn new() -> Self {
|
||||
Css {
|
||||
rules: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Inserts the [`rule`] in the [`Sheet`], if it was not previously
|
||||
/// Inserts the [`Rule`] in the [`Css`], if it was not previously
|
||||
/// inserted.
|
||||
///
|
||||
/// It returns the class name of the provided [`Rule`].
|
||||
///
|
||||
/// [`Sheet`]: struct.Sheet.html
|
||||
/// [`Rule`]: enum.Rule.html
|
||||
pub fn insert(&mut self, bump: &'a bumpalo::Bump, rule: Rule) -> String {
|
||||
let class = rule.class();
|
||||
|
||||
|
|
@ -107,9 +98,7 @@ impl<'a> Css<'a> {
|
|||
class
|
||||
}
|
||||
|
||||
/// Produces the VDOM node of the style [`Sheet`].
|
||||
///
|
||||
/// [`Sheet`]: struct.Sheet.html
|
||||
/// Produces the VDOM node of the [`Css`].
|
||||
pub fn node(self, bump: &'a bumpalo::Bump) -> dodrio::Node<'a> {
|
||||
use dodrio::builder::*;
|
||||
|
||||
|
|
@ -133,8 +122,6 @@ impl<'a> Css<'a> {
|
|||
}
|
||||
|
||||
/// Returns the style value for the given [`Length`].
|
||||
///
|
||||
/// [`Length`]: ../enum.Length.html
|
||||
pub fn length(length: Length) -> String {
|
||||
match length {
|
||||
Length::Shrink => String::from("auto"),
|
||||
|
|
@ -164,15 +151,11 @@ pub fn min_length(units: u32) -> String {
|
|||
}
|
||||
|
||||
/// Returns the style value for the given [`Color`].
|
||||
///
|
||||
/// [`Color`]: ../struct.Color.html
|
||||
pub fn color(Color { r, g, b, a }: Color) -> String {
|
||||
format!("rgba({}, {}, {}, {})", 255.0 * r, 255.0 * g, 255.0 * b, a)
|
||||
}
|
||||
|
||||
/// Returns the style value for the given [`Background`].
|
||||
///
|
||||
/// [`Background`]: ../struct.Background.html
|
||||
pub fn background(background: Background) -> String {
|
||||
match background {
|
||||
Background::Color(c) => color(c),
|
||||
|
|
@ -180,8 +163,6 @@ pub fn background(background: Background) -> String {
|
|||
}
|
||||
|
||||
/// Returns the style value for the given [`Align`].
|
||||
///
|
||||
/// [`Align`]: ../enum.Align.html
|
||||
pub fn align(align: Align) -> &'static str {
|
||||
match align {
|
||||
Align::Start => "flex-start",
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ use std::rc::Rc;
|
|||
/// If you have a [built-in widget], you should be able to use `Into<Element>`
|
||||
/// to turn it into an [`Element`].
|
||||
///
|
||||
/// [built-in widget]: widget/index.html
|
||||
/// [`Widget`]: widget/trait.Widget.html
|
||||
/// [`Element`]: struct.Element.html
|
||||
/// [built-in widget]: mod@crate::widget
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Element<'a, Message> {
|
||||
pub(crate) widget: Box<dyn Widget<Message> + 'a>,
|
||||
|
|
@ -21,9 +19,6 @@ pub struct Element<'a, Message> {
|
|||
|
||||
impl<'a, Message> Element<'a, Message> {
|
||||
/// Create a new [`Element`] containing the given [`Widget`].
|
||||
///
|
||||
/// [`Element`]: struct.Element.html
|
||||
/// [`Widget`]: widget/trait.Widget.html
|
||||
pub fn new(widget: impl Widget<Message> + 'a) -> Self {
|
||||
Self {
|
||||
widget: Box::new(widget),
|
||||
|
|
@ -34,8 +29,6 @@ impl<'a, Message> Element<'a, Message> {
|
|||
///
|
||||
/// This method is useful when you want to decouple different parts of your
|
||||
/// UI and make them __composable__.
|
||||
///
|
||||
/// [`Element`]: struct.Element.html
|
||||
pub fn map<F, B>(self, f: F) -> Element<'a, B>
|
||||
where
|
||||
Message: 'static,
|
||||
|
|
|
|||
|
|
@ -96,31 +96,21 @@ pub use executor::Executor;
|
|||
/// by returning a [`Command`](struct.Command.html) in some of its methods.
|
||||
pub trait Application {
|
||||
/// The [`Executor`] that will run commands and subscriptions.
|
||||
///
|
||||
/// [`Executor`]: trait.Executor.html
|
||||
/// [`executor::Default`]: executor/struct.Default.html
|
||||
type Executor: Executor;
|
||||
|
||||
/// The type of __messages__ your [`Application`] will produce.
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
type Message: Send;
|
||||
|
||||
/// The data needed to initialize your [`Application`].
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
type Flags;
|
||||
|
||||
/// Initializes the [`Application`].
|
||||
///
|
||||
/// Here is where you should return the initial state of your app.
|
||||
///
|
||||
/// Additionally, you can return a [`Command`](struct.Command.html) if you
|
||||
/// need to perform some async action in the background on startup. This is
|
||||
/// useful if you want to load state from a file, perform an initial HTTP
|
||||
/// request, etc.
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
/// Additionally, you can return a [`Command`] if you need to perform some
|
||||
/// async action in the background on startup. This is useful if you want to
|
||||
/// load state from a file, perform an initial HTTP request, etc.
|
||||
fn new(flags: Self::Flags) -> (Self, Command<Self::Message>)
|
||||
where
|
||||
Self: Sized;
|
||||
|
|
@ -129,8 +119,6 @@ pub trait Application {
|
|||
///
|
||||
/// This title can be dynamic! The runtime will automatically update the
|
||||
/// title of your application when necessary.
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
fn title(&self) -> String;
|
||||
|
||||
/// Handles a __message__ and updates the state of the [`Application`].
|
||||
|
|
@ -140,16 +128,11 @@ pub trait Application {
|
|||
/// this method.
|
||||
///
|
||||
/// Any [`Command`] returned will be executed immediately in the background.
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
/// [`Command`]: struct.Command.html
|
||||
fn update(&mut self, message: Self::Message) -> Command<Self::Message>;
|
||||
|
||||
/// Returns the widgets to display in the [`Application`].
|
||||
///
|
||||
/// These widgets can produce __messages__ based on user interaction.
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
fn view(&mut self) -> Element<'_, Self::Message>;
|
||||
|
||||
/// Returns the event [`Subscription`] for the current state of the
|
||||
|
|
@ -160,15 +143,11 @@ pub trait Application {
|
|||
/// [`update`](#tymethod.update).
|
||||
///
|
||||
/// By default, this method returns an empty [`Subscription`].
|
||||
///
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
fn subscription(&self) -> Subscription<Self::Message> {
|
||||
Subscription::none()
|
||||
}
|
||||
|
||||
/// Runs the [`Application`].
|
||||
///
|
||||
/// [`Application`]: trait.Application.html
|
||||
fn run(flags: Self::Flags)
|
||||
where
|
||||
Self: 'static + Sized,
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ use crate::Hasher;
|
|||
/// For instance, you can use a [`Subscription`] to listen to a WebSocket
|
||||
/// connection, keyboard presses, mouse events, time ticks, etc.
|
||||
///
|
||||
/// [`Command`]: ../struct.Command.html
|
||||
/// [`Subscription`]: struct.Subscription.html
|
||||
/// [`Command`]: crate::Command
|
||||
pub type Subscription<T> = iced_futures::Subscription<Hasher, (), T>;
|
||||
|
||||
pub use iced_futures::subscription::Recipe;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
//! ```
|
||||
//! use iced_web::{button, Button, Widget};
|
||||
//! ```
|
||||
//!
|
||||
//! [`Widget`]: trait.Widget.html
|
||||
use crate::{Bus, Css};
|
||||
use dodrio::bumpalo;
|
||||
|
||||
|
|
@ -56,12 +54,8 @@ pub use space::Space;
|
|||
///
|
||||
/// If you want to build your own widgets, you will need to implement this
|
||||
/// trait.
|
||||
///
|
||||
/// [`Widget`]: trait.Widget.html
|
||||
pub trait Widget<Message> {
|
||||
/// Produces a VDOM node for the [`Widget`].
|
||||
///
|
||||
/// [`Widget`]: trait.Widget.html
|
||||
fn node<'b>(
|
||||
&self,
|
||||
bump: &'b bumpalo::Bump,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
//! Allow your users to perform actions by pressing a button.
|
||||
//!
|
||||
//! A [`Button`] has some local [`State`].
|
||||
//!
|
||||
//! [`Button`]: struct.Button.html
|
||||
//! [`State`]: struct.State.html
|
||||
use crate::{css, Background, Bus, Css, Element, Length, Widget};
|
||||
|
||||
pub use iced_style::button::{Style, StyleSheet};
|
||||
|
|
@ -38,9 +35,6 @@ pub struct Button<'a, Message> {
|
|||
impl<'a, Message> Button<'a, Message> {
|
||||
/// Creates a new [`Button`] with some local [`State`] and the given
|
||||
/// content.
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new<E>(_state: &'a mut State, content: E) -> Self
|
||||
where
|
||||
E: Into<Element<'a, Message>>,
|
||||
|
|
@ -58,56 +52,42 @@ impl<'a, Message> Button<'a, Message> {
|
|||
}
|
||||
|
||||
/// Sets the width of the [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the minimum width of the [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn min_width(mut self, min_width: u32) -> Self {
|
||||
self.min_width = min_width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the minimum height of the [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn min_height(mut self, min_height: u32) -> Self {
|
||||
self.min_height = min_height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the padding of the [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn padding(mut self, padding: u16) -> Self {
|
||||
self.padding = padding;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the style of the [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the message that will be produced when the [`Button`] is pressed.
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
pub fn on_press(mut self, msg: Message) -> Self {
|
||||
self.on_press = Some(msg);
|
||||
self
|
||||
|
|
@ -115,15 +95,11 @@ impl<'a, Message> Button<'a, Message> {
|
|||
}
|
||||
|
||||
/// The local state of a [`Button`].
|
||||
///
|
||||
/// [`Button`]: struct.Button.html
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub struct State;
|
||||
|
||||
impl State {
|
||||
/// Creates a new [`State`].
|
||||
///
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new() -> State {
|
||||
State::default()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ impl<Message> Checkbox<Message> {
|
|||
/// * a function that will be called when the [`Checkbox`] is toggled. It
|
||||
/// will receive the new state of the [`Checkbox`] and must produce a
|
||||
/// `Message`.
|
||||
///
|
||||
/// [`Checkbox`]: struct.Checkbox.html
|
||||
pub fn new<F>(is_checked: bool, label: impl Into<String>, f: F) -> Self
|
||||
where
|
||||
F: 'static + Fn(bool) -> Message,
|
||||
|
|
@ -59,24 +57,18 @@ impl<Message> Checkbox<Message> {
|
|||
}
|
||||
|
||||
/// Sets the width of the [`Checkbox`].
|
||||
///
|
||||
/// [`Checkbox`]: struct.Checkbox.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the style of the [`Checkbox`].
|
||||
///
|
||||
/// [`Checkbox`]: struct.Checkbox.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the id of the [`Checkbox`].
|
||||
///
|
||||
/// [`Checkbox`]: struct.Checkbox.html
|
||||
pub fn id(mut self, id: impl Into<String>) -> Self {
|
||||
self.id = Some(id.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ use std::u32;
|
|||
/// A container that distributes its contents vertically.
|
||||
///
|
||||
/// A [`Column`] will try to fill the horizontal space of its container.
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Column<'a, Message> {
|
||||
spacing: u16,
|
||||
|
|
@ -22,15 +20,11 @@ pub struct Column<'a, Message> {
|
|||
|
||||
impl<'a, Message> Column<'a, Message> {
|
||||
/// Creates an empty [`Column`].
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn new() -> Self {
|
||||
Self::with_children(Vec::new())
|
||||
}
|
||||
|
||||
/// Creates a [`Column`] with the given elements.
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn with_children(children: Vec<Element<'a, Message>>) -> Self {
|
||||
Column {
|
||||
spacing: 0,
|
||||
|
|
@ -55,56 +49,42 @@ impl<'a, Message> Column<'a, Message> {
|
|||
}
|
||||
|
||||
/// Sets the padding of the [`Column`].
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn padding(mut self, units: u16) -> Self {
|
||||
self.padding = units;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`Column`].
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Column`].
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum width of the [`Column`].
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||
self.max_width = max_width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum height of the [`Column`] in pixels.
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||
self.max_height = max_height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the horizontal alignment of the contents of the [`Column`] .
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn align_items(mut self, align: Align) -> Self {
|
||||
self.align_items = align;
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds an element to the [`Column`].
|
||||
///
|
||||
/// [`Column`]: struct.Column.html
|
||||
pub fn push<E>(mut self, child: E) -> Self
|
||||
where
|
||||
E: Into<Element<'a, Message>>,
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ pub struct Container<'a, Message> {
|
|||
|
||||
impl<'a, Message> Container<'a, Message> {
|
||||
/// Creates an empty [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn new<T>(content: T) -> Self
|
||||
where
|
||||
T: Into<Element<'a, Message>>,
|
||||
|
|
@ -43,48 +41,36 @@ impl<'a, Message> Container<'a, Message> {
|
|||
}
|
||||
|
||||
/// Sets the padding of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Column.html
|
||||
pub fn padding(mut self, units: u16) -> Self {
|
||||
self.padding = units;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum width of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||
self.max_width = max_width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum height of the [`Container`] in pixels.
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||
self.max_height = max_height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Centers the contents in the horizontal axis of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn center_x(mut self) -> Self {
|
||||
self.horizontal_alignment = Align::Center;
|
||||
|
||||
|
|
@ -92,8 +78,6 @@ impl<'a, Message> Container<'a, Message> {
|
|||
}
|
||||
|
||||
/// Centers the contents in the vertical axis of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn center_y(mut self) -> Self {
|
||||
self.vertical_alignment = Align::Center;
|
||||
|
||||
|
|
@ -101,8 +85,6 @@ impl<'a, Message> Container<'a, Message> {
|
|||
}
|
||||
|
||||
/// Sets the style of the [`Container`].
|
||||
///
|
||||
/// [`Container`]: struct.Container.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style_sheet = style.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ pub struct Image {
|
|||
|
||||
impl Image {
|
||||
/// Creates a new [`Image`] with the given path.
|
||||
///
|
||||
/// [`Image`]: struct.Image.html
|
||||
pub fn new<T: Into<Handle>>(handle: T) -> Self {
|
||||
Image {
|
||||
handle: handle.into(),
|
||||
|
|
@ -46,24 +44,18 @@ impl Image {
|
|||
}
|
||||
|
||||
/// Sets the width of the [`Image`] boundaries.
|
||||
///
|
||||
/// [`Image`]: struct.Image.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Image`] boundaries.
|
||||
///
|
||||
/// [`Image`]: struct.Image.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the alt text of the [`Image`].
|
||||
///
|
||||
/// [`Image`]: struct.Image.html
|
||||
pub fn alt(mut self, alt: impl Into<String>) -> Self {
|
||||
self.alt = alt.into();
|
||||
self
|
||||
|
|
@ -118,8 +110,6 @@ impl<'a, Message> From<Image> for Element<'a, Message> {
|
|||
}
|
||||
|
||||
/// An [`Image`] handle.
|
||||
///
|
||||
/// [`Image`]: struct.Image.html
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Handle {
|
||||
id: u64,
|
||||
|
|
@ -128,8 +118,6 @@ pub struct Handle {
|
|||
|
||||
impl Handle {
|
||||
/// Creates an image [`Handle`] pointing to the image of the given path.
|
||||
///
|
||||
/// [`Handle`]: struct.Handle.html
|
||||
pub fn from_path<T: Into<PathBuf>>(path: T) -> Handle {
|
||||
Self::from_data(Data::Path(path.into()))
|
||||
}
|
||||
|
|
@ -145,15 +133,11 @@ impl Handle {
|
|||
}
|
||||
|
||||
/// Returns the unique identifier of the [`Handle`].
|
||||
///
|
||||
/// [`Handle`]: struct.Handle.html
|
||||
pub fn id(&self) -> u64 {
|
||||
self.id
|
||||
}
|
||||
|
||||
/// Returns a reference to the image [`Data`].
|
||||
///
|
||||
/// [`Data`]: enum.Data.html
|
||||
pub fn data(&self) -> &Data {
|
||||
&self.data
|
||||
}
|
||||
|
|
@ -172,8 +156,6 @@ impl From<&str> for Handle {
|
|||
}
|
||||
|
||||
/// The data of an [`Image`].
|
||||
///
|
||||
/// [`Image`]: struct.Image.html
|
||||
#[derive(Clone, Hash)]
|
||||
pub enum Data {
|
||||
/// A remote image
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ impl ProgressBar {
|
|||
/// It expects:
|
||||
/// * an inclusive range of possible values
|
||||
/// * the current value of the [`ProgressBar`]
|
||||
///
|
||||
/// [`ProgressBar`]: struct.ProgressBar.html
|
||||
pub fn new(range: RangeInclusive<f32>, value: f32) -> Self {
|
||||
ProgressBar {
|
||||
value: value.max(*range.start()).min(*range.end()),
|
||||
|
|
@ -45,24 +43,18 @@ impl ProgressBar {
|
|||
}
|
||||
|
||||
/// Sets the width of the [`ProgressBar`].
|
||||
///
|
||||
/// [`ProgressBar`]: struct.ProgressBar.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`ProgressBar`].
|
||||
///
|
||||
/// [`ProgressBar`]: struct.ProgressBar.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = Some(height);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the style of the [`ProgressBar`].
|
||||
///
|
||||
/// [`ProgressBar`]: struct.ProgressBar.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -49,8 +49,6 @@ impl<Message> Radio<Message> {
|
|||
/// * the current selected value
|
||||
/// * a function that will be called when the [`Radio`] is selected. It
|
||||
/// receives the value of the radio and must produce a `Message`.
|
||||
///
|
||||
/// [`Radio`]: struct.Radio.html
|
||||
pub fn new<F, V>(
|
||||
value: V,
|
||||
label: impl Into<String>,
|
||||
|
|
@ -72,24 +70,18 @@ impl<Message> Radio<Message> {
|
|||
}
|
||||
|
||||
/// Sets the style of the [`Radio`] button.
|
||||
///
|
||||
/// [`Radio`]: struct.Radio.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the name attribute of the [`Radio`] button.
|
||||
///
|
||||
/// [`Radio`]: struct.Radio.html
|
||||
pub fn name(mut self, name: impl Into<String>) -> Self {
|
||||
self.name = Some(name.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the id of the [`Radio`] button.
|
||||
///
|
||||
/// [`Radio`]: struct.Radio.html
|
||||
pub fn id(mut self, id: impl Into<String>) -> Self {
|
||||
self.id = Some(id.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ use std::u32;
|
|||
/// A container that distributes its contents horizontally.
|
||||
///
|
||||
/// A [`Row`] will try to fill the horizontal space of its container.
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct Row<'a, Message> {
|
||||
spacing: u16,
|
||||
|
|
@ -22,15 +20,11 @@ pub struct Row<'a, Message> {
|
|||
|
||||
impl<'a, Message> Row<'a, Message> {
|
||||
/// Creates an empty [`Row`].
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn new() -> Self {
|
||||
Self::with_children(Vec::new())
|
||||
}
|
||||
|
||||
/// Creates a [`Row`] with the given elements.
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn with_children(children: Vec<Element<'a, Message>>) -> Self {
|
||||
Row {
|
||||
spacing: 0,
|
||||
|
|
@ -55,57 +49,42 @@ impl<'a, Message> Row<'a, Message> {
|
|||
}
|
||||
|
||||
/// Sets the padding of the [`Row`].
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn padding(mut self, units: u16) -> Self {
|
||||
self.padding = units;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`Row`].
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Row`].
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum width of the [`Row`].
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||
self.max_width = max_width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum height of the [`Row`].
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||
self.max_height = max_height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the vertical alignment of the contents of the [`Row`] .
|
||||
///
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn align_items(mut self, align: Align) -> Self {
|
||||
self.align_items = align;
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds an [`Element`] to the [`Row`].
|
||||
///
|
||||
/// [`Element`]: ../struct.Element.html
|
||||
/// [`Row`]: struct.Row.html
|
||||
pub fn push<E>(mut self, child: E) -> Self
|
||||
where
|
||||
E: Into<Element<'a, Message>>,
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ pub struct Scrollable<'a, Message> {
|
|||
|
||||
impl<'a, Message> Scrollable<'a, Message> {
|
||||
/// Creates a new [`Scrollable`] with the given [`State`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new(_state: &'a mut State) -> Self {
|
||||
use std::u32;
|
||||
|
||||
|
|
@ -42,64 +39,48 @@ impl<'a, Message> Scrollable<'a, Message> {
|
|||
}
|
||||
|
||||
/// Sets the padding of the [`Scrollable`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn padding(mut self, units: u16) -> Self {
|
||||
self.content = self.content.padding(units);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`Scrollable`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Scrollable`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum width of the [`Scrollable`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||
self.content = self.content.max_width(max_width);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum height of the [`Scrollable`] in pixels.
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn max_height(mut self, max_height: u32) -> Self {
|
||||
self.max_height = max_height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the horizontal alignment of the contents of the [`Scrollable`] .
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn align_items(mut self, align_items: Align) -> Self {
|
||||
self.content = self.content.align_items(align_items);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the style of the [`Scrollable`] .
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Adds an element to the [`Scrollable`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
pub fn push<E>(mut self, child: E) -> Self
|
||||
where
|
||||
E: Into<Element<'a, Message>>,
|
||||
|
|
@ -154,15 +135,11 @@ where
|
|||
}
|
||||
|
||||
/// The local state of a [`Scrollable`].
|
||||
///
|
||||
/// [`Scrollable`]: struct.Scrollable.html
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct State;
|
||||
|
||||
impl State {
|
||||
/// Creates a new [`State`] with the scrollbar located at the top.
|
||||
///
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new() -> Self {
|
||||
State::default()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
//! Display an interactive selector of a single value from a range of values.
|
||||
//!
|
||||
//! A [`Slider`] has some local [`State`].
|
||||
//!
|
||||
//! [`Slider`]: struct.Slider.html
|
||||
//! [`State`]: struct.State.html
|
||||
use crate::{Bus, Css, Element, Length, Widget};
|
||||
|
||||
pub use iced_style::slider::{Handle, HandleShape, Style, StyleSheet};
|
||||
|
|
@ -19,8 +16,6 @@ use std::{ops::RangeInclusive, rc::Rc};
|
|||
/// The [`Slider`] range of numeric values is generic and its step size defaults
|
||||
/// to 1 unit.
|
||||
///
|
||||
/// [`Slider`]: struct.Slider.html
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// # use iced_web::{slider, Slider};
|
||||
|
|
@ -60,9 +55,6 @@ where
|
|||
/// * a function that will be called when the [`Slider`] is dragged.
|
||||
/// It receives the new value of the [`Slider`] and must produce a
|
||||
/// `Message`.
|
||||
///
|
||||
/// [`Slider`]: struct.Slider.html
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new<F>(
|
||||
state: &'a mut State,
|
||||
range: RangeInclusive<T>,
|
||||
|
|
@ -96,24 +88,18 @@ where
|
|||
}
|
||||
|
||||
/// Sets the width of the [`Slider`].
|
||||
///
|
||||
/// [`Slider`]: struct.Slider.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the style of the [`Slider`].
|
||||
///
|
||||
/// [`Slider`]: struct.Slider.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style = style.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the step size of the [`Slider`].
|
||||
///
|
||||
/// [`Slider`]: struct.Slider.html
|
||||
pub fn step(mut self, step: T) -> Self {
|
||||
self.step = step;
|
||||
self
|
||||
|
|
@ -181,15 +167,11 @@ where
|
|||
}
|
||||
|
||||
/// The local state of a [`Slider`].
|
||||
///
|
||||
/// [`Slider`]: struct.Slider.html
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub struct State;
|
||||
|
||||
impl State {
|
||||
/// Creates a new [`State`].
|
||||
///
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,11 @@ pub struct Space {
|
|||
|
||||
impl Space {
|
||||
/// Creates an amount of empty [`Space`] with the given width and height.
|
||||
///
|
||||
/// [`Space`]: struct.Space.html
|
||||
pub fn new(width: Length, height: Length) -> Self {
|
||||
Space { width, height }
|
||||
}
|
||||
|
||||
/// Creates an amount of horizontal [`Space`].
|
||||
///
|
||||
/// [`Space`]: struct.Space.html
|
||||
pub fn with_width(width: Length) -> Self {
|
||||
Space {
|
||||
width,
|
||||
|
|
@ -29,8 +25,6 @@ impl Space {
|
|||
}
|
||||
|
||||
/// Creates an amount of vertical [`Space`].
|
||||
///
|
||||
/// [`Space`]: struct.Space.html
|
||||
pub fn with_height(height: Length) -> Self {
|
||||
Space {
|
||||
width: Length::Shrink,
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ pub struct Text {
|
|||
|
||||
impl Text {
|
||||
/// Create a new fragment of [`Text`] with the given contents.
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
pub fn new<T: Into<String>>(label: T) -> Self {
|
||||
Text {
|
||||
content: label.into(),
|
||||
|
|
@ -44,51 +42,36 @@ impl Text {
|
|||
}
|
||||
|
||||
/// Sets the size of the [`Text`].
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
pub fn size(mut self, size: u16) -> Self {
|
||||
self.size = Some(size);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Color`] of the [`Text`].
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
/// [`Color`]: ../../struct.Color.html
|
||||
pub fn color<C: Into<Color>>(mut self, color: C) -> Self {
|
||||
self.color = Some(color.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Font`] of the [`Text`].
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
/// [`Font`]: ../../struct.Font.html
|
||||
pub fn font(mut self, font: Font) -> Self {
|
||||
self.font = font;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`Text`] boundaries.
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the height of the [`Text`] boundaries.
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
pub fn height(mut self, height: Length) -> Self {
|
||||
self.height = height;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the [`HorizontalAlignment`] of the [`Text`].
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
/// [`HorizontalAlignment`]: enum.HorizontalAlignment.html
|
||||
pub fn horizontal_alignment(
|
||||
mut self,
|
||||
alignment: HorizontalAlignment,
|
||||
|
|
@ -98,9 +81,6 @@ impl Text {
|
|||
}
|
||||
|
||||
/// Sets the [`VerticalAlignment`] of the [`Text`].
|
||||
///
|
||||
/// [`Text`]: struct.Text.html
|
||||
/// [`VerticalAlignment`]: enum.VerticalAlignment.html
|
||||
pub fn vertical_alignment(mut self, alignment: VerticalAlignment) -> Self {
|
||||
self.vertical_alignment = alignment;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
//! Display fields that can be filled with text.
|
||||
//!
|
||||
//! A [`TextInput`] has some local [`State`].
|
||||
//!
|
||||
//! [`TextInput`]: struct.TextInput.html
|
||||
//! [`State`]: struct.State.html
|
||||
use crate::{bumpalo, css, Bus, Css, Element, Length, Widget};
|
||||
|
||||
pub use iced_style::text_input::{Style, StyleSheet};
|
||||
|
|
@ -53,9 +50,6 @@ impl<'a, Message> TextInput<'a, Message> {
|
|||
/// - a placeholder
|
||||
/// - the current value
|
||||
/// - a function that produces a message when the [`TextInput`] changes
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new<F>(
|
||||
state: &'a mut State,
|
||||
placeholder: &str,
|
||||
|
|
@ -81,40 +75,30 @@ impl<'a, Message> TextInput<'a, Message> {
|
|||
}
|
||||
|
||||
/// Converts the [`TextInput`] into a secure password input.
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn password(mut self) -> Self {
|
||||
self.is_secure = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the width of the [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn width(mut self, width: Length) -> Self {
|
||||
self.width = width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the maximum width of the [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn max_width(mut self, max_width: u32) -> Self {
|
||||
self.max_width = max_width;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the padding of the [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn padding(mut self, units: u16) -> Self {
|
||||
self.padding = units;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the text size of the [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn size(mut self, size: u16) -> Self {
|
||||
self.size = Some(size);
|
||||
self
|
||||
|
|
@ -122,16 +106,12 @@ impl<'a, Message> TextInput<'a, Message> {
|
|||
|
||||
/// Sets the message that should be produced when the [`TextInput`] is
|
||||
/// focused and the enter key is pressed.
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn on_submit(mut self, message: Message) -> Self {
|
||||
self.on_submit = Some(message);
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the style of the [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
pub fn style(mut self, style: impl Into<Box<dyn StyleSheet>>) -> Self {
|
||||
self.style_sheet = style.into();
|
||||
self
|
||||
|
|
@ -238,22 +218,16 @@ where
|
|||
}
|
||||
|
||||
/// The state of a [`TextInput`].
|
||||
///
|
||||
/// [`TextInput`]: struct.TextInput.html
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
pub struct State;
|
||||
|
||||
impl State {
|
||||
/// Creates a new [`State`], representing an unfocused [`TextInput`].
|
||||
///
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Creates a new [`State`], representing a focused [`TextInput`].
|
||||
///
|
||||
/// [`State`]: struct.State.html
|
||||
pub fn focused() -> Self {
|
||||
// TODO
|
||||
Self::default()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue