// Copyright 2023 The Grim Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use egui::Context; use crate::gui::Colors; use crate::gui::platform::PlatformCallbacks; use crate::gui::views::Root; /// Implements ui entry point and contains platform-specific callbacks. pub struct PlatformApp { /// Platform specific callbacks handler. pub(crate) platform: Platform, /// Main ui content. root: Root } impl PlatformApp { pub fn new(platform: Platform) -> Self { Self { platform, root: Root::default() } } } impl eframe::App for PlatformApp { fn update(&mut self, ctx: &Context, frame: &mut eframe::Frame) { // Show main content. egui::CentralPanel::default() .frame(egui::Frame { fill: Colors::YELLOW, ..Default::default() }) .show(ctx, |ui| { self.root.ui(ui, frame, &self.platform); }); } fn on_close_event(&mut self) -> bool { Root::show_exit_modal(); self.root.exit_allowed } }