1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 13:20:05 -04:00

Put everything in Context behind the same Mutex (#1050)

* Move all interior mutability from Context to CtxRef and make it a handle
* Rename `CtxRef` to `Context`
* The old `Context` is now `ContextImpl` and is non-pub
* Add benchmark Painter::rect

Co-authored-by: Daniel Keller <dklr433@gmail.com>
This commit is contained in:
Emil Ernerfeldt
2022-01-10 23:13:10 +01:00
committed by GitHub
parent 225d2b506d
commit d5673412dd
75 changed files with 550 additions and 495 deletions

View File

@@ -82,7 +82,7 @@ impl epi::backend::RepaintSignal for NeedRepaint {
pub struct AppRunner {
frame: epi::Frame,
egui_ctx: egui::CtxRef,
egui_ctx: egui::Context,
painter: Box<dyn Painter>,
pub(crate) input: WebInput,
app: Box<dyn epi::App>,
@@ -117,7 +117,7 @@ impl AppRunner {
repaint_signal: needs_repaint.clone(),
});
let egui_ctx = egui::CtxRef::default();
let egui_ctx = egui::Context::default();
load_memory(&egui_ctx);
if prefer_dark_mode == Some(true) {
egui_ctx.set_visuals(egui::Visuals::dark());
@@ -151,7 +151,7 @@ impl AppRunner {
Ok(runner)
}
pub fn egui_ctx(&self) -> &egui::CtxRef {
pub fn egui_ctx(&self) -> &egui::Context {
&self.egui_ctx
}
@@ -174,7 +174,7 @@ impl AppRunner {
pub fn warm_up(&mut self) -> Result<(), JsValue> {
if self.app.warm_up_enabled() {
let saved_memory = self.egui_ctx.memory().clone();
let saved_memory: egui::Memory = self.egui_ctx.memory().clone();
self.egui_ctx.memory().set_everything_is_visible(true);
self.logic()?;
*self.egui_ctx.memory() = saved_memory; // We don't want to remember that windows were huge.