Option to show plates side-by-side (horizontally)
This commit is contained in:
parent
35eba6f906
commit
fb095d644d
|
|
@ -22,6 +22,7 @@ pub struct MainWindowState {
|
||||||
pub show_side_panel: bool,
|
pub show_side_panel: bool,
|
||||||
pub plate_display_options: PlateDisplayOptions,
|
pub plate_display_options: PlateDisplayOptions,
|
||||||
pub csv_export_type: CsvExportType,
|
pub csv_export_type: CsvExportType,
|
||||||
|
pub show_plates_horizontal: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MainWindowState {
|
impl Default for MainWindowState {
|
||||||
|
|
@ -30,6 +31,7 @@ impl Default for MainWindowState {
|
||||||
show_side_panel: true,
|
show_side_panel: true,
|
||||||
plate_display_options: PlateDisplayOptions::default(),
|
plate_display_options: PlateDisplayOptions::default(),
|
||||||
csv_export_type: CsvExportType::default(),
|
csv_export_type: CsvExportType::default(),
|
||||||
|
show_plates_horizontal: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,45 +151,85 @@ impl eframe::App for PlateToolEframe {
|
||||||
ids.sort_unstable();
|
ids.sort_unstable();
|
||||||
ids
|
ids
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn add_plates(
|
||||||
|
ui: &mut egui::Ui,
|
||||||
|
main_state: &MainState,
|
||||||
|
current_transfer_state: &CurrentTransferState,
|
||||||
|
source_plate_state: &Mutex<PlateUiState>,
|
||||||
|
destination_plate_state: &Mutex<PlateUiState>,
|
||||||
|
main_window_state: &MainWindowState,
|
||||||
|
plate_size: egui::Vec2,
|
||||||
|
ordered_ids: Vec<plate_tool_lib::uuid::Uuid>,
|
||||||
|
) {
|
||||||
|
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| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.vertical(|ui| {
|
|
||||||
let available_size = ui.available_size();
|
let available_size = ui.available_size();
|
||||||
let half_height = {
|
if !self.main_window_state.show_plates_horizontal {
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
let plate_size = {
|
||||||
let mut x = available_size;
|
let mut x = available_size;
|
||||||
x.y /= 2.0;
|
x.y /= 2.0;
|
||||||
x
|
x
|
||||||
};
|
};
|
||||||
if let Some(source_pi) = self.main_state.get_current_source_plateinstance() {
|
add_plates(
|
||||||
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),
|
|
||||||
ui,
|
ui,
|
||||||
self.source_plate_state.lock().unwrap().deref_mut(),
|
&self.main_state,
|
||||||
self.main_window_state.plate_display_options,
|
&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),
|
|
||||||
ui,
|
|
||||||
self.destination_plate_state.lock().unwrap().deref_mut(),
|
|
||||||
self.main_window_state.plate_display_options,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
let plate_size = {
|
||||||
|
let mut x = available_size;
|
||||||
|
x.x /= 2.0;
|
||||||
|
x
|
||||||
|
};
|
||||||
|
add_plates(
|
||||||
|
ui,
|
||||||
|
&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
|
// Modal processing
|
||||||
|
|
|
||||||
|
|
@ -186,5 +186,6 @@ fn render_options_menu(
|
||||||
});
|
});
|
||||||
ui.menu_button("Windows", |ui| {
|
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_side_panel, "Toggle side panel");
|
||||||
|
ui.toggle_value(&mut main_window_state.show_plates_horizontal, "Show plates horizontally");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue