use crate::color::Style;
use crate::grid::{Grid, Offset, Pos, Rect, Size};
use super::Surface;
pub struct StyledSurface<'s, 'a> {
pub(super) surface: &'s mut Surface<'a>,
pub(super) style: Style,
}
impl<'a> StyledSurface<'_, 'a> {
#[must_use]
pub const fn style(&self) -> Style {
self.style
}
pub const fn surface(&mut self) -> &mut Surface<'a> {
self.surface
}
pub fn put(&mut self, pos: impl Into<Pos>, ch: char) {
self.surface.put(pos, ch, self.style);
}
pub fn print(&mut self, pos: impl Into<Pos>, text: &str) {
self.surface.print(pos, text, self.style);
}
pub fn fill_rect(&mut self, rect: Rect, ch: char) {
self.surface.fill_rect(rect, ch, self.style);
}
pub fn put_span<S: AsRef<str>>(&mut self, pos: impl Into<Pos>, rows: &[S]) -> Option<()> {
self.surface.put_span(pos, rows, self.style)
}
pub fn put_span_uniform(
&mut self,
pos: impl Into<Pos>,
size: impl Into<Size>,
anchor: char,
fill: char,
) -> Option<()> {
self.surface
.put_span_uniform(pos, size, anchor, fill, self.style)
}
pub fn put_offset(&mut self, pos: impl Into<Pos>, offset: impl Into<Offset>, ch: char) {
self.surface.put_offset(pos, offset, ch, self.style);
}
pub fn put_signed(&mut self, pos: (i32, i32), ch: char) {
self.surface.put_signed(pos, ch, self.style);
}
pub fn blit(&mut self, grid: &Grid, x: u16, y: u16) {
self.surface.blit(grid, x, y);
}
pub fn clear(&mut self) {
self.surface.clear();
}
pub fn clear_region(&mut self, rect: Rect) {
self.surface.clear_region(rect);
}
#[must_use]
pub const fn width(&self) -> u16 {
self.surface.width()
}
#[must_use]
pub const fn height(&self) -> u16 {
self.surface.height()
}
#[must_use]
pub const fn area(&self) -> Rect {
self.surface.area()
}
#[must_use]
pub const fn clip_rect(&self) -> Rect {
self.surface.clip_rect()
}
#[must_use]
pub const fn local_area(&self) -> Rect {
self.surface.area().at_origin()
}
}