diff --git a/src/app.rs b/src/app.rs index 241376d..d4c453a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -229,6 +229,9 @@ struct Context { #[serde(skip)] scale_factor: f32, + #[serde(skip)] + row_scroll_delta: i32, + #[serde(skip)] subheading_size: f32, @@ -1707,6 +1710,7 @@ impl Window { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)] enum PanDirection { Left, Right, @@ -1738,6 +1742,7 @@ impl ProfApp { result.windows.clear(); result.cx.scale_factor = 1.0; + result.cx.row_scroll_delta = 0; #[cfg(not(target_arch = "wasm32"))] { @@ -1867,6 +1872,7 @@ impl ProfApp { RedoZoom, ResetZoom, Pan(PercentageInteger, PanDirection), + Scroll(i32), ExpandVertical, ShrinkVertical, ResetVertical, @@ -1904,6 +1910,10 @@ impl ProfApp { Actions::Pan(Percentage::from(1), PanDirection::Left) } else if i.key_pressed(egui::Key::ArrowRight) { Actions::Pan(Percentage::from(1), PanDirection::Right) + } else if i.key_pressed(egui::Key::ArrowUp) { + Actions::Scroll(1) + } else if i.key_pressed(egui::Key::ArrowDown) { + Actions::Scroll(-1) } else { Actions::NoAction } @@ -1915,6 +1925,10 @@ impl ProfApp { Actions::Pan(Percentage::from(5), PanDirection::Left) } else if i.key_pressed(egui::Key::ArrowRight) { Actions::Pan(Percentage::from(5), PanDirection::Right) + } else if i.key_pressed(egui::Key::ArrowUp) { + Actions::Scroll(5) + } else if i.key_pressed(egui::Key::ArrowDown) { + Actions::Scroll(-5) } else { Actions::NoAction } @@ -1926,6 +1940,7 @@ impl ProfApp { Actions::RedoZoom => ProfApp::redo_pan_zoom(cx), Actions::ResetZoom => ProfApp::zoom(cx, cx.total_interval), Actions::Pan(percent, dir) => ProfApp::pan(cx, percent, dir), + Actions::Scroll(rows) => cx.row_scroll_delta = rows, Actions::ExpandVertical => ProfApp::multiply_scale_factor(cx, 2.0), Actions::ShrinkVertical => ProfApp::multiply_scale_factor(cx, 0.5), Actions::ResetVertical => ProfApp::reset_scale_factor(cx), @@ -2069,6 +2084,8 @@ impl ProfApp { show_row("Zoom to Interval", "Click and Drag"); show_row("Pan 5%", "Left/Right Arrow"); show_row("Pan 1%", "Shift + Left/Right Arrow"); + show_row("Vertical Scroll", "Up/Down Arrow"); + show_row("Fine Vertical Scroll", "Shift + Up/Down Arrow"); show_row("Zoom In", "Ctrl + Plus/Equals"); show_row("Zoom Out", "Ctrl + Minus"); show_row("Undo Pan/Zoom", "Ctrl + Left Arrow"); @@ -2392,6 +2409,10 @@ impl eframe::App for ProfApp { // Just set this on every frame for now cx.row_height = row_height * cx.scale_factor; + let y_scroll_delta = cx.row_height * cx.row_scroll_delta as f32; + ui.scroll_with_delta(Vec2::new(0.0, y_scroll_delta)); + cx.row_scroll_delta = 0; + let mut remaining = windows.len(); // Only wrap in a frame if more than one profile if remaining > 1 {