diff options
author | 2022-08-06 00:32:57 +0200 | |
---|---|---|
committer | 2022-08-06 00:32:57 +0200 | |
commit | 1923dbf7f0769d55e5283f572fde0ce752e28b86 (patch) | |
tree | 7be9b36f941f6e13ddc8884f715c04555b1e77db /src/lib.rs | |
parent | 1b4f38c71f6e05e26599ee75ea9c91dde96e71ae (diff) | |
parent | c23ed7e4a0a2b62a0d7cabe6e35d7323eac543d2 (diff) | |
download | iced-1923dbf7f0769d55e5283f572fde0ce752e28b86.tar.gz iced-1923dbf7f0769d55e5283f572fde0ce752e28b86.tar.bz2 iced-1923dbf7f0769d55e5283f572fde0ce752e28b86.zip |
Merge pull request #1393 from iced-rs/deprecate-stateful-widgets
Replace stateful widgets with the new `iced_pure` API
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 61 |
1 files changed, 17 insertions, 44 deletions
@@ -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)] @@ -203,10 +179,6 @@ pub mod time; pub mod widget; pub mod window; -#[cfg(feature = "pure")] -#[cfg_attr(docsrs, doc(cfg(feature = "pure")))] -pub mod pure; - #[cfg(all(not(feature = "glow"), feature = "wgpu"))] use iced_winit as runtime; @@ -220,25 +192,26 @@ use iced_wgpu as renderer; use iced_glow as renderer; pub use iced_native::theme; - -#[doc(no_inline)] -pub use widget::*; +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, Padding, - Point, Rectangle, Size, Subscription, Vector, + Point, Rectangle, Size, Vector, }; #[cfg(feature = "system")] |