fix issue with plot buttons running out of usable display space

This commit is contained in:
jess 2026-05-15 23:54:06 -07:00
parent 94a930fe3b
commit 7b29447fa6
2 changed files with 27 additions and 17 deletions

View File

@ -1618,29 +1618,23 @@ impl App {
.on_submit(Message::ProbeSubmitAngle(i))
.size(10)
.width(Length::Fixed(40.0));
let mode_picker = iced::widget::pick_list(
probe::PROBE_MODES,
Some(p.mode),
move |m| Message::ProbeSetMode(i, m),
)
.text_size(10)
.width(Length::Fixed(78.0));
let mode_row = row![
button(text(p.label.clone()).size(11)).style(button::secondary),
text(p.label.clone()).size(11),
button(text("<").size(10)).on_press(Message::ProbeRotateBy(i, -15.0)).style(button::secondary),
angle_input,
text("deg").size(10),
button(text(">").size(10)).on_press(Message::ProbeRotateBy(i, 15.0)).style(button::secondary),
button(text("|B|").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Magnitude))
.style(if p.mode == probe::ProbeMode::Magnitude { button::primary } else { button::secondary }),
button(text("Bx").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Bx))
.style(if p.mode == probe::ProbeMode::Bx { button::primary } else { button::secondary }),
button(text("By").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::By))
.style(if p.mode == probe::ProbeMode::By { button::primary } else { button::secondary }),
button(text("ang").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Angle))
.style(if p.mode == probe::ProbeMode::Angle { button::primary } else { button::secondary }),
button(text("Pri").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Primary))
.style(if p.mode == probe::ProbeMode::Primary { button::primary } else { button::secondary }),
button(text("Per").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Perpendicular))
.style(if p.mode == probe::ProbeMode::Perpendicular { button::primary } else { button::secondary }),
button(text("Diff").size(10)).on_press(Message::ProbeSetMode(i, probe::ProbeMode::Differential))
.style(if p.mode == probe::ProbeMode::Differential { button::primary } else { button::secondary }),
mode_picker,
button(text("wav").size(10)).on_press(Message::ProbeExportWav(i)).style(button::secondary),
button(text("x").size(10)).on_press(Message::ProbeRemove(i)).style(button::danger),
].spacing(2);
].spacing(2).align_y(Alignment::Center);
let plot_canvas: Element<'_, Message> =
plot::view::<Message>(p, samples, sim.frame_idx, sim.buffer_size.max(1));
let pane = column![mode_row, plot_canvas]

View File

@ -1,7 +1,7 @@
//! point-sample probes for the magnetic field, time-series plotted per frame in a panel below the canvas.
/// signal extracted from the (bx, by) sample at a probe location for waveform plotting.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
pub enum ProbeMode {
#[default]
Magnitude,
@ -13,6 +13,16 @@ pub enum ProbeMode {
Differential,
}
pub const PROBE_MODES: &[ProbeMode] = &[
ProbeMode::Magnitude,
ProbeMode::Bx,
ProbeMode::By,
ProbeMode::Angle,
ProbeMode::Primary,
ProbeMode::Perpendicular,
ProbeMode::Differential,
];
impl ProbeMode {
pub fn label(self) -> &'static str {
match self {
@ -55,6 +65,12 @@ pub struct Probe {
pub selected: bool,
}
impl std::fmt::Display for ProbeMode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.label())
}
}
/// returns a saturated palette color from a small cycling palette suitable for probe markers and matching plot lines.
pub fn palette_color(idx: usize) -> [u8; 4] {
const PALETTE: &[[u8; 4]] = &[