notedeck: include frame history

for debugging.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-29 10:08:49 -07:00
parent f36390d8f8
commit 418e08541d
12 changed files with 33 additions and 17 deletions

View File

@@ -2,8 +2,8 @@ use crate::persist::{AppSizeHandler, ZoomHandler};
use crate::wallet::GlobalWallet; use crate::wallet::GlobalWallet;
use crate::zaps::Zaps; use crate::zaps::Zaps;
use crate::{ use crate::{
AccountStorage, Accounts, AppContext, Args, DataPath, DataPathType, Directory, Images, frame_history::FrameHistory, AccountStorage, Accounts, AppContext, Args, DataPath,
NoteCache, RelayDebugView, ThemeHandler, UnknownIds, DataPathType, Directory, Images, NoteCache, RelayDebugView, ThemeHandler, UnknownIds,
}; };
use egui::ThemePreference; use egui::ThemePreference;
use egui_winit::clipboard::Clipboard; use egui_winit::clipboard::Clipboard;
@@ -37,6 +37,7 @@ pub struct Notedeck {
unrecognized_args: BTreeSet<String>, unrecognized_args: BTreeSet<String>,
clipboard: Clipboard, clipboard: Clipboard,
zaps: Zaps, zaps: Zaps,
frame_history: FrameHistory,
} }
/// Our chrome, which is basically nothing /// Our chrome, which is basically nothing
@@ -79,8 +80,10 @@ fn render_notedeck(notedeck: &mut Notedeck, ctx: &egui::Context) {
} }
impl eframe::App for Notedeck { impl eframe::App for Notedeck {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
profiling::finish_frame!(); profiling::finish_frame!();
self.frame_history
.on_new_frame(ctx.input(|i| i.time), frame.info().cpu_usage);
// handle account updates // handle account updates
self.accounts.update(&mut self.ndb, &mut self.pool, ctx); self.accounts.update(&mut self.ndb, &mut self.pool, ctx);
@@ -227,6 +230,7 @@ impl Notedeck {
zoom, zoom,
app_size, app_size,
unrecognized_args, unrecognized_args,
frame_history: FrameHistory::default(),
clipboard: Clipboard::new(None), clipboard: Clipboard::new(None),
zaps, zaps,
} }
@@ -251,6 +255,7 @@ impl Notedeck {
theme: &mut self.theme, theme: &mut self.theme,
clipboard: &mut self.clipboard, clipboard: &mut self.clipboard,
zaps: &mut self.zaps, zaps: &mut self.zaps,
frame_history: &mut self.frame_history,
} }
} }

View File

@@ -1,6 +1,6 @@
use crate::{ use crate::{
wallet::GlobalWallet, zaps::Zaps, Accounts, Args, DataPath, Images, NoteCache, ThemeHandler, frame_history::FrameHistory, wallet::GlobalWallet, zaps::Zaps, Accounts, Args, DataPath,
UnknownIds, Images, NoteCache, ThemeHandler, UnknownIds,
}; };
use egui_winit::clipboard::Clipboard; use egui_winit::clipboard::Clipboard;
@@ -22,4 +22,5 @@ pub struct AppContext<'a> {
pub theme: &'a mut ThemeHandler, pub theme: &'a mut ThemeHandler,
pub clipboard: &'a mut Clipboard, pub clipboard: &'a mut Clipboard,
pub zaps: &'a mut Zaps, pub zaps: &'a mut Zaps,
pub frame_history: &'a mut FrameHistory,
} }

View File

@@ -1,4 +1,3 @@
/*
use egui::util::History; use egui::util::History;
pub struct FrameHistory { pub struct FrameHistory {
@@ -47,4 +46,3 @@ impl FrameHistory {
egui::warn_if_debug_build(ui); egui::warn_if_debug_build(ui);
} }
} }
*/

View File

@@ -6,6 +6,7 @@ pub mod debouncer;
mod error; mod error;
pub mod filter; pub mod filter;
pub mod fonts; pub mod fonts;
mod frame_history;
mod imgcache; mod imgcache;
mod muted; mod muted;
pub mod note; pub mod note;

View File

