Skip to content

Commit

Permalink
Update to egui 0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
KoffeinFlummi committed Feb 19, 2025
1 parent be61a3c commit 41a7fe8
Show file tree
Hide file tree
Showing 22 changed files with 242 additions and 583 deletions.
564 changes: 101 additions & 463 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ mint = "0.5.9"
half = { version = "2.4.1", default-features = false }
nalgebra = { version = "0.32", default-features = false, features = ["macros", "mint", "serde-serialize-no-std"] }
# egui & friends
egui = { version = "0.27", default-features = false }
egui-wgpu = { version = "0.27", features = [ "winit" ] }
egui-winit = { version = "0.27", default-features = false, features = [ "android-native-activity" ] }
eframe = { version = "0.27", default-features = false, features = ["glow", "wayland", "x11"] }
egui_plot = "0.27"
egui_extras = { version = "0.27", features = ["image"] }
egui = { version = "0.28", default-features = false }
egui-wgpu = { version = "0.28", features = [ "winit" ] }
egui-winit = { version = "0.28", default-features = false, features = [ "android-native-activity" ] }
eframe = { version = "0.28", default-features = false, features = ["glow", "wayland", "x11"] }
egui_plot = "0.28"
egui_extras = { version = "0.28", features = ["image"] }
# serialization & communication
heapless = { version = "0.8.0", features = ["serde"] }
serde = { version = "1", default-features = false, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion galadriel/src/drag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl egui::Widget for &mut DragCoefficient {
ui.add(
egui::DragValue::new(coef)
.speed(0.001)
.clamp_range(0.001..=10.0),
.range(0.001..=10.0),
)
},
DragCoefficient::Variable(coefficients) => {
Expand Down
12 changes: 6 additions & 6 deletions galadriel/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ impl egui::Widget for &mut Environment {
ui.add(
egui::DragValue::new(&mut self.launch_location.0)
.speed(0.000001)
.clamp_range(-90.0..=90.0)
.range(-90.0..=90.0)
);
ui.add(
egui::DragValue::new(&mut self.launch_location.1)
.speed(0.000001)
.clamp_range(-180.0..=180.0)
.range(-180.0..=180.0)
);
});
ui.end_row();
Expand All @@ -66,7 +66,7 @@ impl egui::Widget for &mut Environment {
egui::DragValue::new(&mut self.launch_altitude)
.suffix(" m")
.speed(0.1)
.clamp_range(-100.0..=6000.0)
.range(-100.0..=6000.0)
);
ui.end_row();

Expand All @@ -75,7 +75,7 @@ impl egui::Widget for &mut Environment {
egui::DragValue::new(&mut self.launch_rail_length)
.suffix(" m")
.speed(0.1)
.clamp_range(1.0..=100.0)
.range(1.0..=100.0)
);
ui.end_row();

Expand All @@ -84,7 +84,7 @@ impl egui::Widget for &mut Environment {
egui::DragValue::new(&mut self.azimuth)
.suffix(" °")
.speed(0.1)
.clamp_range(0.0..=360.0)
.range(0.0..=360.0)
);
ui.end_row();

Expand All @@ -93,7 +93,7 @@ impl egui::Widget for &mut Environment {
egui::DragValue::new(&mut self.elevation)
.suffix(" °")
.speed(0.1)
.clamp_range(0.0..=90.0)
.range(0.0..=90.0)
);
ui.end_row();
});
Expand Down
2 changes: 1 addition & 1 deletion galadriel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl egui::Widget for &mut SimulationSettings {
egui::DragValue::new(&mut self.delta_time)
.suffix(" ms")
.speed(1)
.clamp_range(1..=1000),
.range(1..=1000),
);
ui.end_row();
});
Expand Down
8 changes: 4 additions & 4 deletions galadriel/src/motor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ impl egui::Widget for &mut MotorSettings {
egui::DragValue::new(&mut self.wet_mass)
.suffix(" kg")
.speed(0.001)
.clamp_range(0.0..=200.0),
.range(0.0..=200.0),
);
ui.weak("wet, ");
ui.add(
egui::DragValue::new(&mut self.dry_mass)
.suffix(" kg")
.speed(0.001)
.clamp_range(0.0..=200.0),
.range(0.0..=200.0),
);
ui.weak("dry");
});
Expand All @@ -198,7 +198,7 @@ impl egui::Widget for &mut MotorSettings {
ui.add(
egui::DragValue::new(&mut self.performance)
.speed(0.001)
.clamp_range(0.0..=10.0),
.range(0.0..=10.0),
);
ui.end_row();

Expand All @@ -207,7 +207,7 @@ impl egui::Widget for &mut MotorSettings {
egui::DragValue::new(&mut self.impulse)
.suffix(" Ns")
.speed(0.1)
.clamp_range(0.0..=15000.0),
.range(0.0..=15000.0),
);
ui.end_row();

Expand Down
2 changes: 1 addition & 1 deletion galadriel/src/parachute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl egui::Widget for &mut ParachuteSettings {
egui::DragValue::new(&mut self.area)
.suffix(" m²")
.speed(0.001)
.clamp_range(0.001..=100.0),
.range(0.001..=100.0),
);
ui.end_row();
ui.label("Drag coef.");
Expand Down
4 changes: 2 additions & 2 deletions galadriel/src/rocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl egui::Widget for &mut RocketSettings {
egui::DragValue::new(&mut self.dry_mass)
.suffix(" kg")
.speed(0.001)
.clamp_range(0.0..=200.0),
.range(0.0..=200.0),
);
ui.weak("(without motor casing)");
});
Expand All @@ -146,7 +146,7 @@ impl egui::Widget for &mut RocketSettings {
egui::DragValue::new(&mut self.area)
.suffix(" m²")
.speed(0.001)
.clamp_range(0.0..=1.0),
.range(0.0..=1.0),
);
ui.end_row();

