use crate::alignment;
use crate::text::{Difference, Hit, Text};
use crate::{Point, Size};
pub trait Paragraph: Sized + Default {
type Font: Copy + PartialEq;
fn with_text(text: Text<'_, Self::Font>) -> Self;
fn resize(&mut self, new_bounds: Size);
fn compare(&self, text: Text<'_, Self::Font>) -> Difference;
fn horizontal_alignment(&self) -> alignment::Horizontal;
fn vertical_alignment(&self) -> alignment::Vertical;
fn min_bounds(&self) -> Size;
fn hit_test(&self, point: Point) -> Option<Hit>;
fn grapheme_position(&self, line: usize, index: usize) -> Option<Point>;
fn update(&mut self, text: Text<'_, Self::Font>) {
match self.compare(text) {
Difference::None => {}
Difference::Bounds => {
self.resize(text.bounds);
}
Difference::Shape => {
*self = Self::with_text(text);
}
}
}
fn min_width(&self) -> f32 {
self.min_bounds().width
}
fn min_height(&self) -> f32 {
self.min_bounds().height
}
}