WIP, changing state system
This commit is contained in:
parent
e355399c4a
commit
679fd3e275
47
src/main.rs
47
src/main.rs
@ -20,22 +20,39 @@ use std::fs::File;
|
||||
|
||||
//////////////////// Data Layout ////////////////////
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||
#[serde(default)]
|
||||
struct Node {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
|
||||
pub name: String,
|
||||
pub edges: HashSet<usize>,
|
||||
pub labels: HashMap<String, String>,
|
||||
}
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||
#[serde(default)]
|
||||
struct Board {
|
||||
labels: HashMap<String, Vec<String>>,
|
||||
nodes: HashMap<usize, Node>,
|
||||
}
|
||||
impl Board {
|
||||
pub fn new() -> Self {
|
||||
let nodes = HashMap::new();
|
||||
Board { nodes }
|
||||
let labels = HashMap::new();
|
||||
Board { nodes, labels }
|
||||
}
|
||||
|
||||
pub fn new_node(&mut self, x: f32, y: f32) -> usize {
|
||||
let id = self.next_id();
|
||||
self.nodes.insert(id, Node {
|
||||
x,
|
||||
y,
|
||||
name: String::new(),
|
||||
edges: HashSet::new(),
|
||||
labels: HashMap::new(),
|
||||
});
|
||||
id
|
||||
}
|
||||
|
||||
pub fn add_node(&mut self, x: f32, y: f32, name: String) {
|
||||
@ -44,6 +61,7 @@ impl Board {
|
||||
y,
|
||||
name,
|
||||
edges: HashSet::new(),
|
||||
labels: HashMap::new(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -85,6 +103,29 @@ impl Board {
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////// Node Create/Edit Dialogs ////////////////////
|
||||
fn node_create_dialog(state: &mut AppState, pos_x: f32, pos_y: f32) {
|
||||
let mut win = window::Window::default()
|
||||
.with_size(100, 100)
|
||||
.with_pos(app::event_x_root(), app::event_y_root());
|
||||
let flex = group::Flex::default()
|
||||
.column()
|
||||
.size_of_parent()
|
||||
.center_of_parent();
|
||||
frame::Frame::default().with_label("Name:");
|
||||
let name = input::Input::default();
|
||||
let mut btn = button::Button::default()
|
||||
.with_label("Create");
|
||||
flex.end();
|
||||
win.end();
|
||||
win.make_resizable(true);
|
||||
win.make_modal(true);
|
||||
win.show();
|
||||
while win.shown() {
|
||||
app::wait();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////// Dispatching Functions ////////////////////
|
||||
|
||||
mod dispatch {
|
||||
|
Loading…
Reference in New Issue
Block a user