1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 23:00:04 -04:00
* Fix web
* Fix errors from ./scripts/check.sh
This commit is contained in:
Konkitoman
2023-10-19 18:50:48 +03:00
parent ec37d3861a
commit f5e1d0869e
4 changed files with 16 additions and 23 deletions

View File

@@ -9,7 +9,6 @@
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
mod icon_data; mod icon_data;
use egui::ViewportBuilder;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
pub use icon_data::IconData; pub use icon_data::IconData;
@@ -45,7 +44,7 @@ pub type EventLoopBuilderHook = Box<dyn FnOnce(&mut EventLoopBuilder<UserEvent>)
/// done by `eframe`. /// done by `eframe`.
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
#[cfg(any(feature = "glow", feature = "wgpu"))] #[cfg(any(feature = "glow", feature = "wgpu"))]
pub type WindowBuilderHook = Box<dyn FnOnce(ViewportBuilder) -> ViewportBuilder>; pub type WindowBuilderHook = Box<dyn FnOnce(egui::ViewportBuilder) -> egui::ViewportBuilder>;
/// This is how your app is created. /// This is how your app is created.
/// ///

View File

@@ -174,7 +174,7 @@ impl AppRunner {
/// Returns how long to wait until the next repaint. /// Returns how long to wait until the next repaint.
/// ///
/// Call [`Self::paint`] later to paint /// Call [`Self::paint`] later to paint
pub fn logic(&mut self) -> (std::time::Duration, Vec<egui::ClippedPrimitive>) { pub fn logic(&mut self) -> Vec<egui::ClippedPrimitive> {
let frame_start = now_sec(); let frame_start = now_sec();
super::resize_canvas_to_screen_size(self.canvas_id(), self.web_options.max_size_points); super::resize_canvas_to_screen_size(self.canvas_id(), self.web_options.max_size_points);
@@ -188,7 +188,6 @@ impl AppRunner {
}); });
let egui::FullOutput { let egui::FullOutput {
platform_output, platform_output,
repaint_after,
textures_delta, textures_delta,
shapes, shapes,
.. ..
@@ -205,8 +204,7 @@ impl AppRunner {
self.frame.info.cpu_usage = Some((now_sec() - frame_start) as f32); self.frame.info.cpu_usage = Some((now_sec() - frame_start) as f32);
let repaint_after = repaint_after[&egui::ViewportId::MAIN]; clipped_primitives
(repaint_after, clipped_primitives)
} }
/// Paint the results of the last call to [`Self::logic`]. /// Paint the results of the last call to [`Self::logic`].

View File

@@ -19,11 +19,8 @@ fn paint_and_schedule(runner_ref: &WebRunner) -> Result<(), JsValue> {
fn paint_if_needed(runner: &mut AppRunner) -> Result<(), JsValue> { fn paint_if_needed(runner: &mut AppRunner) -> Result<(), JsValue> {
if runner.needs_repaint.when_to_repaint() <= now_sec() { if runner.needs_repaint.when_to_repaint() <= now_sec() {
runner.needs_repaint.clear(); runner.needs_repaint.clear();
let (repaint_after, clipped_primitives) = runner.logic(); let clipped_primitives = runner.logic();
runner.paint(&clipped_primitives)?; runner.paint(&clipped_primitives)?;
runner
.needs_repaint
.repaint_after(repaint_after.as_secs_f64());
runner.auto_save_if_needed(); runner.auto_save_if_needed();
} }
Ok(()) Ok(())

View File

@@ -147,9 +147,9 @@ impl ViewportBuilder {
/// Sets the initial title of the window in the title bar. /// 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<String>) -> Self { pub fn with_title(mut self, title: impl Into<String>) -> Self {
self.title = title.into(); self.title = title.into();
self self
@@ -159,7 +159,7 @@ impl ViewportBuilder {
/// ///
/// The default is `true`. /// 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 { pub fn with_decorations(mut self, decorations: bool) -> Self {
self.decorations = Some(decorations); self.decorations = Some(decorations);
self self
@@ -169,7 +169,7 @@ impl ViewportBuilder {
/// ///
/// The default is `None`. /// The default is `None`.
/// ///
/// See [`Window::set_fullscreen`] for details. /// Look at winit for more details
/// This will use borderless /// This will use borderless
pub fn with_fullscreen(mut self, fullscreen: bool) -> Self { pub fn with_fullscreen(mut self, fullscreen: bool) -> Self {
self.fullscreen = Some(fullscreen); self.fullscreen = Some(fullscreen);
@@ -180,7 +180,7 @@ impl ViewportBuilder {
/// ///
/// The default is `false`. /// 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 { pub fn with_maximized(mut self, maximized: bool) -> Self {
self.maximized = Some(maximized); self.maximized = Some(maximized);
self self
@@ -190,7 +190,7 @@ impl ViewportBuilder {
/// ///
/// The default is `true`. /// 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 { pub fn with_resizable(mut self, resizable: bool) -> Self {
self.resizable = Some(resizable); self.resizable = Some(resizable);
self self
@@ -201,7 +201,7 @@ impl ViewportBuilder {
/// If this is `true`, writing colors with alpha values different than /// If this is `true`, writing colors with alpha values different than
/// `1.0` will produce a transparent window. On some platforms this /// `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 /// 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`. /// The default is `false`.
/// If this is not working is because the graphic context dozen't support transparency, /// 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. /// Whether the window will be initially focused or not.
/// ///
/// The window should be assumed as not focused by default /// The window should be assumed as not focused by default
/// following by the [`WindowEvent::Focused`].
/// ///
/// ## Platform-specific: /// ## Platform-specific:
/// ///
/// **Android / iOS / X11 / Wayland / Orbital:** Unsupported. /// **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 { pub fn with_active(mut self, active: bool) -> Self {
self.active = Some(active); self.active = Some(active);
self self
@@ -236,7 +235,7 @@ impl ViewportBuilder {
/// ///
/// The default is to show the window. /// 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 { pub fn with_visible(mut self, visible: bool) -> Self {
self.visible = Some(visible); self.visible = Some(visible);
self self
@@ -267,8 +266,8 @@ impl ViewportBuilder {
/// ///
/// If this is not set, some platform-specific dimensions will be used. /// If this is not set, some platform-specific dimensions will be used.
/// ///
/// See [`Window::set_inner_size`] for details.
/// Should be bigger then 0 /// Should be bigger then 0
/// Look at winit for more details
pub fn with_inner_size(mut self, value: Option<Vec2>) -> Self { pub fn with_inner_size(mut self, value: Option<Vec2>) -> Self {
self.inner_size = Some(value); self.inner_size = Some(value);
self self
@@ -279,8 +278,8 @@ impl ViewportBuilder {
/// If this is not set, the window will have no minimum dimensions (aside /// If this is not set, the window will have no minimum dimensions (aside
/// from reserved). /// from reserved).
/// ///
/// See [`Window::set_min_inner_size`] for details.
/// Should be bigger then 0 /// Should be bigger then 0
/// Look at winit for more details
pub fn with_min_inner_size(mut self, value: Option<Vec2>) -> Self { pub fn with_min_inner_size(mut self, value: Option<Vec2>) -> Self {
self.min_inner_size = Some(value); self.min_inner_size = Some(value);
self self
@@ -291,8 +290,8 @@ impl ViewportBuilder {
/// If this is not set, the window will have no maximum or will be set to /// If this is not set, the window will have no maximum or will be set to
/// the primary monitor's dimensions by the platform. /// the primary monitor's dimensions by the platform.
/// ///
/// See [`Window::set_max_inner_size`] for details.
/// Should be bigger then 0 /// Should be bigger then 0
/// Look at winit for more details
pub fn with_max_inner_size(mut self, value: Option<Vec2>) -> Self { pub fn with_max_inner_size(mut self, value: Option<Vec2>) -> Self {
self.max_inner_size = Some(value); self.max_inner_size = Some(value);
self self