use std::time::Duration;
use ratatui::Frame;
use ratatui::crossterm::event::{KeyEvent, MouseEvent};
use ratatui::layout::Rect;
use crate::frame::Binding;
use crate::theme::{Gradients, Theme};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KeyOutcome {
Consumed,
Ignored,
}
#[derive(Debug, Clone, Copy)]
pub struct RenderContext<'a> {
pub theme: &'a Theme,
pub gradients: &'a Gradients,
pub focused: bool,
}
pub trait Panel {
fn title(&self) -> String;
fn counter(&self) -> Option<String> {
None
}
fn bindings(&self) -> &'static [Binding] {
&[]
}
fn max_width(&self) -> Option<u16> {
None
}
fn max_height(&self) -> Option<u16> {
None
}
fn refresh_interval(&self) -> Duration {
Duration::from_secs(1)
}
fn tick(&mut self) {}
fn render(&mut self, frame: &mut Frame, area: Rect, ctx: RenderContext<'_>);
fn handle_key(&mut self, _key: KeyEvent) -> KeyOutcome {
KeyOutcome::Ignored
}
fn handle_mouse(&mut self, _event: MouseEvent, _area: Rect) -> KeyOutcome {
KeyOutcome::Ignored
}
fn captures_input(&self) -> bool {
false
}
fn shutdown(&mut self) {}
}