diff --git a/plate-tool-eframe/src/app.rs b/plate-tool-eframe/src/app.rs index 652006e..d1044b9 100644 --- a/plate-tool-eframe/src/app.rs +++ b/plate-tool-eframe/src/app.rs @@ -22,6 +22,7 @@ pub struct MainWindowState { pub show_side_panel: bool, pub plate_display_options: PlateDisplayOptions, pub csv_export_type: CsvExportType, + pub show_plates_horizontal: bool, } impl Default for MainWindowState { @@ -30,6 +31,7 @@ impl Default for MainWindowState { show_side_panel: true, plate_display_options: PlateDisplayOptions::default(), csv_export_type: CsvExportType::default(), + show_plates_horizontal: false, } } } @@ -149,45 +151,85 @@ impl eframe::App for PlateToolEframe { ids.sort_unstable(); ids }; + + fn add_plates( + ui: &mut egui::Ui, + main_state: &MainState, + current_transfer_state: &CurrentTransferState, + source_plate_state: &Mutex, + destination_plate_state: &Mutex, + main_window_state: &MainWindowState, + plate_size: egui::Vec2, + ordered_ids: Vec, + ) { + if let Some(source_pi) = main_state.get_current_source_plateinstance() { + add_plate( + plate_size, + source_pi.plate.plate_format, + main_state.get_current_source_transfers(), + plate_tool_lib::plate::PlateType::Source, + &ordered_ids, + &main_state.transfer_region_cache, + Some(¤t_transfer_state), + ui, + source_plate_state.lock().unwrap().deref_mut(), + main_window_state.plate_display_options, + ); + } + if let Some(destination_pi) = main_state.get_current_destination_plateinstance() { + add_plate( + plate_size, + destination_pi.plate.plate_format, + main_state.get_current_destination_transfers(), + plate_tool_lib::plate::PlateType::Destination, + &ordered_ids, + &main_state.transfer_region_cache, + Some(¤t_transfer_state), + ui, + destination_plate_state.lock().unwrap().deref_mut(), + main_window_state.plate_display_options, + ); + } + } egui::CentralPanel::default().show(ctx, |ui| { - ui.vertical(|ui| { - let available_size = ui.available_size(); - let half_height = { - let mut x = available_size; - x.y /= 2.0; - x - }; - if let Some(source_pi) = self.main_state.get_current_source_plateinstance() { - add_plate( - half_height, - source_pi.plate.plate_format, - self.main_state.get_current_source_transfers(), - plate_tool_lib::plate::PlateType::Source, - &ordered_ids, - &self.main_state.transfer_region_cache, - Some(&self.current_transfer_state), + let available_size = ui.available_size(); + if !self.main_window_state.show_plates_horizontal { + ui.vertical(|ui| { + let plate_size = { + let mut x = available_size; + x.y /= 2.0; + x + }; + add_plates( ui, - self.source_plate_state.lock().unwrap().deref_mut(), - self.main_window_state.plate_display_options, + &self.main_state, + &self.current_transfer_state, + &self.source_plate_state, + &self.destination_plate_state, + &self.main_window_state, + plate_size, + ordered_ids, ); - } - if let Some(destination_pi) = - self.main_state.get_current_destination_plateinstance() - { - add_plate( - half_height, - destination_pi.plate.plate_format, - self.main_state.get_current_destination_transfers(), - plate_tool_lib::plate::PlateType::Destination, - &ordered_ids, - &self.main_state.transfer_region_cache, - Some(&self.current_transfer_state), + }); + } else { + ui.horizontal(|ui| { + let plate_size = { + let mut x = available_size; + x.x /= 2.0; + x + }; + add_plates( ui, - self.destination_plate_state.lock().unwrap().deref_mut(), - self.main_window_state.plate_display_options, + &self.main_state, + &self.current_transfer_state, + &self.source_plate_state, + &self.destination_plate_state, + &self.main_window_state, + plate_size, + ordered_ids, ); - } - }); + }); + } }); // Modal processing diff --git a/plate-tool-eframe/src/upper_menu.rs b/plate-tool-eframe/src/upper_menu.rs index 4eea045..1086352 100644 --- a/plate-tool-eframe/src/upper_menu.rs +++ b/plate-tool-eframe/src/upper_menu.rs @@ -186,5 +186,6 @@ fn render_options_menu( }); ui.menu_button("Windows", |ui| { ui.toggle_value(&mut main_window_state.show_side_panel, "Toggle side panel"); + ui.toggle_value(&mut main_window_state.show_plates_horizontal, "Show plates horizontally"); }); }