pub struct Palette {
pub paper: Color32,
pub ink: Color32,
pub link: Color32,
}Expand description
The colours a document is drawn in where the document itself does not say.
The document’s own colours are always the document’s: a colour the author
set is drawn as set, whatever the window’s theme. Where a document sets
none, Palette::for_theme follows the window instead of staying fixed —
paper and ink move together, the way a page and its own unset text would
if it were reprinted for the window it is read in, so a document that
never colours itself is legible in both. The chrome around the page —
menus, panels, the grid’s headers — already follows the desktop by the
same principle, one level up.
This does not reach a document that colours its own text but leaves the page unset: that colour is drawn as set, on paper that now follows the window, and an author’s own dark heading can still land on dark paper. That is the narrower case the old, page-only version of this rule was written against; recolouring an author’s own choice for contrast is a larger step than this file takes.
link is the one colour that does not follow this rule: link_format
draws every hyperlink in it regardless of what the document says, because
almost every ODF producer writes a resolved colour into a hyperlink’s
character style whether an author touched it or not — “the document set
a colour” is barely ever true of a link’s blue in the way it is of a
heading’s, so treating it as an author’s choice would mean this file’s
dark mode never reaching almost any real hyperlink.
Fields§
§paper: Color32What the page itself is.
ink: Color32The colour of text the document does not colour.
link: Color32The colour every hyperlink is drawn in, whatever the document says.
Implementations§
Source§impl Palette
impl Palette
Sourcepub fn for_theme(dark_mode: bool) -> Self
pub fn for_theme(dark_mode: bool) -> Self
The palette for a window in, or not in, dark mode.
All three move together, because they are the unset document’s own page and the unset document’s own text, and a page redrawn dark with text left black would be unreadable rather than themed. The dark ink is an off-white rather than pure white, and the dark link a lighter, more saturated blue than the light palette’s — both chosen to meet WCAG AA contrast against the dark paper (measured: ink 11.2:1, link 5.4:1; AA needs 4.5:1) rather than merely looking legible in one shot.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Palette
impl RefUnwindSafe for Palette
impl Send for Palette
impl Sync for Palette
impl Unpin for Palette
impl UnsafeUnpin for Palette
impl UnwindSafe for Palette
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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