diff --git a/Cargo.toml b/Cargo.toml index 2d63fbda9..fd6b1f347 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,7 @@ members = [ "example_glium", "example_wasm", ] + +[profile.release] +lto = true # very slightly smaller wasm +opt-level = 's' # 10-20% smaller wasm diff --git a/docs/example_wasm.js b/docs/example_wasm.js index 92c115f76..b4553d0ba 100644 --- a/docs/example_wasm.js +++ b/docs/example_wasm.js @@ -492,6 +492,10 @@ async function init(input) { handleError(e) } }; + imports.wbg.__wbg_newnoargs_ebdc90c3d1e4e55d = function(arg0, arg1) { + var ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; imports.wbg.__wbg_call_804d3ad7e8acd4d5 = function(arg0, arg1) { try { var ret = getObject(arg0).call(getObject(arg1)); @@ -500,14 +504,6 @@ async function init(input) { handleError(e) } }; - imports.wbg.__wbindgen_object_clone_ref = function(arg0) { - var ret = getObject(arg0); - return addHeapObject(ret); - }; - imports.wbg.__wbg_newnoargs_ebdc90c3d1e4e55d = function(arg0, arg1) { - var ret = new Function(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); - }; imports.wbg.__wbg_globalThis_48a5e9494e623f26 = function() { try { var ret = globalThis.globalThis; @@ -580,6 +576,10 @@ async function init(input) { var ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; + imports.wbg.__wbindgen_object_clone_ref = function(arg0) { + var ret = getObject(arg0); + return addHeapObject(ret); + }; imports.wbg.__wbg_instanceof_Memory_7ccbf540b50fc2bf = function(arg0) { var ret = getObject(arg0) instanceof WebAssembly.Memory; return ret; diff --git a/docs/example_wasm_bg.wasm b/docs/example_wasm_bg.wasm index 0bd847a6c..e5b07a175 100644 Binary files a/docs/example_wasm_bg.wasm and b/docs/example_wasm_bg.wasm differ diff --git a/emigui/src/containers/menu.rs b/emigui/src/containers/menu.rs index c036ea099..c0e416f56 100644 --- a/emigui/src/containers/menu.rs +++ b/emigui/src/containers/menu.rs @@ -44,6 +44,14 @@ pub fn bar(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, add_contents: impl FnOnce(&mut Ui)) { + menu_impl(ui, title, Box::new(add_contents)) +} + +fn menu_impl<'c>( + ui: &mut Ui, + title: impl Into, + add_contents: Box, +) { let title = title.into(); let bar_id = ui.id(); let menu_id = Id::new(&title); diff --git a/emigui/src/containers/window.rs b/emigui/src/containers/window.rs index 191269ac2..5b1f25919 100644 --- a/emigui/src/containers/window.rs +++ b/emigui/src/containers/window.rs @@ -126,6 +126,14 @@ impl<'open> Window<'open> { self, ctx: &Arc, add_contents: impl FnOnce(&mut Ui), + ) -> Option { + self.show_impl(ctx, Box::new(add_contents)) + } + + fn show_impl<'c>( + self, + ctx: &Arc, + add_contents: Box, ) -> Option { let Window { title_label,