From 990f2b310bfecf2e04a8a462f6939833080c62bf Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sat, 19 Oct 2024 18:20:09 +1300 Subject: Complete rewrite of Phosphor The previous version of the library passed events to an implementation of a WindowController trait by calling the trait method associated with each event, and received requests by calling different trait methods and reading the returned values. This had the downside of requiring that any data received from one event had to be stored in the type so that it could be passed back to Phosphor when a request method was called. The new library structure uses a single handle_event method on a trait, which is passed data representing any single event when it is called. Data is returned via a passed mutable reference to an EventQueue, meaning that any number of responses for any event can be immediately returned to Phosphor without having to wait in storage. --- src/window_program.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/window_program.rs (limited to 'src/window_program.rs') diff --git a/src/window_program.rs b/src/window_program.rs new file mode 100644 index 0000000..9a5df2d --- /dev/null +++ b/src/window_program.rs @@ -0,0 +1,13 @@ +use crate::*; + +use buffer::Buffer; +use event_queue::*; + + +pub trait WindowProgram { + fn handle_event(&mut self, event: Event, requests: &mut EventWriter); + + fn process(&mut self, requests: &mut EventWriter); + + fn render(&mut self, buffer: &mut Buffer, full: bool); +} -- cgit v1.2.3-70-g09d2