From 8b1f02f22c7036f8cf363194f49a973af87f9d0e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 30 May 2020 14:56:38 +0200 Subject: [PATCH] [egui] handle dynamic changes to pixels_per_point (dpi scaling) Also: egui::Context::new() no longer takes any arguments --- egui/benches/benchmark.rs | 5 +-- egui/src/context.rs | 95 ++++++++++++++++----------------------- egui/src/introspection.rs | 22 +++++++-- egui/src/paint/fonts.rs | 62 +++++++++++++++---------- egui_wasm/Cargo.toml | 2 +- example_glium/src/main.rs | 7 ++- example_wasm/src/lib.rs | 12 +++-- 7 files changed, 107 insertions(+), 98 deletions(-) diff --git a/egui/benches/benchmark.rs b/egui/benches/benchmark.rs index 0d828f45..0792b990 100644 --- a/egui/benches/benchmark.rs +++ b/egui/benches/benchmark.rs @@ -2,7 +2,7 @@ use criterion::{criterion_group, criterion_main, Criterion}; pub fn criterion_benchmark(c: &mut Criterion) { let mut example_app = egui::examples::ExampleApp::default(); - let mut ctx = egui::Context::new(1.0); + let mut ctx = egui::Context::new(); let raw_input = egui::RawInput { screen_size: egui::vec2(1280.0, 1024.0), @@ -11,8 +11,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("example_app", |b| { b.iter(|| { - ctx.begin_frame(raw_input.clone()); - let mut ui = ctx.fullscreen_ui(); + let mut ui = ctx.begin_frame(raw_input.clone()); example_app.ui(&mut ui, ""); ctx.end_frame() }) diff --git a/egui/src/context.rs b/egui/src/context.rs index 867c1314..4dd93df8 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -16,13 +16,14 @@ struct PaintStats { /// `Ui`:s keep an Arc pointer to this. /// This allows us to create several child `Ui`:s at once, /// all working against the same shared Context. +#[derive(Default)] pub struct Context { /// The default style for new `Ui`:s style: Mutex