From 15c4ae9bad74d467825ab413d0cfc3e1fcdac323 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Tue, 7 May 2024 08:49:49 -0400 Subject: [PATCH] Update the review tree when navigating --- otg/core/src/api.rs | 2 -- otg/core/src/goban.rs | 1 - otg/core/src/types.rs | 1 - otg/gtk/src/components/goban.rs | 11 ----------- otg/gtk/src/components/review_tree.rs | 6 ++++-- otg/gtk/src/views/game_review.rs | 10 ++++++++-- sgf/src/parser.rs | 1 - 7 files changed, 12 insertions(+), 20 deletions(-) diff --git a/otg/core/src/api.rs b/otg/core/src/api.rs index 153984b..9fe080c 100644 --- a/otg/core/src/api.rs +++ b/otg/core/src/api.rs @@ -115,8 +115,6 @@ pub struct Core { impl Core { pub fn new(config: Config) -> Self { - println!("config: {:?}", config); - let library = match config.get::() { Some(ref path) if path.to_path_buf().exists() => { Some(Database::open_path(path.to_path_buf()).unwrap()) diff --git a/otg/core/src/goban.rs b/otg/core/src/goban.rs index 04d659b..ab0d0d8 100644 --- a/otg/core/src/goban.rs +++ b/otg/core/src/goban.rs @@ -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!( diff --git a/otg/core/src/types.rs b/otg/core/src/types.rs index 5b9943a..b2dc076 100644 --- a/otg/core/src/types.rs +++ b/otg/core/src/types.rs @@ -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 { diff --git a/otg/gtk/src/components/goban.rs b/otg/gtk/src/components/goban.rs index a68b2d2..fff1fa0 100644 --- a/otg/gtk/src/components/goban.rs +++ b/otg/gtk/src/components/goban.rs @@ -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 diff --git a/otg/gtk/src/components/review_tree.rs b/otg/gtk/src/components/review_tree.rs index b6d4880..3aff89a 100644 --- a/otg/gtk/src/components/review_tree.rs +++ b/otg/gtk/src/components/review_tree.rs @@ -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)] diff --git a/otg/gtk/src/views/game_review.rs b/otg/gtk/src/views/game_review.rs index 54f6e86..e799109 100644 --- a/otg/gtk/src/views/game_review.rs +++ b/otg/gtk/src/views/game_review.rs @@ -67,6 +67,7 @@ impl GameReview { pub struct GameReview { widget: gtk::Box, goban: Rc>>, + review_tree: Rc>>, resources: ResourceManager, view: Rc>, @@ -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) { diff --git a/sgf/src/parser.rs b/sgf/src/parser.rs index b3dbd25..8492dd2 100644 --- a/sgf/src/parser.rs +++ b/sgf/src/parser.rs @@ -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");