From 9f85f633a31f1c34fe557cddf356a19ea32e67c5 Mon Sep 17 00:00:00 2001 From: Takeshi Tsukamoto Date: Thu, 13 Jun 2024 15:09:12 +0900 Subject: [PATCH] Enable toggle in home --- src/components/runners.rs | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/components/runners.rs b/src/components/runners.rs index 1910ddf..925d4a3 100644 --- a/src/components/runners.rs +++ b/src/components/runners.rs @@ -85,6 +85,62 @@ impl RunnersComponent { Ok(()) } + fn toggle_debug_paint(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleDebugPaint.into())?; + Ok(()) + } + + fn toggle_debug_paint_baselines(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleDebugPaintBaselines.into())?; + Ok(()) + } + + fn toggle_invert_overized_images(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleInvertOversizedImages.into())?; + Ok(()) + } + + fn toggle_repaint_rainbow(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleRepaintRainbow.into())?; + Ok(()) + } + + fn toggle_show_performance_overlay(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleShowPerformanceOverlay.into())?; + Ok(()) + } + + fn toggle_slow_animations(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleSlowAnimations.into())?; + Ok(()) + } + + fn toggle_widget_inspector(&self) -> Result<()> { + self.action_tx + .as_ref() + .ok_or_else(|| eyre!("action_tx is None"))? + .send(ThunkAction::ToggleWidgetInspector.into())?; + Ok(()) + } + fn stop_app(&self) -> Result<()> { self.action_tx .as_ref() @@ -116,6 +172,13 @@ impl Component for RunnersComponent { match key.code { KeyCode::Char('r') => self.hot_reload()?, KeyCode::Char('R') => self.hot_restart()?, + KeyCode::Char('i') => self.toggle_widget_inspector()?, + KeyCode::Char('p') => self.toggle_debug_paint()?, + KeyCode::Char('P') => self.toggle_show_performance_overlay()?, + KeyCode::Char('b') => self.toggle_debug_paint_baselines()?, + KeyCode::Char('I') => self.toggle_invert_overized_images()?, + KeyCode::Char('o') => self.toggle_repaint_rainbow()?, + KeyCode::Char('s') => self.toggle_slow_animations()?, KeyCode::Char('d') => self.stop_app()?, KeyCode::Up | KeyCode::Char('k') => self.previous()?, KeyCode::Down | KeyCode::Char('j') => self.next()?,