diff --git a/ECOSYSTEM.md b/ECOSYSTEM.md deleted file mode 100644 index da3066d8..00000000 --- a/ECOSYSTEM.md +++ /dev/null @@ -1,91 +0,0 @@ -# Ecosystem -This document describes the Iced ecosystem and explains how the different crates relate to each other. - -## Overview -Iced is meant to be used by 2 different types of users: - -- __End-users__. They should be able to: - - get started quickly, - - have many widgets available, - - keep things simple, - - and build applications that are __maintainable__ and __performant__. -- __GUI toolkit developers / Ecosystem contributors__. They should be able to: - - build new kinds of widgets, - - implement custom runtimes, - - integrate existing runtimes in their own system (like game engines), - - and create their own custom renderers. - -Iced consists of different crates which offer different layers of abstractions for our users. This modular architecture helps us keep implementation details hidden and decoupled, which should allow us to rewrite or change strategies in the future. - -
-
-
-
-
-
-
-
-
+
+
-
-
+
+
@@ -34,34 +34,28 @@ Inspired by [Elm].
* Custom widget support (create your own!)
* [Debug overlay with performance metrics]
* First-class support for async actions (use futures!)
-* [Modular ecosystem] split into reusable parts:
+* Modular ecosystem split into reusable parts:
* A [renderer-agnostic native runtime] enabling integration with existing systems
- * Two [built-in renderers] leveraging [`wgpu`] and [`tiny-skia`]
+ * Two built-in renderers leveraging [`wgpu`] and [`tiny-skia`]
* [`iced_wgpu`] supporting Vulkan, Metal and DX12
* [`iced_tiny_skia`] offering a software alternative as a fallback
* A [windowing shell]
- * A [web runtime] leveraging the DOM
-__Iced is currently experimental software.__ [Take a look at the roadmap],
-[check out the issues], and [feel free to contribute!]
+__Iced is currently experimental software.__ [Take a look at the roadmap] and
+[check out the issues].
[Cross-platform support]: https://raw.githubusercontent.com/iced-rs/iced/master/docs/images/todos_desktop.jpg
[text inputs]: https://iced.rs/examples/text_input.mp4
[scrollables]: https://iced.rs/examples/scrollable.mp4
[Debug overlay with performance metrics]: https://iced.rs/examples/debug.mp4
-[Modular ecosystem]: ECOSYSTEM.md
[renderer-agnostic native runtime]: runtime/
[`wgpu`]: https://github.com/gfx-rs/wgpu
[`tiny-skia`]: https://github.com/RazrFalcon/tiny-skia
[`iced_wgpu`]: wgpu/
[`iced_tiny_skia`]: tiny_skia/
-[built-in renderers]: ECOSYSTEM.md#Renderers
[windowing shell]: winit/
-[`dodrio`]: https://github.com/fitzgen/dodrio
-[web runtime]: https://github.com/iced-rs/iced_web
[Take a look at the roadmap]: ROADMAP.md
[check out the issues]: https://github.com/iced-rs/iced/issues
-[feel free to contribute!]: #contributing--feedback
## Overview
@@ -164,7 +158,7 @@ Read the [book], the [documentation], and the [examples] to learn more!
## Implementation details
Iced was originally born as an attempt at bringing the simplicity of [Elm] and
-[The Elm Architecture] into [Coffee], a 2D game engine I am working on.
+[The Elm Architecture] into [Coffee], a 2D game library I am working on.
The core of the library was implemented during May 2019 in [this pull request].
[The first alpha version] was eventually released as
@@ -172,25 +166,17 @@ The core of the library was implemented during May 2019 in [this pull request].
implemented the current [tour example] on top of [`ggez`], a game library.
Since then, the focus has shifted towards providing a batteries-included,
-end-user-oriented GUI library, while keeping [the ecosystem] modular:
-
-
-
-
-
-
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs
index 32db5090..4a3f35ed 100644
--- a/widget/src/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -1,4 +1,35 @@
-//! Show toggle controls using checkboxes.
+//! Checkboxes can be used to let users make binary choices.
+//!
+//! # 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::checkbox;
+//!
+//! struct State {
+//! is_checked: bool,
+//! }
+//!
+//! enum Message {
+//! CheckboxToggled(bool),
+//! }
+//!
+//! fn view(state: &State) -> Element<'_, Message> {
+//! checkbox("Toggle me!", state.is_checked)
+//! .on_toggle(Message::CheckboxToggled)
+//! .into()
+//! }
+//!
+//! fn update(state: &mut State, message: Message) {
+//! match message {
+//! Message::CheckboxToggled(is_checked) => {
+//! state.is_checked = is_checked;
+//! }
+//! }
+//! }
+//! ```
+//! 
use crate::core::alignment;
use crate::core::event::{self, Event};
use crate::core::layout;
@@ -17,19 +48,34 @@ use crate::core::{
/// A box that can be checked.
///
/// # Example
-///
/// ```no_run
-/// # type Checkbox<'a, Message> = iced_widget::Checkbox<'a, Message>;
+/// # 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>;
/// #
-/// pub enum Message {
+/// use iced::widget::checkbox;
+///
+/// struct State {
+/// is_checked: bool,
+/// }
+///
+/// enum Message {
/// CheckboxToggled(bool),
/// }
///
-/// let is_checked = true;
+/// fn view(state: &State) -> Element<'_, Message> {
+/// checkbox("Toggle me!", state.is_checked)
+/// .on_toggle(Message::CheckboxToggled)
+/// .into()
+/// }
///
-/// Checkbox::new("Toggle me!", is_checked).on_toggle(Message::CheckboxToggled);
+/// fn update(state: &mut State, message: Message) {
+/// match message {
+/// Message::CheckboxToggled(is_checked) => {
+/// state.is_checked = is_checked;
+/// }
+/// }
+/// }
/// ```
-///
/// 
#[allow(missing_debug_implementations)]
pub struct Checkbox<
diff --git a/widget/src/column.rs b/widget/src/column.rs
index d3ea4cf7..fc4653b9 100644
--- a/widget/src/column.rs
+++ b/widget/src/column.rs
@@ -12,6 +12,27 @@ use crate::core::{
};
/// A container that distributes its contents vertically.
+///
+/// # Example
+/// ```no_run
+/// # mod iced { pub mod widget { pub use iced_widget::*; } }
+/// # pub type State = ();
+/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
+/// use iced::widget::{button, column};
+///
+/// #[derive(Debug, Clone)]
+/// enum Message {
+/// // ...
+/// }
+///
+/// fn view(state: &State) -> Element<'_, Message> {
+/// column![
+/// "I am on top!",
+/// button("I am in the center!"),
+/// "I am below.",
+/// ].into()
+/// }
+/// ```
#[allow(missing_debug_implementations)]
pub struct Column<'a, Message, Theme = crate::Theme, Renderer = crate::Renderer>
{
diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs
index a51701ca..fb661ad5 100644
--- a/widget/src/combo_box.rs
+++ b/widget/src/combo_box.rs
@@ -1,4 +1,59 @@
-//! Display a dropdown list of searchable and selectable options.
+//! Combo boxes display a dropdown list of searchable and selectable options.
+//!
+//! # 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::combo_box;
+//!
+//! struct State {
+//! fruits: combo_box::State (
program: P,
@@ -999,8 +1762,31 @@ where
/// Creates a new [`QRCode`] widget from the given [`Data`].
///
+/// QR codes display information in a type of two-dimensional matrix barcode.
+///
/// [`QRCode`]: crate::QRCode
/// [`Data`]: crate::qr_code::Data
+///
+/// # 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::qr_code;
+///
+/// struct State {
+/// data: qr_code::Data,
+/// }
+///
+/// #[derive(Debug, Clone)]
+/// enum Message {
+/// // ...
+/// }
+///
+/// fn view(state: &State) -> Element<'_, Message> {
+/// qr_code(&state.data).into()
+/// }
+/// ```
#[cfg(feature = "qr_code")]
pub fn qr_code<'a, Theme>(
data: &'a crate::qr_code::Data,
@@ -1060,3 +1846,55 @@ where
{
Themer::new(move |_| new_theme.clone(), content)
}
+
+/// Creates a [`PaneGrid`] with the given [`pane_grid::State`] and view function.
+///
+/// Pane grids let your users split regions of your application and organize layout dynamically.
+///
+/// # 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::{pane_grid, text};
+///
+/// struct State {
+/// panes: pane_grid::State
#[cfg(feature = "image")]
pub fn image
pub mod viewer;
pub use viewer::Viewer;
@@ -22,16 +39,23 @@ pub fn viewer
#[derive(Debug)]
-pub struct Image