Improved prelude
This commit is contained in:
@@ -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()));
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use osui::prelude::*;
|
||||
|
||||
pub fn main() {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use osui::prelude::*;
|
||||
|
||||
pub fn main() {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use osui::prelude::*;
|
||||
|
||||
pub fn main() {
|
||||
|
||||
+1
-1
@@ -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
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user