input_mode_during
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user