Skip to content

Nested Layouts #5449

Answered by Markkaz
Markkaz asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, after a night of trying different things I found a solution. I force the ui.horizontal to a fixed with and then I can center it:

let layout = egui::Layout::centered_and_justified(egui::Direction::LeftToRight);
            ui.allocate_ui_with_layout([600., 50.].into(), layout, |ui| {
                ui.horizontal(|ui| {
                    ui.label(egui::RichText::new("Difficulty: ").size(24.).color(egui::Color32::WHITE));

                    if ui.add_sized(
                        egui::Vec2::new(200., 50.),
                        egui::SelectableLabel::new(
                            difficulty.0 == Difficulty::Easy,
                            egui::RichText::new("Easy").size(24…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Markkaz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant