2020-01-10 01:28:45 +01:00
|
|
|
//! Build window-based GUI applications.
|
2021-09-01 19:21:49 +07:00
|
|
|
mod action;
|
2020-01-10 01:28:45 +01:00
|
|
|
mod event;
|
2022-08-18 14:39:15 +02:00
|
|
|
mod mode;
|
2023-01-12 05:18:25 +01:00
|
|
|
mod redraw_request;
|
2022-12-10 01:53:00 +13:00
|
|
|
mod user_attention;
|
2020-01-10 01:28:45 +01:00
|
|
|
|
2021-09-01 19:21:49 +07:00
|
|
|
pub use action::Action;
|
2020-01-10 01:28:45 +01:00
|
|
|
pub use event::Event;
|
2022-08-18 14:39:15 +02:00
|
|
|
pub use mode::Mode;
|
2023-01-12 05:18:25 +01:00
|
|
|
pub use redraw_request::RedrawRequest;
|
2022-12-10 01:53:00 +13:00
|
|
|
pub use user_attention::UserAttention;
|
2023-01-12 04:35:41 +01:00
|
|
|
|
|
|
|
|
use crate::subscription::{self, Subscription};
|
2023-01-12 06:24:44 +01:00
|
|
|
use crate::time::Instant;
|
2023-01-12 04:35:41 +01:00
|
|
|
|
|
|
|
|
/// Subscribes to the frames of the window of the running application.
|
|
|
|
|
///
|
|
|
|
|
/// The resulting [`Subscription`] will produce items at a rate equal to the
|
2023-01-13 18:17:15 +01:00
|
|
|
/// refresh rate of the window. Note that this rate may be variable, as it is
|
|
|
|
|
/// normally managed by the graphics driver and/or the OS.
|
|
|
|
|
///
|
|
|
|
|
/// In any case, this [`Subscription`] is useful to smoothly draw application-driven
|
|
|
|
|
/// animations without missing any frames.
|
2023-01-12 04:35:41 +01:00
|
|
|
pub fn frames() -> Subscription<Instant> {
|
|
|
|
|
subscription::raw_events(|event, _status| match event {
|
|
|
|
|
crate::Event::Window(Event::RedrawRequested(at)) => Some(at),
|
|
|
|
|
_ => None,
|
|
|
|
|
})
|
|
|
|
|
}
|