This commit is contained in:
2022-05-11 15:41:31 -05:00
parent 8300f2a254
commit 8c6f54054c
3 changed files with 28 additions and 29 deletions

View File

@@ -8,7 +8,6 @@ use rfd::FileDialog;
use board_builder::{ Board, CoordTransformer, read_board_from_file, write_board_to_file };
use std::path::Path;
use std::collections::HashMap;
use std::rc::Rc;
use std::cell::RefCell;
@@ -109,7 +108,7 @@ impl eframe::App for BoardBuilderApp {
} else {
PointerButton::Middle
};
let (x, y) = view.to_coords(pos);
let (x, y) = view.xform(pos);
self.dispatch_click(btn, x, y);
}
}
@@ -171,7 +170,7 @@ impl BoardBuilderApp {
Color32::BLACK
};
painter.text(
view.from_coords(node.x, node.y),
view.inv_xform(node.x, node.y),
Align2::CENTER_CENTER,
&node.name,
FontId::proportional(16.0),
@@ -181,7 +180,7 @@ impl BoardBuilderApp {
for edge in &node.edges {
let other_node = &board.nodes[edge];
painter.line_segment(
[view.from_coords(node.x, node.y), view.from_coords(other_node.x, other_node.y)],
[view.inv_xform(node.x, node.y), view.inv_xform(other_node.x, other_node.y)],
stroke,
);
}
@@ -294,7 +293,7 @@ impl EditLabelsDialog {
});
col[1].horizontal(|ui| {
if ui.button("+").clicked() {
todo!();
self.add_value_dialog.show();
}
if ui.button("-").clicked() {
todo!();
@@ -311,25 +310,6 @@ impl EditLabelsDialog {
}
}
#[derive(Default)]
struct EditNodeDialog {
open: bool,
name: String,
id: usize,
labels: HashMap<String, String>,
}
impl EditNodeDialog {
fn show(&mut self, id: usize, board: &Board) {
self.open = true;
let node = board.nodes.get(&id).unwrap();
self.id = id;
self.name = node.name.clone();
self.labels = node.labels.clone();
}
}
#[derive(Default)]
struct StringDialog {
@@ -373,3 +353,22 @@ impl StringDialog {
}
}
}
// #[derive(Default)]
// struct EditNodeDialog {
// open: bool,
// name: String,
// id: usize,
// labels: HashMap<String, String>,
// }
// impl EditNodeDialog {
// fn show(&mut self, id: usize, board: &Board) {
// self.open = true;
// let node = board.nodes.get(&id).unwrap();
// self.id = id;
// self.name = node.name.clone();
// self.labels = node.labels.clone();
// }
// }