initial layout
This commit is contained in:
commit
1452662862
|
@ -0,0 +1,3 @@
|
|||
/target
|
||||
/.idea/
|
||||
/Cargo.lock
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "mixsy-gtk"
|
||||
version = "0.1.0"
|
||||
authors = ["Max Bradbury <max@tinybird.info>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
gio = "^0"
|
||||
gtk = "^0"
|
|
@ -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::<Vec<_>>());
|
||||
}
|
Loading…
Reference in New Issue