You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I use bevy and bevy_egui libraries. I have this approach that my widget-system-functions receive as an input a part of Ui (owned Ui struct) and add widgets on it. The only way to pass Ui part to the bevy system function that I could figure out, was to create an owned Ui structure by new_child and insert it to entity for later execution. The problem is that when creating an owned version of Ui I have to allocate the space manually before, for example:
egui::Window::new("Adjust CPU Usage")
.open(&mut window_open.0)
.max_size(egui::Vec2::new(300.0, 100.0))
.show(ctx, |ui| {
let response = ui.allocate_space(ui.available_size());
let child_ui = ui.new_child(
UiBuilder::default()
.max_rect(egui::Rect::from_min_size(response.1.min, response.1.size())),
);
ui_callbacks.push(UiCallback {
system_id: programs_cpu_usage_system_id,
ui: child_ui,
});
});
The problem here is that in fact only a fraction of the original allocated space might get used, leaving the rest of allocated space unusable and oftentimes the parent ui too big.
Describe the solution you'd like
I would expect new_child to work similarly to for example allocate_new_ui where the parent Ui will shrink to match the size of child ui.
Describe alternatives you've considered
I considered using on of: allocate_new_ui, allocate_ui but they expect callback function. In my design I want my widget function to also be bevy systems, that look something like this:
fn total_cpu_usage(In(mut ui): In<Ui>, programs: Query<&Program>, cpu: Query<&Cpu>) {
let total_usage = programs
.iter()
.map(|program| program.cpu_usage)
.sum::<f32>();
let bar = egui::ProgressBar::new(total_usage).show_percentage();
ui.label(format!(
"CPU ({:.2} GHz): ",
cpu.get_single().unwrap().frequency
));
ui.add(bar);
}
and this architecture actually works, except for the flaw that is described in first point.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I use bevy and bevy_egui libraries. I have this approach that my widget-system-functions receive as an input a part of Ui (owned Ui struct) and add widgets on it. The only way to pass Ui part to the bevy system function that I could figure out, was to create an owned Ui structure by
new_child
and insert it to entity for later execution. The problem is that when creating an owned version of Ui I have to allocate the space manually before, for example:The problem here is that in fact only a fraction of the original allocated space might get used, leaving the rest of allocated space unusable and oftentimes the parent ui too big.
Describe the solution you'd like
I would expect
new_child
to work similarly to for exampleallocate_new_ui
where the parent Ui will shrink to match the size of child ui.Describe alternatives you've considered
I considered using on of:
allocate_new_ui
,allocate_ui
but they expect callback function. In my design I want my widget function to also be bevy systems, that look something like this:and this architecture actually works, except for the flaw that is described in first point.
The text was updated successfully, but these errors were encountered: