toolbar: process actions

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-06-06 15:40:04 -07:00
parent 0ea1a92ea7
commit e8d240df42
4 changed files with 95 additions and 17 deletions

View File

@@ -39,7 +39,7 @@ pub struct Columns {
columns: Vec<Column>,
/// The selected column for key navigation
selected: i32,
pub selected: i32,
}
impl Columns {
@@ -47,6 +47,35 @@ impl Columns {
Columns::default()
}
/// Choose which column is selected. If in narrow mode, this
/// decides which column to render in the main view
pub fn select_column(&mut self, index: i32) {
let len = self.columns.len();
if index < (len as i32) {
self.selected = index;
}
}
/// Select the column based on the timeline kind.
///
/// TODO: add timeline if missing?
pub fn select_by_kind(&mut self, kind: &TimelineKind) {
for (i, col) in self.columns.iter().enumerate() {
for route in col.router().routes() {
if let Some(timeline) = route.timeline_id() {
if timeline == kind {
tracing::info!("selecting {kind:?} column");
self.select_column(i as i32);
return;
}
}
}
}
tracing::error!("failed to select {kind:?} column");
}
pub fn add_new_timeline_column(
&mut self,
timeline_cache: &mut TimelineCache,