commit cf8af27a1cdfdde2a0b32333d16c411fb5d87a7a Author: WanderingPenwing Date: Thu Mar 7 08:07:53 2024 +0100 initial commit diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..dae6a0d --- /dev/null +++ b/src/main.rs @@ -0,0 +1,57 @@ +use eframe::egui; +use std::{thread, time}; + + +const MAX_FPS : f32 = 30.0; + + +fn main() -> Result<(), eframe::Error> { + + let options = eframe::NativeOptions { + viewport: egui::ViewportBuilder::default() + .with_inner_size([1200.0, 800.0]), + ..Default::default() + }; + + eframe::run_native( + "Jiji", + options, + Box::new(move |_cc| Box::from(Jiji::default())), + ) +} + + +struct Jiji { + token: String, + next_frame: time::Instant, +} + + +impl Default for Jiji { + fn default() -> Self { + Self { + token: "test".to_string(), + next_frame: time::Instant::now(), + } + } +} + + +impl eframe::App for Jiji { + fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + thread::sleep(time::Duration::from_secs_f32( + ((1.0 / MAX_FPS) - self.next_frame.elapsed().as_secs_f32()).max(0.0), + )); + self.next_frame = time::Instant::now(); + + self.draw_feed(ctx); + } +} + +impl Jiji { + pub fn draw_feed(&mut self, ctx: &egui::Context) { + egui::CentralPanel::default().show(ctx, |ui| { + ui.label("Hello there"); + }); + } +} \ No newline at end of file