initial commit
This commit is contained in:
58
src/testing/mod.rs
Normal file
58
src/testing/mod.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use app::App;
|
||||
use gui::{primitive::Axis, NodeArrayUtil, NodeUtil, RoundedRect, UIColor};
|
||||
use render::Renderer;
|
||||
use winit::{event::WindowEvent, event_loop::ActiveEventLoop, window::Window};
|
||||
|
||||
mod app;
|
||||
mod render;
|
||||
|
||||
pub fn main() {
|
||||
App::run();
|
||||
}
|
||||
|
||||
pub struct Client {
|
||||
renderer: Renderer,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn new(window: Arc<Window>) -> Self {
|
||||
let mut renderer = Renderer::new(window);
|
||||
let rect = RoundedRect {
|
||||
color: UIColor::WHITE,
|
||||
radius: 10.0,
|
||||
thickness: 0.0,
|
||||
inner_radius: 0.0,
|
||||
};
|
||||
let ui = (
|
||||
(
|
||||
rect.color(UIColor::BLUE),
|
||||
(
|
||||
rect.color(UIColor::RED),
|
||||
(rect.color(UIColor::ORANGE), rect.color(UIColor::LIME))
|
||||
.proportioned(Axis::Y, [1, 1]),
|
||||
rect.color(UIColor::YELLOW),
|
||||
)
|
||||
.proportioned(Axis::X, [2, 2, 1])
|
||||
.pad(10),
|
||||
)
|
||||
.proportioned(Axis::X, [1, 3]),
|
||||
rect.color(UIColor::GREEN),
|
||||
)
|
||||
.proportioned(Axis::Y, [3, 1])
|
||||
.pad(10)
|
||||
.into();
|
||||
renderer.update(&ui);
|
||||
Self { renderer }
|
||||
}
|
||||
|
||||
pub fn event(&mut self, event: WindowEvent, event_loop: &ActiveEventLoop) {
|
||||
match event {
|
||||
WindowEvent::CloseRequested => event_loop.exit(),
|
||||
WindowEvent::RedrawRequested => self.renderer.draw(),
|
||||
WindowEvent::Resized(size) => self.renderer.resize(&size),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user