input_mode_during

This commit is contained in:
2026-06-15 11:44:18 -05:00
parent 439fc44106
commit f2dc7861d9
4 changed files with 20 additions and 11 deletions
+9 -4
View File
@@ -2,10 +2,12 @@
//!
//! An animation encapsulates a time-bounded visual effect: it advances via
//! [`update`](Animation::update), renders via [`draw`](Animation::draw), and
//! reports its layer and which [`InputMode`] to enter when it finishes.
//!
//! **While any animation is running, all input is ignored.** The front-end checks
//! [`Ui::active_animation`](crate::ui::Ui::active_animation) before dispatching events.
//! reports its layer, which [`InputMode`] is active while it runs
//! ([`input_mode_during`](Animation::input_mode_during)), and which mode to
//! enter when it finishes ([`input_mode_after`](Animation::input_mode_after)).
//! Most animations use the default `input_mode_during` ([`InputMode::Ignore`]),
//! but open animations may advertise an interactive mode so the overlay is
//! responsive before the animation completes.
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
@@ -28,6 +30,9 @@ pub trait Animation {
fn draw(&self, area: Rect, buf: &mut Buffer);
/// Which region this animation draws to (board area vs. full overlay).
fn layer(&self) -> AnimationLayer;
/// Which [`InputMode`] is active while this animation is running.
/// Defaults to [`InputMode::Ignore`] (all input discarded).
fn input_mode_during(&self) -> InputMode { InputMode::Ignore }
/// Which [`InputMode`] to enter when the animation finishes.
fn input_mode_after(&self) -> InputMode;
}