commit 1452662862413f2e4ecfb715f25e7280e23a84bd Author: Max Bradbury Date: Fri Sep 25 10:53:11 2020 +0100 initial layout diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8ec11bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +/.idea/ +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a7a32fc --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "mixsy-gtk" +version = "0.1.0" +authors = ["Max Bradbury "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +gio = "^0" +gtk = "^0" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..0669bff --- /dev/null +++ b/src/main.rs @@ -0,0 +1,86 @@ +#![windows_subsystem = "windows"] + +use gio::prelude::*; +use gtk::prelude::*; +use gtk::{Orientation, Adjustment}; +use std::env::args; + +const SPACING: i32 = 16; + +fn error_popup(message: &str) { + let popup = gtk::Window::new(gtk::WindowType::Toplevel); + popup.set_title("error"); + popup.set_border_width(SPACING as u32); + popup.set_position(gtk::WindowPosition::Center); + popup.set_default_size(256, 64); + + let vertical = gtk::Box::new(Orientation::Vertical, SPACING); + popup.add(&vertical); + + let message = gtk::Label::new(Some(message)); + vertical.add(&message); + + let button_ok = gtk::Button::with_label("OK"); + vertical.add(&button_ok); + + popup.show_all(); + + button_ok.connect_clicked(move |_| unsafe { + popup.destroy(); + }); +} + +fn add_text_box(container: >k::Box, label: &str) -> gtk::TextView { + let vertical = gtk::Box::new(Orientation::Vertical, SPACING); + vertical.set_property_expand(true); + + let label = gtk::Label::new(Some(label)); + vertical.add(&label); + + let h: Option<>k::Adjustment> = None; + let v: Option<>k::Adjustment> = None; + let scrolled_window = gtk::ScrolledWindow::new(h, v); + scrolled_window.set_property_expand(true); + let text_view = gtk::TextView::new(); + scrolled_window.add(&text_view); + vertical.add(&scrolled_window); + + container.add(&vertical); + + text_view +} + +fn build_ui(application: >k::Application) { + let window = gtk::ApplicationWindow::new(application); + + window.set_title("mixsy"); + window.set_border_width(SPACING as u32); + window.set_position(gtk::WindowPosition::Center); + window.set_default_size(396, 512); + + let vertical = gtk::Box::new(Orientation::Vertical, SPACING); + + let input_main = add_text_box(&vertical, "main game data"); + let input_additional = add_text_box(&vertical, "additional game data"); + + let button = gtk::Button::with_label("mix!"); + vertical.add(&button); + + let output = add_text_box(&vertical, "output"); + + window.add(&vertical); + window.show_all(); +} + +fn main() { + let application = gtk::Application::new( + Some("dev.tinybird.max.mixsy"), + Default::default() + ).expect("Initialization failed..."); + + application.connect_activate(|app| { + build_ui(app); + }); + + application.run(&args().collect::>()); +}