Skip to content

Commit

Permalink
egui_web: by default, use full web browser size (#1378)
Browse files Browse the repository at this point in the history
* egui_web: by default, use full web browser size

Closes #1377

* Remove max_size_points from demo app
  • Loading branch information
emilk authored Mar 19, 2022
1 parent 6ce8594 commit 465c961
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 37 deletions.
3 changes: 2 additions & 1 deletion eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions eframe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
17 changes: 0 additions & 17 deletions egui_demo_lib/src/backend_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ pub struct BackendPanel {
#[cfg_attr(feature = "serde", serde(skip))]
pixels_per_point: Option<f32>,

/// 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,

Expand All @@ -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(),
}
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 0 additions & 4 deletions egui_demo_lib/src/wrap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
Expand Down
3 changes: 2 additions & 1 deletion egui_web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions egui_web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down
9 changes: 4 additions & 5 deletions epi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
/// <https://bugzilla.mozilla.org/show_bug.cgi?id=1010527#c0> (unfixed since 2014).
/// A large canvas can lead to bad frame rates on some older browsers on some platforms
/// (see <https://bugzilla.mozilla.org/show_bug.cgi?id=1010527#c0>).
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`.
Expand Down

0 comments on commit 465c961

Please sign in to comment.