MCPcopy Create free account
hub / github.com/BillyDM/Firewheel / update

Method update

examples/sampler_test/src/ui.rs:39–150  ·  view source on GitHub ↗
(&mut self, cx: &egui::Context, _frame: &mut eframe::Frame)

Source from the content-addressed store, hash-verified

37
38impl App for DemoApp {
39 fn update(&mut self, cx: &egui::Context, _frame: &mut eframe::Frame) {
40 let now = Instant::now();
41 let dt = (now - self.prev_frame_instant).as_secs_f32();
42 self.prev_frame_instant = now;
43
44 self.audio_system.update_meters(dt);
45
46 egui::TopBottomPanel::top("top_panel").show(cx, |ui| {
47 egui::MenuBar::new().ui(ui, |ui| {
48 #[cfg(not(target_arch = "wasm32"))]
49 {
50 ui.menu_button("Menu", |ui| {
51 if ui.button("Quit").clicked() {
52 cx.send_viewport_cmd(egui::ViewportCommand::Close)
53 }
54 });
55 ui.add_space(16.0);
56 }
57
58 egui::widgets::global_theme_preference_switch(ui);
59 });
60 });
61
62 egui::CentralPanel::default().show(cx, |ui| {
63 for (i, sampler_state) in self.sampler_views.iter_mut().enumerate() {
64 ui.horizontal(|ui| {
65 ui.label(sampler_state.text);
66
67 if ui.button("Start or Restart").clicked() {
68 self.audio_system.start_or_restart(i);
69 }
70
71 if self.audio_system.is_playing(i) {
72 if ui.button("Pause").clicked() {
73 self.audio_system.pause(i);
74 }
75 } else if self.audio_system.is_paused(i) && ui.button("Resume").clicked() {
76 self.audio_system.resume(i);
77 }
78
79 if ui.button("Stop").clicked() {
80 self.audio_system.stop(i);
81 }
82
83 if ui.checkbox(&mut sampler_state.repeat, "repeat").changed() {
84 let repeat_mode = if sampler_state.repeat {
85 RepeatMode::RepeatEndlessly
86 } else {
87 RepeatMode::PlayOnce
88 };
89
90 self.audio_system.set_repeat_mode(i, repeat_mode);
91 }
92
93 if ui
94 .add(
95 egui::Slider::new(&mut sampler_state.percent_volume, 0.0..=100.0)
96 .text("volume"),

Callers

nothing calls this directly

Calls 15

nowFunction · 0.85
update_metersMethod · 0.80
uiMethod · 0.80
is_playingMethod · 0.80
is_pausedMethod · 0.80
set_repeat_modeMethod · 0.80
set_volumeMethod · 0.80
set_speedMethod · 0.80
peak_meter_valuesMethod · 0.80
start_or_restartMethod · 0.45
pauseMethod · 0.45

Tested by

no test coverage detected