Skip to main content

Palette

Struct Palette 

Source
#[non_exhaustive]
pub struct Palette {
Show 26 fields pub page: Color32, pub raised: Color32, pub overlay: Color32, pub well: Color32, pub sunken: Color32, pub bevel_light: Color32, pub bevel_dark: Color32, pub elevation: Color32, pub content: Color32, pub content_secondary: Color32, pub content_muted: Color32, pub action: Color32, pub content_on_action: Color32, pub danger: Color32, pub success: Color32, pub warning: Color32, pub info: Color32, pub border: Color32, pub info_surface: Color32, pub success_surface: Color32, pub warning_surface: Color32, pub danger_surface: Color32, pub row_hover: Color32, pub row_rule: Color32, pub row_selected: Color32, pub heats: [Color32; 5],
}
Expand description

The resolved colours this renderer needs, as flat values.

Built by the app from whatever it already uses to resolve a theme, then held and reused. Deliberately not a trait and not string-keyed: a bevel is painted per widget per frame, and a map lookup per edge is a cost with nothing to show for it.

#[non_exhaustive], so a colour added here is not a breaking change: build one with Palette::from_theme (the theme feature), or start from Palette::two_tone and set every colour the app resolves.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§page: Color32

surface-page.

§raised: Color32

surface-raised.

§overlay: Color32

surface-overlay.

§well: Color32

surface-well.

Required, not optional. makeover derives it for every theme, so a resolved palette without a well is not a thing that exists here. makeover-tui keeps its own Option for a different reason, since a terminal can have the colour and still be unable to show it.

§sunken: Color32

surface-sunken.

A surface set back from the one it sits on, by colour and nothing else. Not a well: a well is a hole with an edge, and this has no edge. An immediate-mode renderer paints an arbitrary rect, so unlike makeover-tui it has no excuse for declining this one.

Required rather than optional, on the same footing as well: all 31 themes makeover embeds author it.

§bevel_light: Color32

bevel-light.

§bevel_dark: Color32

bevel-dark.

§elevation: Color32

elevation.

What a surface that floats OVER the page is cast onto it with. The one intent here that is about a surface’s relationship to the page rather than about the surface, which is why it is a translucent near-black on every theme rather than something read off the palette’s own ramp.

Only for a surface that overlays. A menu, a tooltip, a modal. A surface in the layout takes a bevel, and reaching for this on a panel or a card is how a pre-Platinum look survives a conversion under a new name.

egui has a real answer for this where a terminal does not: see Palette::cast, which is the shadow to hand an egui::Frame.

§content: Color32

content.

Ordinary text.

§content_secondary: Color32

content-secondary.

Inactive but usable: it still answers a press. The middle tone of the three (wiki three-tone-convention), and the one an unchosen option in a choice field takes.

Not content_muted, which carries a claim: State::Disabled resolves to it, so a live control wearing it tells the user it will not answer. makeover-tui draws the same widget the same way from makeover-tui@230bf63.

A step of content toward the page, derived at load by makeover rather than authored, so it is read off the resolved theme here like any other token and never re-derived.

§content_muted: Color32

content-muted.

A field’s hint, and what makeover_layout::State::Disabled resolves to. Both readings come from the description rather than from here: State::Disabled names this intent by token.

§action: Color32

action-primary.

What a control is drawn in.

This is the intent CellPart exists to separate. A cell holding a control that takes the cell’s text colour is the drift CellPart names.

§content_on_action: Color32

content-on-action: ink that stays readable on action.

Derived by the theme with readable_on(action) rather than picked here, so a theme whose action hue is pale gets dark ink without this renderer knowing which themes those are.

The one thing that fills with action is the act a screen is for, the leading control, which is why this colour exists. A renderer that fills with the accent and leaves the label on the ordinary content colour is one theme change away from unreadable.

§danger: Color32

danger.

A field’s error message, a destructive control, a bar that has run over.

§success: Color32

success.

The three status intents arrive together and not one at a time: Tone is five members wide and a resolver missing one has to invent a colour for it, which is the substitution Palette::fill refuses.

§warning: Color32

warning.

§info: Color32

info.

§border: Color32

border, the authored line colour.

A neutral badge’s edge: a badge on the raised ground is raised too, so the edge is what draws it.

§info_surface: Color32

info-surface: raised with 12 percent of info. A badge’s fill.

The four tone surfaces arrive together for the status intents’ reason.

§success_surface: Color32

success-surface.

§warning_surface: Color32

warning-surface.

§danger_surface: Color32

danger-surface.

§row_hover: Color32

row-hover: the row under the pointer, at 9 percent.

§row_rule: Color32

row-rule: the hairline between rows and around a table, at 26 percent.

§row_selected: Color32

row-selected: a selected row, raised with 18 percent of the accent.

A fill and never a foreground, so a row that is red for a failure stays red while it is selected.

§heats: [Color32; 5]

heat-0 to heat-4: the measure ramp, quietest first, from the raised ground to the cursor row’s mix. Read through heat.

Implementations§

Source§

