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 tracing::{error, info};
@ -132,30 +132,25 @@ impl eframe::App for TemplateApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let Self { .. } = self;
// Examples of how to create different panels and windows.
// Pick whichever suits you.
// Tip: a good default choice is to just keep the `CentralPanel`.
// For inspiration and more examples, go to https://emilk.github.io/egui
let mut style: Style = (*ctx.style()).clone();
style.spacing.button_padding = BUTTON_PADDING;
ctx.set_style(style);
#[cfg(not(target_arch = "wasm32"))] // no File->Quit on web pages!
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| {
if ui.button("Quit").clicked() {
_frame.close();
}
});
});
});
// #[cfg(not(target_arch = "wasm32"))]
// egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// // The top panel is often a good place for a menu bar:
// egui::menu::bar(ui, |ui| {
// ui.menu_button("File", |ui| {
// if ui.button("Quit").clicked() {
// _frame.close();
// }
// });
// });
// });
self.error_state = ErrorState::default();
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));
Frame::none().fill(Color32::GREEN).show(ui, |ui| {
@ -182,13 +177,6 @@ impl eframe::App for TemplateApp {
{
info!("Clicked button {}", 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();