From 465c96122cf6aea72e7fbd8d6e7c2c048e88424f Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 19 Mar 2022 13:47:30 +0100 Subject: [PATCH] egui_web: by default, use full web browser size (#1378) * egui_web: by default, use full web browser size Closes https://github.com/emilk/egui/issues/1377 * Remove max_size_points from demo app --- eframe/CHANGELOG.md | 3 ++- eframe/src/lib.rs | 4 ---- egui_demo_lib/src/backend_panel.rs | 17 ----------------- egui_demo_lib/src/wrap_app.rs | 4 ---- egui_web/CHANGELOG.md | 3 ++- egui_web/src/lib.rs | 5 ----- epi/src/lib.rs | 9 ++++----- 7 files changed, 8 insertions(+), 37 deletions(-) diff --git a/eframe/CHANGELOG.md b/eframe/CHANGELOG.md index b7fb979d..a03be5de 100644 --- a/eframe/CHANGELOG.md +++ b/eframe/CHANGELOG.md @@ -5,9 +5,10 @@ NOTE: [`egui_web`](../egui_web/CHANGELOG.md), [`egui-winit`](../egui-winit/CHANG ## Unreleased -* Remove the `egui_glium` feature. `eframe` will now always use `egui_glow` as the native backend ([#1357](https://github.com/emilk/egui/pull/1357)). * Change default for `NativeOptions::drag_and_drop_support` to `true` ([#1329](https://github.com/emilk/egui/pull/1329)). +* Remove the `egui_glium` feature. `eframe` will now always use `egui_glow` as the native backend ([#1357](https://github.com/emilk/egui/pull/1357)). * Removed `Frame::request_repaint` - just call `egui::Context::request_repaint` for the same effect ([#1366](https://github.com/emilk/egui/pull/1366)). +* Use full browser width by default ([#1378](https://github.com/emilk/egui/pull/1378)). ## 0.17.0 - 2022-02-22 diff --git a/eframe/src/lib.rs b/eframe/src/lib.rs index 6c7e7f8d..732d60a1 100644 --- a/eframe/src/lib.rs +++ b/eframe/src/lib.rs @@ -84,10 +84,6 @@ pub use egui_web::wasm_bindgen; /// Install event listeners to register different input events /// and start running the given app. /// -/// For performance reasons (on some browsers) the egui canvas does not, by default, -/// fill the whole width of the browser. -/// This can be changed by overriding [`epi::Frame::max_size_points`]. -/// /// ``` no_run /// #[cfg(target_arch = "wasm32")] /// use wasm_bindgen::prelude::*; diff --git a/egui_demo_lib/src/backend_panel.rs b/egui_demo_lib/src/backend_panel.rs index e54b97d1..0daa3a45 100644 --- a/egui_demo_lib/src/backend_panel.rs +++ b/egui_demo_lib/src/backend_panel.rs @@ -54,10 +54,6 @@ pub struct BackendPanel { #[cfg_attr(feature = "serde", serde(skip))] pixels_per_point: Option, - /// maximum size of the web browser canvas - max_size_points_ui: egui::Vec2, - pub max_size_points_active: egui::Vec2, - #[cfg_attr(feature = "serde", serde(skip))] frame_history: crate::frame_history::FrameHistory, @@ -70,8 +66,6 @@ impl Default for BackendPanel { open: false, run_mode: Default::default(), pixels_per_point: Default::default(), - max_size_points_ui: egui::Vec2::new(1024.0, 2048.0), - max_size_points_active: egui::Vec2::new(1024.0, 2048.0), frame_history: Default::default(), egui_windows: Default::default(), } @@ -157,17 +151,6 @@ impl BackendPanel { ui.hyperlink("https://github.com/emilk/egui"); ui.separator(); - - ui.add( - egui::Slider::new(&mut self.max_size_points_ui.x, 512.0..=f32::INFINITY) - .logarithmic(true) - .largest_finite(8192.0) - .text("Max width"), - ) - .on_hover_text("Maximum width of the egui region of the web page."); - if !ui.ctx().is_using_pointer() { - self.max_size_points_active = self.max_size_points_ui; - } } show_integration_name(ui, &frame.info()); diff --git a/egui_demo_lib/src/wrap_app.rs b/egui_demo_lib/src/wrap_app.rs index d8d701d3..e80240e4 100644 --- a/egui_demo_lib/src/wrap_app.rs +++ b/egui_demo_lib/src/wrap_app.rs @@ -65,10 +65,6 @@ impl epi::App for WrapApp { epi::set_value(storage, epi::APP_KEY, self); } - fn max_size_points(&self) -> egui::Vec2 { - self.backend_panel.max_size_points_active - } - fn clear_color(&self) -> egui::Rgba { egui::Rgba::TRANSPARENT // we set a `CentralPanel` fill color in `demo_windows.rs` } diff --git a/egui_web/CHANGELOG.md b/egui_web/CHANGELOG.md index 91bee2c7..ecffcb7f 100644 --- a/egui_web/CHANGELOG.md +++ b/egui_web/CHANGELOG.md @@ -3,8 +3,9 @@ All notable changes to the `egui_web` integration will be noted in this file. ## Unreleased -* egui code will no longer be called after panic ([#1306](https://github.com/emilk/egui/pull/1306)) +* egui code will no longer be called after panic ([#1306](https://github.com/emilk/egui/pull/1306)). * Remove the "webgl" feature. `egui_web` now always use `glow` (which in turn wraps WebGL) ([#1356](https://github.com/emilk/egui/pull/1356)). +* Use full browser width by default ([#1378](https://github.com/emilk/egui/pull/1378)). ## 0.17.0 - 2022-02-22 diff --git a/egui_web/src/lib.rs b/egui_web/src/lib.rs index 062c9ac0..8bddd04a 100644 --- a/egui_web/src/lib.rs +++ b/egui_web/src/lib.rs @@ -3,11 +3,6 @@ //! This library is an [`epi`] backend. //! //! If you are writing an app, you may want to look at [`eframe`](https://docs.rs/eframe) instead. -//! -//! ## Specifying the size of the egui canvas -//! For performance reasons (on some browsers) the egui canvas does not, by default, -//! fill the whole width of the browser. -//! This can be changed by overriding [`epi::App::max_size_points`]. // Forbid warnings in release builds: #![cfg_attr(not(debug_assertions), deny(warnings))] diff --git a/epi/src/lib.rs b/epi/src/lib.rs index 005b132c..d1bda8d0 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -176,13 +176,12 @@ pub trait App { /// The size limit of the web app canvas. /// - /// By default the size if limited to 1024x2048. + /// By default the max size is [`egui::Vec2::INFINITY`], i.e. unlimited. /// - /// A larger canvas can lead to bad frame rates on some browsers on some platforms. - /// In particular, Firefox on Mac and Linux is really bad at handling large WebGL canvases: - /// (unfixed since 2014). + /// A large canvas can lead to bad frame rates on some older browsers on some platforms + /// (see ). fn max_size_points(&self) -> egui::Vec2 { - egui::Vec2::new(1024.0, 2048.0) + egui::Vec2::INFINITY } /// Background color for the app, e.g. what is sent to `gl.clearColor`.