Skip to content

Commit a015971

Browse files
committed
Use deprecated egui::menu as temp workaround
egui 0.32 refactored menus, and now having a ComboBox within the menu does not work properly. Temporarily use the deprecated menu instead.
1 parent e67d599 commit a015971

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

objdiff-gui/src/app.rs

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,10 @@ impl eframe::App for App {
660660
let side_panel_available = diff_state.current_view == View::SymbolDiff;
661661

662662
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
663-
egui::MenuBar::new().ui(ui, |ui| {
663+
// Temporarily use pre-egui 0.32 menu. ComboBox within menu
664+
// is currently broken. Issue TBD
665+
#[allow(deprecated)]
666+
egui::menu::bar(ui, |ui| {
664667
if ui
665668
.add_enabled(
666669
side_panel_available,
@@ -672,7 +675,8 @@ impl eframe::App for App {
672675
*show_side_panel = !*show_side_panel;
673676
}
674677
ui.separator();
675-
ui.menu_button("File", |ui| {
678+
let bar_state = egui::menu::BarState::load(ui.ctx(), ui.id());
679+
egui::menu::menu_button(ui, "File", |ui| {
676680
#[cfg(debug_assertions)]
677681
if ui.button("Debug…").clicked() {
678682
*show_debug = !*show_debug;
@@ -689,22 +693,29 @@ impl eframe::App for App {
689693
};
690694
if recent_projects.is_empty() {
691695
ui.add_enabled(false, egui::Button::new("Recent projects…"));
692-
} else {
693-
ui.menu_button("Recent Projects…", |ui| {
694-
if ui.button("Clear").clicked() {
695-
state.write().unwrap().config.recent_projects.clear();
696-
};
697-
ui.separator();
698-
for path in recent_projects {
699-
if ui.button(&path).clicked() {
700-
state
701-
.write()
702-
.unwrap()
703-
.set_project_dir(Utf8PlatformPathBuf::from(path));
704-
ui.close();
696+
} else if let Some(menu_root) = bar_state.as_ref() {
697+
egui::menu::submenu_button(
698+
ui,
699+
menu_root.menu_state.clone(),
700+
"Recent Projects…",
701+
|ui| {
702+
if ui.button("Clear").clicked() {
703+
state.write().unwrap().config.recent_projects.clear();
704+
};
705+
ui.separator();
706+
for path in recent_projects {
707+
if ui.button(&path).clicked() {
708+
state
709+
.write()
710+
.unwrap()
711+
.set_project_dir(Utf8PlatformPathBuf::from(path));
712+
ui.close();
713+
}
705714
}
706-
}
707-
});
715+
},
716+
);
717+
} else {
718+
ui.add_enabled(false, egui::Button::new("Recent projects…"));
708719
}
709720
if ui.button("Appearance…").clicked() {
710721
*show_appearance_config = !*show_appearance_config;
@@ -718,7 +729,7 @@ impl eframe::App for App {
718729
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
719730
}
720731
});
721-
ui.menu_button("Tools", |ui| {
732+
egui::menu::menu_button(ui, "Tools", |ui| {
722733
if ui.button("Demangle…").clicked() {
723734
*show_demangle = !*show_demangle;
724735
ui.close();
@@ -728,7 +739,7 @@ impl eframe::App for App {
728739
ui.close();
729740
}
730741
});
731-
ui.menu_button("Diff Options", |ui| {
742+
egui::menu::menu_button(ui, "Diff Options", |ui| {
732743
if ui.button("Arch Settings…").clicked() {
733744
*show_arch_config = !*show_arch_config;
734745
ui.close();

0 commit comments

Comments
 (0)