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

View File

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

View File

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

View File

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

View File

@@ -177,18 +177,24 @@ impl Chrome {
}
};
if support_button(ui).clicked() {
return Some(ChromePanelAction::Support);
}
let support_resp = support_button(ui);
if theme_action.is_some() {
return theme_action;
if ctx.args.debug {
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() {
Some(ChromePanelAction::Account)
} else if settings_resp.clicked() {
Some(ChromePanelAction::Settings)
} else if theme_action.is_some() {
theme_action
} else if support_resp.clicked() {
Some(ChromePanelAction::Support)
} else {
None
}

View File

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

View File

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

View File

@@ -0,0 +1 @@

View File

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

View File

@@ -193,7 +193,11 @@ fn goto_top_button(center: Pos2) -> impl egui::Widget {
});
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 side = radius / 2.0;

View File

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

View File

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