Improved prelude

This commit is contained in:
2026-01-31 00:15:40 +01:00
parent ab9548920c
commit 85342d641f
6 changed files with 9 additions and 10 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
use std::{sync::mpsc, sync::Arc, thread};
use osui::prelude::*;
use std::{sync::mpsc, thread};
pub fn main() {
let engine = Arc::new(Benchmark::new(Console::new()));
-2
View File
@@ -1,5 +1,3 @@
use std::sync::Arc;
use osui::prelude::*;
pub fn main() {
-2
View File
@@ -1,5 +1,3 @@
use std::sync::Arc;
use osui::prelude::*;
pub fn main() {
-2
View File
@@ -1,5 +1,3 @@
use std::sync::Arc;
use osui::prelude::*;
pub fn main() {
+1 -1
View File
@@ -15,7 +15,7 @@ pub trait Engine<Output = ()> {
fn init<C: ComponentImpl + 'static>(&self, component: C) -> Arc<Context>;
fn render(&self, cx: &Arc<Context>);
fn render_delay(&self) {
std::thread::sleep(std::time::Duration::from_millis(16))
crate::sleep(16);
}
fn render_view(&self, area: &Area, view: &View) -> DrawContext;
+6 -1
View File
@@ -14,8 +14,9 @@ pub mod prelude {
pub use crate::frontend::*;
pub use crate::render::*;
pub use crate::state::*;
pub use crate::View;
pub use crate::{sleep, Error, Result, View, ViewWrapper};
pub use osui_macros::{component, rsx};
pub use std::sync::{Arc, Mutex};
}
pub type View = Arc<dyn Fn(&mut DrawContext) + Send + Sync>;
@@ -32,3 +33,7 @@ impl From<std::sync::PoisonError<std::sync::MutexGuard<'_, bool>>> for Error {
Error::PoisonError
}
}
pub fn sleep(delay_ms: u64) {
std::thread::sleep(std::time::Duration::from_millis(delay_ms));
}