impl Palette

Source

pub const fn two_tone(page: Color32, ink: Color32) -> Self

Every surface page and every ink ink, with no cast shadow.

A starting point for the setters, legible on its own and wrong in every detail a theme decides: an app that resolves its own colours starts here and sets each one, and a colour added to this type later arrives at one of these two rather than as a compile error in every consumer.

Source

pub const fn page(self, colour: Color32) -> Self

Set page.

Source

pub const fn raised(self, colour: Color32) -> Self

Set raised.

Source

pub const fn overlay(self, colour: Color32) -> Self

Set overlay.

Source

pub const fn well(self, colour: Color32) -> Self

Set well.

Source

pub const fn sunken(self, colour: Color32) -> Self

Set sunken.

Source

pub const fn bevel_light(self, colour: Color32) -> Self

Source

pub const fn bevel_dark(self, colour: Color32) -> Self

Source

pub const fn elevation(self, colour: Color32) -> Self

Set elevation.

Source

pub const fn content(self, colour: Color32) -> Self

Set content.

Source

pub const fn content_secondary(self, colour: Color32) -> Self

Source

pub const fn content_muted(self, colour: Color32) -> Self

Source

pub const fn action(self, colour: Color32) -> Self

Set action.

Source

pub const fn content_on_action(self, colour: Color32) -> Self

Source

pub const fn danger(self, colour: Color32) -> Self

Set danger.

Source

pub const fn success(self, colour: Color32) -> Self

Set success.

Source

pub const fn warning(self, colour: Color32) -> Self

Set warning.

Source

pub const fn info(self, colour: Color32) -> Self

Set info.

Source

pub const fn border(self, colour: Color32) -> Self

Set border.

Source

pub const fn info_surface(self, colour: Color32) -> Self

Source

pub const fn success_surface(self, colour: Color32) -> Self

Source

pub const fn warning_surface(self, colour: Color32) -> Self

Source

pub const fn danger_surface(self, colour: Color32) -> Self

Source

pub const fn row_hover(self, colour: Color32) -> Self

Set row_hover.

Source

pub const fn row_rule(self, colour: Color32) -> Self

Set row_rule.

Source

pub const fn row_selected(self, colour: Color32) -> Self

Source

pub const fn heats(self, ramp: [Color32; 5]) -> Self

Set heats.

Source

pub fn from_theme(tokens: &SemanticTokens) -> Result<Self, MissingToken>

Every colour, read from a resolved makeover theme.

§Errors

MissingToken naming the first token the theme does not resolve. makeover derives every one of these for every shipped theme, so this fails only on a theme file missing a base intent.

Source§

impl Palette

Source

pub const fn fill(&self, fill: Fill) -> Option<Color32>

Resolve a surface intent, or None for one this renderer does not know.

A plain lookup, and no substitution.

Option, because Fill is #[non_exhaustive] and a total function over an open enum can only stay total by inventing a colour for a member it has never heard of. Every member the description has today is answered with Some.

Source

pub const fn tone(&self, tone: Tone) -> Color32

The colour a Tone reads as.

Total, unlike fill, and the difference is not an inconsistency. Fill is #[non_exhaustive] and Tone is not: the description layer settled tone at five members and grows surfaces, so a total function here cannot be made to invent a colour by an upstream release the way a total fill could.

Tone::Neutral is content rather than a colour of its own, which is what “an ordinary fact” means: a neutral badge is text in a box, not a fifth status.

Source

pub const fn heat(&self, heat: Heat) -> Option<Color32>

The fill a measure band sits on, or None at band 0, which is the ground and draws nothing. A band past the last reads as the last.

Source

pub const fn tone_surface(&self, tone: Tone) -> Color32

What a badge of this tone is filled with: its tone surface, or the raised surface for Tone::Neutral, as makeover-webview fills one.

Source

pub const fn tone_edge(&self, tone: Tone) -> Color32

What a badge of this tone is edged with: its tone, or border for Tone::Neutral, whose tone is the ink.

Source

pub const fn cast(&self) -> Shadow

The cast shadow for a surface that overlays the page.

What “overlaying” means in immediate mode, answered rather than skipped. egui already paints shadows for its menus and windows through egui::Frame::shadow, so the honest port is to hand that machinery the theme’s tone instead of egui’s own default, not to invent a painter here the way paint_bevel had to.

The geometry matches what makeover-webview composes, in points rather than pixels: a small downward offset and a wide soft blur. A Platinum-era menu sits just off the page rather than hovering above it.

egui::Frame::popup(ui.style())
    .shadow(palette.cast())
    .show(ui, |ui| { ui.label("over the page"); });
Source

pub const fn edge(&self, edge: Edge) -> Color32

Resolve a bevel edge intent.

Trait Implementations§

Source§

impl Clone for Palette

Source§

fn clone(&self) -> Self

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 Palette

Source§

impl Debug for Palette

Source§

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

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

impl Eq for Palette

Source§

impl PartialEq for Palette

Source§

fn eq(&self, other: &Self) -> 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 Palette

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.