Refactor upper_menu to have sub functions for menu structure
This commit is contained in:
parent
e855732901
commit
35eba6f906
|
|
@ -19,66 +19,66 @@ pub fn render_menu_bar(
|
|||
) {
|
||||
egui::MenuBar::new().ui(ui, |ui| {
|
||||
ui.menu_button("File", |ui| {
|
||||
if ui.button("New Plate").clicked() {
|
||||
crate::modals::open_new_plate_modal(modal_state);
|
||||
}
|
||||
ui.menu_button("Export", |ui| {
|
||||
render_export_menu(
|
||||
ui,
|
||||
main_state,
|
||||
modal_state,
|
||||
current_transfer_state,
|
||||
main_window_state,
|
||||
);
|
||||
});
|
||||
ui.menu_button("Import", |ui| {
|
||||
if ui.button("Import from JSON").clicked() {}
|
||||
if ui.button("Import transfer from CSV").clicked() {}
|
||||
});
|
||||
if ui.button("Reset All").clicked() {
|
||||
*main_state = MainState::default();
|
||||
*current_transfer_state = CurrentTransferState::default();
|
||||
}
|
||||
if ui.button("Dump State").clicked() {
|
||||
log::warn!("{:?}\n{:?}", main_state, current_transfer_state);
|
||||
}
|
||||
render_file_menu(
|
||||
ui,
|
||||
main_state,
|
||||
modal_state,
|
||||
current_transfer_state,
|
||||
main_window_state,
|
||||
);
|
||||
});
|
||||
ui.menu_button("Options", |ui| {
|
||||
ui.menu_button("Styles", |ui| {
|
||||
ui.toggle_value(
|
||||
&mut main_window_state.plate_display_options.show_transfer_hashes,
|
||||
"Toggle transfer hashes",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut main_window_state.plate_display_options.show_volume_heatmap,
|
||||
"Toggle volume heatmap",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut main_window_state.plate_display_options.show_coordinates,
|
||||
"Toggle coordinate highlighting",
|
||||
);
|
||||
});
|
||||
ui.menu_button("Exports", |ui| {
|
||||
ui.menu_button("CSV Export Type", |ui| {
|
||||
ui.radio_value(
|
||||
&mut main_window_state.csv_export_type,
|
||||
CsvExportType::Normal,
|
||||
format!("{}", CsvExportType::Normal),
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut main_window_state.csv_export_type,
|
||||
CsvExportType::EchoClient,
|
||||
format!("{}", CsvExportType::EchoClient),
|
||||
);
|
||||
});
|
||||
});
|
||||
ui.menu_button("Windows", |ui| {
|
||||
ui.toggle_value(&mut main_window_state.show_side_panel, "Toggle side panel");
|
||||
});
|
||||
render_options_menu(
|
||||
ui,
|
||||
main_state,
|
||||
modal_state,
|
||||
current_transfer_state,
|
||||
main_window_state,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn render_file_menu(
|
||||
ui: &mut egui::Ui,
|
||||
main_state: &mut MainState,
|
||||
modal_state: &mut ModalState,
|
||||
current_transfer_state: &mut CurrentTransferState,
|
||||
main_window_state: &mut MainWindowState,
|
||||
) {
|
||||
if ui.button("New Plate").clicked() {
|
||||
crate::modals::open_new_plate_modal(modal_state);
|
||||
}
|
||||
|
||||
ui.menu_button("Export", |ui| {
|
||||
render_export_menu(
|
||||
ui,
|
||||
main_state,
|
||||
modal_state,
|
||||
current_transfer_state,
|
||||
main_window_state,
|
||||
);
|
||||
});
|
||||
|
||||
ui.menu_button("Import", |ui| {
|
||||
render_import_menu(
|
||||
ui,
|
||||
main_state,
|
||||
modal_state,
|
||||
current_transfer_state,
|
||||
main_window_state,
|
||||
);
|
||||
});
|
||||
|
||||
if ui.button("Reset All").clicked() {
|
||||
*main_state = MainState::default();
|
||||
*current_transfer_state = CurrentTransferState::default();
|
||||
}
|
||||
if ui.button("Dump State").clicked() {
|
||||
log::warn!("{:?}\n{:?}", main_state, current_transfer_state);
|
||||
}
|
||||
}
|
||||
|
||||
fn render_export_menu(
|
||||
ui: &mut egui::Ui,
|
||||
main_state: &mut MainState,
|
||||
|
|
@ -137,3 +137,54 @@ fn render_export_menu(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_import_menu(
|
||||
ui: &mut egui::Ui,
|
||||
_main_state: &mut MainState,
|
||||
_modal_state: &mut ModalState,
|
||||
_current_transfer_state: &mut CurrentTransferState,
|
||||
_main_window_state: &mut MainWindowState,
|
||||
) {
|
||||
if ui.button("Import from JSON").clicked() {}
|
||||
if ui.button("Import transfer from CSV").clicked() {}
|
||||
}
|
||||
|
||||
fn render_options_menu(
|
||||
ui: &mut egui::Ui,
|
||||
_main_state: &mut MainState,
|
||||
_modal_state: &mut ModalState,
|
||||
_current_transfer_state: &mut CurrentTransferState,
|
||||
main_window_state: &mut MainWindowState,
|
||||
) {
|
||||
ui.menu_button("Styles", |ui| {
|
||||
ui.toggle_value(
|
||||
&mut main_window_state.plate_display_options.show_transfer_hashes,
|
||||
"Toggle transfer hashes",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut main_window_state.plate_display_options.show_volume_heatmap,
|
||||
"Toggle volume heatmap",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut main_window_state.plate_display_options.show_coordinates,
|
||||
"Toggle coordinate highlighting",
|
||||
);
|
||||
});
|
||||
ui.menu_button("Exports", |ui| {
|
||||
ui.menu_button("CSV Export Type", |ui| {
|
||||
ui.radio_value(
|
||||
&mut main_window_state.csv_export_type,
|
||||
CsvExportType::Normal,
|
||||
format!("{}", CsvExportType::Normal),
|
||||
);
|
||||
ui.radio_value(
|
||||
&mut main_window_state.csv_export_type,
|
||||
CsvExportType::EchoClient,
|
||||
format!("{}", CsvExportType::EchoClient),
|
||||
);
|
||||
});
|
||||
});
|
||||
ui.menu_button("Windows", |ui| {
|
||||
ui.toggle_value(&mut main_window_state.show_side_panel, "Toggle side panel");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue