preview: add scroll to profile pic demo
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -174,34 +174,36 @@ mod preview {
|
|||||||
|
|
||||||
impl View for ProfilePicPreview {
|
impl View for ProfilePicPreview {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.horizontal_wrapped(|ui| {
|
egui::ScrollArea::both().show(ui, |ui| {
|
||||||
let txn = Transaction::new(&self.ndb).unwrap();
|
ui.horizontal_wrapped(|ui| {
|
||||||
for key in &self.keys {
|
let txn = Transaction::new(&self.ndb).unwrap();
|
||||||
let profile = self.ndb.get_profile_by_key(&txn, *key).unwrap();
|
for key in &self.keys {
|
||||||
let url = profile
|
let profile = self.ndb.get_profile_by_key(&txn, *key).unwrap();
|
||||||
.record()
|
let url = profile
|
||||||
.profile()
|
.record()
|
||||||
.expect("should have profile")
|
.profile()
|
||||||
.picture()
|
.expect("should have profile")
|
||||||
.expect("should have picture");
|
.picture()
|
||||||
|
.expect("should have picture");
|
||||||
|
|
||||||
let expand_size = 10.0;
|
let expand_size = 10.0;
|
||||||
let anim_speed = 0.05;
|
let anim_speed = 0.05;
|
||||||
|
|
||||||
let (rect, size, _resp) = ui::anim::hover_expand(
|
let (rect, size, _resp) = ui::anim::hover_expand(
|
||||||
ui,
|
ui,
|
||||||
egui::Id::new(profile.key().unwrap()),
|
egui::Id::new(profile.key().unwrap()),
|
||||||
ui::ProfilePic::default_size(),
|
ui::ProfilePic::default_size(),
|
||||||
expand_size,
|
expand_size,
|
||||||
anim_speed,
|
anim_speed,
|
||||||
);
|
);
|
||||||
|
|
||||||
ui.put(rect, ui::ProfilePic::new(&mut self.cache, url).size(size))
|
ui.put(rect, ui::ProfilePic::new(&mut self.cache, url).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);
|
||||||
ui.add(ui::ProfilePreview::new(&profile, &mut self.cache));
|
ui.add(ui::ProfilePreview::new(&profile, &mut self.cache));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user