fix uidev
This commit is contained in:
@@ -1,29 +1,26 @@
|
|||||||
use glam::{Vec2, vec2};
|
use glam::{vec2, Vec2};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use testbed::{Testbed, testbed_any::TestbedAny};
|
use testbed::{testbed_any::TestbedAny, Testbed};
|
||||||
use timestep::Timestep;
|
use timestep::Timestep;
|
||||||
use tracing_subscriber::EnvFilter;
|
|
||||||
use tracing_subscriber::filter::LevelFilter;
|
use tracing_subscriber::filter::LevelFilter;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
|
use tracing_subscriber::EnvFilter;
|
||||||
use vulkan::init_window;
|
use vulkan::init_window;
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
Validated, VulkanError,
|
|
||||||
command_buffer::CommandBufferUsage,
|
command_buffer::CommandBufferUsage,
|
||||||
format::Format,
|
format::Format,
|
||||||
image::{ImageUsage, view::ImageView},
|
image::{view::ImageView, ImageUsage},
|
||||||
swapchain::{
|
swapchain::{
|
||||||
CompositeAlpha, PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo,
|
acquire_next_image, CompositeAlpha, PresentMode, Surface, SurfaceInfo, Swapchain,
|
||||||
SwapchainPresentInfo, acquire_next_image,
|
SwapchainCreateInfo, SwapchainPresentInfo,
|
||||||
},
|
},
|
||||||
sync::GpuFuture,
|
sync::GpuFuture,
|
||||||
|
Validated, VulkanError,
|
||||||
};
|
};
|
||||||
use wgui::{
|
use wgui::{
|
||||||
event::{
|
event::{MouseButtonIndex, MouseDownEvent, MouseMotionEvent, MouseUpEvent, MouseWheelEvent},
|
||||||
EventListenerCollection, MouseButtonIndex, MouseDownEvent, MouseMotionEvent, MouseUpEvent,
|
gfx::{cmd::WGfxClearMode, WGfx},
|
||||||
MouseWheelEvent,
|
|
||||||
},
|
|
||||||
gfx::{WGfx, cmd::WGfxClearMode},
|
|
||||||
renderer_vk::{self},
|
renderer_vk::{self},
|
||||||
};
|
};
|
||||||
use winit::{
|
use winit::{
|
||||||
@@ -35,7 +32,7 @@ use winit::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
rate_limiter::RateLimiter,
|
rate_limiter::RateLimiter,
|
||||||
testbed::{
|
testbed::{
|
||||||
TestbedUpdateParams, testbed_dashboard::TestbedDashboard, testbed_generic::TestbedGeneric,
|
testbed_dashboard::TestbedDashboard, testbed_generic::TestbedGeneric, TestbedUpdateParams,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,14 +60,12 @@ fn init_logging() {
|
|||||||
.init();
|
.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_testbed(
|
fn load_testbed() -> anyhow::Result<Box<dyn Testbed>> {
|
||||||
listeners: &mut EventListenerCollection<(), ()>,
|
|
||||||
) -> anyhow::Result<Box<dyn Testbed>> {
|
|
||||||
let name = std::env::var("TESTBED").unwrap_or_default();
|
let name = std::env::var("TESTBED").unwrap_or_default();
|
||||||
Ok(match name.as_str() {
|
Ok(match name.as_str() {
|
||||||
"dashboard" => Box::new(TestbedDashboard::new(listeners)?),
|
"dashboard" => Box::new(TestbedDashboard::new()?),
|
||||||
"" => Box::new(TestbedGeneric::new(listeners)?),
|
"" => Box::new(TestbedGeneric::new()?),
|
||||||
_ => Box::new(TestbedAny::new(&name, listeners)?),
|
_ => Box::new(TestbedAny::new(&name)?),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,9 +99,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
let mut scale = window.scale_factor() as f32;
|
let mut scale = window.scale_factor() as f32;
|
||||||
|
|
||||||
let mut listeners = EventListenerCollection::default();
|
let mut testbed = load_testbed()?;
|
||||||
|
|
||||||
let mut testbed = load_testbed(&mut listeners)?;
|
|
||||||
|
|
||||||
let mut mouse = Vec2::ZERO;
|
let mut mouse = Vec2::ZERO;
|
||||||
|
|
||||||
@@ -139,26 +132,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.layout()
|
.layout()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_event(
|
.push_event(
|
||||||
&mut listeners,
|
|
||||||
&wgui::event::Event::MouseWheel(MouseWheelEvent {
|
&wgui::event::Event::MouseWheel(MouseWheelEvent {
|
||||||
shift: Vec2::new(x, y),
|
shift: Vec2::new(x, y),
|
||||||
pos: mouse / scale,
|
pos: mouse / scale,
|
||||||
device: 0,
|
device: 0,
|
||||||
}),
|
}),
|
||||||
(&mut (), &mut ()),
|
&mut (),
|
||||||
|
&mut (),
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
MouseScrollDelta::PixelDelta(pos) => testbed
|
MouseScrollDelta::PixelDelta(pos) => testbed
|
||||||
.layout()
|
.layout()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_event(
|
.push_event(
|
||||||
&mut listeners,
|
|
||||||
&wgui::event::Event::MouseWheel(MouseWheelEvent {
|
&wgui::event::Event::MouseWheel(MouseWheelEvent {
|
||||||
shift: Vec2::new(pos.x as f32 / 5.0, pos.y as f32 / 5.0),
|
shift: Vec2::new(pos.x as f32 / 5.0, pos.y as f32 / 5.0),
|
||||||
pos: mouse / scale,
|
pos: mouse / scale,
|
||||||
device: 0,
|
device: 0,
|
||||||
}),
|
}),
|
||||||
(&mut (), &mut ()),
|
&mut (),
|
||||||
|
&mut (),
|
||||||
)
|
)
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
},
|
},
|
||||||
@@ -172,13 +165,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.layout()
|
.layout()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_event(
|
.push_event(
|
||||||
&mut listeners,
|
|
||||||
&wgui::event::Event::MouseDown(MouseDownEvent {
|
&wgui::event::Event::MouseDown(MouseDownEvent {
|
||||||
pos: mouse / scale,
|
pos: mouse / scale,
|
||||||
index: MouseButtonIndex::Left,
|
index: MouseButtonIndex::Left,
|
||||||
device: 0,
|
device: 0,
|
||||||
}),
|
}),
|
||||||
(&mut (), &mut ()),
|
&mut (),
|
||||||
|
&mut (),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
@@ -186,13 +179,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.layout()
|
.layout()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_event(
|
.push_event(
|
||||||
&mut listeners,
|
|
||||||
&wgui::event::Event::MouseUp(MouseUpEvent {
|
&wgui::event::Event::MouseUp(MouseUpEvent {
|
||||||
pos: mouse / scale,
|
pos: mouse / scale,
|
||||||
index: MouseButtonIndex::Left,
|
index: MouseButtonIndex::Left,
|
||||||
device: 0,
|
device: 0,
|
||||||
}),
|
}),
|
||||||
(&mut (), &mut ()),
|
&mut (),
|
||||||
|
&mut (),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@@ -207,12 +200,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.layout()
|
.layout()
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_event(
|
.push_event(
|
||||||
&mut listeners,
|
|
||||||
&wgui::event::Event::MouseMotion(MouseMotionEvent {
|
&wgui::event::Event::MouseMotion(MouseMotionEvent {
|
||||||
pos: mouse / scale,
|
pos: mouse / scale,
|
||||||
device: 0,
|
device: 0,
|
||||||
}),
|
}),
|
||||||
(&mut (), &mut ()),
|
&mut (),
|
||||||
|
&mut (),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@@ -298,7 +291,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
testbed
|
testbed
|
||||||
.update(TestbedUpdateParams {
|
.update(TestbedUpdateParams {
|
||||||
listeners: &mut listeners,
|
|
||||||
width: (swapchain_size[0] as f32 / scale) as _,
|
width: (swapchain_size[0] as f32 / scale) as _,
|
||||||
height: (swapchain_size[1] as f32 / scale) as _,
|
height: (swapchain_size[1] as f32 / scale) as _,
|
||||||
timestep_alpha: timestep.alpha,
|
timestep_alpha: timestep.alpha,
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
use wgui::{event::EventListenerCollection, layout::RcLayout};
|
use wgui::layout::RcLayout;
|
||||||
|
|
||||||
pub mod testbed_any;
|
pub mod testbed_any;
|
||||||
pub mod testbed_dashboard;
|
pub mod testbed_dashboard;
|
||||||
pub mod testbed_generic;
|
pub mod testbed_generic;
|
||||||
|
|
||||||
pub struct TestbedUpdateParams<'a> {
|
pub struct TestbedUpdateParams {
|
||||||
pub listeners: &'a mut EventListenerCollection<(), ()>,
|
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
pub height: f32,
|
pub height: f32,
|
||||||
pub timestep_alpha: f32,
|
pub timestep_alpha: f32,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use crate::{
|
|||||||
use glam::Vec2;
|
use glam::Vec2;
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
event::EventListenerCollection,
|
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
layout::{LayoutParams, RcLayout},
|
layout::{LayoutParams, RcLayout},
|
||||||
parser::{ParseDocumentParams, ParserState},
|
parser::{ParseDocumentParams, ParserState},
|
||||||
@@ -19,7 +18,7 @@ pub struct TestbedAny {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TestbedAny {
|
impl TestbedAny {
|
||||||
pub fn new(name: &str, listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
|
pub fn new(name: &str) -> anyhow::Result<Self> {
|
||||||
let path = AssetPath::BuiltIn(&format!("gui/{name}.xml"));
|
let path = AssetPath::BuiltIn(&format!("gui/{name}.xml"));
|
||||||
|
|
||||||
let globals = WguiGlobals::new(
|
let globals = WguiGlobals::new(
|
||||||
@@ -28,7 +27,6 @@ impl TestbedAny {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (layout, state) = wgui::parser::new_layout_from_assets(
|
let (layout, state) = wgui::parser::new_layout_from_assets(
|
||||||
listeners,
|
|
||||||
&ParseDocumentParams {
|
&ParseDocumentParams {
|
||||||
globals,
|
globals,
|
||||||
path,
|
path,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::testbed::{Testbed, TestbedUpdateParams};
|
use crate::testbed::{Testbed, TestbedUpdateParams};
|
||||||
use wgui::{event::EventListenerCollection, layout::RcLayout};
|
use wgui::layout::RcLayout;
|
||||||
|
|
||||||
pub struct TestbedDashboard {
|
pub struct TestbedDashboard {
|
||||||
layout: RcLayout,
|
layout: RcLayout,
|
||||||
@@ -7,9 +7,8 @@ pub struct TestbedDashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TestbedDashboard {
|
impl TestbedDashboard {
|
||||||
pub fn new(listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
|
pub fn new() -> anyhow::Result<Self> {
|
||||||
let (frontend, layout) =
|
let (frontend, layout) = dash_frontend::Frontend::new()?;
|
||||||
dash_frontend::Frontend::new(dash_frontend::FrontendParams { listeners })?;
|
|
||||||
Ok(Self { frontend, layout })
|
Ok(Self { frontend, layout })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +18,6 @@ impl Testbed for TestbedDashboard {
|
|||||||
let mut frontend = self.frontend.borrow_mut();
|
let mut frontend = self.frontend.borrow_mut();
|
||||||
frontend.update(
|
frontend.update(
|
||||||
&self.frontend,
|
&self.frontend,
|
||||||
params.listeners,
|
|
||||||
params.width,
|
params.width,
|
||||||
params.height,
|
params.height,
|
||||||
params.timestep_alpha,
|
params.timestep_alpha,
|
||||||
|
|||||||
@@ -8,12 +8,11 @@ use glam::Vec2;
|
|||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::{
|
components::{
|
||||||
Component,
|
|
||||||
button::{ButtonClickCallback, ComponentButton},
|
button::{ButtonClickCallback, ComponentButton},
|
||||||
checkbox::ComponentCheckbox,
|
checkbox::ComponentCheckbox,
|
||||||
|
Component,
|
||||||
},
|
},
|
||||||
drawing::Color,
|
drawing::Color,
|
||||||
event::EventListenerCollection,
|
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
i18n::Translation,
|
i18n::Translation,
|
||||||
layout::{Layout, LayoutParams, RcLayout, Widget},
|
layout::{Layout, LayoutParams, RcLayout, Widget},
|
||||||
@@ -71,7 +70,7 @@ fn handle_button_click(button: Rc<ComponentButton>, label: Widget, text: &'stati
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TestbedGeneric {
|
impl TestbedGeneric {
|
||||||
pub fn new(listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
|
pub fn new() -> anyhow::Result<Self> {
|
||||||
const XML_PATH: AssetPath = AssetPath::BuiltIn("gui/various_widgets.xml");
|
const XML_PATH: AssetPath = AssetPath::BuiltIn("gui/various_widgets.xml");
|
||||||
|
|
||||||
let globals = WguiGlobals::new(
|
let globals = WguiGlobals::new(
|
||||||
@@ -107,7 +106,6 @@ impl TestbedGeneric {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (layout, state) = wgui::parser::new_layout_from_assets(
|
let (layout, state) = wgui::parser::new_layout_from_assets(
|
||||||
listeners,
|
|
||||||
&ParseDocumentParams {
|
&ParseDocumentParams {
|
||||||
globals: globals.clone(),
|
globals: globals.clone(),
|
||||||
path: XML_PATH,
|
path: XML_PATH,
|
||||||
@@ -190,7 +188,7 @@ impl TestbedGeneric {
|
|||||||
|
|
||||||
fn show_popup(
|
fn show_popup(
|
||||||
&mut self,
|
&mut self,
|
||||||
params: &mut TestbedUpdateParams,
|
_params: &mut TestbedUpdateParams,
|
||||||
layout: &mut Layout,
|
layout: &mut Layout,
|
||||||
data: &mut Data,
|
data: &mut Data,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
@@ -198,7 +196,6 @@ impl TestbedGeneric {
|
|||||||
globals: self.globals.clone(),
|
globals: self.globals.clone(),
|
||||||
position: Vec2::new(128.0, 128.0),
|
position: Vec2::new(128.0, 128.0),
|
||||||
layout,
|
layout,
|
||||||
listeners: params.listeners,
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user