diff options
-rw-r--r-- | src/window_manager.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/window_manager.rs b/src/window_manager.rs index 2652682..9322adb 100644 --- a/src/window_manager.rs +++ b/src/window_manager.rs @@ -10,14 +10,22 @@ pub struct WindowManager { } impl WindowManager { - pub fn new(min_frame_duration: Duration) -> Self { + pub fn new() -> Self { Self { event_loop: EventLoop::new(), windows: HashMap::new(), - min_frame_duration, + min_frame_duration: Duration::ZERO, } } + pub fn with_frame_limit(mut self, limit: u64) -> Self { + self.min_frame_duration = match limit { + 0 => Duration::ZERO, + _ => Duration::from_nanos(1_000_000_000 / limit), + }; + return self; + } + /// Add a window to the window manager before the event loop begins. pub fn add_window(&mut self, controller: Box<dyn WindowController>) { let window = Window::new(&self.event_loop, controller); |