summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/application.rs104
-rw-r--r--src/element.rs4
-rw-r--r--src/error.rs10
-rw-r--r--src/lib.rs101
-rw-r--r--src/overlay.rs16
-rw-r--r--src/sandbox.rs70
-rw-r--r--src/widget.rs269
-rw-r--r--src/window.rs2
-rw-r--r--src/window/mode.rs12
-rw-r--r--src/window/settings.rs5
10 files changed, 387 insertions, 206 deletions
diff --git a/src/application.rs b/src/application.rs
index 14a16d61..23ce034e 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -1,5 +1,7 @@
-use crate::window;
-use crate::{Color, Command, Element, Executor, Settings, Subscription};
+//! Build interactive cross-platform applications.
+use crate::{Command, Element, Executor, Settings, Subscription};
+
+pub use iced_native::application::{Appearance, StyleSheet};
/// An interactive cross-platform application.
///
@@ -37,15 +39,15 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription};
/// to listen to time.
/// - [`todos`], a todos tracker inspired by [TodoMVC].
///
-/// [The repository has a bunch of examples]: https://github.com/hecrj/iced/tree/0.3/examples
-/// [`clock`]: https://github.com/hecrj/iced/tree/0.3/examples/clock
-/// [`download_progress`]: https://github.com/hecrj/iced/tree/0.3/examples/download_progress
-/// [`events`]: https://github.com/hecrj/iced/tree/0.3/examples/events
-/// [`game_of_life`]: https://github.com/hecrj/iced/tree/0.3/examples/game_of_life
-/// [`pokedex`]: https://github.com/hecrj/iced/tree/0.3/examples/pokedex
-/// [`solar_system`]: https://github.com/hecrj/iced/tree/0.3/examples/solar_system
-/// [`stopwatch`]: https://github.com/hecrj/iced/tree/0.3/examples/stopwatch
-/// [`todos`]: https://github.com/hecrj/iced/tree/0.3/examples/todos
+/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.4/examples
+/// [`clock`]: https://github.com/iced-rs/iced/tree/0.4/examples/clock
+/// [`download_progress`]: https://github.com/iced-rs/iced/tree/0.4/examples/download_progress
+/// [`events`]: https://github.com/iced-rs/iced/tree/0.4/examples/events
+/// [`game_of_life`]: https://github.com/iced-rs/iced/tree/0.4/examples/game_of_life
+/// [`pokedex`]: https://github.com/iced-rs/iced/tree/0.4/examples/pokedex
+/// [`solar_system`]: https://github.com/iced-rs/iced/tree/0.4/examples/solar_system
+/// [`stopwatch`]: https://github.com/iced-rs/iced/tree/0.4/examples/stopwatch
+/// [`todos`]: https://github.com/iced-rs/iced/tree/0.4/examples/todos
/// [`Sandbox`]: crate::Sandbox
/// [`Canvas`]: crate::widget::Canvas
/// [PokéAPI]: https://pokeapi.co/
@@ -57,7 +59,8 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription};
/// says "Hello, world!":
///
/// ```no_run
-/// use iced::{executor, Application, Command, Element, Settings, Text};
+/// use iced::executor;
+/// use iced::{Application, Command, Element, Settings, Theme};
///
/// pub fn main() -> iced::Result {
/// Hello::run(Settings::default())
@@ -67,8 +70,9 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription};
///
/// impl Application for Hello {
/// type Executor = executor::Default;
-/// type Message = ();
/// type Flags = ();
+/// type Message = ();
+/// type Theme = Theme;
///
/// fn new(_flags: ()) -> (Hello, Command<Self::Message>) {
/// (Hello, Command::none())
@@ -82,8 +86,8 @@ use crate::{Color, Command, Element, Executor, Settings, Subscription};
/// Command::none()
/// }
///
-/// fn view(&mut self) -> Element<Self::Message> {
-/// Text::new("Hello, world!").into()
+/// fn view(&self) -> Element<Self::Message> {
+/// "Hello, world!".into()
/// }
/// }
/// ```
@@ -99,6 +103,9 @@ pub trait Application: Sized {
/// The type of __messages__ your [`Application`] will produce.
type Message: std::fmt::Debug + Send;
+ /// The theme of your [`Application`].
+ type Theme: Default + StyleSheet;
+
/// The data needed to initialize your [`Application`].
type Flags;
@@ -129,6 +136,26 @@ pub trait Application: Sized {
/// Any [`Command`] returned will be executed immediately in the background.
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.
+ fn view(&self) -> Element<'_, Self::Message, crate::Renderer<Self::Theme>>;
+
+ /// Returns the current [`Theme`] of the [`Application`].
+ ///
+ /// [`Theme`]: Self::Theme
+ fn theme(&self) -> Self::Theme {
+ Self::Theme::default()
+ }
+
+ /// Returns the current [`Style`] of the [`Theme`].
+ ///
+ /// [`Style`]: <Self::Theme as StyleSheet>::Style
+ /// [`Theme`]: Self::Theme
+ fn style(&self) -> <Self::Theme as StyleSheet>::Style {
+ <Self::Theme as StyleSheet>::Style::default()
+ }
+
/// Returns the event [`Subscription`] for the current state of the
/// application.
///
@@ -141,30 +168,6 @@ pub trait Application: Sized {
Subscription::none()
}
- /// Returns the widgets to display in the [`Application`].
- ///
- /// These widgets can produce __messages__ based on user interaction.
- fn view(&mut self) -> Element<'_, Self::Message>;
-
- /// Returns the current [`Application`] mode.
- ///
- /// The runtime will automatically transition your application if a new mode
- /// is returned.
- ///
- /// Currently, the mode only has an effect in native platforms.
- ///
- /// By default, an application will run in windowed mode.
- fn mode(&self) -> window::Mode {
- window::Mode::Windowed
- }
-
- /// Returns the background color of the [`Application`].
- ///
- /// By default, it returns [`Color::WHITE`].
- fn background_color(&self) -> Color {
- Color::WHITE
- }
-
/// Returns the scale factor of the [`Application`].
///
/// It can be used to dynamically control the size of the UI at runtime
@@ -198,6 +201,7 @@ pub trait Application: Sized {
where
Self: 'static,
{
+ #[allow(clippy::needless_update)]
let renderer_settings = crate::renderer::Settings {
default_font: settings.default_font,
default_text_size: settings.default_text_size,
@@ -213,7 +217,7 @@ pub trait Application: Sized {
Ok(crate::runtime::application::run::<
Instance<Self>,
Self::Executor,
- crate::renderer::window::Compositor,
+ crate::renderer::window::Compositor<Self::Theme>,
>(settings.into(), renderer_settings)?)
}
}
@@ -224,14 +228,14 @@ impl<A> iced_winit::Program for Instance<A>
where
A: Application,
{
- type Renderer = crate::renderer::Renderer;
+ type Renderer = crate::Renderer<A::Theme>;
type Message = A::Message;
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
self.0.update(message)
}
- fn view(&mut self) -> Element<'_, Self::Message> {
+ fn view(&self) -> Element<'_, Self::Message, Self::Renderer> {
self.0.view()
}
}
@@ -252,20 +256,16 @@ where
self.0.title()
}
- fn mode(&self) -> iced_winit::Mode {
- match self.0.mode() {
- window::Mode::Windowed => iced_winit::Mode::Windowed,
- window::Mode::Fullscreen => iced_winit::Mode::Fullscreen,
- window::Mode::Hidden => iced_winit::Mode::Hidden,
- }
+ fn theme(&self) -> A::Theme {
+ self.0.theme()
}
- fn subscription(&self) -> Subscription<Self::Message> {
- self.0.subscription()
+ fn style(&self) -> <A::Theme as StyleSheet>::Style {
+ self.0.style()
}
- fn background_color(&self) -> Color {
- self.0.background_color()
+ fn subscription(&self) -> Subscription<Self::Message> {
+ self.0.subscription()
}
fn scale_factor(&self) -> f64 {
diff --git a/src/element.rs b/src/element.rs
index 8bad18c1..2eb1bb4d 100644
--- a/src/element.rs
+++ b/src/element.rs
@@ -1,5 +1,5 @@
/// A generic widget.
///
/// This is an alias of an `iced_native` element with a default `Renderer`.
-pub type Element<'a, Message> =
- crate::runtime::Element<'a, Message, crate::renderer::Renderer>;
+pub type Element<'a, Message, Renderer = crate::Renderer> =
+ crate::runtime::Element<'a, Message, Renderer>;
diff --git a/src/error.rs b/src/error.rs
index 17479c60..0bfa3ff1 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -11,9 +11,9 @@ pub enum Error {
#[error("the application window could not be created")]
WindowCreationFailed(Box<dyn std::error::Error + Send + Sync>),
- /// A suitable graphics adapter or device could not be found.
- #[error("a suitable graphics adapter or device could not be found")]
- GraphicsAdapterNotFound,
+ /// The application graphics context could not be created.
+ #[error("the application graphics context could not be created")]
+ GraphicsCreationFailed(iced_graphics::Error),
}
impl From<iced_winit::Error> for Error {
@@ -25,8 +25,8 @@ impl From<iced_winit::Error> for Error {
iced_winit::Error::WindowCreationFailed(error) => {
Error::WindowCreationFailed(Box::new(error))
}
- iced_winit::Error::GraphicsAdapterNotFound => {
- Error::GraphicsAdapterNotFound
+ iced_winit::Error::GraphicsCreationFailed(error) => {
+ Error::GraphicsCreationFailed(error)
}
}
}
diff --git a/src/lib.rs b/src/lib.rs
index b34bb72c..4276f86a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,19 +19,19 @@
//!
//! Check out the [repository] and the [examples] for more details!
//!
-//! [Cross-platform support]: https://github.com/hecrj/iced/blob/master/docs/images/todos_desktop.jpg?raw=true
+//! [Cross-platform support]: https://github.com/iced-rs/iced/blob/master/docs/images/todos_desktop.jpg?raw=true
//! [text inputs]: https://gfycat.com/alertcalmcrow-rust-gui
//! [scrollables]: https://gfycat.com/perkybaggybaboon-rust-gui
//! [Debug overlay with performance metrics]: https://gfycat.com/incredibledarlingbee
-//! [Modular ecosystem]: https://github.com/hecrj/iced/blob/master/ECOSYSTEM.md
-//! [renderer-agnostic native runtime]: https://github.com/hecrj/iced/tree/master/native
+//! [Modular ecosystem]: https://github.com/iced-rs/iced/blob/master/ECOSYSTEM.md
+//! [renderer-agnostic native runtime]: https://github.com/iced-rs/iced/0.4/master/native
//! [`wgpu`]: https://github.com/gfx-rs/wgpu-rs
-//! [built-in renderer]: https://github.com/hecrj/iced/tree/master/wgpu
-//! [windowing shell]: https://github.com/hecrj/iced/tree/master/winit
+//! [built-in renderer]: https://github.com/iced-rs/iced/tree/0.4/wgpu
+//! [windowing shell]: https://github.com/iced-rs/iced/tree/0.4/winit
//! [`dodrio`]: https://github.com/fitzgen/dodrio
-//! [web runtime]: https://github.com/hecrj/iced/tree/master/web
-//! [examples]: https://github.com/hecrj/iced/tree/0.3/examples
-//! [repository]: https://github.com/hecrj/iced
+//! [web runtime]: https://github.com/iced-rs/iced_web
+//! [examples]: https://github.com/iced-rs/iced/tree/0.4/examples
+//! [repository]: https://github.com/iced-rs/iced
//!
//! # Overview
//! Inspired by [The Elm Architecture], Iced expects you to split user
@@ -51,15 +51,9 @@
//! We start by modelling the __state__ of our application:
//!
//! ```
-//! use iced::button;
-//!
//! struct Counter {
//! // The counter value
//! value: i32,
-//!
-//! // The local state of the two buttons
-//! increment_button: button::State,
-//! decrement_button: button::State,
//! }
//! ```
//!
@@ -78,15 +72,9 @@
//! __view logic__:
//!
//! ```
-//! # use iced::button;
-//! #
//! # struct Counter {
//! # // The counter value
//! # value: i32,
-//! #
-//! # // The local state of the two buttons
-//! # increment_button: button::State,
-//! # decrement_button: button::State,
//! # }
//! #
//! # #[derive(Debug, Clone, Copy)]
@@ -95,28 +83,22 @@
//! # DecrementPressed,
//! # }
//! #
-//! use iced::{Button, Column, Text};
+//! use iced::widget::{button, column, text, Column};
//!
//! impl Counter {
//! pub fn view(&mut self) -> Column<Message> {
//! // We use a column: a simple vertical layout
-//! Column::new()
-//! .push(
-//! // The increment button. We tell it to produce an
-//! // `IncrementPressed` message when pressed
-//! Button::new(&mut self.increment_button, Text::new("+"))
-//! .on_press(Message::IncrementPressed),
-//! )
-//! .push(
-//! // We show the value of the counter here
-//! Text::new(self.value.to_string()).size(50),
-//! )
-//! .push(
-//! // The decrement button. We tell it to produce a
-//! // `DecrementPressed` message when pressed
-//! Button::new(&mut self.decrement_button, Text::new("-"))
-//! .on_press(Message::DecrementPressed),
-//! )
+//! column![
+//! // The increment button. We tell it to produce an
+//! // `IncrementPressed` message when pressed
+//! button("+").on_press(Message::IncrementPressed),
+//!
+//! // We show the value of the counter here
+//! text(self.value).size(50),
+//!
+//! // The decrement button. We tell it to produce a
+//! button("-").on_press(Message::DecrementPressed),
+//! ]
//! }
//! }
//! ```
@@ -125,15 +107,9 @@
//! our __state__ accordingly in our __update logic__:
//!
//! ```
-//! # use iced::button;
-//! #
//! # struct Counter {
//! # // The counter value
//! # value: i32,
-//! #
-//! # // The local state of the two buttons
-//! # increment_button: button::State,
-//! # decrement_button: button::State,
//! # }
//! #
//! # #[derive(Debug, Clone, Copy)]
@@ -174,22 +150,31 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
-#![deny(missing_docs)]
-#![deny(missing_debug_implementations)]
-#![deny(unused_results)]
-#![forbid(unsafe_code)]
-#![forbid(rust_2018_idioms)]
+#![deny(
+ missing_debug_implementations,
+ missing_docs,
+ unused_results,
+ clippy::extra_unused_lifetimes,
+ clippy::from_over_into,
+ clippy::needless_borrow,
+ clippy::new_without_default,
+ clippy::useless_conversion
+)]
+#![forbid(rust_2018_idioms, unsafe_code)]
+#![allow(clippy::inherent_to_string, clippy::type_complexity)]
#![cfg_attr(docsrs, feature(doc_cfg))]
-mod application;
+
mod element;
mod error;
mod result;
mod sandbox;
+pub mod application;
pub mod clipboard;
pub mod executor;
pub mod keyboard;
pub mod mouse;
+pub mod overlay;
pub mod settings;
pub mod time;
pub mod widget;
@@ -207,20 +192,28 @@ use iced_wgpu as renderer;
#[cfg(feature = "glow")]
use iced_glow as renderer;
-#[doc(no_inline)]
-pub use widget::*;
+pub use iced_native::theme;
+pub use runtime::event;
+pub use runtime::subscription;
pub use application::Application;
pub use element::Element;
pub use error::Error;
+pub use event::Event;
pub use executor::Executor;
+pub use renderer::Renderer;
pub use result::Result;
pub use sandbox::Sandbox;
pub use settings::Settings;
+pub use subscription::Subscription;
+pub use theme::Theme;
pub use runtime::alignment;
pub use runtime::futures;
pub use runtime::{
- Alignment, Background, Color, Command, ContentFit, Font, Length, Point,
- Rectangle, Size, Subscription, Vector,
+ Alignment, Background, Color, Command, ContentFit, Font, Length, Padding,
+ Point, Rectangle, Size, Vector,
};
+
+#[cfg(feature = "system")]
+pub use runtime::system;
diff --git a/src/overlay.rs b/src/overlay.rs
new file mode 100644
index 00000000..a7003751
--- /dev/null
+++ b/src/overlay.rs
@@ -0,0 +1,16 @@
+//! Display interactive elements on top of other widgets.
+
+/// A generic [`Overlay`].
+///
+/// This is an alias of an `iced_native` element with a default `Renderer`.
+pub type Element<'a, Message, Renderer = crate::Renderer> =
+ iced_native::overlay::Element<'a, Message, Renderer>;
+
+pub mod menu {
+ //! Build and show dropdown menus.
+ pub use iced_native::overlay::menu::{Appearance, State, StyleSheet};
+
+ /// A widget that produces a message when clicked.
+ pub type Menu<'a, Message, Renderer = crate::Renderer> =
+ iced_native::overlay::Menu<'a, Message, Renderer>;
+}
diff --git a/src/sandbox.rs b/src/sandbox.rs
index 2306c650..bdb6ad5a 100644
--- a/src/sandbox.rs
+++ b/src/sandbox.rs
@@ -1,6 +1,5 @@
-use crate::{
- Application, Color, Command, Element, Error, Settings, Subscription,
-};
+use crate::theme::{self, Theme};
+use crate::{Application, Command, Element, Error, Settings, Subscription};
/// A sandboxed [`Application`].
///
@@ -35,19 +34,19 @@ use crate::{
/// - [`tour`], a simple UI tour that can run both on native platforms and the
/// web!
///
-/// [The repository has a bunch of examples]: https://github.com/hecrj/iced/tree/0.3/examples
-/// [`bezier_tool`]: https://github.com/hecrj/iced/tree/0.3/examples/bezier_tool
-/// [`counter`]: https://github.com/hecrj/iced/tree/0.3/examples/counter
-/// [`custom_widget`]: https://github.com/hecrj/iced/tree/0.3/examples/custom_widget
-/// [`geometry`]: https://github.com/hecrj/iced/tree/0.3/examples/geometry
-/// [`pane_grid`]: https://github.com/hecrj/iced/tree/0.3/examples/pane_grid
-/// [`progress_bar`]: https://github.com/hecrj/iced/tree/0.3/examples/progress_bar
-/// [`styling`]: https://github.com/hecrj/iced/tree/0.3/examples/styling
-/// [`svg`]: https://github.com/hecrj/iced/tree/0.3/examples/svg
-/// [`tour`]: https://github.com/hecrj/iced/tree/0.3/examples/tour
+/// [The repository has a bunch of examples]: https://github.com/iced-rs/iced/tree/0.4/examples
+/// [`bezier_tool`]: https://github.com/iced-rs/iced/tree/0.4/examples/bezier_tool
+/// [`counter`]: https://github.com/iced-rs/iced/tree/0.4/examples/counter
+/// [`custom_widget`]: https://github.com/iced-rs/iced/tree/0.4/examples/custom_widget
+/// [`geometry`]: https://github.com/iced-rs/iced/tree/0.4/examples/geometry
+/// [`pane_grid`]: https://github.com/iced-rs/iced/tree/0.4/examples/pane_grid
+/// [`progress_bar`]: https://github.com/iced-rs/iced/tree/0.4/examples/progress_bar
+/// [`styling`]: https://github.com/iced-rs/iced/tree/0.4/examples/styling
+/// [`svg`]: https://github.com/iced-rs/iced/tree/0.4/examples/svg
+/// [`tour`]: https://github.com/iced-rs/iced/tree/0.4/examples/tour
/// [`Canvas widget`]: crate::widget::Canvas
/// [the overview]: index.html#overview
-/// [`iced_wgpu`]: https://github.com/hecrj/iced/tree/0.3/wgpu
+/// [`iced_wgpu`]: https://github.com/iced-rs/iced/tree/0.4/wgpu
/// [`Svg` widget]: crate::widget::Svg
/// [Ghostscript Tiger]: https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg
///
@@ -57,7 +56,7 @@ use crate::{
/// says "Hello, world!":
///
/// ```no_run
-/// use iced::{Element, Sandbox, Settings, Text};
+/// use iced::{Element, Sandbox, Settings};
///
/// pub fn main() -> iced::Result {
/// Hello::run(Settings::default())
@@ -80,8 +79,8 @@ use crate::{
/// // This application has no interactions
/// }
///
-/// fn view(&mut self) -> Element<Self::Message> {
-/// Text::new("Hello, world!").into()
+/// fn view(&self) -> Element<Self::Message> {
+/// "Hello, world!".into()
/// }
/// }
/// ```
@@ -109,13 +108,23 @@ pub trait Sandbox {
/// Returns the widgets to display in the [`Sandbox`].
///
/// These widgets can produce __messages__ based on user interaction.
- fn view(&mut self) -> Element<'_, Self::Message>;
+ fn view(&self) -> Element<'_, Self::Message>;
- /// Returns the background color of the [`Sandbox`].
+ /// Returns the current [`Theme`] of the [`Sandbox`].
///
- /// By default, it returns [`Color::WHITE`].
- fn background_color(&self) -> Color {
- Color::WHITE
+ /// If you want to use your own custom theme type, you will have to use an
+ /// [`Application`].
+ ///
+ /// By default, it returns [`Theme::default`].
+ fn theme(&self) -> Theme {
+ Theme::default()
+ }
+
+ /// Returns the current style variant of [`theme::Application`].
+ ///
+ /// By default, it returns [`theme::Application::default`].
+ fn style(&self) -> theme::Application {
+ theme::Application::default()
}
/// Returns the scale factor of the [`Sandbox`].
@@ -159,6 +168,7 @@ where
type Executor = iced_futures::backend::null::Executor;
type Flags = ();
type Message = T::Message;
+ type Theme = Theme;
fn new(_flags: ()) -> (Self, Command<T::Message>) {
(T::new(), Command::none())
@@ -174,16 +184,20 @@ where
Command::none()
}
- fn subscription(&self) -> Subscription<T::Message> {
- Subscription::none()
+ fn view(&self) -> Element<'_, T::Message> {
+ T::view(self)
}
- fn view(&mut self) -> Element<'_, T::Message> {
- T::view(self)
+ fn theme(&self) -> Self::Theme {
+ T::theme(self)
+ }
+
+ fn style(&self) -> theme::Application {
+ T::style(self)
}
- fn background_color(&self) -> Color {
- T::background_color(self)
+ fn subscription(&self) -> Subscription<T::Message> {
+ Subscription::none()
}
fn scale_factor(&self) -> f64 {
diff --git a/src/widget.rs b/src/widget.rs
index c619bcfa..9f09cb8f 100644
--- a/src/widget.rs
+++ b/src/widget.rs
@@ -1,65 +1,232 @@
//! Display information and interactive controls in your application.
-//!
-//! # Re-exports
-//! For convenience, the contents of this module are available at the root
-//! module. Therefore, you can directly type:
-//!
-//! ```
-//! use iced::{button, Button};
-//! ```
-//!
-//! # Stateful widgets
-//! Some widgets need to keep track of __local state__.
-//!
-//! These widgets have their own module with a `State` type. For instance, a
-//! [`TextInput`] has some [`text_input::State`].
-pub use crate::renderer::widget::{
- button, checkbox, container, pane_grid, pick_list, progress_bar, radio,
- rule, scrollable, slider, text_input, toggler, tooltip, Column, Row, Space,
- Text,
-};
-
-#[cfg(any(feature = "canvas", feature = "glow_canvas"))]
-#[cfg_attr(
- docsrs,
- doc(cfg(any(feature = "canvas", feature = "glow_canvas")))
-)]
-pub use crate::renderer::widget::canvas;
-
-#[cfg(any(feature = "qr_code", feature = "glow_qr_code"))]
-#[cfg_attr(
- docsrs,
- doc(cfg(any(feature = "qr_code", feature = "glow_qr_code")))
-)]
-pub use crate::renderer::widget::qr_code;
+pub use iced_native::widget::helpers::*;
+pub use iced_native::{column, row};
+
+/// A container that distributes its contents vertically.
+pub type Column<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Column<'a, Message, Renderer>;
+
+/// A container that distributes its contents horizontally.
+pub type Row<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Row<'a, Message, Renderer>;
+
+pub mod text {
+ //! Write some text for your users to read.
+ pub use iced_native::widget::text::{Appearance, StyleSheet};
+
+ /// A paragraph of text.
+ pub type Text<'a, Renderer = crate::Renderer> =
+ iced_native::widget::Text<'a, Renderer>;
+}
+
+pub mod button {
+ //! Allow your users to perform actions by pressing a button.
+ pub use iced_native::widget::button::{Appearance, StyleSheet};
+
+ /// A widget that produces a message when clicked.
+ pub type Button<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Button<'a, Message, Renderer>;
+}
+
+pub mod checkbox {
+ //! Show toggle controls using checkboxes.
+ pub use iced_native::widget::checkbox::{Appearance, StyleSheet};
+
+ /// A box that can be checked.
+ pub type Checkbox<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Checkbox<'a, Message, Renderer>;
+}
+
+pub mod container {
+ //! Decorate content and apply alignment.
+ pub use iced_native::widget::container::{Appearance, StyleSheet};
+
+ /// An element decorating some content.
+ pub type Container<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Container<'a, Message, Renderer>;
+}
+
+pub mod pane_grid {
+ //! Let your users split regions of your application and organize layout dynamically.
+ //!
+ //! [![Pane grid - Iced](https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif)](https://gfycat.com/mixedflatjellyfish)
+ //!
+ //! # Example
+ //! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,
+ //! drag and drop, and hotkey support.
+ //!
+ //! [`pane_grid` example]: https://github.com/iced-rs/iced/tree/0.4/examples/pane_grid
+ pub use iced_native::widget::pane_grid::{
+ Axis, Configuration, Direction, DragEvent, Line, Node, Pane,
+ ResizeEvent, Split, State, StyleSheet,
+ };
+
+ /// A collection of panes distributed using either vertical or horizontal splits
+ /// to completely fill the space available.
+ ///
+ /// [![Pane grid - Iced](https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif)](https://gfycat.com/mixedflatjellyfish)
+ pub type PaneGrid<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::PaneGrid<'a, Message, Renderer>;
+
+ /// The content of a [`Pane`].
+ pub type Content<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::pane_grid::Content<'a, Message, Renderer>;
+
+ /// The title bar of a [`Pane`].
+ pub type TitleBar<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::pane_grid::TitleBar<'a, Message, Renderer>;
+}
+
+pub mod pick_list {
+ //! Display a dropdown list of selectable values.
+ pub use iced_native::widget::pick_list::{Appearance, StyleSheet};
+
+ /// A widget allowing the selection of a single value from a list of options.
+ pub type PickList<'a, T, Message, Renderer = crate::Renderer> =
+ iced_native::widget::PickList<'a, T, Message, Renderer>;
+}
+
+pub mod radio {
+ //! Create choices using radio buttons.
+ pub use iced_native::widget::radio::{Appearance, StyleSheet};
+
+ /// A circular button representing a choice.
+ pub type Radio<Message, Renderer = crate::Renderer> =
+ iced_native::widget::Radio<Message, Renderer>;
+}
+
+pub mod scrollable {
+ //! Navigate an endless amount of content with a scrollbar.
+ pub use iced_native::widget::scrollable::{
+ snap_to, style::Scrollbar, style::Scroller, Id, StyleSheet,
+ };
+
+ /// A widget that can vertically display an infinite amount of content
+ /// with a scrollbar.
+ pub type Scrollable<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Scrollable<'a, Message, Renderer>;
+}
+
+pub mod toggler {
+ //! Show toggle controls using togglers.
+ pub use iced_native::widget::toggler::{Appearance, StyleSheet};
+
+ /// A toggler widget.
+ pub type Toggler<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Toggler<'a, Message, Renderer>;
+}
+
+pub mod text_input {
+ //! Display fields that can be filled with text.
+ pub use iced_native::widget::text_input::{
+ focus, Appearance, Id, StyleSheet,
+ };
+
+ /// A field that can be filled with text.
+ pub type TextInput<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::TextInput<'a, Message, Renderer>;
+}
+
+pub mod tooltip {
+ //! Display a widget over another.
+ pub use iced_native::widget::tooltip::Position;
+
+ /// A widget allowing the selection of a single value from a list of options.
+ pub type Tooltip<'a, Message, Renderer = crate::Renderer> =
+ iced_native::widget::Tooltip<'a, Message, Renderer>;
+}
+
+pub use iced_native::widget::progress_bar;
+pub use iced_native::widget::rule;
+pub use iced_native::widget::slider;
+pub use iced_native::widget::Space;
+
+pub use button::Button;
+pub use checkbox::Checkbox;
+pub use container::Container;
+pub use pane_grid::PaneGrid;
+pub use pick_list::PickList;
+pub use progress_bar::ProgressBar;
+pub use radio::Radio;
+pub use rule::Rule;
+pub use scrollable::Scrollable;
+pub use slider::Slider;
+pub use text::Text;
+pub use text_input::TextInput;
+pub use toggler::Toggler;
+pub use tooltip::Tooltip;
+
+#[cfg(feature = "canvas")]
+#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
+pub use iced_graphics::widget::canvas;
+
+#[cfg(feature = "canvas")]
+#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
+/// Creates a new [`Canvas`].
+pub fn canvas<P, Message, Theme>(program: P) -> Canvas<Message, Theme, P>
+where
+ P: canvas::Program<Message, Theme>,
+{
+ Canvas::new(program)
+}
+
+#[cfg(feature = "image")]
#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
pub mod image {
//! Display images in your user interface.
- pub use crate::runtime::image::Handle;
- pub use crate::runtime::widget::image::viewer;
- pub use crate::runtime::widget::image::{Image, Viewer};
+ pub use iced_native::image::Handle;
+
+ /// A frame that displays an image.
+ pub type Image = iced_native::widget::Image<Handle>;
+
+ pub use iced_native::widget::image::viewer;
+ pub use viewer::Viewer;
}
+#[cfg(feature = "qr_code")]
+#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
+pub use iced_graphics::widget::qr_code;
+
+#[cfg(feature = "svg")]
#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
pub mod svg {
- //! Display vector graphics in your user interface.
- pub use crate::runtime::svg::Handle;
- pub use crate::runtime::widget::svg::Svg;
+ //! Display vector graphics in your application.
+ pub use iced_native::svg::Handle;
+ pub use iced_native::widget::Svg;
}
-#[doc(no_inline)]
-pub use {
- button::Button, checkbox::Checkbox, container::Container, image::Image,
- pane_grid::PaneGrid, pick_list::PickList, progress_bar::ProgressBar,
- radio::Radio, rule::Rule, scrollable::Scrollable, slider::Slider, svg::Svg,
- text_input::TextInput, toggler::Toggler, tooltip::Tooltip,
-};
-
-#[cfg(any(feature = "canvas", feature = "glow_canvas"))]
-#[doc(no_inline)]
+#[cfg(feature = "canvas")]
+#[cfg_attr(docsrs, doc(cfg(feature = "canvas")))]
pub use canvas::Canvas;
-#[cfg(any(feature = "qr_code", feature = "glow_qr_code"))]
-#[doc(no_inline)]
+#[cfg(feature = "image")]
+#[cfg_attr(docsrs, doc(cfg(feature = "image")))]
+pub use image::Image;
+
+#[cfg(feature = "qr_code")]
+#[cfg_attr(docsrs, doc(cfg(feature = "qr_code")))]
pub use qr_code::QRCode;
+
+#[cfg(feature = "svg")]
+#[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
+pub use svg::Svg;
+
+use crate::Command;
+use iced_native::widget::operation;
+
+/// Focuses the previous focusable widget.
+pub fn focus_previous<Message>() -> Command<Message>
+where
+ Message: 'static,
+{
+ Command::widget(operation::focusable::focus_previous())
+}
+
+/// Focuses the next focusable widget.
+pub fn focus_next<Message>() -> Command<Message>
+where
+ Message: 'static,
+{
+ Command::widget(operation::focusable::focus_next())
+}
diff --git a/src/window.rs b/src/window.rs
index 71158816..eb5e17a6 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -1,12 +1,10 @@
//! Configure the window of your application in native platforms.
-mod mode;
mod position;
mod settings;
pub mod icon;
pub use icon::Icon;
-pub use mode::Mode;
pub use position::Position;
pub use settings::Settings;
diff --git a/src/window/mode.rs b/src/window/mode.rs
deleted file mode 100644
index fdce8e23..00000000
--- a/src/window/mode.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-/// The mode of a window-based application.
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-pub enum Mode {
- /// The application appears in its own window.
- Windowed,
-
- /// The application takes the whole screen of its current monitor.
- Fullscreen,
-
- /// The application is hidden
- Hidden,
-}
diff --git a/src/window/settings.rs b/src/window/settings.rs
index 8e32f4fb..24d0f4f9 100644
--- a/src/window/settings.rs
+++ b/src/window/settings.rs
@@ -15,6 +15,9 @@ pub struct Settings {
/// The maximum size of the window.
pub max_size: Option<(u32, u32)>,
+ /// Whether the window should be visible or not.
+ pub visible: bool,
+
/// Whether the window should be resizable or not.
pub resizable: bool,
@@ -38,6 +41,7 @@ impl Default for Settings {
position: Position::default(),
min_size: None,
max_size: None,
+ visible: true,
resizable: true,
decorations: true,
transparent: false,
@@ -54,6 +58,7 @@ impl From<Settings> for iced_winit::settings::Window {
position: iced_winit::Position::from(settings.position),
min_size: settings.min_size,
max_size: settings.max_size,
+ visible: settings.visible,
resizable: settings.resizable,
decorations: settings.decorations,
transparent: settings.transparent,