pub use crossterm::event::{KeyEvent, MouseEvent};
use ratatui::{layout::Rect, widgets::StatefulWidget, Frame};
use crate::{selection::Selection, widgets::legend::LegendSection};
pub trait InteractiveStatefulWidget: StatefulWidget {
type Input;
type Event;
fn update_state(state: &mut Self::State, input: Self::Input);
fn handle_event(_state: &mut Self::State, _event: Self::Event) -> bool {
false
}
}
pub trait Mode {
type Dag;
fn name(&self) -> &'static str;
fn keybindings(&self) -> &'static [(&'static str, &'static str)];
fn current_selection(&self) -> Option<Selection>;
fn legend_sections(&self) -> Vec<LegendSection> {
Vec::new()
}
fn take_clicked_error(&mut self) -> Option<String> {
None
}
fn update(&mut self, dag: Option<&Self::Dag>, error: Option<String>);
fn handle_key(&mut self, _key: KeyEvent) -> bool {
false
}
fn handle_mouse(&mut self, _mouse: MouseEvent) -> bool {
false
}
fn render(&mut self, frame: &mut Frame, area: Rect);
}