From a66df997bbf0c4066fabd16af56a95a68cbf05e9 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Tue, 11 Apr 2023 11:48:08 -0400 Subject: [PATCH] Toggle the color palette with Ctrl+W Doesn't work in VS Code's terminal, but that's OK. It works in Ubuntu's Terminal app. --- paint.css | 6 +++++- paint.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/paint.css b/paint.css index 3c2635d..223c6c8 100644 --- a/paint.css +++ b/paint.css @@ -6,7 +6,7 @@ Screen { layout: grid; grid-size: 1; grid-columns: 1fr; - grid-rows: 1fr 6; + grid-rows: 1fr 0; } #main-horizontal-split { @@ -22,6 +22,10 @@ Screen { grid-columns: 18 1fr; } +.show_colors_box #paint { + grid-rows: 1fr 6; +} + #editing-area { background: $surface-lighten-3; } diff --git a/paint.py b/paint.py index 0da4bd4..99c482a 100644 --- a/paint.py +++ b/paint.py @@ -261,6 +261,7 @@ class PaintApp(App): CSS_PATH = "paint.css" show_tools_box = var(True) + show_colors_box = var(True) selected_tool = var(Tool.pencil) selected_color = var(palette[0]) selected_char = var(" ") @@ -276,6 +277,14 @@ class PaintApp(App): self.remove_class("show_tools_box") else: self.add_class("show_tools_box") + + def watch_show_colors_box(self, show_colors_box: bool) -> None: + """Called when show_colors_box changes.""" + self.query_one("#colors_box").display = show_colors_box + if self.has_class("show_colors_box"): + self.remove_class("show_colors_box") + else: + self.add_class("show_colors_box") def watch_selected_tool(self, old_selected_tool: Tool, selected_tool: Tool) -> None: """Called when selected_tool changes.""" @@ -341,6 +350,8 @@ class PaintApp(App): self.exit() elif key == "ctrl+t": self.show_tools_box = not self.show_tools_box + elif key == "ctrl+w": + self.show_colors_box = not self.show_colors_box def on_button_pressed(self, event: Button.Pressed) -> None: """Called when a button is pressed."""