Layout tweaks to make the window resizable again
This commit is contained in:
parent
d12ad8fc13
commit
961ca7c910
|
@ -14,7 +14,7 @@ mod widgets;
|
|||
|
||||
fn main() -> Result<(), eframe::Error> {
|
||||
let options = eframe::NativeOptions {
|
||||
viewport: egui::ViewportBuilder::default(),
|
||||
viewport: egui::ViewportBuilder::default().with_min_inner_size((1200.0, 700.0)),
|
||||
..Default::default()
|
||||
};
|
||||
eframe::run_native(
|
||||
|
@ -156,7 +156,9 @@ impl eframe::App for CheapsdoControl {
|
|||
|
||||
ui.separator();
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
||||
self.output_control(ui, ctx);
|
||||
ui.separator();
|
||||
ui.vertical(|ui| {
|
||||
ui.vertical(|ui| ui.label(egui::RichText::new("TCXO Status").size(20.0)));
|
||||
ui.add_space(20.0);
|
||||
|
@ -164,10 +166,6 @@ impl eframe::App for CheapsdoControl {
|
|||
ui.add_space(20.0);
|
||||
self.show_plots(ui);
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
|
||||
self.output_control(ui, ctx);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use eframe::egui::Color32;
|
||||
use eframe::egui::{self};
|
||||
use eframe::egui::{Color32, Vec2};
|
||||
|
||||
use crate::serial;
|
||||
use crate::widgets;
|
||||
|
@ -12,92 +12,98 @@ const PLL_MAX_FREQ: u32 = 900_000_000;
|
|||
const OUT_MIN_FREQ: u32 = 500_000;
|
||||
const OUT_MAX_FREQ: u32 = 225_000_000;
|
||||
|
||||
//Layout::top_down(Align::Center)
|
||||
|
||||
impl CheapsdoControl {
|
||||
pub fn output_control(&mut self, ui: &mut egui::Ui, ctx: &egui::Context) {
|
||||
ui.vertical(|ui| {
|
||||
ui.label(egui::RichText::new("Output Settings").size(20.0));
|
||||
ui.add_space(20.0);
|
||||
egui::Grid::new("output_pll_settings")
|
||||
.spacing([20.0, 5.0])
|
||||
.show(ui, |ui| {
|
||||
ui.label("PLL A Frequency [Hz]");
|
||||
widgets::frequency_input(
|
||||
self.pll_a_frequency_id,
|
||||
&mut self.pll_settings.pll_a_frequency,
|
||||
PLL_MIN_FREQ,
|
||||
PLL_MAX_FREQ,
|
||||
&ctx,
|
||||
ui,
|
||||
);
|
||||
ui.end_row();
|
||||
|
||||
ui.label("PLL B Frequency [Hz]");
|
||||
widgets::frequency_input(
|
||||
self.pll_b_frequency_id,
|
||||
&mut self.pll_settings.pll_b_frequency,
|
||||
PLL_MIN_FREQ,
|
||||
PLL_MAX_FREQ,
|
||||
&ctx,
|
||||
ui,
|
||||
);
|
||||
ui.end_row();
|
||||
});
|
||||
|
||||
for i in 0..3 {
|
||||
ui.separator();
|
||||
|
||||
egui::Grid::new(format!("output_clk{}_settings", i + 1))
|
||||
ui.allocate_ui_with_layout(
|
||||
(250.0, 500.0).into(),
|
||||
egui::Layout::top_down(egui::Align::Center),
|
||||
|ui| {
|
||||
ui.label(egui::RichText::new("Output Settings").size(20.0));
|
||||
ui.add_space(20.0);
|
||||
egui::Grid::new("output_pll_settings")
|
||||
.spacing([20.0, 5.0])
|
||||
.show(ui, |ui| {
|
||||
ui.label(format!("MS{} PLL", i));
|
||||
widgets::pll_selector(&mut self.pll_settings.outputs[i].source, ui);
|
||||
ui.end_row();
|
||||
|
||||
ui.label(format!("MS{} Frequency [Hz]", i + 1));
|
||||
ui.label("PLL A Frequency [Hz]");
|
||||
widgets::frequency_input(
|
||||
self.output_frequency_id[i],
|
||||
&mut self.pll_settings.outputs[i].frequency,
|
||||
OUT_MIN_FREQ,
|
||||
OUT_MAX_FREQ,
|
||||
self.pll_a_frequency_id,
|
||||
&mut self.pll_settings.pll_a_frequency,
|
||||
PLL_MIN_FREQ,
|
||||
PLL_MAX_FREQ,
|
||||
&ctx,
|
||||
ui,
|
||||
);
|
||||
ui.end_row();
|
||||
|
||||
ui.label(format!("MS{} Enable", i + 1));
|
||||
|
||||
widgets::on_off_toggle(&mut self.pll_settings.outputs[i].enable, ui);
|
||||
|
||||
ui.label("PLL B Frequency [Hz]");
|
||||
widgets::frequency_input(
|
||||
self.pll_b_frequency_id,
|
||||
&mut self.pll_settings.pll_b_frequency,
|
||||
PLL_MIN_FREQ,
|
||||
PLL_MAX_FREQ,
|
||||
&ctx,
|
||||
ui,
|
||||
);
|
||||
ui.end_row();
|
||||
});
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
let apply_button = ui.add_enabled(
|
||||
self.cmd_tx.is_some(),
|
||||
egui::Button::new("Apply").fill(egui::Color32::DARK_GREEN),
|
||||
);
|
||||
if apply_button.clicked() {
|
||||
if let Some(cmd_tx) = &self.cmd_tx {
|
||||
cmd_tx
|
||||
.send(serial::Cmd::SetPLLSetting(self.pll_settings.clone()))
|
||||
.unwrap();
|
||||
}
|
||||
for i in 0..3 {
|
||||
ui.separator();
|
||||
|
||||
egui::Grid::new(format!("output_clk{}_settings", i + 1))
|
||||
.spacing([20.0, 5.0])
|
||||
.show(ui, |ui| {
|
||||
ui.label(format!("MS{} PLL", i));
|
||||
widgets::pll_selector(&mut self.pll_settings.outputs[i].source, ui);
|
||||
ui.end_row();
|
||||
|
||||
ui.label(format!("MS{} Frequency [Hz]", i + 1));
|
||||
widgets::frequency_input(
|
||||
self.output_frequency_id[i],
|
||||
&mut self.pll_settings.outputs[i].frequency,
|
||||
OUT_MIN_FREQ,
|
||||
OUT_MAX_FREQ,
|
||||
&ctx,
|
||||
ui,
|
||||
);
|
||||
ui.end_row();
|
||||
|
||||
ui.label(format!("MS{} Enable", i + 1));
|
||||
|
||||
widgets::on_off_toggle(&mut self.pll_settings.outputs[i].enable, ui);
|
||||
|
||||
ui.end_row();
|
||||
});
|
||||
}
|
||||
|
||||
ui.add_space(40.0);
|
||||
|
||||
let reset_button = ui.add_enabled(
|
||||
self.cmd_tx.is_some(),
|
||||
egui::Button::new("Reset").fill(egui::Color32::DARK_RED),
|
||||
);
|
||||
if reset_button.clicked() {
|
||||
if let Some(cmd_tx) = &self.cmd_tx {
|
||||
cmd_tx.send(serial::Cmd::GetPLLSettings).unwrap();
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
let apply_button = ui.add_enabled(
|
||||
self.cmd_tx.is_some(),
|
||||
egui::Button::new("Apply").fill(egui::Color32::DARK_GREEN),
|
||||
);
|
||||
if apply_button.clicked() {
|
||||
if let Some(cmd_tx) = &self.cmd_tx {
|
||||
cmd_tx
|
||||
.send(serial::Cmd::SetPLLSetting(self.pll_settings.clone()))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ui.add_space(40.0);
|
||||
|
||||
let reset_button = ui.add_enabled(
|
||||
self.cmd_tx.is_some(),
|
||||
egui::Button::new("Reset").fill(egui::Color32::DARK_RED),
|
||||
);
|
||||
if reset_button.clicked() {
|
||||
if let Some(cmd_tx) = &self.cmd_tx {
|
||||
cmd_tx.send(serial::Cmd::GetPLLSettings).unwrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ impl CheapsdoControl {
|
|||
pub fn show_plots(&self, ui: &mut egui::Ui) {
|
||||
let average_line = Line::new(PlotPoints::new(self.average_points.clone()));
|
||||
Plot::new("frequency_plot")
|
||||
.width(900.0)
|
||||
.view_aspect(3.0)
|
||||
.view_aspect(3.5)
|
||||
.allow_zoom(false)
|
||||
.allow_scroll(false)
|
||||
.allow_drag(false)
|
||||
|
@ -67,8 +66,7 @@ impl CheapsdoControl {
|
|||
|
||||
let pwm_line = Line::new(PlotPoints::new(self.pwm_points.clone()));
|
||||
Plot::new("pwm_plot")
|
||||
.width(900.0)
|
||||
.view_aspect(3.0)
|
||||
.view_aspect(3.5)
|
||||
.allow_zoom(false)
|
||||
.allow_scroll(false)
|
||||
.allow_drag(false)
|
||||
|
|
Loading…
Reference in New Issue