pub trait ArmasContextExt {
// Required methods
fn armas_theme(&self) -> Theme;
fn set_armas_theme(&self, theme: Theme);
}Expand description
Extension trait for storing Armas theme in egui Context
§Example
use armas_basic::ext::ArmasContextExt;
use armas_basic::Theme;
fn setup(ctx: &egui::Context) {
// Set theme once
ctx.set_armas_theme(Theme::dark());
}
fn my_ui(ui: &mut egui::Ui) {
// Components automatically get theme from context
let theme = ui.ctx().armas_theme();
// ...
}Required Methods§
Sourcefn armas_theme(&self) -> Theme
fn armas_theme(&self) -> Theme
Get the current Armas theme from context
Returns the theme previously set with set_armas_theme().
If no theme was set, returns Theme::dark() as default.
Sourcefn set_armas_theme(&self, theme: Theme)
fn set_armas_theme(&self, theme: Theme)
Set the Armas theme in context
This stores the theme globally in egui’s context, making it available to all components without explicit passing.
§Example
// Set theme once at startup
ctx.set_armas_theme(Theme::dark());
// Change theme dynamically
if user_wants_light_theme {
ctx.set_armas_theme(Theme::light());
}