pub struct Theme {Show 14 fields
pub dark: bool,
pub overlay_manager: OverlayManager,
pub image_tint_recommended: bool,
pub kind: ThemeKind,
pub colors: ThemeColors,
pub visuals: ThemeVisuals,
pub typography: Typography,
pub window_frame: Frame,
pub frame1: Frame,
pub frame2: Frame,
pub corner_radius: u8,
pub inner_margin: i8,
pub outer_margin: i8,
pub button_padding: Vec2,
}Expand description
Complete look: colors, typography, frames, and widget visuals.
Theme is Clone. Theme::install takes &mut self (the elegance
path records a key on self). Clone before install if you need to keep
an unmodified copy:
let mut theme = Theme::new(ThemeKind::TokyoNight);
theme.install(&ctx);Fields§
§dark: boolTrue if the theme is dark
overlay_manager: OverlayManagerTracks open windows so OverlayManager::paint_overlay can dim the canvas.
image_tint_recommended: boolTrue if a tint is recomended to be applied to images to soften the contrast between the image and the background
This is usually true for themes with very dark background
kind: ThemeKindWhich built-in palette this theme was constructed from.
colors: ThemeColorsSemantic color slots.
visuals: ThemeVisualsPer-widget chrome (button, label, combo, text edit, frames).
typography: TypographyFont sizes used by this crate’s widgets and the demo.
window_frame: FrameUsed for Frame not native windows
frame1: FrameBase container frame for major UI sections.
frame2: FrameFrame for nested elements, like individual list items.
corner_radius: u8Corner radius for widgets
inner_margin: i8Inner margin for widgets
outer_margin: i8Outer margin for widgets
Padding inside buttons
Must use this from egui::Ui::spacing_mut to change the padding
Implementations§
Source§impl Theme
impl Theme
Sourcepub fn style(&self) -> Style
pub fn style(&self) -> Style
Stock egui::Style for this kind (widgets, selection, window fill).
Button visuals from ThemeVisuals.
Sourcepub fn label_visuals(&self) -> LabelVisuals
pub fn label_visuals(&self) -> LabelVisuals
Label visuals from ThemeVisuals (same shape as button visuals).
Sourcepub fn combo_box_visuals(&self) -> ComboBoxVisuals
pub fn combo_box_visuals(&self) -> ComboBoxVisuals
Combo-box visuals from ThemeVisuals.
Sourcepub fn text_edit_visuals(&self) -> TextEditVisuals
pub fn text_edit_visuals(&self) -> TextEditVisuals
Text-edit visuals from ThemeVisuals.
Widget visuals stored by Theme::install, if any.
Widgets resolve in this order: self.visuals → context → egui::Style.
Sourcepub fn label_visuals_from_ctx(ctx: &Context) -> Option<LabelVisuals>
pub fn label_visuals_from_ctx(ctx: &Context) -> Option<LabelVisuals>
Same as Self::button_visuals_from_ctx for labels.
Sourcepub fn combo_box_visuals_from_ctx(ctx: &Context) -> Option<ComboBoxVisuals>
pub fn combo_box_visuals_from_ctx(ctx: &Context) -> Option<ComboBoxVisuals>
Same as Self::button_visuals_from_ctx for combo boxes.
Sourcepub fn text_edit_visuals_from_ctx(ctx: &Context) -> Option<TextEditVisuals>
pub fn text_edit_visuals_from_ctx(ctx: &Context) -> Option<TextEditVisuals>
Same as Self::button_visuals_from_ctx for text edits.
Sourcepub fn install(&mut self, ctx: &Context)
pub fn install(&mut self, ctx: &Context)
Install this theme into the given egui context.
Widgets then pick up their visuals from ctx automatically.
Sourcepub fn current(ctx: &Context) -> Theme
pub fn current(ctx: &Context) -> Theme
Read the current theme from the context if it exists, otherwise return the default theme
Sourcepub fn remap_derived_frames(&mut self, old: &ThemeColors)
pub fn remap_derived_frames(&mut self, old: &ThemeColors)
Keep derived frame colors in sync with a palette change.
Only updates a color if it still matches the previous palette slot
(e.g. frame1.fill == old.widget_bg). Custom colors and structural
frame properties (margins, rounding, shadow offsets) are left alone.
Trait Implementations§
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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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