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:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user