From d53ccc857da4d4cda769904342aeb5a82a64f146 Mon Sep 17 00:00:00 2001 From: Bingus Date: Wed, 12 Jul 2023 19:21:05 -0700 Subject: refactored window storage; new helper window events (Destroyed, Created); clippy + fmt; --- runtime/src/multi_window/program.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 runtime/src/multi_window/program.rs (limited to 'runtime/src/multi_window/program.rs') diff --git a/runtime/src/multi_window/program.rs b/runtime/src/multi_window/program.rs new file mode 100644 index 00000000..c3989d0d --- /dev/null +++ b/runtime/src/multi_window/program.rs @@ -0,0 +1,32 @@ +//! Build interactive programs using The Elm Architecture. +use crate::{window, Command}; + +use crate::core::text; +use crate::core::{Element, Renderer}; + +/// The core of a user interface for a multi-window application following The Elm Architecture. +pub trait Program: Sized { + /// The graphics backend to use to draw the [`Program`]. + type Renderer: Renderer + text::Renderer; + + /// The type of __messages__ your [`Program`] will produce. + type Message: std::fmt::Debug + Send; + + /// Handles a __message__ and updates the state of the [`Program`]. + /// + /// This is where you define your __update logic__. All the __messages__, + /// produced by either user interactions or commands, will be handled by + /// this method. + /// + /// Any [`Command`] returned will be executed immediately in the + /// background by shells. + fn update(&mut self, message: Self::Message) -> Command; + + /// Returns the widgets to display in the [`Program`] for the `window`. + /// + /// These widgets can produce __messages__ based on user interaction. + fn view( + &self, + window: window::Id, + ) -> Element<'_, Self::Message, Self::Renderer>; +} -- cgit From ea42af766f345715ff7a7168182d3896ee79cfbc Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 2 Dec 2023 20:41:58 +0100 Subject: Use `AtomicU64` for `window::Id` --- runtime/src/multi_window/program.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/src/multi_window/program.rs') diff --git a/runtime/src/multi_window/program.rs b/runtime/src/multi_window/program.rs index c3989d0d..591b3e9a 100644 --- a/runtime/src/multi_window/program.rs +++ b/runtime/src/multi_window/program.rs @@ -1,8 +1,8 @@ //! Build interactive programs using The Elm Architecture. -use crate::{window, Command}; - use crate::core::text; +use crate::core::window; use crate::core::{Element, Renderer}; +use crate::Command; /// The core of a user interface for a multi-window application following The Elm Architecture. pub trait Program: Sized { -- cgit