Skip to content

Commit f273224

Browse files
committed
feat: change to scroll to end on load only
1 parent 1d39bd5 commit f273224

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/app.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct LogViewerApp {
2828
show_last_filename: bool,
2929
track_item_align: Option<Align>,
3030
shortcuts: Shortcuts,
31-
auto_scroll_to_end: bool,
31+
should_scroll_to_end_on_load: bool,
3232
// TODO 4: Add UI to set / unset field
3333
/// When set adds a field with this name and populates it with the row numbers
3434
pub row_idx_field_name: Option<String>,
@@ -51,7 +51,7 @@ impl Default for LogViewerApp {
5151
last_filename: Default::default(),
5252
track_item_align: Default::default(),
5353
shortcuts: Default::default(),
54-
auto_scroll_to_end: Default::default(),
54+
should_scroll_to_end_on_load: Default::default(),
5555
row_idx_field_name: Some("row#".to_string()),
5656
should_focus_search: Default::default(),
5757
should_scroll: Default::default(),
@@ -97,7 +97,7 @@ impl LogViewerApp {
9797
let mut table_builder = TableBuilder::new(ui)
9898
.striped(true)
9999
.resizable(true)
100-
.stick_to_bottom(self.auto_scroll_to_end)
100+
// .stick_to_bottom(self.scroll_to_end_on_load) // Removed because it disabled scroll on move of selected
101101
.cell_layout(egui::Layout::left_to_right(egui::Align::LEFT));
102102

103103
let n = self.data_display_options.main_list_fields().len();
@@ -308,7 +308,7 @@ impl LogViewerApp {
308308
data.filter = old_data.filter.take();
309309
}
310310
self.data = Some(data);
311-
if self.auto_scroll_to_end {
311+
if self.should_scroll_to_end_on_load {
312312
self.move_selected_last();
313313
}
314314
LoadingStatus::NotInProgress
@@ -354,12 +354,15 @@ impl LogViewerApp {
354354
fn ui_options(&mut self, ui: &mut egui::Ui) {
355355
ui.collapsing("Options", |ui| {
356356
ui.checkbox(&mut self.show_last_filename, "Show last filename");
357-
ui.checkbox(&mut self.auto_scroll_to_end, "Auto scroll to end")
358-
.on_hover_text(shortcut_hint_text(
359-
ui,
360-
"Enables Auto Scroll and Scroll to bottom on loading a new file",
361-
&self.shortcuts.auto_scroll,
362-
));
357+
ui.checkbox(
358+
&mut self.should_scroll_to_end_on_load,
359+
"Scroll to end on load",
360+
)
361+
.on_hover_text(shortcut_hint_text(
362+
ui,
363+
"Only has an effect when a new file is loaded",
364+
&self.shortcuts.auto_scroll,
365+
));
363366
ui.horizontal(|ui| {
364367
ui.label("Item align:");
365368
self.should_scroll |= ui
@@ -459,7 +462,7 @@ impl LogViewerApp {
459462
self.focus_search_text_edit();
460463
}
461464
if ui.input_mut(|i| i.consume_shortcut(&self.shortcuts.auto_scroll)) {
462-
self.auto_scroll_to_end = !self.auto_scroll_to_end;
465+
self.should_scroll_to_end_on_load = !self.should_scroll_to_end_on_load;
463466
}
464467
}
465468

0 commit comments

Comments
 (0)