pub struct Style {Show 17 fields
pub font: &'static BitmapFont,
pub scale: u8,
pub label: &'static str,
pub tail: Tail,
pub ink_dim: Rgb,
pub ink_bright: Rgb,
pub ground: Rgb,
pub rule: Option<Rgb>,
pub pad_x: i16,
pub pad_y: i16,
pub centre_x: i16,
pub top: i16,
pub min_size: (i16, i16),
pub step_ticks: u16,
pub pulse_ticks: u16,
pub blend: Blend,
pub ring: (i16, i16),
/* private fields */
}Expand description
What the indicator looks like and where it sits.
Build one with Style::new (a const fn, so a static or const works)
and refine it with the with_* methods.
Fields§
§font: &'static BitmapFontThe glyph source. Any [BitmapFont] works; the label is laid out with
the font’s advances (per glyph for a proportional font), and the box always
has room for the whole tail, so it does not change width as the tail steps.
scale: u8Integer pixel scale: every font pixel becomes a scale-square.
label: &'static strThe label, ASCII.
tail: TailWhat follows the label.
ink_dim: RgbThe darkest ink of the breathing.
ink_bright: RgbThe brightest ink of the breathing. Equal to ink_dim for a steady ink.
ground: RgbThe colour the box is filled with before the text, so each redraw erases the last one.
rule: Option<Rgb>A one-pixel line along the top edge of the box, if any.
pad_x: i16Horizontal space between the box edge and the content.
pad_y: i16Vertical space between the box edge and the content.
centre_x: i16Screen x the box is centred on.
top: i16Screen y of the box’s top edge.
min_size: (i16, i16)The smallest the box may be, (width, height): the content is centred in
it. (0, 0) sizes the box to its content plus the padding.
step_ticks: u16VBlanks per tail step.
pulse_ticks: u16VBlanks per full breath (dim to bright and back). Even and at least
twice LEVELS; a smaller value is raised to that.
blend: BlendHow the spinner’s lights blend with what is under them.
ring: (i16, i16)Spinner dot size and spacing between dot centres, in unscaled display units.
Implementations§
Source§impl Style
impl Style
Sourcepub const fn new(
font: &'static BitmapFont,
label: &'static str,
ink: Rgb,
ground: Rgb,
) -> Self
pub const fn new( font: &'static BitmapFont, label: &'static str, ink: Rgb, ground: Rgb, ) -> Self
A style with sensible defaults: scale 1, three dots a third of a second apart at 60 Hz (20 VBlanks), a steady ink, a breath of 64 VBlanks if one is asked for, the box centred horizontally on a 320-wide screen near the foot of the picture.
Sourcepub const fn with_breath(self, dim: Rgb, bright: Rgb) -> Self
pub const fn with_breath(self, dim: Rgb, bright: Rgb) -> Self
The same style breathing between dim and bright.
Sourcepub const fn at(self, centre_x: i16, top: i16) -> Self
pub const fn at(self, centre_x: i16, top: i16) -> Self
The same style with its box centred on centre_x, top edge at top.
Sourcepub const fn in_corner(
self,
size: i16,
screen_w: i16,
screen_h: i16,
margin: i16,
) -> Self
pub const fn in_corner( self, size: i16, screen_w: i16, screen_h: i16, margin: i16, ) -> Self
The same style as a square size pixels tall in the bottom-right corner of
a screen_w x screen_h picture, margin pixels in from the bottom edge:
the corner widget. With an empty label and a Tail::Spinner it is the small
black square with a ring of lights in it.
The square is square on the screen. A mode whose pixels are not square (512
wide at 240 lines on a 4:3 set, say) makes the box wider in pixels by the
pixel aspect (see with_display, which this calls), and
the side margin is stretched the same way so both margins look alike.
Sourcepub const fn with_display(self, width: i16, height: i16) -> Self
pub const fn with_display(self, width: i16, height: i16) -> Self
The same style told the display mode it is drawn in, width x height
pixels. A 4:3 television shows any mode at 4:3, so a pixel is
(4 / 3) * height / width times as wide as it is tall: square at 320 x 240
and 640 x 480, wide at 256 x 240, narrow at 512 x 240. The spinner and the
corner box are laid out in units one pixel tall and widened by that factor,
so they are square on the screen, not in the framebuffer.
Sourcepub const fn with_ring(self, dot: i16, pitch: i16) -> Self
pub const fn with_ring(self, dot: i16, pitch: i16) -> Self
The same style with spinner dots dot units square, pitch units between
the centres of neighbouring dots (units are one pixel tall before
scaled; the ring is three pitches and a dot across).
Sourcepub const fn with_blend(self, blend: Blend) -> Self
pub const fn with_blend(self, blend: Blend) -> Self
The same style with the spinner’s lights blended by blend.
Sourcepub const fn scaled(self, scale: u8) -> Self
pub const fn scaled(self, scale: u8) -> Self
The same style at integer scale scale (at least 1).
Sourcepub const fn with_rule(self, rule: Rgb) -> Self
pub const fn with_rule(self, rule: Rgb) -> Self
The same style with rule along the box’s top edge.
Sourcepub const fn padded(self, pad_x: i16, pad_y: i16) -> Self
pub const fn padded(self, pad_x: i16, pad_y: i16) -> Self
The same style with pad_x and pad_y between the content and the box edge.
Sourcepub const fn timed(self, step_ticks: u16, pulse_ticks: u16) -> Self
pub const fn timed(self, step_ticks: u16, pulse_ticks: u16) -> Self
The same style with the tail stepping every step_ticks VBlanks (at
least 1) and a full breath taking pulse_ticks.
Sourcepub fn bounds(&self) -> (i16, i16, i16, i16)
pub fn bounds(&self) -> (i16, i16, i16, i16)
The box as (x, y, width, height) in screen pixels.
Sourcepub const fn look(&self, tick: u32) -> Look
pub const fn look(&self, tick: u32) -> Look
The look at tick VBlanks after the indicator began.
The tail steps once every step_ticks and repeats. The ink follows a
triangle wave: dim, up to bright at half a breath, back to dim. With a
steady ink (ink_dim == ink_bright) the level is held at 0, so the
picture only changes when the tail steps.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnsafeUnpin for Style
impl UnwindSafe for Style
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)