trying fps max of 30
This commit is contained in:
parent
08d7344a02
commit
0d38cd53fa
|
@ -23,4 +23,6 @@ Added indent recognition (when there is a line break, the indentation level is k
|
||||||
|
|
||||||
|
|
||||||
# 1.0.3 :
|
# 1.0.3 :
|
||||||
Added Ctrl+T : turn 4 spaces into tab across the whole document
|
Added testing
|
||||||
|
Added Ctrl+T : turn 4 spaces into tab across the whole document
|
||||||
|
Added Time debug
|
18
src/main.rs
18
src/main.rs
|
@ -3,7 +3,7 @@ mod calcifer;
|
||||||
|
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use calcifer::code_editor::ColorTheme;
|
use calcifer::code_editor::ColorTheme;
|
||||||
use std::{path::Path, sync::Arc, time::Instant};
|
use std::{path::Path, sync::Arc, time, thread};
|
||||||
|
|
||||||
use tools::Demo;
|
use tools::Demo;
|
||||||
use calcifer::code_editor::themes::DEFAULT_THEMES;
|
use calcifer::code_editor::themes::DEFAULT_THEMES;
|
||||||
|
@ -12,6 +12,7 @@ const TERMINAL_HEIGHT : f32 = 200.0;
|
||||||
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
||||||
const SAVE_PATH : &str = "calcifer_save.json";
|
const SAVE_PATH : &str = "calcifer_save.json";
|
||||||
const TIME_LABELS : [&str; 5] = ["settings", "tree", "terminal", "tabs", "content"];
|
const TIME_LABELS : [&str; 5] = ["settings", "tree", "terminal", "tabs", "content"];
|
||||||
|
const MAX_FPS : f32 = 30.0;
|
||||||
|
|
||||||
|
|
||||||
fn main() -> Result<(), eframe::Error> {
|
fn main() -> Result<(), eframe::Error> {
|
||||||
|
@ -60,6 +61,7 @@ struct Calcifer {
|
||||||
|
|
||||||
debug_display: bool,
|
debug_display: bool,
|
||||||
time_watch: Vec<f32>,
|
time_watch: Vec<f32>,
|
||||||
|
next_frame: time::Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ impl Default for Calcifer {
|
||||||
|
|
||||||
debug_display: false,
|
debug_display: false,
|
||||||
time_watch: vec![0.0; TIME_LABELS.len()],
|
time_watch: vec![0.0; TIME_LABELS.len()],
|
||||||
|
next_frame: time::Instant::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +89,10 @@ impl Default for Calcifer {
|
||||||
|
|
||||||
impl eframe::App for Calcifer {
|
impl eframe::App for Calcifer {
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
let mut watch = Instant::now();
|
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();
|
||||||
|
|
||||||
|
let mut watch = time::Instant::now();
|
||||||
|
|
||||||
if ctx.input( |i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl) {
|
if ctx.input( |i| i.key_pressed(egui::Key::S) && i.modifiers.ctrl) {
|
||||||
self.handle_save_file(self.save_tab());
|
self.handle_save_file(self.save_tab());
|
||||||
|
@ -110,22 +116,22 @@ impl eframe::App for Calcifer {
|
||||||
self.draw_settings(ctx);
|
self.draw_settings(ctx);
|
||||||
|
|
||||||
self.time_watch[0] = watch.elapsed().as_micros() as f32 / 1000.0;
|
self.time_watch[0] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
watch = Instant::now();
|
watch = time::Instant::now();
|
||||||
|
|
||||||
self.draw_tree_panel(ctx);
|
self.draw_tree_panel(ctx);
|
||||||
|
|
||||||
self.time_watch[1] = watch.elapsed().as_micros() as f32 / 1000.0;
|
self.time_watch[1] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
watch = Instant::now();
|
watch = time::Instant::now();
|
||||||
|
|
||||||
self.draw_terminal_panel(ctx);
|
self.draw_terminal_panel(ctx);
|
||||||
|
|
||||||
self.time_watch[2] = watch.elapsed().as_micros() as f32 / 1000.0;
|
self.time_watch[2] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
watch = Instant::now();
|
watch = time::Instant::now();
|
||||||
|
|
||||||
self.draw_tab_panel(ctx);
|
self.draw_tab_panel(ctx);
|
||||||
|
|
||||||
self.time_watch[3] = watch.elapsed().as_micros() as f32 / 1000.0;
|
self.time_watch[3] = watch.elapsed().as_micros() as f32 / 1000.0;
|
||||||
watch = Instant::now();
|
watch = time::Instant::now();
|
||||||
|
|
||||||
self.draw_content_panel(ctx);
|
self.draw_content_panel(ctx);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue