make Widget impl ProfilePic mutably
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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)),
|
||||
);
|
||||
|
||||
@@ -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)),
|
||||
)
|
||||
|
||||
@@ -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)),
|
||||
);
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,7 +290,10 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
||||
|
||||
ui.put(
|
||||
rect,
|
||||
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 as f32),
|
||||
)
|
||||
.interact(sense)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user