pub struct SkInfo { /* private fields */ }
Expand description
Non canonical structure whose purpose is to expose infos far from Sk
see also: Sk::get_sk_info_clone
§Examples
use stereokit_rust::sk::{Sk, SkSettings, AppMode, SkInfo};
use stereokit_rust::{system::LogLevel, ui::Ui, maths::Pose};
let sk_info = Some(sk.get_sk_info_clone());
let settings = SkInfo::settings_from(&sk_info);
if cfg!(feature = "test-xr-mode") {
assert_eq!(settings.mode, AppMode::XR);
} else {
assert_eq!(settings.mode, AppMode::Offscreen);
}
let system = SkInfo::system_from(&sk_info);
assert_eq!(system.get_display_width(), 0);
#[cfg(feature = "event-loop")]
{
use stereokit_rust::tools::screenshot::{ScreenshotViewer, SHOW_SCREENSHOT_WINDOW};
// send event
SkInfo::send_event(&sk_info,
StepperAction::add_default::<ScreenshotViewer>("SCR_ID1"));
// get event_loop_proxy clone to use in other threads
let event_loop_proxy = SkInfo::event_loop_proxy_from(&sk_info);
// get a closure, ready to send an event with a given value
let show_screenshot = SkInfo::get_message_closure(sk_info,
"SCR_ID1", SHOW_SCREENSHOT_WINDOW);
let mut window_pose = Pose::IDENTITY;
test_steps!(// !!!! Get a proper main loop !!!!
Ui::window_begin("Default Font", &mut window_pose, None, None, None);
if Ui::button("Show screenshot", None) {
show_screenshot("true".into())
}
Ui::window_end();
);
}
Implementations§
Source§impl SkInfo
impl SkInfo
Sourcepub fn get_settings(&self) -> SkSettings
pub fn get_settings(&self) -> SkSettings
This is a copy of the settings that StereoKit was initialized with, so you can refer back to them a little
easier. Some of these values will be different than provided, as StereoKit will resolve some default values
based on the platform capabilities or internal preference. These are read only, and keep in mind that some
settings are only requests! Check Sk::get_system
and other properties for the current state of StereoKit.
SkInfo::settings_from
is more easy to use.
https://stereokit.net/Pages/StereoKit/SK/Settings.html
Sourcepub fn get_system(&self) -> SystemInfo
pub fn get_system(&self) -> SystemInfo
This structure contains information about the current system and its capabilities. There’s a lot of different MR
devices, so it’s nice to have code for systems with particular characteristics!
SkInfo::system_from
is more easy to use.
https://stereokit.net/Pages/StereoKit/SK/System.html
Sourcepub fn get_event_loop_proxy(&self) -> Option<EventLoopProxy<StepperAction>>
pub fn get_event_loop_proxy(&self) -> Option<EventLoopProxy<StepperAction>>
Get an event_loop_proxy clone to send events.
SkInfo::event_loop_proxy_from
is more easy to use.
Sourcepub fn settings_from(sk_info: &Option<Rc<RefCell<SkInfo>>>) -> SkSettings
pub fn settings_from(sk_info: &Option<Rc<RefCell<SkInfo>>>) -> SkSettings
This is a copy of the settings that StereoKit was initialized with, so you can refer back to them a little easier. Some of these values will be different than provided, as StereoKit will resolve some default values based on the platform capabilities or internal preference. These are read only, and keep in mind that some settings are only requests! Check SK.System and other properties for the current state of StereoKit. https://stereokit.net/Pages/StereoKit/SK/Settings.html
sk_info
- The SkInfo smart pointer to get the settings from
see also Sk::get_settings
Sourcepub fn system_from(sk_info: &Option<Rc<RefCell<SkInfo>>>) -> SystemInfo
pub fn system_from(sk_info: &Option<Rc<RefCell<SkInfo>>>) -> SystemInfo
This structure contains information about the current system and its capabilities. There’s a lot of different MR devices, so it’s nice to have code for systems with particular characteristics! https://stereokit.net/Pages/StereoKit/SK/System.html
sk_info
- The SkInfo smart pointer to get the SystemInfo from.
see also Sk::get_system
Sourcepub fn event_loop_proxy_from(
sk_info: &Option<Rc<RefCell<SkInfo>>>,
) -> Option<EventLoopProxy<StepperAction>>
pub fn event_loop_proxy_from( sk_info: &Option<Rc<RefCell<SkInfo>>>, ) -> Option<EventLoopProxy<StepperAction>>
Get an event_loop_proxy clone to send events
sk_info
- The SkInfo smart pointer to get the event_loop_proxy from.
see also Sk::get_sk_info_clone
§Examples
use stereokit_rust::sk::{Sk, SkSettings, AppMode, SkInfo, QuitReason};
use stereokit_rust::framework::SkClosures;
use std::thread;
use std::time::Duration;
let sk_info = Some(sk.get_sk_info_clone());
let event_loop_proxy = SkInfo::event_loop_proxy_from(&sk_info);
// Spawn a new thread to send an event after a delay
let handle = thread::spawn(move || {
thread::sleep(Duration::from_millis(100));
if let Some(proxy) = event_loop_proxy {
proxy.send_event(StepperAction::quit("thread", "I'm done!")).unwrap();
}
});
SkClosures::new(sk, |sk, token| {
// Only the thread can stop this test
// model.draw(token, Matrix::IDENTITY, None, None);
})
.shutdown(|sk| {
assert_eq!(sk.get_quit_reason(), QuitReason::User);
})
.run(event_loop);
// If we are here the thread has finished
handle.join().unwrap();
Sourcepub fn send_event(sk_info: &Option<Rc<RefCell<SkInfo>>>, message: StepperAction)
pub fn send_event(sk_info: &Option<Rc<RefCell<SkInfo>>>, message: StepperAction)
Send a StepperAction to the event loop
sk_info
- The SkInfo smart pointer to get the event loop proxy frommessage
- The StepperAction to send to the event loop
see also SkInfo::get_message_closure
Sourcepub fn get_message_closure(
sk_info: Option<Rc<RefCell<SkInfo>>>,
id: impl AsRef<str>,
key: &str,
) -> impl Fn(String)
pub fn get_message_closure( sk_info: Option<Rc<RefCell<SkInfo>>>, id: impl AsRef<str>, key: &str, ) -> impl Fn(String)
Get a closure to send a message to the event loop from a given ID for a given key. This is useful for HandMenuRadial for example.
see also SkInfo::send_event
see examples/demos/hand_menu_radial1.rs
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SkInfo
impl RefUnwindSafe for SkInfo
impl !Send for SkInfo
impl !Sync for SkInfo
impl Unpin for SkInfo
impl UnwindSafe for SkInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.