2023-04-12 21:52:35 +03:00
|
|
|
// 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.
|
|
|
|
|
2023-04-27 01:28:55 +03:00
|
|
|
use std::cmp::min;
|
|
|
|
|
2023-04-19 02:14:39 +03:00
|
|
|
use eframe::Frame;
|
2023-04-27 01:28:55 +03:00
|
|
|
use egui::{Color32, Context, Stroke};
|
2023-04-21 03:45:59 +03:00
|
|
|
use egui::style::Margin;
|
2023-04-27 01:28:55 +03:00
|
|
|
|
2023-04-27 21:20:22 +03:00
|
|
|
use crate::gui::{COLOR_LIGHT, COLOR_YELLOW};
|
2023-04-27 01:28:55 +03:00
|
|
|
use crate::gui::platform::PlatformCallbacks;
|
|
|
|
use crate::gui::screens::{Root, Screen};
|
2023-04-19 02:14:39 +03:00
|
|
|
|
2023-04-18 16:19:43 +03:00
|
|
|
pub struct PlatformApp<Platform> {
|
2023-04-27 01:28:55 +03:00
|
|
|
pub(crate) app: App,
|
2023-04-18 16:19:43 +03:00
|
|
|
pub(crate) platform: Platform,
|
2023-04-19 02:14:39 +03:00
|
|
|
}
|
|
|
|
|
2023-04-27 01:28:55 +03:00
|
|
|
pub struct App {
|
|
|
|
root: Root,
|
2023-04-19 02:14:39 +03:00
|
|
|
}
|
|
|
|
|
2023-04-27 01:28:55 +03:00
|
|
|
impl Default for App {
|
2023-04-19 02:14:39 +03:00
|
|
|
fn default() -> Self {
|
2023-04-27 01:28:55 +03:00
|
|
|
Self {
|
|
|
|
root: Root::default(),
|
2023-04-21 03:45:59 +03:00
|
|
|
}
|
|
|
|
}
|
2023-04-27 01:28:55 +03:00
|
|
|
}
|
2023-04-21 03:45:59 +03:00
|
|
|
|
2023-04-27 01:28:55 +03:00
|
|
|
impl App {
|
2023-04-22 21:16:17 +03:00
|
|
|
pub fn ui(&mut self, ctx: &Context, frame: &mut Frame, cb: &dyn PlatformCallbacks) {
|
2023-04-27 21:20:22 +03:00
|
|
|
let Self { root } = self;
|
2023-04-22 21:16:17 +03:00
|
|
|
egui::CentralPanel::default()
|
2023-04-21 23:59:59 +03:00
|
|
|
.frame(egui::Frame {
|
|
|
|
inner_margin: Margin::same(0.0),
|
|
|
|
outer_margin: Margin::same(0.0),
|
2023-04-27 21:20:22 +03:00
|
|
|
stroke: Stroke::NONE,
|
|
|
|
fill: COLOR_LIGHT,
|
2023-04-22 21:16:17 +03:00
|
|
|
.. Default::default()
|
2023-04-21 23:59:59 +03:00
|
|
|
})
|
2023-04-22 21:16:17 +03:00
|
|
|
.show(ctx, |ui| {
|
2023-04-27 21:20:22 +03:00
|
|
|
root.ui(ui, frame, cb)
|
2023-04-21 03:45:59 +03:00
|
|
|
});
|
2023-04-19 02:14:39 +03:00
|
|
|
}
|
2023-04-21 03:45:59 +03:00
|
|
|
}
|
|
|
|
|