Skip to main content

Theme

Struct Theme 

Source
pub struct Theme {
    pub bg: Color,
    pub panel_bg: Color,
    pub border: Color,
    pub title_bg: Color,
    pub fg: Color,
    pub accent: Color,
    pub hover_bg: Color,
    pub press_bg: Color,
    pub dim: Color,
}
Expand description

A palette of named color roles, rather than a CSS-style cascade: draw code picks the role it means (theme.accent, theme.border) and the active Theme decides what color that resolves to.

This crate has no opinion on how an app picks between DARK and LIGHT (a manual toggle key, a SystemTheme from Event::ThemeChanged, or just always the same one): it only owns the two palettes themselves, so an app doesn’t have to invent one from scratch.

§Examples

use retroglyph_widgets::Theme;

let theme = Theme::DARK;
assert_eq!(theme.fg, Theme::DARK.fg);
assert_ne!(theme.bg, Theme::LIGHT.bg);

Fields§

§bg: Color

The window/screen background, behind every panel.

§panel_bg: Color

A panel’s own background, layered over bg.

§border: Color

Panel borders and dividers.

§title_bg: Color

A panel title bar’s background.

§fg: Color

Default (non-emphasized) text.

§accent: Color

Emphasis: selection, focus rings, primary actions.

§hover_bg: Color

An interactive widget’s background while hovered.

§press_bg: Color

An interactive widget’s background while pressed.

§dim: Color

De-emphasized text (hints, secondary labels, disabled-looking text).

Implementations§

Source§

impl Theme

Source

pub const DARK: Self

A dark palette: light text on a near-black background.

Source

pub const LIGHT: Self

A light palette: dark text on a near-white background. Same role relationships as DARK (accent stays a legible blue, hover_bg/press_bg stay a step apart from panel_bg), inverted for contrast against a light background rather than just flipping each channel.

Contrast is higher than a typical OS light theme: retroglyph’s pseudo-graphics (gauges, progress bars, log lines) draw with a 2-color paletted look where every panel-bg/border/text pair has to be distinct at a glance with no sub-pixel anti-aliasing to soften the edges.

Trait Implementations§

Source§

impl Clone for Theme

Source§

fn clone(&self) -> Theme

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Theme

Source§

impl Debug for Theme

Source§

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

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

impl Eq for Theme

Source§

impl PartialEq for Theme

Source§

fn eq(&self, other: &Theme) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Theme

Auto Trait Implementations§

§

impl Freeze for Theme

§

impl RefUnwindSafe for Theme

§

impl Send for Theme

§

impl Sync for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<C> WithAlpha for C
where C: Copy,

Source§

fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>

Wraps self with alpha, storing alpha before the color in memory (see AlphaFirst).
Source§

fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>

Wraps self with alpha, storing alpha after the color in memory (see AlphaLast).