mirror of https://codeberg.org/topola/topola.git
egui: add frame timestep slider
This commit is contained in:
parent
1c7042c8c3
commit
96af3bcd7f
|
|
@ -36,4 +36,6 @@ show-origin-destination = Show Origin–Destination
|
|||
|
||||
show-layer-manager = Show Layer Manager
|
||||
|
||||
frame-timestep = Frame Timestep
|
||||
|
||||
specctra-session-file = Specctra session file
|
||||
|
|
|
|||
|
|
@ -124,15 +124,19 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
fn update_state(&mut self, dt: f32) {
|
||||
fn advance_state_by_dt(&mut self, dt: f32) {
|
||||
self.update_counter += dt;
|
||||
|
||||
if self.update_counter <= 0.1 {
|
||||
while self.update_counter >= self.top.frame_timestep {
|
||||
self.update_counter -= self.top.frame_timestep;
|
||||
|
||||
if !self.update_state() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.update_counter = 0.0;
|
||||
|
||||
fn update_state(&mut self) -> bool {
|
||||
let mut content_file_receiver = FileReceiver::new(&self.content_channel.1);
|
||||
|
||||
if let Ok(bufread) = content_file_receiver.try_recv() {
|
||||
|
|
@ -155,13 +159,16 @@ impl App {
|
|||
}
|
||||
|
||||
if let Some(ref mut execute) = self.maybe_execute {
|
||||
let status = match execute.step(invoker) {
|
||||
Ok(status) => status,
|
||||
Err(err) => return,
|
||||
};
|
||||
match execute.step(invoker) {
|
||||
Ok(InvokerStatus::Running) => return true,
|
||||
Ok(InvokerStatus::Finished(..)) => return false,
|
||||
Err(err) => return false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl eframe::App for App {
|
||||
|
|
@ -184,7 +191,7 @@ impl eframe::App for App {
|
|||
&self.maybe_design,
|
||||
);
|
||||
|
||||
self.update_state(ctx.input(|i| i.stable_dt));
|
||||
self.advance_state_by_dt(ctx.input(|i| i.stable_dt));
|
||||
|
||||
self.bottom
|
||||
.update(ctx, &self.translator, &self.viewport, &self.maybe_execute);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ pub struct Top {
|
|||
pub show_bboxes: bool,
|
||||
pub show_origin_destination: bool,
|
||||
pub show_layer_manager: bool,
|
||||
pub frame_timestep: f32,
|
||||
}
|
||||
|
||||
impl Top {
|
||||
|
|
@ -49,6 +50,7 @@ impl Top {
|
|||
show_bboxes: false,
|
||||
show_origin_destination: false,
|
||||
show_layer_manager: true,
|
||||
frame_timestep: 0.1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,6 +175,14 @@ impl Top {
|
|||
ui.separator();
|
||||
|
||||
ui.checkbox(&mut self.show_layer_manager, tr.text("show-layer-manager"));
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.label(tr.text("frame-timestep"));
|
||||
ui.add(egui::widgets::Slider::new(
|
||||
&mut self.frame_timestep,
|
||||
0.0..=3.0,
|
||||
));
|
||||
});
|
||||
|
||||
ui.menu_button(tr.text("menu-place"), |ui| {
|
||||
|
|
|
|||
Loading…
Reference in New Issue