Expand Down
12 changes: 6 additions & 6 deletions galadriel/src/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl egui::Widget for &mut SensorSettings {
egui::DragValue::new(&mut self.std_dev_gyroscope)
.suffix(" °/s")
.speed(0.001)
.clamp_range(0.001..=100.0),
.range(0.001..=100.0),
);
ui.end_row();

Expand All @@ -109,7 +109,7 @@ impl egui::Widget for &mut SensorSettings {
egui::DragValue::new(&mut self.std_dev_accelerometer1)
.suffix(" m/s²")
.speed(0.001)
.clamp_range(0.001..=100.0),
.range(0.001..=100.0),
);
ui.end_row();

Expand All @@ -118,7 +118,7 @@ impl egui::Widget for &mut SensorSettings {
egui::DragValue::new(&mut self.std_dev_accelerometer2)
.suffix(" m/s²")
.speed(0.001)
.clamp_range(0.001..=100.0),
.range(0.001..=100.0),
);
ui.end_row();

Expand All @@ -127,7 +127,7 @@ impl egui::Widget for &mut SensorSettings {
egui::DragValue::new(&mut self.std_dev_magnetometer)
.suffix(" µT")
.speed(0.001)
.clamp_range(0.001..=100.0),
.range(0.001..=100.0),
);
ui.end_row();

Expand All @@ -136,15 +136,15 @@ impl egui::Widget for &mut SensorSettings {
egui::DragValue::new(&mut self.std_dev_barometer)
.suffix(" m")
.speed(0.001)
.clamp_range(0.001..=10000.0),
.range(0.001..=10000.0),
);
ui.end_row();

ui.label("Barometer IIR α");
ui.add(
egui::DragValue::new(&mut self.barometer_iir_alpha)
.speed(0.0001)
.clamp_range(0.9..=1.0),
.range(0.9..=1.0),
);
ui.end_row();
});
Expand Down
12 changes: 6 additions & 6 deletions galadriel/src/thrusters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ impl egui::Widget for &mut ThrusterSettings {
egui::DragValue::new(&mut self.propellant_mass)
.suffix(" kg")
.speed(0.001)
.clamp_range(0.0..=200.0),
.range(0.0..=200.0),
);
ui.weak(" with ");
ui.add(
egui::DragValue::new(&mut self.propellant_density)
.suffix(" kg/^3")
.speed(0.001)
.clamp_range(0.0..=200.0),
.range(0.0..=200.0),
);
ui.weak(" in ");
ui.add(
egui::DragValue::new(&mut self.tank_volume)
.suffix(" L")
.speed(0.01)
.clamp_range(0.0..=200.0),
.range(0.0..=200.0),
);
});
ui.end_row();
Expand All @@ -126,7 +126,7 @@ impl egui::Widget for &mut ThrusterSettings {
egui::DragValue::new(&mut self.nominal_tank_pressure)
.suffix(" bar")
.speed(0.1)
.clamp_range(0.0..=1000.0),
.range(0.0..=1000.0),
);
ui.end_row();

