1- use glam:: { vec2, Vec2 } ;
2- use std:: sync:: Arc ;
3- use testbed:: { testbed_any:: TestbedAny , Testbed } ;
1+ use glam:: { Vec2 , vec2} ;
2+ use std:: { rc:: Rc , sync:: Arc } ;
3+ use testbed:: { Testbed , testbed_any:: TestbedAny } ;
4+ use tracing_subscriber:: EnvFilter ;
45use tracing_subscriber:: filter:: LevelFilter ;
56use tracing_subscriber:: layer:: SubscriberExt ;
67use tracing_subscriber:: util:: SubscriberInitExt ;
7- use tracing_subscriber:: EnvFilter ;
88use vulkan:: init_window;
99use vulkano:: {
10+ Validated , VulkanError ,
1011 command_buffer:: CommandBufferUsage ,
1112 format:: Format ,
12- image:: { view:: ImageView , ImageUsage } ,
13+ image:: { ImageUsage , view:: ImageView } ,
1314 swapchain:: {
14- acquire_next_image , ColorSpace , CompositeAlpha , PresentMode , Surface , SurfaceInfo , Swapchain ,
15- SwapchainCreateInfo , SwapchainPresentInfo ,
15+ ColorSpace , CompositeAlpha , PresentMode , Surface , SurfaceInfo , Swapchain , SwapchainCreateInfo ,
16+ SwapchainPresentInfo , acquire_next_image ,
1617 } ,
1718 sync:: GpuFuture ,
18- Validated , VulkanError ,
1919} ;
2020use wgui:: {
21- event:: { MouseButtonIndex , MouseDownEvent , MouseMotionEvent , MouseUpEvent , MouseWheelEvent } ,
22- gfx:: { cmd:: WGfxClearMode , WGfx } ,
21+ event:: { MouseButtonEvent , MouseButtonIndex , MouseMotionEvent , MouseWheelEvent } ,
22+ gfx:: { WGfx , cmd:: WGfxClearMode } ,
2323 renderer_vk:: { self } ,
2424} ;
2525use winit:: {
@@ -32,7 +32,7 @@ use wlx_common::{audio, timestep::Timestep};
3232use crate :: {
3333 rate_limiter:: RateLimiter ,
3434 testbed:: {
35- testbed_dashboard:: TestbedDashboard , testbed_generic:: TestbedGeneric , TestbedUpdateParams ,
35+ TestbedUpdateParams , testbed_dashboard:: TestbedDashboard , testbed_generic:: TestbedGeneric ,
3636 } ,
3737} ;
3838
@@ -174,7 +174,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
174174 testbed
175175 . layout ( )
176176 . push_event (
177- & wgui:: event:: Event :: MouseDown ( MouseDownEvent {
177+ & wgui:: event:: Event :: MouseDown ( MouseButtonEvent {
178178 pos : mouse / scale,
179179 index : MouseButtonIndex :: Left ,
180180 device : 0 ,
@@ -187,7 +187,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
187187 testbed
188188 . layout ( )
189189 . push_event (
190- & wgui:: event:: Event :: MouseUp ( MouseUpEvent {
190+ & wgui:: event:: Event :: MouseUp ( MouseButtonEvent {
191191 pos : mouse / scale,
192192 index : MouseButtonIndex :: Left ,
193193 device : 0 ,
@@ -221,33 +221,46 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
221221 ..
222222 } => {
223223 if event. state == ElementState :: Pressed {
224- if event. physical_key == PhysicalKey :: Code ( KeyCode :: F10 ) {
225- debug_draw_enabled = !debug_draw_enabled;
226- if debug_draw_enabled {
227- log:: info!(
228- "Debug draw enabled\n \t Aqua: widget boundary\n \t Magenta: Scissoring (separate render pass)"
229- ) ;
224+ if !event. repeat {
225+ if event. physical_key == PhysicalKey :: Code ( KeyCode :: F10 ) {
226+ debug_draw_enabled = !debug_draw_enabled;
227+ if debug_draw_enabled {
228+ log:: info!(
229+ "Debug draw enabled\n \t Aqua: widget boundary\n \t Magenta: Scissoring (separate render pass)"
230+ ) ;
231+ }
232+ testbed. layout ( ) . mark_redraw ( ) ;
230233 }
231- testbed. layout ( ) . mark_redraw ( ) ;
232- }
233234
234- if event. physical_key == PhysicalKey :: Code ( KeyCode :: F11 ) {
235- testbed. layout ( ) . print_tree ( ) ;
236- }
235+ if event. physical_key == PhysicalKey :: Code ( KeyCode :: F11 ) {
236+ testbed. layout ( ) . print_tree ( ) ;
237+ }
237238
238- if event. physical_key == PhysicalKey :: Code ( KeyCode :: Equal ) {
239- scale *= 1.25 ;
240- render_context
241- . update_viewport ( & mut shared_context, swapchain_size, scale)
242- . unwrap ( ) ;
243- }
239+ if event. physical_key == PhysicalKey :: Code ( KeyCode :: Equal ) {
240+ scale *= 1.25 ;
241+ render_context
242+ . update_viewport ( & mut shared_context, swapchain_size, scale)
243+ . unwrap ( ) ;
244+ }
244245
245- if event. physical_key == PhysicalKey :: Code ( KeyCode :: Minus ) {
246- scale *= 0.75 ;
247- render_context
248- . update_viewport ( & mut shared_context, swapchain_size, scale)
249- . unwrap ( ) ;
246+ if event. physical_key == PhysicalKey :: Code ( KeyCode :: Minus ) {
247+ scale *= 0.75 ;
248+ render_context
249+ . update_viewport ( & mut shared_context, swapchain_size, scale)
250+ . unwrap ( ) ;
251+ }
250252 }
253+
254+ testbed
255+ . layout ( )
256+ . push_event (
257+ & wgui:: event:: Event :: TextInput ( wgui:: event:: TextInputEvent {
258+ text : event. text . map ( |text| Rc :: from ( text. as_str ( ) ) ) ,
259+ } ) ,
260+ & mut ( ) ,
261+ & mut ( ) ,
262+ )
263+ . unwrap ( ) ;
251264 }
252265 }
253266 Event :: WindowEvent {
0 commit comments