| 493 | } |
| 494 | |
| 495 | void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { |
| 496 | if (last_metric < 0) { |
| 497 | return; |
| 498 | } |
| 499 | |
| 500 | Ref<InputEventMouse> me = p_ev; |
| 501 | Ref<InputEventMouseButton> mb = p_ev; |
| 502 | Ref<InputEventMouseMotion> mm = p_ev; |
| 503 | MouseButton button_idx = mb.is_valid() ? mb->get_button_index() : MouseButton(); |
| 504 | |
| 505 | if ( |
| 506 | (mb.is_valid() && button_idx == MouseButton::LEFT && mb->is_pressed()) || |
| 507 | (mm.is_valid())) { |
| 508 | int x = me->get_position().x - 1; |
| 509 | hover_metric = x * frame_metrics.size() / graph->get_size().width; |
| 510 | |
| 511 | x = x * frame_metrics.size() / graph->get_size().width; |
| 512 | x = x / Math::exp(graph_zoom) + _get_zoom_left_border(); |
| 513 | x = CLAMP(x, 0, frame_metrics.size() - 1); |
| 514 | |
| 515 | if (mb.is_valid() || (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) { |
| 516 | updating_frame = true; |
| 517 | |
| 518 | if (x < total_metrics) { |
| 519 | cursor_metric_edit->set_value(_get_frame_metric(x).frame_number); |
| 520 | } |
| 521 | updating_frame = false; |
| 522 | |
| 523 | if (activate->is_pressed()) { |
| 524 | if (!seeking) { |
| 525 | emit_signal(SNAME("break_request")); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | seeking = true; |
| 530 | |
| 531 | if (!frame_delay->is_processing()) { |
| 532 | frame_delay->set_wait_time(0.1); |
| 533 | frame_delay->start(); |
| 534 | } |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | if (graph_zoom > 0 && mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::MIDDLE) || mm->get_button_mask().has_flag(MouseButtonMask::RIGHT))) { |
| 539 | // Panning. |
| 540 | const int max_profiles_shown = frame_metrics.size() / Math::exp(graph_zoom); |
| 541 | pan_accumulator += (float)mm->get_relative().x * max_profiles_shown / graph->get_size().width; |
| 542 | |
| 543 | if (Math::abs(pan_accumulator) > 1) { |
| 544 | zoom_center = CLAMP(zoom_center - (int)pan_accumulator, max_profiles_shown / 2, frame_metrics.size() - max_profiles_shown / 2); |
| 545 | pan_accumulator -= (int)pan_accumulator; |
| 546 | _update_plot(); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | if (button_idx == MouseButton::WHEEL_DOWN) { |
| 551 | // Zooming. |
| 552 | graph_zoom = MAX(-0.05 + graph_zoom, 0); |
nothing calls this directly
no test coverage detected