#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct Vertex {
pub position: [f32; 2],
pub tex_coords: [f32; 2],
}
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct BackgroundInstance {
pub position: [f32; 2],
pub size: [f32; 2],
pub color: [f32; 4],
}
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct TextInstance {
pub position: [f32; 2],
pub size: [f32; 2],
pub tex_offset: [f32; 2],
pub tex_size: [f32; 2],
pub color: [f32; 4],
pub is_colored: u32, }
pub use par_term_config::Cell;
#[derive(Clone, Debug)]
pub(crate) struct GlyphInfo {
#[allow(dead_code)] pub key: u64,
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
pub bearing_x: f32,
pub bearing_y: f32,
pub is_colored: bool,
pub prev: Option<u64>,
pub next: Option<u64>,
}
pub(crate) type RowCacheEntry = bool;
#[derive(Clone, Copy, Debug, Default)]
pub struct PaneViewport {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub focused: bool,
pub opacity: f32,
pub padding: f32,
pub content_offset_x: f32,
pub content_offset_y: f32,
}
impl PaneViewport {
pub fn new(x: f32, y: f32, width: f32, height: f32, focused: bool, opacity: f32) -> Self {
Self {
x,
y,
width,
height,
focused,
opacity,
padding: 0.0,
content_offset_x: 0.0,
content_offset_y: 0.0,
}
}
pub fn with_padding(
x: f32,
y: f32,
width: f32,
height: f32,
focused: bool,
opacity: f32,
padding: f32,
) -> Self {
Self {
x,
y,
width,
height,
focused,
opacity,
padding,
content_offset_x: 0.0,
content_offset_y: 0.0,
}
}
pub fn to_scissor_rect(&self) -> (u32, u32, u32, u32) {
(
self.x.max(0.0) as u32,
self.y.max(0.0) as u32,
self.width.max(1.0) as u32,
self.height.max(1.0) as u32,
)
}
pub fn content_origin(&self) -> (f32, f32) {
(
self.x + self.padding + self.content_offset_x,
self.y + self.padding + self.content_offset_y,
)
}
pub fn content_size(&self) -> (f32, f32) {
(
(self.width - self.padding * 2.0).max(1.0),
(self.height - self.padding * 2.0).max(1.0),
)
}
pub fn grid_size(&self, cell_width: f32, cell_height: f32) -> (usize, usize) {
let (content_width, content_height) = self.content_size();
let cols = (content_width / cell_width).floor() as usize;
let rows = (content_height / cell_height).floor() as usize;
(cols.max(1), rows.max(1))
}
}