| 523 | } |
| 524 | |
| 525 | void EditorVisualProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) { |
| 526 | if (last_metric < 0) { |
| 527 | return; |
| 528 | } |
| 529 | |
| 530 | Ref<InputEventMouse> me = p_ev; |
| 531 | Ref<InputEventMouseButton> mb = p_ev; |
| 532 | Ref<InputEventMouseMotion> mm = p_ev; |
| 533 | |
| 534 | if ( |
| 535 | (mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed()) || |
| 536 | (mm.is_valid())) { |
| 537 | int half_w = graph->get_size().width / 2; |
| 538 | int x = me->get_position().x; |
| 539 | if (x > half_w) { |
| 540 | x -= half_w; |
| 541 | } |
| 542 | x = x * frame_metrics.size() / half_w; |
| 543 | |
| 544 | bool show_hover = x >= 0 && x < frame_metrics.size(); |
| 545 | |
| 546 | if (x < 0) { |
| 547 | x = 0; |
| 548 | } |
| 549 | |
| 550 | if (x >= frame_metrics.size()) { |
| 551 | x = frame_metrics.size() - 1; |
| 552 | } |
| 553 | |
| 554 | int metric = frame_metrics.size() - x - 1; |
| 555 | metric = last_metric - metric; |
| 556 | while (metric < 0) { |
| 557 | metric += frame_metrics.size(); |
| 558 | } |
| 559 | |
| 560 | if (show_hover) { |
| 561 | hover_metric = metric; |
| 562 | |
| 563 | } else { |
| 564 | hover_metric = -1; |
| 565 | } |
| 566 | |
| 567 | if (mb.is_valid() || mm->get_button_mask().has_flag(MouseButtonMask::LEFT)) { |
| 568 | //cursor_metric=x; |
| 569 | updating_frame = true; |
| 570 | |
| 571 | //metric may be invalid, so look for closest metric that is valid, this makes snap feel better |
| 572 | bool valid = false; |
| 573 | for (int i = 0; i < frame_metrics.size(); i++) { |
| 574 | if (frame_metrics[metric].valid) { |
| 575 | valid = true; |
| 576 | break; |
| 577 | } |
| 578 | |
| 579 | metric++; |
| 580 | if (metric >= frame_metrics.size()) { |
| 581 | metric = 0; |
| 582 | } |
nothing calls this directly
no test coverage detected