Update the review tree when navigating
This commit is contained in:
parent
7dd531b493
commit
15c4ae9bad
|
@ -115,8 +115,6 @@ pub struct Core {
|
|||
|
||||
impl Core {
|
||||
pub fn new(config: Config) -> Self {
|
||||
println!("config: {:?}", config);
|
||||
|
||||
let library = match config.get::<LibraryPath>() {
|
||||
Some(ref path) if path.to_path_buf().exists() => {
|
||||
Some(Database::open_path(path.to_path_buf()).unwrap())
|
||||
|
|
|
@ -611,7 +611,6 @@ mod test {
|
|||
),
|
||||
];
|
||||
|
||||
println!("{}", board);
|
||||
for (board, coordinate, group, liberties) in test_cases {
|
||||
assert_eq!(board.group(&coordinate), group.as_ref());
|
||||
assert_eq!(
|
||||
|
|
|
@ -352,7 +352,6 @@ impl DepthTree {
|
|||
.unwrap()
|
||||
.traverse_pre_order()
|
||||
.fold(0, |max, node| {
|
||||
println!("node depth: {}", node.data().depth);
|
||||
if node.data().depth > max {
|
||||
node.data().depth
|
||||
} else {
|
||||
|
|
|
@ -102,22 +102,11 @@ impl Goban {
|
|||
}
|
||||
|
||||
pub fn set_board_state(&mut self, board_state: otg_core::Goban) {
|
||||
println!("updating board state");
|
||||
*self.imp().board_state.borrow_mut() = board_state;
|
||||
self.queue_draw();
|
||||
}
|
||||
|
||||
fn redraw(&self, ctx: &cairo::Context, width: i32, height: i32) {
|
||||
println!("{} x {}", width, height);
|
||||
/*
|
||||
let background = load_pixbuf(
|
||||
"/com/luminescent-dreams/otg-gtk/wood_texture.jpg",
|
||||
false,
|
||||
WIDTH + 40,
|
||||
HEIGHT + 40,
|
||||
);
|
||||
*/
|
||||
|
||||
let background = self
|
||||
.imp()
|
||||
.resource_manager
|
||||
|
|
|
@ -60,9 +60,11 @@ impl ReviewTree {
|
|||
s
|
||||
}
|
||||
|
||||
fn redraw(&self, ctx: &Context, _width: i32, _height: i32) {
|
||||
println!("redraw: {} {}", _width, _height);
|
||||
pub fn queue_draw(&self) {
|
||||
self.drawing_area.queue_draw();
|
||||
}
|
||||
|
||||
fn redraw(&self, ctx: &Context, _width: i32, _height: i32) {
|
||||
#[allow(deprecated)]
|
||||
let context = WidgetExt::style_context(&self.widget);
|
||||
#[allow(deprecated)]
|
||||
|
|
|
@ -67,6 +67,7 @@ impl GameReview {
|
|||
pub struct GameReview {
|
||||
widget: gtk::Box,
|
||||
goban: Rc<RefCell<Option<Goban>>>,
|
||||
review_tree: Rc<RefCell<Option<ReviewTree>>>,
|
||||
|
||||
resources: ResourceManager,
|
||||
view: Rc<RefCell<GameReviewViewModel>>,
|
||||
|
@ -80,7 +81,8 @@ impl GameReview {
|
|||
|
||||
let s = Self {
|
||||
widget,
|
||||
goban: Rc::new(RefCell::new(None)),
|
||||
goban: Default::default(),
|
||||
review_tree: Default::default(),
|
||||
resources,
|
||||
view,
|
||||
};
|
||||
|
@ -89,7 +91,6 @@ impl GameReview {
|
|||
keypress_controller.connect_key_pressed({
|
||||
let s = s.clone();
|
||||
move |_, key, _, _| {
|
||||
println!("keystroke: {}", key);
|
||||
let mut view = s.view.borrow_mut();
|
||||
match key {
|
||||
Key::Down => view.next_move(),
|
||||
|
@ -105,6 +106,10 @@ impl GameReview {
|
|||
Some(ref mut goban) => goban.set_board_state(view.game_view()),
|
||||
None => {}
|
||||
};
|
||||
match *s.review_tree.borrow() {
|
||||
Some(ref tree) => tree.queue_draw(),
|
||||
None => {}
|
||||
}
|
||||
Propagation::Stop
|
||||
}
|
||||
});
|
||||
|
@ -161,6 +166,7 @@ impl GameReview {
|
|||
self.widget.append(&sidebar);
|
||||
|
||||
*self.goban.borrow_mut() = Some(board);
|
||||
*self.review_tree.borrow_mut() = Some(review_tree);
|
||||
}
|
||||
|
||||
fn redraw(&self) {
|
||||
|
|
|
@ -306,7 +306,6 @@ impl Move {
|
|||
let column = column_char as u8 - b'a';
|
||||
let row_char = parts.next().unwrap();
|
||||
let row = row_char as u8 - b'a';
|
||||
println!("[{}] {} [{}] {}", row_char, row, column_char, column);
|
||||
Some((row, column))
|
||||
} else {
|
||||
unimplemented!("moves must contain exactly two characters");
|
||||
|
|
Loading…
Reference in New Issue