controls.rs (1716B)
1 use eframe::egui; 2 use egui::Ui; 3 4 use crate::app::SimApp; 5 use crate::state::RunState; 6 7 impl SimApp { 8 pub(crate) fn controls_ui(&mut self, ui: &mut Ui) { 9 // Two rows keep the controls within the width of the memory view. 10 ui.horizontal_wrapped(|ui| { 11 if ui.button("Reset [ctrl+r]").clicked() { 12 self.reset(); 13 } 14 if ui.button("Step cycle [space]").clicked() { 15 self.step_cycle(); 16 } 17 if ui.button("Next instruction [n]").clicked() { 18 self.next_instruction(); 19 } 20 let free_run_label = if self.run_state == RunState::FreeRun { 21 "Stop [ctrl+space]" 22 } else { 23 "Free run [ctrl+space]" 24 }; 25 if ui.button(free_run_label).clicked() { 26 self.toggle_free_run(); 27 } 28 }); 29 ui.horizontal_wrapped(|ui| { 30 if ui.button("Set PC to cursor [p]").clicked() { 31 self.set_pc_to_cursor(); 32 } 33 if ui.button("Run to cursor [ctrl+shift+space]").clicked() { 34 self.run_to_cursor(); 35 } 36 if ui.button("Run to PC").clicked() { 37 self.run_to_input_pc(); 38 } 39 if ui.button("Load memory").clicked() { 40 self.load_memory(); 41 } 42 if ui.button("Save memory").clicked() { 43 self.save_memory(); 44 } 45 }); 46 ui.horizontal_wrapped(|ui| { 47 let mut tracing = self.tracing; 48 if ui.toggle_value(&mut tracing, "Trace [t]").changed() { 49 self.toggle_trace(); 50 } 51 }); 52 } 53 }