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 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 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()
|
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) {
|
fn timeline_pfp(&mut self, ui: &mut egui::Ui, id: &TimelineKind, pfp_size: f32) {
|
||||||
let txn = Transaction::new(self.ndb).unwrap();
|
let txn = Transaction::new(self.ndb).unwrap();
|
||||||
|
|
||||||
if let Some(pfp) = id
|
if let Some(mut pfp) = id
|
||||||
.pubkey()
|
.pubkey()
|
||||||
.and_then(|pk| self.pubkey_pfp(&txn, pk.bytes(), pfp_size))
|
.and_then(|pk| self.pubkey_pfp(&txn, pk.bytes(), pfp_size))
|
||||||
{
|
{
|
||||||
ui.add(pfp);
|
ui.add(&mut pfp);
|
||||||
} else {
|
} 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) {
|
fn show_profile(&mut self, ui: &mut egui::Ui, pubkey: &Pubkey, pfp_size: f32) {
|
||||||
let txn = Transaction::new(self.ndb).unwrap();
|
let txn = Transaction::new(self.ndb).unwrap();
|
||||||
if let Some(pfp) = self.pubkey_pfp(&txn, pubkey.bytes(), pfp_size) {
|
if let Some(mut pfp) = self.pubkey_pfp(&txn, pubkey.bytes(), pfp_size) {
|
||||||
ui.add(pfp);
|
ui.add(&mut pfp);
|
||||||
} else {
|
} 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))
|
Some(ProfilePic::from_profile(self.note_context.img_cache, p)?.size(pfp_size))
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(pfp) = poster_pfp {
|
if let Some(mut pfp) = poster_pfp {
|
||||||
ui.add(pfp);
|
ui.add(&mut pfp);
|
||||||
} else {
|
} else {
|
||||||
ui.add(
|
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),
|
.size(pfp_size),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl<'a> EditProfileView<'a> {
|
|||||||
});
|
});
|
||||||
ui.put(
|
ui.put(
|
||||||
pfp_rect,
|
pfp_rect,
|
||||||
ProfilePic::new(self.img_cache, pfp_url)
|
&mut ProfilePic::new(self.img_cache, pfp_url)
|
||||||
.size(size)
|
.size(size)
|
||||||
.border(ProfilePic::border_stroke(ui)),
|
.border(ProfilePic::border_stroke(ui)),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.put(
|
ui.put(
|
||||||
pfp_rect,
|
pfp_rect,
|
||||||
ProfilePic::new(
|
&mut ProfilePic::new(
|
||||||
self.note_context.img_cache,
|
self.note_context.img_cache,
|
||||||
get_profile_url(Some(&profile)),
|
get_profile_url(Some(&profile)),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ fn user_result<'a>(
|
|||||||
|
|
||||||
let pfp_resp = ui.put(
|
let pfp_resp = ui.put(
|
||||||
icon_rect,
|
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)),
|
.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",
|
"author",
|
||||||
move |ui| {
|
move |ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
ProfilePic::from_profile_or_default(
|
&mut ProfilePic::from_profile_or_default(
|
||||||
cache,
|
cache,
|
||||||
ndb.get_profile_by_pubkey(&txn, pubkey.bytes())
|
ndb.get_profile_by_pubkey(&txn, pubkey.bytes())
|
||||||
.ok()
|
.ok()
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
|
|
||||||
ui.put(
|
ui.put(
|
||||||
rect,
|
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| {
|
.on_hover_ui_at_pointer(|ui| {
|
||||||
ui.set_max_width(300.0);
|
ui.set_max_width(300.0);
|
||||||
@@ -290,7 +290,10 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
|
|
||||||
ui.put(
|
ui.put(
|
||||||
rect,
|
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),
|
.size(pfp_size as f32),
|
||||||
)
|
)
|
||||||
.interact(sense)
|
.interact(sense)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub struct ProfilePic<'cache, 'url> {
|
|||||||
border: Option<Stroke>,
|
border: Option<Stroke>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl egui::Widget for ProfilePic<'_, '_> {
|
impl egui::Widget for &mut ProfilePic<'_, '_> {
|
||||||
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
||||||
render_pfp(ui, self.cache, self.url, self.size, self.border)
|
render_pfp(ui, self.cache, self.url, self.size, self.border)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ impl<'a, 'cache> ProfilePreview<'a, 'cache> {
|
|||||||
|
|
||||||
ui.put(
|
ui.put(
|
||||||
pfp_rect,
|
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)
|
.size(size)
|
||||||
.border(ProfilePic::border_stroke(ui)),
|
.border(ProfilePic::border_stroke(ui)),
|
||||||
);
|
);
|
||||||
@@ -90,7 +90,7 @@ impl egui::Widget for SimpleProfilePreview<'_, '_> {
|
|||||||
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
||||||
Frame::new()
|
Frame::new()
|
||||||
.show(ui, |ui| {
|
.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.vertical(|ui| {
|
||||||
ui.add(display_name_widget(&get_display_name(self.profile), true));
|
ui.add(display_name_widget(&get_display_name(self.profile), true));
|
||||||
if !self.is_nsec {
|
if !self.is_nsec {
|
||||||
|
|||||||
Reference in New Issue
Block a user