1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 21:00:03 -04:00

eframe: selectively expose parts of the API based on compile target (#1867)

A lot of the `eframe` API is native-only or web-only. With this PR, only the parts that are implemented for each platform is exposed.

This means you'll need to add `#[cfg(target_arch = "wasm32")]` around code that uses the web-parts of the eframe API, and add `#[cfg(not(target_arch = "wasm32"))]` around the parts that are for native/desktop.
This commit is contained in:
Emil Ernerfeldt
2022-07-29 14:37:23 +02:00
committed by GitHub
parent 51052c08e9
commit 8c09804abd
7 changed files with 76 additions and 69 deletions

View File

@@ -170,13 +170,12 @@ impl AppRunner {
};
let info = epi::IntegrationInfo {
web_info: Some(epi::WebInfo {
web_info: epi::WebInfo {
location: web_location(),
}),
},
system_theme,
cpu_usage: None,
native_pixels_per_point: Some(native_pixels_per_point()),
window_info: None,
};
let storage = LocalStorage::default();
@@ -293,16 +292,7 @@ impl AppRunner {
{
let app_output = self.frame.take_app_output();
let epi::backend::AppOutput {
quit: _, // Can't quit a web page
window_size: _, // Can't resize a web page
window_title: _, // TODO(emilk): change title of window
decorated: _, // Can't toggle decorations
fullscreen: _, // TODO(emilk): fullscreen web window
drag_window: _, // Can't be dragged
window_pos: _, // Can't set position of a web page
visible: _, // Can't hide a web page
} = app_output;
let epi::backend::AppOutput {} = app_output;
}
self.frame.info.cpu_usage = Some((now_sec() - frame_start) as f32);

View File

@@ -181,9 +181,7 @@ pub fn install_document_events(runner_container: &AppRunnerContainer) -> Result<
"hashchange",
|_: web_sys::Event, mut runner_lock| {
// `epi::Frame::info(&self)` clones `epi::IntegrationInfo`, but we need to modify the original here
if let Some(web_info) = &mut runner_lock.frame.info.web_info {
web_info.location.hash = location_hash();
}
runner_lock.frame.info.web_info.location.hash = location_hash();
},
)?;