-
Hello. I am trying to create a small UI with egui. Here is what I try to do. I assume this can be done with the library, but I cannot find a way to specify a region of fixed height or width. I found that I can create two elements of which one is of fixed size and the other fills the remaining space: egui/egui_demo_lib/src/apps/demo/password.rs Lines 35 to 51 in 9dc092b From the demo I also see that I can make an element fill the height by using cross justify: egui/egui_demo_lib/src/apps/demo/layout_test.rs Lines 80 to 84 in ebb08f8 However, I am having trouble with creating a fixed width or height areas that I can fill with these elements. As an example, I would like to be able to somehow split the center panel into the two halves. Then continue to place some elements into the two areas. I was able to create the elements into a fixed height layout, but setting the height seems quite clunky and feels like there is probably a better way to do this. Also, I am unsure how to create and place this code into a bottom halve of the desired layout. I feel like there should be a way to first divide areas into some kind of parts where the actual buttons are then placed into, but I have not yet found how to do that. egui::CentralPanel::default().show(ctx, |ui| {
let result = ui.with_layout(egui::Layout::right_to_left().with_cross_justify(true), |ui| {
ui.set_min_height(100.0);
ui.set_max_height(100.0);
ui.add_sized([100.0, 1.0], egui::SomeElement);
ui.add_sized(
ui.available_size(),
egui::SomeElement,
);
});
}); I am also a bit sad that I am not able to use the nice ui.button() API when sizing elements or trying to set layout settings. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
This is a bit under-developed at the moment (i.e. not the best APIs), but you should be able to bolt it together using:
It would be good with some better API:s and a demo of this, but I don't have time to do that :( |
Beta Was this translation helpful? Give feedback.
This is a bit under-developed at the moment (i.e. not the best APIs), but you should be able to bolt it together using:
ui.child_ui
to exactly specify where you wantUi
.It would be good with some better API:s and a demo of this, but I don't have time to do that :(