set variable for scroll offset
necessary to maintain scroll positions across popup & Nav Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -65,10 +65,15 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
|
|
||||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<ProfileViewAction> {
|
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<ProfileViewAction> {
|
||||||
let scroll_id = egui::Id::new(("profile_scroll", self.col_id, self.pubkey));
|
let scroll_id = egui::Id::new(("profile_scroll", self.col_id, self.pubkey));
|
||||||
|
let offset_id = scroll_id.with("scroll_offset");
|
||||||
|
|
||||||
ScrollArea::vertical()
|
let mut scroll_area = ScrollArea::vertical().id_salt(scroll_id);
|
||||||
.id_salt(scroll_id)
|
|
||||||
.show(ui, |ui| {
|
if let Some(offset) = ui.data(|i| i.get_temp::<f32>(offset_id)) {
|
||||||
|
scroll_area = scroll_area.vertical_scroll_offset(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = scroll_area.show(ui, |ui| {
|
||||||
let mut action = None;
|
let mut action = None;
|
||||||
let txn = Transaction::new(self.note_context.ndb).expect("txn");
|
let txn = Transaction::new(self.note_context.ndb).expect("txn");
|
||||||
if let Ok(profile) = self
|
if let Ok(profile) = self
|
||||||
@@ -124,8 +129,11 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
action
|
action
|
||||||
})
|
});
|
||||||
.inner
|
|
||||||
|
ui.data_mut(|d| d.insert_temp(offset_id, output.state.offset.y));
|
||||||
|
|
||||||
|
output.inner
|
||||||
}
|
}
|
||||||
|
|
||||||
fn profile_body(&mut self, ui: &mut egui::Ui, profile: ProfileRecord<'_>) -> bool {
|
fn profile_body(&mut self, ui: &mut egui::Ui, profile: ProfileRecord<'_>) -> bool {
|
||||||
|
|||||||
@@ -54,12 +54,19 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
||||||
let txn = Transaction::new(self.note_context.ndb).expect("txn");
|
let txn = Transaction::new(self.note_context.ndb).expect("txn");
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
let mut scroll_area = egui::ScrollArea::vertical()
|
||||||
.id_salt(self.id_source)
|
.id_salt(self.id_source)
|
||||||
.animated(false)
|
.animated(false)
|
||||||
.auto_shrink([false, false])
|
.auto_shrink([false, false])
|
||||||
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible)
|
.scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysVisible);
|
||||||
.show(ui, |ui| {
|
|
||||||
|
let offset_id = self.id_source.with("scroll_offset");
|
||||||
|
|
||||||
|
if let Some(offset) = ui.data(|i| i.get_temp::<f32>(offset_id)) {
|
||||||
|
scroll_area = scroll_area.vertical_scroll_offset(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = scroll_area.show(ui, |ui| {
|
||||||
let root_id = match RootNoteId::new(
|
let root_id = match RootNoteId::new(
|
||||||
self.note_context.ndb,
|
self.note_context.ndb,
|
||||||
self.note_context.note_cache,
|
self.note_context.note_cache,
|
||||||
@@ -109,7 +116,10 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
|||||||
self.jobs,
|
self.jobs,
|
||||||
)
|
)
|
||||||
.show(ui)
|
.show(ui)
|
||||||
})
|
});
|
||||||
.inner
|
|
||||||
|
ui.data_mut(|d| d.insert_temp(offset_id, output.state.offset.y));
|
||||||
|
|
||||||
|
output.inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,12 @@ fn timeline_ui(
|
|||||||
.auto_shrink([false, false])
|
.auto_shrink([false, false])
|
||||||
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible);
|
.scroll_bar_visibility(ScrollBarVisibility::AlwaysVisible);
|
||||||
|
|
||||||
|
let offset_id = scroll_id.with("timeline_scroll_offset");
|
||||||
|
|
||||||
|
if let Some(offset) = ui.data(|i| i.get_temp::<f32>(offset_id)) {
|
||||||
|
scroll_area = scroll_area.vertical_scroll_offset(offset);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(goto_top_resp) = goto_top_resp {
|
if let Some(goto_top_resp) = goto_top_resp {
|
||||||
if goto_top_resp.clicked() {
|
if goto_top_resp.clicked() {
|
||||||
scroll_area = scroll_area.vertical_scroll_offset(0.0);
|
scroll_area = scroll_area.vertical_scroll_offset(0.0);
|
||||||
@@ -163,6 +169,8 @@ fn timeline_ui(
|
|||||||
.show(ui)
|
.show(ui)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.data_mut(|d| d.insert_temp(offset_id, scroll_output.state.offset.y));
|
||||||
|
|
||||||
let at_top_after_scroll = scroll_output.state.offset.y == 0.0;
|
let at_top_after_scroll = scroll_output.state.offset.y == 0.0;
|
||||||
let cur_show_top_button = ui.ctx().data(|d| d.get_temp::<bool>(show_top_button_id));
|
let cur_show_top_button = ui.ctx().data(|d| d.get_temp::<bool>(show_top_button_id));
|
||||||
|
|
||||||
@@ -362,9 +370,9 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
|||||||
let len = self.tab.notes.len();
|
let len = self.tab.notes.len();
|
||||||
|
|
||||||
let is_muted = self.is_muted;
|
let is_muted = self.is_muted;
|
||||||
|
|
||||||
self.tab
|
self.tab
|
||||||
.list
|
.list
|
||||||
.clone()
|
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.ui_custom_layout(ui, len, |ui, start_index| {
|
.ui_custom_layout(ui, len, |ui, start_index| {
|
||||||
ui.spacing_mut().item_spacing.y = 0.0;
|
ui.spacing_mut().item_spacing.y = 0.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user