Expand All @@ -136,14 +136,14 @@ impl egui::Widget for &mut ThrusterSettings {
egui::DragValue::new(&mut self.nominal_thrust)
.suffix(" N")
.speed(0.01)
.clamp_range(0.0..=1000.0),
.range(0.0..=1000.0),
);
ui.weak(format!(" @ {}bar, ", self.nominal_tank_pressure));
ui.add(
egui::DragValue::new(&mut self.thrust_pressure_slope)
.suffix(" N/bar")
.speed(0.01)
.clamp_range(0.0..=1000.0),
.range(0.0..=1000.0),
);
});
ui.end_row();
Expand Down
6 changes: 3 additions & 3 deletions gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ eframe = { workspace = true }
egui_plot = { workspace = true }
egui_extras = { workspace = true }
image = { version = "0.24", default-features = false, features = ["jpeg", "png"] }
egui_tiles = "0.8.0"
transform-gizmo-egui = "0.1.0"
walkers = "0.22"
egui_tiles = "0.9.0"
transform-gizmo-egui = "0.3.0"
walkers = "0.24"
# serialization & communication
heapless = { workspace = true }
serde = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion gui/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ pub trait ReplayableDataSource: DataSource {
let total = (last - first).as_secs_f32();
let elapsed = self.end().map(|p| (p - first).as_secs_f32()).unwrap_or(0.0);

ui.set_enabled(self.playback_state().is_some());
if self.playback_state().is_none() {
ui.disable();
}

if ui.button("⏮").clicked() {
*self.playback_state_mut() = Some(PlaybackState::Paused(first));
Expand Down
13 changes: 6 additions & 7 deletions gui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ impl Sam {
#[cfg(feature = "profiling")]
puffin::profile_function!();

ui.set_enabled(!self.archive_window.open);
if self.archive_window.open {
ui.disable();
}

ui.allocate_ui_with_layout(ui.available_size(), Layout::right_to_left(Align::Center), |ui| {
match self.tab {
GuiTab::Launch => {}
Expand All @@ -214,11 +217,7 @@ impl Sam {

// Everything else. This has to be called after all the other panels are created.
match self.tab {
GuiTab::Launch => {
egui::CentralPanel::default().show(ctx, |ui| {
ui.set_enabled(enabled)
}).inner
}
GuiTab::Launch => egui::CentralPanel::default().show(ctx, |_ui| {}).inner,
GuiTab::Plot => self.plot_tab.main_ui(ctx, data_source.deref_mut(), &mut self.settings, enabled),
GuiTab::Configure => {
let changed = self.configure_tab.main_ui(ctx, data_source.deref_mut(), &mut self.settings, enabled);
Expand Down Expand Up @@ -267,7 +266,7 @@ pub fn main(log_file: Option<PathBuf>, simulate: Option<Option<String>>) -> Resu
},
..Default::default()
},
Box::new(|cc| Box::new(Sam::init(&cc.egui_ctx, app_settings, data_source))),
Box::new(|cc| Ok(Box::new(Sam::init(&cc.egui_ctx, app_settings, data_source)))),
)?;

Ok(())
Expand Down
16 changes: 9 additions & 7 deletions gui/src/panels/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,19 @@ impl HeaderPanel {

if ctx.screen_rect().width() > 1000.0 {
egui::TopBottomPanel::top("topbar").min_height(60.0).max_height(60.0).show(ctx, |ui| {
ui.set_enabled(enabled);
ui.horizontal_centered(|ui| {
Self::header_ui(ui, data_source, false);
ui.add_enabled_ui(enabled, |ui| {
ui.horizontal_centered(|ui| {
Self::header_ui(ui, data_source, false);
})
});
});
} else {
egui::TopBottomPanel::top("topbar").min_height(20.0).max_height(300.0).show(ctx, |ui| {
ui.set_enabled(enabled);
CollapsingHeader::new("Status & Controls").default_open(false).show(ui, |ui| {
Self::header_ui(ui, data_source, true);
ui.add_space(10.0);
ui.add_enabled_ui(enabled, |ui| {
CollapsingHeader::new("Status & Controls").default_open(false).show(ui, |ui| {
Self::header_ui(ui, data_source, true);
ui.add_space(10.0);
});
});
});
}
Expand Down
5 changes: 4 additions & 1 deletion gui/src/panels/menu_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ impl MenuBarPanel {
let data_source_is_log = any.is::<LogFileDataSource>();

egui::TopBottomPanel::top("menubar").min_height(30.0).max_height(30.0).show(ctx, |ui| {
ui.set_enabled(enabled);
if !enabled {
ui.disable();
}

ui.horizontal_centered(|ui| {
let image = if ui.style().visuals.dark_mode {
egui::Image::new(egui::include_image!("../../assets/logo_dark_mode.png"))
Expand Down
13 changes: 9 additions & 4 deletions gui/src/panels/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ impl SimulationPanel {
let old_settings = data_source.settings.clone();

egui::SidePanel::left("sim").min_width(300.0).max_width(500.0).resizable(true).show(ctx, |ui| {
ui.set_enabled(enabled);
if !enabled {
ui.disable();
}

ui.add_space(10.0);
ui.heading("Simulation");
ui.add_space(10.0);
Expand Down Expand Up @@ -44,11 +47,13 @@ impl SimulationPanel {
ui.end_row();
});

// Disable other settings if we are using a source log
ui.set_enabled(data_source.settings.replicated_log_id.is_none());
ui.add_space(10.0);

ui.add(&mut data_source.settings.galadriel);
// Disable other settings if we are using a source log
ui.add_enabled(
data_source.settings.replicated_log_id.is_none(),
&mut data_source.settings.galadriel
);
})
});

Expand Down
Loading

0 comments on commit 41a7fe8

Please sign in to comment.