pub struct ScreenshotViewer {
pub enabled: bool,
pub picture_size: Vec2,
pub field_of_view: f32,
pub window_pose: Pose,
pub window_size: Vec2,
/* private fields */
}
Expand description
A simple screenshot viewer to take / save / display screenshots.
§Fields that can be changed before initialization:
picture_size
- The size of the picture to take. Default is Vec2::new(800.0, 600.0).field_of_view
- The field of view of the camera. Default is 90.0.windows_pose
- The initial pose of the window.window_size
- The size of the window. Default is Vec2::new(42.0, 37.0) * CM.enabled
- If the screenshot viewer is enabled at start. Default istrue
§Events this stepper is listening to:
SHOW_SCREENSHOT_WINDOW
- Event that triggers when the window is visible (“true”) or hidden (“false”).FILE_BROWSER_OPEN
- Event that triggers when a file as been selected with the file browser. You can use this event too if you want to load a screenshot.
§Examples
use stereokit_rust::{maths::Vec3, sk::SkInfo, ui::Ui,
tools::{file_browser::FILE_BROWSER_OPEN,
screenshot::{ScreenshotViewer, SHOW_SCREENSHOT_WINDOW}}};
let sk_info = Some(sk.get_sk_info_clone());
let mut screenshot_viewer = ScreenshotViewer::default();
screenshot_viewer.window_pose = Ui::popup_pose([0.0, 0.15, 1.3]);
sk.send_event(StepperAction::add("ScrViewer", screenshot_viewer));
let screenshot_path = std::env::current_dir().unwrap().join("assets/textures/screenshot.raw");
assert!(screenshot_path.exists());
let scr_file = screenshot_path.to_str().expect("String should be valid");
number_of_steps = 4;
filename_scr = "screenshots/screenshot_viewer.jpeg";
test_screenshot!( // !!!! Get a proper main loop !!!!
if iter == 0 {
sk.send_event(StepperAction::event( "main", SHOW_SCREENSHOT_WINDOW,"false",));
} else if iter == 1 {
sk.send_event(StepperAction::event( "main", SHOW_SCREENSHOT_WINDOW,"true",));
// The image is not visible at the next step, but at the step after.
sk.send_event(StepperAction::event( "ScrViewer", FILE_BROWSER_OPEN, scr_file));
}
);

Fields§
§enabled: bool
§picture_size: Vec2
§field_of_view: f32
§window_pose: Pose
§window_size: Vec2
Trait Implementations§
Source§impl Default for ScreenshotViewer
impl Default for ScreenshotViewer
Source§impl IStepper for ScreenshotViewer
impl IStepper for ScreenshotViewer
Source§fn enabled(&self) -> bool
fn enabled(&self) -> bool
Is this IStepper enabled? When false, StereoKit will not call Step. This can be a good way to temporarily
disable the IStepper without removing or shutting it down.
https://stereokit.net/Pages/StereoKit.Framework/IStepper/Enabled.html
Source§fn initialize(&mut self, id: StepperId, sk_info: Rc<RefCell<SkInfo>>) -> bool
fn initialize(&mut self, id: StepperId, sk_info: Rc<RefCell<SkInfo>>) -> bool
This is called by StereoKit at the start of the next frame, and on the main thread. This happens before
StereoKit’s main Step callback, and always after Sk.initialize.
https://stereokit.net/Pages/StereoKit.Framework/IStepper/Initialize.html
id : The id of the stepper
sk : The SkInfo of the runnin Sk instance. Read more
Source§fn step(&mut self, token: &MainThreadToken)
fn step(&mut self, token: &MainThreadToken)
This Step method will be called every frame of the application, as long as Enabled is true. This happens
immediately before the main application’s Step callback.
https://stereokit.net/Pages/StereoKit.Framework/IStepper/Step.html
Source§fn shutdown(&mut self)
fn shutdown(&mut self)
This is called when the IStepper is removed, or the application shuts down. This is always called on the main
thread, and happens at the start of the next frame, before the main application’s Step callback.
https://stereokit.net/Pages/StereoKit.Framework/IStepper/Shutdown.html
Source§fn shutdown_done(&mut self) -> bool
fn shutdown_done(&mut self) -> bool
If shutdown is to be performed in multiple steps, with or without threads and in order to avoid black or
frozen screens, write the on going shutdown here Read more
Source§fn initialize_done(&mut self) -> bool
fn initialize_done(&mut self) -> bool
If initialization is to be performed in multiple steps, with or without threads and in order to avoid black or
frozen screens, write the on going initialization here Read more
impl Send for ScreenshotViewer
Auto Trait Implementations§
impl Freeze for ScreenshotViewer
impl !RefUnwindSafe for ScreenshotViewer
impl !Sync for ScreenshotViewer
impl Unpin for ScreenshotViewer
impl !UnwindSafe for ScreenshotViewer
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.