Process dragging, scrolling and zooming.
(
&mut self,
ui: &mut Ui,
size: Vec2,
response: &Response,
_root: &FlameGraphNode,
)
| 403 | |
| 404 | /// Process dragging, scrolling and zooming. |
| 405 | fn process_inputs( |
| 406 | &mut self, |
| 407 | ui: &mut Ui, |
| 408 | size: Vec2, |
| 409 | response: &Response, |
| 410 | _root: &FlameGraphNode, |
| 411 | ) { |
| 412 | let Some(cursor) = response.hover_pos() else { |
| 413 | // Check for Enter key even when not hovered (for filter navigation) |
| 414 | if ui.input(|i| i.key_pressed(Key::Enter)) |
| 415 | && self.filter.len() >= 3 |
| 416 | && !self.matching_frames.is_empty() |
| 417 | { |
| 418 | let shift_held = ui.input(|i| i.modifiers.shift); |
| 419 | if shift_held { |
| 420 | self.navigate_to_prev_match(size); |
| 421 | } else { |
| 422 | self.navigate_to_next_match(size); |
| 423 | } |
| 424 | } |
| 425 | return; |
| 426 | }; |
| 427 | |
| 428 | // Handle Enter key for navigating through matches |
| 429 | if ui.input(|i| i.key_pressed(Key::Enter)) |
| 430 | && self.filter.len() >= 3 |
| 431 | && !self.matching_frames.is_empty() |
| 432 | { |
| 433 | let shift_held = ui.input(|i| i.modifiers.shift); |
| 434 | if shift_held { |
| 435 | self.navigate_to_prev_match(size); |
| 436 | } else { |
| 437 | self.navigate_to_next_match(size); |
| 438 | } |
| 439 | return; |
| 440 | } |
| 441 | |
| 442 | // Double-click -> reset the view. |
| 443 | if response.double_clicked() { |
| 444 | self.origin = Pos2::ZERO; |
| 445 | self.x_zoom = 1.0; |
| 446 | self.sandwich_view = None; // Exit sandwich view on double-click |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | let (scroll, mut zoom) = ui.input(|x| (x.smooth_scroll_delta, x.zoom_delta_2d())); |
| 451 | self.origin -= response.drag_delta(); |
| 452 | self.origin -= scroll; |
| 453 | |
| 454 | for key in ui.input(|x| x.keys_down.clone()) { |
| 455 | match key { |
| 456 | Key::H | Key::ArrowLeft => self.origin.x -= 100.0, |
| 457 | Key::L | Key::ArrowRight => self.origin.x += 100.0, |
| 458 | Key::K | Key::ArrowUp => { |
| 459 | if ui.input(|x| x.modifiers).command_only() { |
| 460 | zoom.x -= 0.25 |
| 461 | } else { |
| 462 | self.origin.y -= 100.0; |
no test coverage detected