diff --git a/Cargo.lock b/Cargo.lock index f4a56e9..7039c06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -864,6 +864,14 @@ dependencies = [ [[package]] name = "falling-sand" version = "0.1.0" +dependencies = [ + "cairo-rs", + "gio", + "glib", + "glib-build-tools 0.17.10", + "gtk4", + "libadwaita", +] [[package]] name = "fastrand" diff --git a/falling-sand/Cargo.toml b/falling-sand/Cargo.toml index 9fc91e6..17167fc 100644 --- a/falling-sand/Cargo.toml +++ b/falling-sand/Cargo.toml @@ -6,3 +6,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +adw = { version = "0.5", package = "libadwaita", features = [ "v1_4" ] } +cairo-rs = { version = "0.18" } +gio = { version = "0.18" } +glib = { version = "0.18" } +gtk = { version = "0.7", package = "gtk4", features = [ "v4_10" ] } + +[build-dependencies] +glib-build-tools = "0.17" \ No newline at end of file diff --git a/falling-sand/src/main.rs b/falling-sand/src/main.rs index e7a11a9..7d80c4a 100644 --- a/falling-sand/src/main.rs +++ b/falling-sand/src/main.rs @@ -1,3 +1,51 @@ -fn main() { - println!("Hello, world!"); +use cairo::Context; +use glib::Object; +use gtk::{prelude::*, subclass::prelude::*}; + +const WIDTH: i32 = 600; +const HEIGHT: i32 = 600; + +#[derive(Debug, Default)] +pub struct SandPrivate; + +#[glib::object_subclass] +impl ObjectSubclass for SandPrivate { + const NAME: &'static str = "Sand"; + type Type = Sand; + type ParentType = gtk::DrawingArea; +} + +impl ObjectImpl for SandPrivate {} +impl WidgetImpl for SandPrivate {} +impl DrawingAreaImpl for SandPrivate {} + +glib::wrapper! { + pub struct Sand(ObjectSubclass) @extends gtk::DrawingArea, gtk::Widget; +} + +impl Sand { + pub fn new() -> Self { + let s: Self = Object::builder().build(); + s.set_width_request(WIDTH); + s.set_height_request(HEIGHT); + + s + } +} + +fn main() { + let app = gtk::Application::builder() + .application_id("com.luminescent-dreams.falling-sand") + .build(); + + app.connect_activate(move |app| { + let window = gtk::ApplicationWindow::new(app); + window.present(); + + let sand = Sand::new(); + + window.set_child(Some(&sand)); + }); + + app.run(); }