creating a gtk window now spawns a new thread
This commit is contained in:
parent
0c3a160dd5
commit
c65b922a45
3 changed files with 18 additions and 11 deletions
|
|
@ -34,6 +34,7 @@ impl Game {
|
|||
pub fn add_window(&mut self) {
|
||||
moonhare_log::info(format!("Adding window to {:?}", self));
|
||||
Window::create();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
use std::marker;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::platforms::gtk_window::GTKWindow;
|
||||
|
||||
pub mod window_config;
|
||||
|
||||
pub mod platforms;
|
||||
|
|
@ -24,20 +27,24 @@ pub trait MoonhareWindow {
|
|||
}
|
||||
|
||||
pub struct Window {
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl Window {
|
||||
/// creates a gtk4 window
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn create() {
|
||||
use std::thread;
|
||||
|
||||
use gtk4::gio::prelude::ApplicationExtManual;
|
||||
|
||||
use crate::platforms::gtk_window::GTKWindow;
|
||||
|
||||
let application = GTKWindow::init();
|
||||
|
||||
application.get_application().run();
|
||||
thread::spawn(|| {
|
||||
moonhare_log::info("Created Window thread");
|
||||
let application = GTKWindow::init();
|
||||
application.get_application().run();
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
use gtk4::{gio::prelude::ApplicationExt, prelude::{GtkWindowExt, WidgetExt}, Application, ApplicationWindow};
|
||||
|
||||
use gtk4::{gio::prelude::{ApplicationExt, ApplicationExtManual}, glib::object::ObjectExt, prelude::{GtkWindowExt, WidgetExt}, subclass::prelude::GtkApplicationImpl, Application, ApplicationWindow};
|
||||
|
||||
use crate::{MoonhareWindow, WindowResult};
|
||||
use crate::{window_config, MoonhareWindow};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct GTKWindow {
|
||||
|
|
@ -18,11 +16,12 @@ impl GTKWindow {
|
|||
|
||||
fn build_ui(application: &Application) {
|
||||
let window = ApplicationWindow::new(application);
|
||||
window.set_title(Some("Moonhare Engine GTK"));
|
||||
window.set_default_size(1280, 720);
|
||||
let window_config = window_config::WindowConfig::default();
|
||||
window.set_title(Some(format!("{} GTK", window_config.title).as_str()));
|
||||
window.set_default_size(window_config.width as i32, window_config.height as i32);
|
||||
window.set_visible(window_config.visble);
|
||||
|
||||
window.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue