notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 7d2112b47254082648bda804cbb39311ef91c0c1
parent 640bf742c09404f6d706df2f532200e6abff27db
Author: kernelkind <kernelkind@gmail.com>
Date:   Tue, 29 Apr 2025 16:05:58 -0400

make `Widget` impl `ProfilePic` mutably

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck_chrome/src/chrome.rs | 4++--
Mcrates/notedeck_columns/src/ui/column/header.rs | 18++++++++++++------
Mcrates/notedeck_columns/src/ui/note/post.rs | 6+++---
Mcrates/notedeck_columns/src/ui/profile/edit.rs | 2+-
Mcrates/notedeck_columns/src/ui/profile/mod.rs | 2+-
Mcrates/notedeck_columns/src/ui/search_results.rs | 2+-
Mcrates/notedeck_dave/src/ui/dave.rs | 2+-
Mcrates/notedeck_ui/src/note/mod.rs | 9++++++---
Mcrates/notedeck_ui/src/profile/picture.rs | 2+-
Mcrates/notedeck_ui/src/profile/preview.rs | 4++--
10 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/crates/notedeck_chrome/src/chrome.rs b/crates/notedeck_chrome/src/chrome.rs @@ -275,9 +275,9 @@ impl Chrome { let txn = Transaction::new(ctx.ndb).expect("should be able to create txn"); let profile_url = get_account_url(&txn, ctx.ndb, ctx.accounts.get_selected_account()); - let widget = ProfilePic::new(ctx.img_cache, profile_url).size(cur_pfp_size); + let mut widget = ProfilePic::new(ctx.img_cache, profile_url).size(cur_pfp_size); - ui.put(helper.get_animation_rect(), widget); + ui.put(helper.get_animation_rect(), &mut widget); helper.take_animation_response() } diff --git a/crates/notedeck_columns/src/ui/column/header.rs b/crates/notedeck_columns/src/ui/column/header.rs @@ -400,13 +400,16 @@ impl<'a> NavTitle<'a> { fn timeline_pfp(&mut self, ui: &mut egui::Ui, id: &TimelineKind, pfp_size: f32) { let txn = Transaction::new(self.ndb).unwrap(); - if let Some(pfp) = id + if let Some(mut pfp) = id .pubkey() .and_then(|pk| self.pubkey_pfp(&txn, pk.bytes(), pfp_size)) { - ui.add(pfp); + ui.add(&mut pfp); } else { - ui.add(ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url()).size(pfp_size)); + ui.add( + &mut ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url()) + .size(pfp_size), + ); } } @@ -466,10 +469,13 @@ impl<'a> NavTitle<'a> { fn show_profile(&mut self, ui: &mut egui::Ui, pubkey: &Pubkey, pfp_size: f32) { let txn = Transaction::new(self.ndb).unwrap(); - if let Some(pfp) = self.pubkey_pfp(&txn, pubkey.bytes(), pfp_size) { - ui.add(pfp); + if let Some(mut pfp) = self.pubkey_pfp(&txn, pubkey.bytes(), pfp_size) { + ui.add(&mut pfp); } else { - ui.add(ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url()).size(pfp_size)); + ui.add( + &mut ProfilePic::new(self.img_cache, notedeck::profile::no_pfp_url()) + .size(pfp_size), + ); }; } diff --git a/crates/notedeck_columns/src/ui/note/post.rs b/crates/notedeck_columns/src/ui/note/post.rs @@ -142,11 +142,11 @@ impl<'a, 'd> PostView<'a, 'd> { Some(ProfilePic::from_profile(self.note_context.img_cache, p)?.size(pfp_size)) }); - if let Some(pfp) = poster_pfp { - ui.add(pfp); + if let Some(mut pfp) = poster_pfp { + ui.add(&mut pfp); } else { ui.add( - ProfilePic::new(self.note_context.img_cache, notedeck::profile::no_pfp_url()) + &mut ProfilePic::new(self.note_context.img_cache, notedeck::profile::no_pfp_url()) .size(pfp_size), ); } diff --git a/crates/notedeck_columns/src/ui/profile/edit.rs b/crates/notedeck_columns/src/ui/profile/edit.rs @@ -60,7 +60,7 @@ impl<'a> EditProfileView<'a> { }); ui.put( pfp_rect, - ProfilePic::new(self.img_cache, pfp_url) + &mut ProfilePic::new(self.img_cache, pfp_url) .size(size) .border(ProfilePic::border_stroke(ui)), ); diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -148,7 +148,7 @@ impl<'a, 'd> ProfileView<'a, 'd> { ui.horizontal(|ui| { ui.put( pfp_rect, - ProfilePic::new( + &mut ProfilePic::new( self.note_context.img_cache, get_profile_url(Some(&profile)), ) diff --git a/crates/notedeck_columns/src/ui/search_results.rs b/crates/notedeck_columns/src/ui/search_results.rs @@ -140,7 +140,7 @@ fn user_result<'a>( let pfp_resp = ui.put( icon_rect, - ProfilePic::new(cache, get_profile_url(Some(profile))) + &mut ProfilePic::new(cache, get_profile_url(Some(profile))) .size(helper.scale_1d_pos(min_img_size)), ); diff --git a/crates/notedeck_dave/src/ui/dave.rs b/crates/notedeck_dave/src/ui/dave.rs @@ -395,7 +395,7 @@ fn query_call_ui(cache: &mut notedeck::Images, ndb: &Ndb, query: &QueryCall, ui: "author", move |ui| { ui.add( - ProfilePic::from_profile_or_default( + &mut ProfilePic::from_profile_or_default( cache, ndb.get_profile_by_pubkey(&txn, pubkey.bytes()) .ok() diff --git a/crates/notedeck_ui/src/note/mod.rs b/crates/notedeck_ui/src/note/mod.rs @@ -265,7 +265,7 @@ impl<'a, 'd> NoteView<'a, 'd> { ui.put( rect, - ProfilePic::new(self.note_context.img_cache, pic).size(size), + &mut ProfilePic::new(self.note_context.img_cache, pic).size(size), ) .on_hover_ui_at_pointer(|ui| { ui.set_max_width(300.0); @@ -290,8 +290,11 @@ impl<'a, 'd> NoteView<'a, 'd> { ui.put( rect, - ProfilePic::new(self.note_context.img_cache, notedeck::profile::no_pfp_url()) - .size(pfp_size as f32), + &mut ProfilePic::new( + self.note_context.img_cache, + notedeck::profile::no_pfp_url(), + ) + .size(pfp_size as f32), ) .interact(sense) } diff --git a/crates/notedeck_ui/src/profile/picture.rs b/crates/notedeck_ui/src/profile/picture.rs @@ -11,7 +11,7 @@ pub struct ProfilePic<'cache, 'url> { border: Option<Stroke>, } -impl egui::Widget for ProfilePic<'_, '_> { +impl egui::Widget for &mut ProfilePic<'_, '_> { fn ui(self, ui: &mut egui::Ui) -> egui::Response { render_pfp(ui, self.cache, self.url, self.size, self.border) } diff --git a/crates/notedeck_ui/src/profile/preview.rs b/crates/notedeck_ui/src/profile/preview.rs @@ -38,7 +38,7 @@ impl<'a, 'cache> ProfilePreview<'a, 'cache> { ui.put( pfp_rect, - ProfilePic::new(self.cache, get_profile_url(Some(self.profile))) + &mut ProfilePic::new(self.cache, get_profile_url(Some(self.profile))) .size(size) .border(ProfilePic::border_stroke(ui)), ); @@ -90,7 +90,7 @@ impl egui::Widget for SimpleProfilePreview<'_, '_> { fn ui(self, ui: &mut egui::Ui) -> egui::Response { Frame::new() .show(ui, |ui| { - ui.add(ProfilePic::new(self.cache, get_profile_url(self.profile)).size(48.0)); + ui.add(&mut ProfilePic::new(self.cache, get_profile_url(self.profile)).size(48.0)); ui.vertical(|ui| { ui.add(display_name_widget(&get_display_name(self.profile), true)); if !self.is_nsec {