mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Add ctx.set_visuals()
This commit is contained in:
@@ -462,6 +462,17 @@ impl Context {
|
||||
self.memory().options.style = style.into();
|
||||
}
|
||||
|
||||
/// The [`Visuals`] used by all new windows, panels etc.
|
||||
///
|
||||
/// Example:
|
||||
/// ```
|
||||
/// # let mut ctx = egui::CtxRef::default();
|
||||
/// ctx.set_visuals(egui::Visuals::light()); // Switch to light mode
|
||||
/// ```
|
||||
pub fn set_visuals(&self, visuals: crate::Visuals) {
|
||||
std::sync::Arc::make_mut(&mut self.memory().options.style).visuals = visuals;
|
||||
}
|
||||
|
||||
/// The number of physical pixels for each logical point.
|
||||
pub fn pixels_per_point(&self) -> f32 {
|
||||
self.input.pixels_per_point()
|
||||
|
||||
@@ -126,7 +126,7 @@ pub use {
|
||||
painter::Painter,
|
||||
response::Response,
|
||||
sense::Sense,
|
||||
style::Style,
|
||||
style::{Style, Visuals},
|
||||
ui::Ui,
|
||||
widgets::*,
|
||||
};
|
||||
|
||||
@@ -122,13 +122,13 @@ impl Ui {
|
||||
|
||||
/// Short for `&self.style().visuals`
|
||||
/// visuals options for this `Ui` and its children.
|
||||
pub fn visuals(&self) -> &crate::style::Visuals {
|
||||
pub fn visuals(&self) -> &crate::Visuals {
|
||||
&self.style.visuals
|
||||
}
|
||||
|
||||
/// Mutably borrow internal `visuals`.
|
||||
/// Changes apply to this `Ui` and its subsequent children.
|
||||
pub fn visuals_mut(&mut self) -> &mut crate::style::Visuals {
|
||||
pub fn visuals_mut(&mut self) -> &mut crate::Visuals {
|
||||
&mut self.style_mut().visuals
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user