Skip to content

Commit 0efd129

Browse files
committed
feat: add alignment option
1 parent b6d1477 commit 0efd129

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/app.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct LogViewerApp {
2323
start_open_path: Arc<Mutex<Option<PathBuf>>>,
2424
last_filename: Arc<Mutex<Option<PathBuf>>>,
2525
show_last_filename: bool,
26+
track_item_align: Option<Align>,
2627

2728
#[serde(skip)]
2829
should_scroll: bool,
@@ -38,6 +39,7 @@ impl Default for LogViewerApp {
3839
start_open_path: Default::default(),
3940
loading_status: Default::default(),
4041
last_filename: Default::default(),
42+
track_item_align: Default::default(),
4143
should_scroll: Default::default(),
4244
show_last_filename: true,
4345
}
@@ -103,7 +105,7 @@ impl LogViewerApp {
103105
(true, Some(data)) => {
104106
self.should_scroll = false;
105107
if let Some(selected_row) = data.selected_row {
106-
table_builder.scroll_to_row(selected_row, Some(Align::Center))
108+
table_builder.scroll_to_row(selected_row, self.track_item_align)
107109
} else {
108110
table_builder
109111
}
@@ -344,6 +346,22 @@ impl LogViewerApp {
344346
fn ui_options(&mut self, ui: &mut egui::Ui) {
345347
ui.collapsing("Options", |ui| {
346348
ui.checkbox(&mut self.show_last_filename, "Show last filename");
349+
350+
ui.horizontal(|ui| {
351+
ui.label("Item align:");
352+
self.should_scroll |= ui
353+
.radio_value(&mut self.track_item_align, Some(Align::Min), "Top")
354+
.clicked();
355+
self.should_scroll |= ui
356+
.radio_value(&mut self.track_item_align, Some(Align::Center), "Center")
357+
.clicked();
358+
self.should_scroll |= ui
359+
.radio_value(&mut self.track_item_align, Some(Align::Max), "Bottom")
360+
.clicked();
361+
self.should_scroll |= ui
362+
.radio_value(&mut self.track_item_align, None, "None (Bring into view)")
363+
.clicked();
364+
});
347365
});
348366
}
349367

0 commit comments

Comments
 (0)