mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Create a UiBuilder for building Uis (#4969)
* Part of https://github.com/emilk/egui/issues/4634 The goals is to create fewer, more powerful entry points. ### Added * `egui::UiBuilder` * `Ui::allocate_new_ui` * `Ui::new_child` ### Breaking changes * `Ui::new` now takes a `UiBuilder` * Deprecated * `ui.add_visible_ui` * `ui.allocate_ui_at_rect` * `ui.child_ui` * `ui.child_ui_with_id_source` * `ui.push_stack_info`
This commit is contained in:
@@ -71,7 +71,7 @@ fn custom_window_frame(ctx: &egui::Context, title: &str, add_contents: impl FnOn
|
||||
rect
|
||||
}
|
||||
.shrink(4.0);
|
||||
let mut content_ui = ui.child_ui(content_rect, *ui.layout(), None);
|
||||
let mut content_ui = ui.new_child(UiBuilder::new().max_rect(content_rect));
|
||||
add_contents(&mut content_ui);
|
||||
});
|
||||
}
|
||||
@@ -116,14 +116,17 @@ fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title:
|
||||
ui.ctx().send_viewport_cmd(ViewportCommand::StartDrag);
|
||||
}
|
||||
|
||||
ui.allocate_ui_at_rect(title_bar_rect, |ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.allocate_new_ui(
|
||||
UiBuilder::new()
|
||||
.max_rect(title_bar_rect)
|
||||
.layout(egui::Layout::right_to_left(egui::Align::Center)),
|
||||
|ui| {
|
||||
ui.spacing_mut().item_spacing.x = 0.0;
|
||||
ui.visuals_mut().button_frame = false;
|
||||
ui.add_space(8.0);
|
||||
close_maximize_minimize(ui);
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Show some close/maximize/minimize buttons for the native window.
|
||||
|
||||
Reference in New Issue
Block a user