@@ -177,18 +177,24 @@ impl Chrome {
} }
}; };
if support_button(ui).clicked() { let support_resp = support_button(ui);
return Some(ChromePanelAction::Support);
}
if theme_action.is_some() { if ctx.args.debug {
return theme_action; ui.weak(format!("{}", ctx.frame_history.fps() as i32));
ui.weak(format!(
"{:10.1}",
ctx.frame_history.mean_frame_time() * 1e3
));
} }
if pfp_resp.clicked() { if pfp_resp.clicked() {
Some(ChromePanelAction::Account) Some(ChromePanelAction::Account)
} else if settings_resp.clicked() { } else if settings_resp.clicked() {
Some(ChromePanelAction::Settings) Some(ChromePanelAction::Settings)
} else if theme_action.is_some() {
theme_action
} else if support_resp.clicked() {
Some(ChromePanelAction::Support)
} else { } else {
None None
} }

View File

@@ -13,7 +13,6 @@ mod column;
mod deck_state; mod deck_state;
mod decks; mod decks;
mod draft; mod draft;
mod frame_history;
mod key_parsing; mod key_parsing;
pub mod login_manager; pub mod login_manager;
mod media_upload; mod media_upload;

View File

@@ -1,9 +1,9 @@
use notedeck_ui::colors::PINK;
use egui::{ use egui::{
Align, Button, Frame, Image, InnerResponse, Layout, RichText, ScrollArea, Ui, UiBuilder, Vec2, Align, Button, Frame, Image, InnerResponse, Layout, RichText, ScrollArea, Ui, UiBuilder, Vec2,
}; };
use nostrdb::{Ndb, Transaction}; use nostrdb::{Ndb, Transaction};
use notedeck::{Accounts, Images}; use notedeck::{Accounts, Images};
use notedeck_ui::colors::PINK;
use super::profile::preview::SimpleProfilePreview; use super::profile::preview::SimpleProfilePreview;

View File

@@ -0,0 +1 @@

View File

@@ -1,11 +1,11 @@
use std::collections::HashMap; use std::collections::HashMap;
use notedeck_ui::colors::PINK;
use crate::relay_pool_manager::{RelayPoolManager, RelayStatus}; use crate::relay_pool_manager::{RelayPoolManager, RelayStatus};
use crate::ui::{Preview, PreviewConfig, View}; use crate::ui::{Preview, PreviewConfig, View};
use egui::{ use egui::{
Align, Button, CornerRadius, Frame, Id, Image, Layout, Margin, Rgba, RichText, Ui, Vec2, Align, Button, CornerRadius, Frame, Id, Image, Layout, Margin, Rgba, RichText, Ui, Vec2,
}; };
use notedeck_ui::colors::PINK;
use enostr::RelayPool; use enostr::RelayPool;
use notedeck::{Accounts, NotedeckTextStyle}; use notedeck::{Accounts, NotedeckTextStyle};

View File

@@ -193,7 +193,11 @@ fn goto_top_button(center: Pos2) -> impl egui::Widget {
}); });
let painter = ui.painter(); let painter = ui.painter();
painter.circle_filled(center, helper.scale_1d_pos(radius), notedeck_ui::colors::PINK); painter.circle_filled(
center,
helper.scale_1d_pos(radius),
notedeck_ui::colors::PINK,
);
let create_pt = |angle: f32| { let create_pt = |angle: f32| {
let side = radius / 2.0; let side = radius / 2.0;

View File

@@ -352,6 +352,7 @@ impl DaveAvatar {
.multiply(&z_rotation) .multiply(&z_rotation)
.multiply(&self.rotation); .multiply(&self.rotation);
tracing::trace!("repainting due to avatar rotation");
ui.ctx().request_repaint(); ui.ctx().request_repaint();
} }
} }

View File

@@ -1,9 +1,9 @@
mod anim; mod anim;
pub mod colors; pub mod colors;
pub mod gif; pub mod gif;
pub mod icons;
pub mod images; pub mod images;
pub mod profile; pub mod profile;
pub mod icons;
pub use anim::AnimationHelper; pub use anim::AnimationHelper;
pub use profile::ProfilePic; pub use profile::ProfilePic;