notedeck

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

commit c007cbd4f2e460c84cc1b5e44a537e67c331cd5f
parent b917d480154beef4bad07df9ff8ffd196de86b42
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 28 Jul 2024 13:04:09 -0500

preview: add scroll to profile pic demo

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/ui/profile/picture.rs | 58++++++++++++++++++++++++++++++----------------------------
1 file changed, 30 insertions(+), 28 deletions(-)

diff --git a/src/ui/profile/picture.rs b/src/ui/profile/picture.rs @@ -174,34 +174,36 @@ mod preview { impl View for ProfilePicPreview { fn ui(&mut self, ui: &mut egui::Ui) { - ui.horizontal_wrapped(|ui| { - let txn = Transaction::new(&self.ndb).unwrap(); - for key in &self.keys { - let profile = self.ndb.get_profile_by_key(&txn, *key).unwrap(); - let url = profile - .record() - .profile() - .expect("should have profile") - .picture() - .expect("should have picture"); - - let expand_size = 10.0; - let anim_speed = 0.05; - - let (rect, size, _resp) = ui::anim::hover_expand( - ui, - egui::Id::new(profile.key().unwrap()), - ui::ProfilePic::default_size(), - expand_size, - anim_speed, - ); - - ui.put(rect, ui::ProfilePic::new(&mut self.cache, url).size(size)) - .on_hover_ui_at_pointer(|ui| { - ui.set_max_width(300.0); - ui.add(ui::ProfilePreview::new(&profile, &mut self.cache)); - }); - } + egui::ScrollArea::both().show(ui, |ui| { + ui.horizontal_wrapped(|ui| { + let txn = Transaction::new(&self.ndb).unwrap(); + for key in &self.keys { + let profile = self.ndb.get_profile_by_key(&txn, *key).unwrap(); + let url = profile + .record() + .profile() + .expect("should have profile") + .picture() + .expect("should have picture"); + + let expand_size = 10.0; + let anim_speed = 0.05; + + let (rect, size, _resp) = ui::anim::hover_expand( + ui, + egui::Id::new(profile.key().unwrap()), + ui::ProfilePic::default_size(), + expand_size, + anim_speed, + ); + + ui.put(rect, ui::ProfilePic::new(&mut self.cache, url).size(size)) + .on_hover_ui_at_pointer(|ui| { + ui.set_max_width(300.0); + ui.add(ui::ProfilePreview::new(&profile, &mut self.cache)); + }); + } + }); }); } }