This commit is contained in:
Austen Adler 2023-09-18 22:17:30 -04:00
parent 191b2da96c
commit c713e0dbd1

View File

@ -1,4 +1,4 @@
use egui::{Button, Color32, FontId, Frame, Grid, Key, Label, RichText, Rounding, Stroke, Vec2}; use egui::{Button, Color32, FontId, Frame, Grid, Key, Label, RichText, Rounding, Stroke, Vec2, Style};
use rpn_rs::calc::{errors::CalculatorError, Calculator}; use rpn_rs::calc::{errors::CalculatorError, Calculator};
use tracing::{error, info}; use tracing::{error, info};
@ -132,30 +132,25 @@ impl eframe::App for TemplateApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let Self { .. } = self; let Self { .. } = self;
// Examples of how to create different panels and windows. let mut style: Style = (*ctx.style()).clone();
// Pick whichever suits you. style.spacing.button_padding = BUTTON_PADDING;
// Tip: a good default choice is to just keep the `CentralPanel`. ctx.set_style(style);
// For inspiration and more examples, go to https://emilk.github.io/egui
#[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages! // #[cfg(not(target_arch = "wasm32"))]
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { // egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar: // // The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| { // egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| { // ui.menu_button("File", |ui| {
if ui.button("Quit").clicked() { // if ui.button("Quit").clicked() {
_frame.close(); // _frame.close();
} // }
}); // });
}); // });
}); // });
self.error_state = ErrorState::default(); self.error_state = ErrorState::default();
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {
ui.style_mut().spacing.button_padding = BUTTON_PADDING;
// The central panel the region left after adding TopPanel's and SidePanel's
ui.input(|i: &egui::InputState| self.handle_input(i)); ui.input(|i: &egui::InputState| self.handle_input(i));
Frame::none().fill(Color32::GREEN).show(ui, |ui| { Frame::none().fill(Color32::GREEN).show(ui, |ui| {
@ -182,13 +177,6 @@ impl eframe::App for TemplateApp {
{ {
info!("Clicked button {}", button.value); info!("Clicked button {}", button.value);
self.calculator_input(button.value); self.calculator_input(button.value);
// if let Err(e) = self.calculator.take_input(button.value) {
// error!("Calculator input error: {e:?}");
// self.latest_error = Some(e);
// fresh_error = true;
// } else if !fresh_error {
// self.latest_error = None;
// }
} }
} }
ui.end_row(); ui.end_row();