Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

Style

Struct Style 

Source
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 BitmapFont

The 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: u8

Integer pixel scale: every font pixel becomes a scale-square.

§label: &'static str

The label, ASCII.

§tail: Tail

What follows the label.

§ink_dim: Rgb

The darkest ink of the breathing.

§ink_bright: Rgb

The brightest ink of the breathing. Equal to ink_dim for a steady ink.

§ground: Rgb

The 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: i16

Horizontal space between the box edge and the content.

§pad_y: i16

Vertical space between the box edge and the content.

§centre_x: i16

Screen x the box is centred on.

§top: i16

Screen 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: u16

VBlanks per tail step.

§pulse_ticks: u16

VBlanks per full breath (dim to bright and back). Even and at least twice LEVELS; a smaller value is raised to that.

§blend: Blend

How 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

Source

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.

Source

pub const fn with_breath(self, dim: Rgb, bright: Rgb) -> Self

The same style breathing between dim and bright.

Source

pub const fn with_tail(self, tail: Tail) -> Self

The same style with tail after the label.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub const fn with_blend(self, blend: Blend) -> Self

The same style with the spinner’s lights blended by blend.

Source

pub const fn ring_size(&self) -> (i16, i16)

The ring’s width and height in pixels.

Source

pub const fn scaled(self, scale: u8) -> Self

The same style at integer scale scale (at least 1).

Source

pub const fn with_rule(self, rule: Rgb) -> Self

The same style with rule along the box’s top edge.

Source

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.

Source

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.

Source

pub fn bounds(&self) -> (i16, i16, i16, i16)

The box as (x, y, width, height) in screen pixels.

Source

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.

Source

pub const fn ink(&self, level: u8) -> Rgb

The ink colour at level.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Style

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for Style

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.