@@ -13,11 +13,12 @@ use lambda_platform::winit::{
1313use crate :: core:: {
1414 component:: RenderableComponent ,
1515 events:: {
16+ ComponentEvent ,
1617 Events ,
17- KernelEvent ,
18+ RuntimeEvent ,
1819 WindowEvent ,
1920 } ,
20- kernel:: Kernel ,
21+ kernel:: Runtime ,
2122 render:: {
2223 window:: {
2324 Window ,
@@ -28,14 +29,14 @@ use crate::core::{
2829 } ,
2930} ;
3031
31- pub struct LambdaKernelBuilder {
32+ pub struct GenericRuntimeBuilder {
3233 app_name : String ,
3334 render_api : RenderContextBuilder ,
3435 window_size : ( u32 , u32 ) ,
3536 components : Vec < Box < dyn RenderableComponent < Events > > > ,
3637}
3738
38- impl LambdaKernelBuilder {
39+ impl GenericRuntimeBuilder {
3940 pub fn new ( app_name : & str ) -> Self {
4041 return Self {
4142 app_name : app_name. to_string ( ) ,
@@ -79,7 +80,7 @@ impl LambdaKernelBuilder {
7980 /// Builds a LambdaKernel equipped with Windowing, an event loop, and a
8081 /// component stack that allows components to be dynamically pushed into the
8182 /// Kernel to receive events & render access.
82- pub fn build ( self ) -> LambdaKernel {
83+ pub fn build ( self ) -> GenericRuntime {
8384 let name = self . app_name ;
8485 let mut event_loop = create_event_loop :: < Events > ( ) ;
8586 let ( width, height) = self . window_size ;
@@ -91,7 +92,7 @@ impl LambdaKernelBuilder {
9192 let component_stack = self . components ;
9293 let render_api = self . render_api . build ( & window) ;
9394
94- return LambdaKernel {
95+ return GenericRuntime {
9596 name,
9697 event_loop,
9798 window,
@@ -104,24 +105,24 @@ impl LambdaKernelBuilder {
104105/// A windowed and event-driven kernel that can be used to render a
105106/// scene on the primary GPU across Windows, MacOS, and Linux at this point in
106107/// time.
107- pub struct LambdaKernel {
108+ pub struct GenericRuntime {
108109 name : String ,
109110 event_loop : Loop < Events > ,
110111 window : Window ,
111112 component_stack : Vec < Box < dyn RenderableComponent < Events > > > ,
112113 render_api : RenderContext ,
113114}
114115
115- impl LambdaKernel { }
116+ impl GenericRuntime { }
116117
117- impl Kernel for LambdaKernel {
118+ impl Runtime for GenericRuntime {
118119 /// Initiates an event loop that captures the context of the LambdaKernel
119120 /// and generates events from the windows event loop until the end of the event loops
120121 /// lifetime (Whether that be initiated intentionally or via error).
121122 fn run ( self ) {
122123 // Decompose Kernel components for transferring ownership to the
123124 // closure.
124- let LambdaKernel {
125+ let GenericRuntime {
125126 mut window,
126127 mut event_loop,
127128 mut component_stack,
@@ -132,8 +133,8 @@ impl Kernel for LambdaKernel {
132133 let mut active_render_api = Some ( render_api) ;
133134
134135 let publisher = event_loop. create_publisher ( ) ;
135- publisher. publish_event ( Events :: Kernel {
136- event : KernelEvent :: Initialized ,
136+ publisher. publish_event ( Events :: Runtime {
137+ event : RuntimeEvent :: Initialized ,
137138 issued_at : Instant :: now ( ) ,
138139 } ) ;
139140
@@ -144,8 +145,8 @@ impl Kernel for LambdaKernel {
144145 WinitEvent :: WindowEvent { event, .. } => match event {
145146 WinitWindowEvent :: CloseRequested => {
146147 // Issue a Shutdown event to deallocate resources and clean up.
147- publisher. publish_event ( Events :: Kernel {
148- event : KernelEvent :: Shutdown ,
148+ publisher. publish_event ( Events :: Runtime {
149+ event : RuntimeEvent :: Shutdown ,
149150 issued_at : Instant :: now ( ) ,
150151 } ) ;
151152 }
@@ -175,39 +176,39 @@ impl Kernel for LambdaKernel {
175176 WinitWindowEvent :: ReceivedCharacter ( _) => { }
176177 WinitWindowEvent :: Focused ( _) => { }
177178 WinitWindowEvent :: KeyboardInput {
178- device_id : _ ,
179- input : _ ,
180- is_synthetic : _ ,
179+ device_id,
180+ input,
181+ is_synthetic,
181182 } => { }
182183 WinitWindowEvent :: ModifiersChanged ( _) => { }
183184 WinitWindowEvent :: CursorMoved {
184- device_id : _ ,
185- position : _ ,
186- modifiers : _ ,
185+ device_id,
186+ position,
187+ modifiers,
187188 } => { }
188- WinitWindowEvent :: CursorEntered { device_id : _ } => { }
189- WinitWindowEvent :: CursorLeft { device_id : _ } => { }
189+ WinitWindowEvent :: CursorEntered { device_id } => { }
190+ WinitWindowEvent :: CursorLeft { device_id } => { }
190191 WinitWindowEvent :: MouseWheel {
191- device_id : _ ,
192- delta : _ ,
193- phase : _ ,
194- modifiers : _ ,
192+ device_id,
193+ delta,
194+ phase,
195+ modifiers,
195196 } => { }
196197 WinitWindowEvent :: MouseInput {
197- device_id : _ ,
198- state : _ ,
199- button : _ ,
200- modifiers : _ ,
198+ device_id,
199+ state,
200+ button,
201+ modifiers,
201202 } => { }
202203 WinitWindowEvent :: TouchpadPressure {
203- device_id : _ ,
204- pressure : _ ,
205- stage : _ ,
204+ device_id,
205+ pressure,
206+ stage,
206207 } => { }
207208 WinitWindowEvent :: AxisMotion {
208- device_id : _ ,
209- axis : _ ,
210- value : _ ,
209+ device_id,
210+ axis,
211+ value,
211212 } => { }
212213 WinitWindowEvent :: Touch ( _) => { }
213214 WinitWindowEvent :: ThemeChanged ( _) => { }
@@ -229,24 +230,18 @@ impl Kernel for LambdaKernel {
229230 }
230231 WinitEvent :: RedrawRequested ( _) => { }
231232 WinitEvent :: NewEvents ( _) => { }
232- WinitEvent :: DeviceEvent {
233- device_id : _,
234- event : _,
235- } => { }
233+ WinitEvent :: DeviceEvent { device_id, event } => { }
236234 WinitEvent :: UserEvent ( lambda_event) => match lambda_event {
237- Events :: Kernel {
238- event,
239- issued_at : _,
240- } => match event {
241- KernelEvent :: Initialized => {
235+ Events :: Runtime { event, issued_at } => match event {
236+ RuntimeEvent :: Initialized => {
242237 println ! ( "Starting the kernel {}" , name) ;
243238 for component in & mut component_stack {
244239 component. on_attach ( ) ;
245240 component
246241 . on_renderer_attached ( active_render_api. as_mut ( ) . unwrap ( ) ) ;
247242 }
248243 }
249- KernelEvent :: Shutdown => {
244+ RuntimeEvent :: Shutdown => {
250245 for component in & mut component_stack {
251246 component. on_detach ( ) ;
252247 component
@@ -273,9 +268,11 @@ impl Kernel for LambdaKernel {
273268 } ) ;
274269 }
275270
276- /// When the lambda kernel starts, it will attach all of the components that
277- /// have been added to the kernel during the construction phase.
278- fn on_start ( & mut self ) { }
271+ /// When the generic runtime starts, it will attach all of the components that
272+ /// have been added during the construction phase in the users code.
273+ fn on_start ( & mut self ) {
274+ println ! ( "Starting the runtime {}" , self . name) ;
275+ }
279276
280277 fn on_stop ( & mut self ) {
281278 println ! ( "Stopping {}" , self . name)
0 commit comments