From c9c8eacfc7392eab1a18d1a6905e808dfc4c3b80 Mon Sep 17 00:00:00 2001 From: blamarche Date: Wed, 9 Dec 2020 18:36:31 -0500 Subject: [PATCH] Utilize redraw trigger for board coordinates toggle --- CONTRIBUTIONS.md | 1 + README.md | 1 + katrain/__main__.py | 5 +---- katrain/gui/badukpan.py | 8 ++++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md index 85b2c31..61e4cbb 100644 --- a/CONTRIBUTIONS.md +++ b/CONTRIBUTIONS.md @@ -49,6 +49,7 @@ Many thanks to these additional authors: * "ajkenny84" for the red-green colourblind theme. * Lukasz Wierzbowski for the ability to paste urls for sgfs and helping fix alt-gr issues. * Carton He for a fix to handling empty komi values in sgfs. +* "blamarche" for adding the board coordinates toggle ## Translators diff --git a/README.md b/README.md index 32289e1..1e467ba 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ In addition to shortcuts mentioned above and those shown in the main menu: * **[Alt]**: Open the main menu. * **[~]** or **[ ` ]** or **[F12]**: Cycles through more minimalistic UI modes. +* **[k]**: Toggle display of board coordinates. * **[p]**: Pass * **[pause]**: Pause/Resume timer * **[arrow left]** or **[z]**: Undo move. Hold shift for 10 moves at a time, or ctrl to skip to the start. diff --git a/katrain/__main__.py b/katrain/__main__.py index 41613f0..52c2d3c 100644 --- a/katrain/__main__.py +++ b/katrain/__main__.py @@ -138,9 +138,6 @@ class KaTrainGui(Screen, KaTrainBase): self.idle_analysis = not self.idle_analysis self.update_state() - def toggle_board_coordinates(self): - self.board_gui.enable_coordinates(not self.board_gui.get_enable_coordinates()) - def start(self): if self.engine: return @@ -549,7 +546,7 @@ class KaTrainGui(Screen, KaTrainBase): elif keycode[1] == "spacebar": self.toggle_continuous_analysis() elif keycode[1] == "k": - self.toggle_board_coordinates() + self.board_gui.toggle_coordinates() elif keycode[1] in ["pause", "break", "f15"] and not ctrl_pressed: self.controls.timer.paused = not self.controls.timer.paused elif keycode[1] in ["`", "~", "f12"]: diff --git a/katrain/gui/badukpan.py b/katrain/gui/badukpan.py index 19bf84d..2912a30 100644 --- a/katrain/gui/badukpan.py +++ b/katrain/gui/badukpan.py @@ -62,10 +62,10 @@ class BadukPanWidget(Widget): self.bind(size=self.redraw_trigger, pos=self.redraw_trigger) Clock.schedule_interval(self.animate_pv, 0.1) - def enable_coordinates(self, enabled): - self.draw_coords_enabled = enabled - self.draw_board() - self.draw_board_contents() + def toggle_coordinates(self): + self.draw_coords_enabled = not self.draw_coords_enabled + self.redraw_trigger() + return self.draw_coords_enabled def get_enable_coordinates(self): return self.draw_coords_enabled