Module framework

Module framework 

Source
Expand description

A namespace containing features exclusive to the rust bindings for StereoKit.

These are higher level pieces of functionality that do not necessarily adhere to the same goals and restrictions as StereoKit’s core functionality does. This corresponds to the C# namespace: https://stereokit.net/Pages/StereoKit.Framework.html

  • An event loop manager based on Winit.
  • HandMenuRadial related structs, enums and functions.

At the core of this framework is the crate::IStepper derive macro, which allows you to create a stepper that can be run in the event loop.

§Examples

which are also unit tests:

use stereokit_rust::{ font::Font, maths::{Matrix, Quat, Vec3},
                      system::{Text, TextStyle}, util::named_colors};

#[derive(IStepper)]
pub struct MyStepper {
    id: StepperId,
    sk_info: Option<Rc<RefCell<SkInfo>>>,

    transform: Matrix,
    pub text: String,
    text_style: Option<TextStyle>,
}
unsafe impl Send for MyStepper {}
impl Default for MyStepper {
    fn default() -> Self {
        Self {
            id: "MyStepper".to_string(),
            sk_info: None,

            transform: Matrix::IDENTITY,
            text: "IStepper\nderive\nmacro".to_owned(),
            text_style: None,
        }
    }
}
impl MyStepper {
    fn start(&mut self) -> bool {
        self.transform = Matrix::t_r([0.05, 0.0, -0.2], [0.0, 200.0, 0.0]);
        self.text_style = Some(Text::make_style(Font::default(), 0.3, named_colors::RED));
        true
    }
    fn check_event(&mut self, _id: &StepperId, _key: &str, _value: &str) {}
    fn draw(&mut self, token: &MainThreadToken) {
        Text::add_at(token, &self.text, self.transform, self.text_style,
                     None, None, None, None, None, None);
    }
}

sk.send_event(StepperAction::add_default::<MyStepper>("My_Basic_Stepper_ID"));

filename_scr = "screenshots/istepper_macro.jpeg";
test_screenshot!( // !!!! Get a proper main loop !!!!
    // No code here as we only use MyStepper
);

IStepper derive macro

SkClosures IStepper StepperAction Steppers StepperClosures

Structs§

HandMenuItem
This is a collection of display and behavior information for a single item on the hand menu. https://stereokit.net/Pages/StereoKit.Framework/HandMenuItem.html
HandMenuRadial
A menu that shows up in circle around the user’s hand! Selecting an item can perform an action, or even spawn a sub-layer of menu items. This is an easy way to store actions out of the way, yet remain easily accessible to the user.
HandRadialLayer
This class represents a single layer in the HandRadialMenu. Each item in the layer is displayed around the radial menu’s circle. https://stereokit.net/Pages/StereoKit.Framework/HandRadialLayer.html
Screen
The video stepper
SkClosures
Since winit v0.30 we have to implement winit::application::ApplicationHandler and run the app with SkClosures::run or SkClosures::run_app
StepperClosures
Helper to create the whole code of a Stepper in method IStepper::initialize() while avoiding multiple fields.
StepperHandler
All you need to step a Stepper, then remove it
Steppers
Steppers manager. This is used internally by StereoKit, but you can use it to prepare your next scene managers. Non canonical. https://stereokit.net/Pages/StereoKit.Framework/IStepper.html

Enums§

HandMenuAction
This enum specifies how HandMenuItems should behave when selected! This is in addition to the HandMenuItem’s callback function. https://stereokit.net/Pages/StereoKit.Framework/HandMenuAction.html
HandRadial
A Cell of the radial menu which can be a Layer or an item.
StepperAction
Steppers actions list. These are the events you can trigger from any threads. There are 3 ways to trigger an action:
StepperState
State of the stepper

Constants§

HAND_MENU_RADIAL
The way to swap between more than one hand_menu_radial. Use this prefix for your ID to your HandMenuRadial menus
HAND_MENU_RADIAL_FOCUS
If this menu is the one who takes the focus (true) or if he returns the focus on the menu previously active (false)
ISTEPPER_REMOVED
Event indicating that the stepper is removed.
ISTEPPER_RUNNING
Event indicating that the stepper is running.

Traits§

IStepper
See derive macro crate::IStepper which is usefull to implement this trait. This is a lightweight standard interface for fire-and-forget systems that can be attached to StereoKit! This is particularly handy for extensions/plugins that need to run in the background of your application, or even for managing some of your own simpler systems.

Type Aliases§

StepperId
A lazy way to identify IStepper instances