|
|
@ -3,11 +3,7 @@ mod mouse_manager;
|
|
|
|
mod renderer;
|
|
|
|
mod renderer;
|
|
|
|
|
|
|
|
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
|
sync::{
|
|
|
|
sync::mpsc::Receiver,
|
|
|
|
atomic::{AtomicBool, Ordering},
|
|
|
|
|
|
|
|
mpsc::Receiver,
|
|
|
|
|
|
|
|
Arc,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
time::{Duration, Instant},
|
|
|
|
time::{Duration, Instant},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -33,6 +29,7 @@ use crate::{
|
|
|
|
editor::WindowCommand,
|
|
|
|
editor::WindowCommand,
|
|
|
|
redraw_scheduler::REDRAW_SCHEDULER,
|
|
|
|
redraw_scheduler::REDRAW_SCHEDULER,
|
|
|
|
renderer::Renderer,
|
|
|
|
renderer::Renderer,
|
|
|
|
|
|
|
|
running_tracker::*,
|
|
|
|
settings::{maybe_save_window_size, SETTINGS},
|
|
|
|
settings::{maybe_save_window_size, SETTINGS},
|
|
|
|
utils::Dimensions,
|
|
|
|
utils::Dimensions,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -99,13 +96,13 @@ impl GlutinWindowWrapper {
|
|
|
|
self.windowed_context.window().set_title(&self.title);
|
|
|
|
self.windowed_context.window().set_title(&self.title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn handle_quit(&mut self, running: &Arc<AtomicBool>) {
|
|
|
|
pub fn handle_quit(&mut self) {
|
|
|
|
if SETTINGS.get::<CmdLineSettings>().remote_tcp.is_none() {
|
|
|
|
if SETTINGS.get::<CmdLineSettings>().remote_tcp.is_none() {
|
|
|
|
self.ui_command_sender
|
|
|
|
self.ui_command_sender
|
|
|
|
.send(ParallelCommand::Quit.into())
|
|
|
|
.send(ParallelCommand::Quit.into())
|
|
|
|
.expect("Could not send quit command to bridge");
|
|
|
|
.expect("Could not send quit command to bridge");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
running.store(false, Ordering::Relaxed);
|
|
|
|
RUNNING_TRACKER.quit("window closed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -118,7 +115,7 @@ impl GlutinWindowWrapper {
|
|
|
|
REDRAW_SCHEDULER.queue_next_frame();
|
|
|
|
REDRAW_SCHEDULER.queue_next_frame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn handle_event(&mut self, event: Event<()>, running: &Arc<AtomicBool>) {
|
|
|
|
pub fn handle_event(&mut self, event: Event<()>) {
|
|
|
|
self.keyboard_manager.handle_event(&event);
|
|
|
|
self.keyboard_manager.handle_event(&event);
|
|
|
|
self.mouse_manager.handle_event(
|
|
|
|
self.mouse_manager.handle_event(
|
|
|
|
&event,
|
|
|
|
&event,
|
|
|
@ -128,13 +125,13 @@ impl GlutinWindowWrapper {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
match event {
|
|
|
|
match event {
|
|
|
|
Event::LoopDestroyed => {
|
|
|
|
Event::LoopDestroyed => {
|
|
|
|
self.handle_quit(running);
|
|
|
|
self.handle_quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::WindowEvent {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
} => {
|
|
|
|
self.handle_quit(running);
|
|
|
|
self.handle_quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Event::WindowEvent {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::ScaleFactorChanged { scale_factor, .. },
|
|
|
|
event: WindowEvent::ScaleFactorChanged { scale_factor, .. },
|
|
|
@ -242,7 +239,6 @@ pub fn create_window(
|
|
|
|
batched_draw_command_receiver: Receiver<Vec<DrawCommand>>,
|
|
|
|
batched_draw_command_receiver: Receiver<Vec<DrawCommand>>,
|
|
|
|
window_command_receiver: Receiver<WindowCommand>,
|
|
|
|
window_command_receiver: Receiver<WindowCommand>,
|
|
|
|
ui_command_sender: LoggingTx<UiCommand>,
|
|
|
|
ui_command_sender: LoggingTx<UiCommand>,
|
|
|
|
running: Arc<AtomicBool>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let icon = {
|
|
|
|
let icon = {
|
|
|
|
let icon = load_from_memory(ICON).expect("Failed to parse icon data");
|
|
|
|
let icon = load_from_memory(ICON).expect("Failed to parse icon data");
|
|
|
@ -312,7 +308,7 @@ pub fn create_window(
|
|
|
|
let mut previous_frame_start = Instant::now();
|
|
|
|
let mut previous_frame_start = Instant::now();
|
|
|
|
|
|
|
|
|
|
|
|
event_loop.run(move |e, _window_target, control_flow| {
|
|
|
|
event_loop.run(move |e, _window_target, control_flow| {
|
|
|
|
if !running.load(Ordering::Relaxed) {
|
|
|
|
if RUNNING_TRACKER.is_running() {
|
|
|
|
maybe_save_window_size(window_wrapper.saved_grid_size);
|
|
|
|
maybe_save_window_size(window_wrapper.saved_grid_size);
|
|
|
|
std::process::exit(0);
|
|
|
|
std::process::exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -321,7 +317,7 @@ pub fn create_window(
|
|
|
|
|
|
|
|
|
|
|
|
window_wrapper.handle_window_commands();
|
|
|
|
window_wrapper.handle_window_commands();
|
|
|
|
window_wrapper.synchronize_settings();
|
|
|
|
window_wrapper.synchronize_settings();
|
|
|
|
window_wrapper.handle_event(e, &running);
|
|
|
|
window_wrapper.handle_event(e);
|
|
|
|
|
|
|
|
|
|
|
|
let refresh_rate = { SETTINGS.get::<WindowSettings>().refresh_rate as f32 };
|
|
|
|
let refresh_rate = { SETTINGS.get::<WindowSettings>().refresh_rate as f32 };
|
|
|
|
let expected_frame_length_seconds = 1.0 / refresh_rate;
|
|
|
|
let expected_frame_length_seconds = 1.0 / refresh_rate;
|
|
|
|