use crate::input::{Action, FocusEvent, ModKeys, MouseEvent};
use crate::layout::{Cells, Dim, LengthBound, Pos};
use crate::text::{StyleGroup, Theme, WidgetGroup};
use crate::widget::{Border, Button, ScrollView};
use crate::Result;
pub trait Widget {
fn widget_group(&self) -> WidgetGroup {
WidgetGroup::Normal
}
fn style_group(&self) -> StyleGroup {
StyleGroup::Enabled
}
fn width_bounds(&self, _theme: &Theme) -> LengthBound {
LengthBound::default()
}
fn height_bounds(&self, _theme: &Theme, _width: u16) -> LengthBound {
LengthBound::default()
}
fn draw(&self, _cells: &mut Cells, _offset: Pos) -> Result<()> {
Ok(())
}
fn focus(&self, _fev: FocusEvent) -> Option<Action> {
None
}
fn mouse_event(
&self,
_mev: MouseEvent,
_mods: ModKeys,
_dim: Dim,
_pos: Pos,
) -> Option<Action> {
None
}
fn into_border(self) -> Border<Self>
where
Self: Sized,
{
Border::new(self)
}
fn into_button(self) -> Border<Button<Self>>
where
Self: Sized,
{
Border::new(Button::new(self))
}
fn into_scroll_view(self) -> ScrollView<Self>
where
Self: Sized,
{
ScrollView::new(self)
}
}