pub struct Grid {
pub cursor: Option<(u16, u16)>,
pub caret: Option<Bounds>,
pub paint: Vec<Paint>,
pub bands: Vec<u16>,
/* private fields */
}Fields§
§cursor: Option<(u16, u16)>§caret: Option<Bounds>The caret’s exact place on the pixel tiers, when text isn’t on whole cells.
paint: Vec<Paint>Drawn over the cells on the pixel tiers, in order.
bands: Vec<u16>Columns where a new band starts, in order. Each band of a row is its own tile, so text that scrolls isn’t tied to whatever the sidebar or minimap shows at that height.
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn scroll_rows(&mut self, top: u16, bottom: u16, by: i32)
pub fn scroll_rows(&mut self, top: u16, bottom: u16, by: i32)
Moves rows top..=bottom up by by rows, or down if negative, across the whole width,
as a terminal’s scroll region does. The rows left behind hold nothing any real cell
matches, so the next diff draws them.
pub fn new(width: u16, height: u16, style: Style) -> Self
Sourcepub fn label(
&mut self,
x: u16,
y: u16,
text: &str,
style: Style,
max_x: u16,
) -> u16
pub fn label( &mut self, x: u16, y: u16, text: &str, style: Style, max_x: u16, ) -> u16
Text in the interface font on the pixel tiers, and ordinary cells on the cell tier.
Sourcepub fn painted_so_far(&self) -> usize
pub fn painted_so_far(&self) -> usize
How much has been painted so far, to lift_since later.
Sourcepub fn lift_since(&mut self, from: usize, rows: f32)
pub fn lift_since(&mut self, from: usize, rows: f32)
Moves what was painted since from up by rows, which only the pixel tiers can show:
the cells under it stay in their rows, and so does where a click lands.
Sourcepub fn label_at(
&mut self,
x_px: f32,
x: u16,
y: u16,
text: &str,
style: Style,
max_x: u16,
size: u8,
) -> u16
pub fn label_at( &mut self, x_px: f32, x: u16, y: u16, text: &str, style: Style, max_x: u16, size: u8, ) -> u16
A label starting between cells, at a size relative to the interface font.
Sourcepub fn text_run(
&mut self,
(x, y): (f32, f32),
max_x: f32,
text: &str,
(color, underline): (Rgb, bool),
font: Font,
)
pub fn text_run( &mut self, (x, y): (f32, f32), max_x: f32, text: &str, (color, underline): (Rgb, bool), font: Font, )
Paints a run of text with no cells behind it, at a place in cells and rows.
Sourcepub fn set_caret(&mut self, x: f32, y: u16, height: f32)
pub fn set_caret(&mut self, x: f32, y: u16, height: f32)
Puts the caret at a place between cells, height rows tall and centred on y.
Sourcepub fn label_right(
&mut self,
right: u16,
y: u16,
text: &str,
style: Style,
size: u8,
)
pub fn label_right( &mut self, right: u16, y: u16, text: &str, style: Style, size: u8, )
A label whose right edge sits at right, since proportional text is narrower than
its cells and would otherwise leave a gap at the end.
Sourcepub fn field(&mut self, rect: Rect, behind: Rgb, fill: Rgb, border: Rgb)
pub fn field(&mut self, rect: Rect, behind: Rgb, fill: Rgb, border: Rgb)
A rounded box inside rect, with square corners cleaned up behind it.
A rounded button in a row of its own. The cell tier shows cells, which may be
wider than the label.
A button that stands past its row, for where there’s air around it.
A large button centred between y and the row below it.
Sourcepub fn centred_text(&mut self, x: f32, y: f32, text: &str, color: Rgb, size: u8)
pub fn centred_text(&mut self, x: f32, y: f32, text: &str, color: Rgb, size: u8)
Paints text centred on x, at a place in rows.
pub fn panel( &mut self, bounds: Bounds, radius: u8, fill: Option<Rgb>, border: Option<Rgb>, )
Sourcepub fn dashed_panel(
&mut self,
bounds: Bounds,
radius: u8,
fill: Option<Rgb>,
border: Rgb,
)
pub fn dashed_panel( &mut self, bounds: Bounds, radius: u8, fill: Option<Rgb>, border: Rgb, )
A panel with its border in dashes, for something offered rather than settled.
Sourcepub fn popup(&mut self, bounds: Bounds, radius: u8, fill: Rgb, border: Rgb)
pub fn popup(&mut self, bounds: Bounds, radius: u8, fill: Rgb, border: Rgb)
A panel floating above the page, with a soft shadow.
Sourcepub fn wash(
&mut self,
bounds: Bounds,
radius: u8,
(color, alpha): (Rgb, u8),
border: Option<Rgb>,
)
pub fn wash( &mut self, bounds: Bounds, radius: u8, (color, alpha): (Rgb, u8), border: Option<Rgb>, )
A see-through wash of color over bounds, alpha out of 255, with a border.
pub fn hairline(&mut self, bounds: Bounds, color: Rgb)
Sourcepub fn glyph(
&mut self,
x: f32,
y: u16,
icon: Icon,
color: Rgb,
fallback: &str,
style: Style,
)
pub fn glyph( &mut self, x: f32, y: u16, icon: Icon, color: Rgb, fallback: &str, style: Style, )
A small icon, one row tall, with its left edge at x. fallback is what the cell
tier shows there.
Sourcepub fn corners(&mut self, bounds: Bounds, radius: u8, color: Rgb, which: u8)
pub fn corners(&mut self, bounds: Bounds, radius: u8, color: Rgb, which: u8)
Paint that touches row y, in drawing order.
pub fn paint_on_row(&self, y: u16) -> impl Iterator<Item = &Paint>
pub fn width(&self) -> u16
pub fn height(&self) -> u16
pub fn area(&self) -> Rect
pub fn cell(&self, x: u16, y: u16) -> &Cell
pub fn row(&self, y: u16) -> &[Cell]
pub fn fill(&mut self, rect: Rect, style: Style)
Sourcepub fn put_str(
&mut self,
x: u16,
y: u16,
text: &str,
style: Style,
max_x: u16,
) -> u16
pub fn put_str( &mut self, x: u16, y: u16, text: &str, style: Style, max_x: u16, ) -> u16
Writes text stopping before max_x, and returns the column after it. A wide
character that doesn’t fit becomes a space.
Sourcepub fn put_icon(
&mut self,
x: u16,
y: u16,
icon: Icon,
size: (u8, u8),
style: Style,
)
pub fn put_icon( &mut self, x: u16, y: u16, icon: Icon, size: (u8, u8), style: Style, )
Places a multi-cell icon with its top-left corner at x, y.
Sourcepub fn set_style(&mut self, rect: Rect, f: impl Fn(Style) -> Style)
pub fn set_style(&mut self, rect: Rect, f: impl Fn(Style) -> Style)
Overrides the style of existing cells, keeping their text.