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

Reduce .wasm size by around 20%

This commit is contained in:
Emil Ernerfeldt
2020-05-20 18:58:21 +02:00
parent 002944b775
commit 3022231e4f
5 changed files with 28 additions and 8 deletions

View File

@@ -44,6 +44,14 @@ pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Inter
/// Construct a top level menu in a menu bar. This would be e.g. "File", "Edit" etc.
pub fn menu(ui: &mut Ui, title: impl Into<String>, add_contents: impl FnOnce(&mut Ui)) {
menu_impl(ui, title, Box::new(add_contents))
}
fn menu_impl<'c>(
ui: &mut Ui,
title: impl Into<String>,
add_contents: Box<dyn FnOnce(&mut Ui) + 'c>,
) {
let title = title.into();
let bar_id = ui.id();
let menu_id = Id::new(&title);

View File

@@ -126,6 +126,14 @@ impl<'open> Window<'open> {
self,
ctx: &Arc<Context>,
add_contents: impl FnOnce(&mut Ui),
) -> Option<InteractInfo> {
self.show_impl(ctx, Box::new(add_contents))
}
fn show_impl<'c>(
self,
ctx: &Arc<Context>,
add_contents: Box<dyn FnOnce(&mut Ui) + 'c>,
) -> Option<InteractInfo> {
let Window {
title_label,