From f5e1d0869ebdf346aeb274351076221cb0c920d2 Mon Sep 17 00:00:00 2001 From: Konkitoman Date: Thu, 19 Oct 2023 18:50:48 +0300 Subject: [PATCH] Fixing: * Fix web * Fix errors from ./scripts/check.sh --- crates/eframe/src/epi/mod.rs | 3 +-- crates/eframe/src/web/app_runner.rs | 6 ++---- crates/eframe/src/web/events.rs | 5 +---- crates/egui/src/viewport.rs | 25 ++++++++++++------------- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/crates/eframe/src/epi/mod.rs b/crates/eframe/src/epi/mod.rs index ba83acbb4..1309d78ec 100644 --- a/crates/eframe/src/epi/mod.rs +++ b/crates/eframe/src/epi/mod.rs @@ -9,7 +9,6 @@ #[cfg(not(target_arch = "wasm32"))] mod icon_data; -use egui::ViewportBuilder; #[cfg(not(target_arch = "wasm32"))] pub use icon_data::IconData; @@ -45,7 +44,7 @@ pub type EventLoopBuilderHook = Box) /// done by `eframe`. #[cfg(not(target_arch = "wasm32"))] #[cfg(any(feature = "glow", feature = "wgpu"))] -pub type WindowBuilderHook = Box ViewportBuilder>; +pub type WindowBuilderHook = Box egui::ViewportBuilder>; /// This is how your app is created. /// diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 934a31c40..a750c1334 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -174,7 +174,7 @@ impl AppRunner { /// Returns how long to wait until the next repaint. /// /// Call [`Self::paint`] later to paint - pub fn logic(&mut self) -> (std::time::Duration, Vec) { + pub fn logic(&mut self) -> Vec { let frame_start = now_sec(); super::resize_canvas_to_screen_size(self.canvas_id(), self.web_options.max_size_points); @@ -188,7 +188,6 @@ impl AppRunner { }); let egui::FullOutput { platform_output, - repaint_after, textures_delta, shapes, .. @@ -205,8 +204,7 @@ impl AppRunner { self.frame.info.cpu_usage = Some((now_sec() - frame_start) as f32); - let repaint_after = repaint_after[&egui::ViewportId::MAIN]; - (repaint_after, clipped_primitives) + clipped_primitives } /// Paint the results of the last call to [`Self::logic`]. diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index ea5a5bf08..907d7f8e6 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -19,11 +19,8 @@ fn paint_and_schedule(runner_ref: &WebRunner) -> Result<(), JsValue> { fn paint_if_needed(runner: &mut AppRunner) -> Result<(), JsValue> { if runner.needs_repaint.when_to_repaint() <= now_sec() { runner.needs_repaint.clear(); - let (repaint_after, clipped_primitives) = runner.logic(); + let clipped_primitives = runner.logic(); runner.paint(&clipped_primitives)?; - runner - .needs_repaint - .repaint_after(repaint_after.as_secs_f64()); runner.auto_save_if_needed(); } Ok(()) diff --git a/crates/egui/src/viewport.rs b/crates/egui/src/viewport.rs index 941e56792..180a70943 100644 --- a/crates/egui/src/viewport.rs +++ b/crates/egui/src/viewport.rs @@ -147,9 +147,9 @@ impl ViewportBuilder { /// Sets the initial title of the window in the title bar. /// - /// The default is `"winit window"`. + /// The default is `"Dummy egui viewport"`. /// - /// See [`Window::set_title`] for details. + /// Look at winit for more details pub fn with_title(mut self, title: impl Into) -> Self { self.title = title.into(); self @@ -159,7 +159,7 @@ impl ViewportBuilder { /// /// The default is `true`. /// - /// See [`Window::set_decorations`] for details. + /// Look at winit for more details pub fn with_decorations(mut self, decorations: bool) -> Self { self.decorations = Some(decorations); self @@ -169,7 +169,7 @@ impl ViewportBuilder { /// /// The default is `None`. /// - /// See [`Window::set_fullscreen`] for details. + /// Look at winit for more details /// This will use borderless pub fn with_fullscreen(mut self, fullscreen: bool) -> Self { self.fullscreen = Some(fullscreen); @@ -180,7 +180,7 @@ impl ViewportBuilder { /// /// The default is `false`. /// - /// See [`Window::set_maximized`] for details. + /// Look at winit for more details pub fn with_maximized(mut self, maximized: bool) -> Self { self.maximized = Some(maximized); self @@ -190,7 +190,7 @@ impl ViewportBuilder { /// /// The default is `true`. /// - /// See [`Window::set_resizable`] for details. + /// Look at winit for more details pub fn with_resizable(mut self, resizable: bool) -> Self { self.resizable = Some(resizable); self @@ -201,7 +201,7 @@ impl ViewportBuilder { /// If this is `true`, writing colors with alpha values different than /// `1.0` will produce a transparent window. On some platforms this /// is more of a hint for the system and you'd still have the alpha - /// buffer. To control it see [`Window::set_transparent`]. + /// buffer. /// /// The default is `false`. /// If this is not working is because the graphic context dozen't support transparency, @@ -220,13 +220,12 @@ impl ViewportBuilder { /// Whether the window will be initially focused or not. /// /// The window should be assumed as not focused by default - /// following by the [`WindowEvent::Focused`]. /// /// ## Platform-specific: /// /// **Android / iOS / X11 / Wayland / Orbital:** Unsupported. /// - /// [`WindowEvent::Focused`]: crate::event::WindowEvent::Focused. + /// Look at winit for more details pub fn with_active(mut self, active: bool) -> Self { self.active = Some(active); self @@ -236,7 +235,7 @@ impl ViewportBuilder { /// /// The default is to show the window. /// - /// See [`Window::set_visible`] for details. + /// Look at winit for more details pub fn with_visible(mut self, visible: bool) -> Self { self.visible = Some(visible); self @@ -267,8 +266,8 @@ impl ViewportBuilder { /// /// If this is not set, some platform-specific dimensions will be used. /// - /// See [`Window::set_inner_size`] for details. /// Should be bigger then 0 + /// Look at winit for more details pub fn with_inner_size(mut self, value: Option) -> Self { self.inner_size = Some(value); self @@ -279,8 +278,8 @@ impl ViewportBuilder { /// If this is not set, the window will have no minimum dimensions (aside /// from reserved). /// - /// See [`Window::set_min_inner_size`] for details. /// Should be bigger then 0 + /// Look at winit for more details pub fn with_min_inner_size(mut self, value: Option) -> Self { self.min_inner_size = Some(value); self @@ -291,8 +290,8 @@ impl ViewportBuilder { /// If this is not set, the window will have no maximum or will be set to /// the primary monitor's dimensions by the platform. /// - /// See [`Window::set_max_inner_size`] for details. /// Should be bigger then 0 + /// Look at winit for more details pub fn with_max_inner_size(mut self, value: Option) -> Self { self.max_inner_size = Some(value); self