1pub mod controller;
12pub mod model;
13pub mod view;
14
15use controller::PlotController;
16use eframe::egui;
17use view::PlotEditorView;
18
19pub struct PlotEditorApp {
22 controller: PlotController,
23 view: PlotEditorView,
24}
25
26impl PlotEditorApp {
27 pub fn new() -> Self {
29 Self {
30 controller: PlotController::new(),
31 view: PlotEditorView::new(),
32 }
33 }
34
35 pub fn controller_mut(&mut self) -> &mut PlotController {
37 &mut self.controller
38 }
39}
40
41impl Default for PlotEditorApp {
42 fn default() -> Self {
43 Self::new()
44 }
45}
46
47impl eframe::App for PlotEditorApp {
48 fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
49 let actions = self.view.draw(ctx, &self.controller);
50 for action in actions {
51 let _ = self.controller.dispatch(action);
52 }
53 }
54}
55
56pub fn run_native() -> Result<(), eframe::Error> {
59 let native_options = eframe::NativeOptions::default();
60 eframe::run_native(
61 "KiThe Plot Redactor",
62 native_options,
63 Box::new(|cc| {
64 cc.egui_ctx.set_visuals(eframe::egui::Visuals::light());
65 Ok(Box::new(PlotEditorApp::new()))
66 }),
67 )
68}