Move `App::persist_window` to `NativeOptions` and `App::max_size_points` to `WebOptions` (#3397)
* Move `App::persist_window` to `NativeOptions` * Move `App::max_size_points` to `WebOptions` * Build fixes
This commit is contained in:
parent
1b18f8e266
commit
b3e19f5b7d
|
|
@ -182,13 +182,6 @@ pub trait App {
|
|||
std::time::Duration::from_secs(30)
|
||||
}
|
||||
|
||||
/// The size limit of the web app canvas.
|
||||
///
|
||||
/// By default the max size is [`egui::Vec2::INFINITY`], i.e. unlimited.
|
||||
fn max_size_points(&self) -> egui::Vec2 {
|
||||
egui::Vec2::INFINITY
|
||||
}
|
||||
|
||||
/// Background color values for the app, e.g. what is sent to `gl.clearColor`.
|
||||
///
|
||||
/// This is the background of your windows if you don't set a central panel.
|
||||
|
|
@ -208,12 +201,6 @@ pub trait App {
|
|||
// _visuals.window_fill() would also be a natural choice
|
||||
}
|
||||
|
||||
/// Controls whether or not the native window position and size will be
|
||||
/// persisted (only if the "persistence" feature is enabled).
|
||||
fn persist_native_window(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Controls whether or not the egui memory (window positions etc) will be
|
||||
/// persisted (only if the "persistence" feature is enabled).
|
||||
fn persist_egui_memory(&self) -> bool {
|
||||
|
|
@ -455,6 +442,10 @@ pub struct NativeOptions {
|
|||
/// }
|
||||
/// ```
|
||||
pub app_id: Option<String>,
|
||||
|
||||
/// Controls whether or not the native window position and size will be
|
||||
/// persisted (only if the "persistence" feature is enabled).
|
||||
pub persist_window: bool,
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
|
@ -529,6 +520,8 @@ impl Default for NativeOptions {
|
|||
wgpu_options: egui_wgpu::WgpuConfiguration::default(),
|
||||
|
||||
app_id: None,
|
||||
|
||||
persist_window: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -566,6 +559,11 @@ pub struct WebOptions {
|
|||
/// Configures wgpu instance/device/adapter/surface creation and renderloop.
|
||||
#[cfg(feature = "wgpu")]
|
||||
pub wgpu_options: egui_wgpu::WgpuConfiguration,
|
||||
|
||||
/// The size limit of the web app canvas.
|
||||
///
|
||||
/// By default the max size is [`egui::Vec2::INFINITY`], i.e. unlimited.
|
||||
pub max_size_points: egui::Vec2,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
|
@ -581,6 +579,8 @@ impl Default for WebOptions {
|
|||
|
||||
#[cfg(feature = "wgpu")]
|
||||
wgpu_options: egui_wgpu::WgpuConfiguration::default(),
|
||||
|
||||
max_size_points: egui::Vec2::INFINITY,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,6 +354,8 @@ pub struct EpiIntegration {
|
|||
can_drag_window: bool,
|
||||
window_state: WindowState,
|
||||
follow_system_theme: bool,
|
||||
#[cfg(feature = "persistence")]
|
||||
persist_window: bool,
|
||||
app_icon_setter: super::app_icon::AppTitleIconSetter,
|
||||
}
|
||||
|
||||
|
|
@ -422,6 +424,8 @@ impl EpiIntegration {
|
|||
can_drag_window: false,
|
||||
window_state,
|
||||
follow_system_theme: native_options.follow_system_theme,
|
||||
#[cfg(feature = "persistence")]
|
||||
persist_window: native_options.persist_window,
|
||||
app_icon_setter,
|
||||
}
|
||||
}
|
||||
|
|
@ -593,7 +597,7 @@ impl EpiIntegration {
|
|||
crate::profile_function!();
|
||||
|
||||
if let Some(window) = _window {
|
||||
if _app.persist_native_window() {
|
||||
if self.persist_window {
|
||||
crate::profile_scope!("native_window");
|
||||
epi::set_value(
|
||||
storage,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use crate::{epi, App};
|
|||
use super::{now_sec, web_painter::WebPainter, NeedRepaint};
|
||||
|
||||
pub struct AppRunner {
|
||||
web_options: crate::WebOptions,
|
||||
pub(crate) frame: epi::Frame,
|
||||
egui_ctx: egui::Context,
|
||||
painter: super::ActiveWebPainter,
|
||||
|
|
@ -98,6 +99,7 @@ impl AppRunner {
|
|||
}
|
||||
|
||||
let mut runner = Self {
|
||||
web_options,
|
||||
frame,
|
||||
egui_ctx,
|
||||
painter,
|
||||
|
|
@ -174,7 +176,7 @@ impl AppRunner {
|
|||
pub fn logic(&mut self) -> (std::time::Duration, Vec<egui::ClippedPrimitive>) {
|
||||
let frame_start = now_sec();
|
||||
|
||||
super::resize_canvas_to_screen_size(self.canvas_id(), self.app.max_size_points());
|
||||
super::resize_canvas_to_screen_size(self.canvas_id(), self.web_options.max_size_points);
|
||||
let canvas_size = super::canvas_size_in_points(self.canvas_id());
|
||||
let raw_input = self.input.new_frame(canvas_size);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue