| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/magnifier/magnification_controller.h" | 5 #include "ash/magnifier/magnification_controller.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/root_window_transformers.h" | 10 #include "ash/display/root_window_transformers.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 // Threadshold of panning. If the cursor moves to within pixels (in DIP) of | 62 // Threadshold of panning. If the cursor moves to within pixels (in DIP) of |
| 63 // |kCursorPanningMargin| from the edge, the view-port moves. | 63 // |kCursorPanningMargin| from the edge, the view-port moves. |
| 64 const int kCursorPanningMargin = 100; | 64 const int kCursorPanningMargin = 100; |
| 65 | 65 |
| 66 // Threadshold of panning. If the caret moves to within pixels (in DIP) of | 66 // Threadshold of panning. If the caret moves to within pixels (in DIP) of |
| 67 // |kCaretPanningMargin| from the edge, the view-port moves. | 67 // |kCaretPanningMargin| from the edge, the view-port moves. |
| 68 const int kCaretPanningMargin = 50; | 68 const int kCaretPanningMargin = 50; |
| 69 | 69 |
| 70 void MoveCursorTo(aura::WindowTreeHost* host, const gfx::Point& root_location) { | 70 void MoveCursorTo(aura::WindowTreeHost* host, const gfx::Point& root_location) { |
| 71 gfx::Point3F host_location_3f(root_location); | 71 auto host_location_3f = gfx::Point3F(gfx::PointF(root_location)); |
| 72 host->GetRootTransform().TransformPoint(&host_location_3f); | 72 host->GetRootTransform().TransformPoint(&host_location_3f); |
| 73 host->MoveCursorToHostLocation( | 73 host->MoveCursorToHostLocation( |
| 74 gfx::ToCeiledPoint(host_location_3f.AsPointF())); | 74 gfx::ToCeiledPoint(host_location_3f.AsPointF())); |
| 75 } | 75 } |
| 76 | 76 |
| 77 ui::InputMethod* GetInputMethod(aura::Window* root_window) { | 77 ui::InputMethod* GetInputMethod(aura::Window* root_window) { |
| 78 if (root_window->GetHost()) | 78 if (root_window->GetHost()) |
| 79 return root_window->GetHost()->GetInputMethod(); | 79 return root_window->GetHost()->GetInputMethod(); |
| 80 return nullptr; | 80 return nullptr; |
| 81 } | 81 } |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 ValidateScale(&scale); | 561 ValidateScale(&scale); |
| 562 Shell::GetInstance()->accessibility_delegate()-> | 562 Shell::GetInstance()->accessibility_delegate()-> |
| 563 SaveScreenMagnifierScale(scale); | 563 SaveScreenMagnifierScale(scale); |
| 564 RedrawKeepingMousePosition(scale, animate); | 564 RedrawKeepingMousePosition(scale, animate); |
| 565 } | 565 } |
| 566 | 566 |
| 567 void MagnificationControllerImpl::MoveWindow(int x, int y, bool animate) { | 567 void MagnificationControllerImpl::MoveWindow(int x, int y, bool animate) { |
| 568 if (!is_enabled_) | 568 if (!is_enabled_) |
| 569 return; | 569 return; |
| 570 | 570 |
| 571 Redraw(gfx::Point(x, y), scale_, animate); | 571 Redraw(gfx::PointF(x, y), scale_, animate); |
| 572 } | 572 } |
| 573 | 573 |
| 574 void MagnificationControllerImpl::MoveWindow(const gfx::Point& point, | 574 void MagnificationControllerImpl::MoveWindow(const gfx::Point& point, |
| 575 bool animate) { | 575 bool animate) { |
| 576 if (!is_enabled_) | 576 if (!is_enabled_) |
| 577 return; | 577 return; |
| 578 | 578 |
| 579 Redraw(point, scale_, animate); | 579 Redraw(gfx::PointF(point), scale_, animate); |
| 580 } | 580 } |
| 581 | 581 |
| 582 void MagnificationControllerImpl::SetScrollDirection( | 582 void MagnificationControllerImpl::SetScrollDirection( |
| 583 ScrollDirection direction) { | 583 ScrollDirection direction) { |
| 584 scroll_direction_ = direction; | 584 scroll_direction_ = direction; |
| 585 StartOrStopScrollIfNecessary(); | 585 StartOrStopScrollIfNecessary(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 void MagnificationControllerImpl::SetEnabled(bool enabled) { | 588 void MagnificationControllerImpl::SetEnabled(bool enabled) { |
| 589 Shell* shell = Shell::GetInstance(); | 589 Shell* shell = Shell::GetInstance(); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 // Panning up. | 717 // Panning up. |
| 718 y_diff = point.y() - (top + y_target_margin); | 718 y_diff = point.y() - (top + y_target_margin); |
| 719 start_zoom = true; | 719 start_zoom = true; |
| 720 } else if (bottom - y_panning_margin < point.y()) { | 720 } else if (bottom - y_panning_margin < point.y()) { |
| 721 // Panning down. | 721 // Panning down. |
| 722 y_diff = point.y() - (bottom - y_target_margin); | 722 y_diff = point.y() - (bottom - y_target_margin); |
| 723 start_zoom = true; | 723 start_zoom = true; |
| 724 } | 724 } |
| 725 int y = top + y_diff; | 725 int y = top + y_diff; |
| 726 if (start_zoom && !is_on_animation_) { | 726 if (start_zoom && !is_on_animation_) { |
| 727 bool ret = RedrawDIP(gfx::Point(x, y), scale_, | 727 bool ret = RedrawDIP(gfx::PointF(x, y), scale_, |
| 728 0, // No animation on panning. | 728 0, // No animation on panning. |
| 729 kDefaultAnimationTweenType); | 729 kDefaultAnimationTweenType); |
| 730 | 730 |
| 731 if (ret) { | 731 if (ret) { |
| 732 // If the magnified region is moved, hides the mouse cursor and moves it. | 732 // If the magnified region is moved, hides the mouse cursor and moves it. |
| 733 if (x_diff != 0 || y_diff != 0) | 733 if (x_diff != 0 || y_diff != 0) |
| 734 MoveCursorTo(root_window_->GetHost(), point); | 734 MoveCursorTo(root_window_->GetHost(), point); |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 } | 737 } |
| 738 | 738 |
| 739 void MagnificationControllerImpl::MoveMagnifierWindowCenterPoint( | 739 void MagnificationControllerImpl::MoveMagnifierWindowCenterPoint( |
| 740 const gfx::Point& point) { | 740 const gfx::Point& point) { |
| 741 DCHECK(root_window_); | 741 DCHECK(root_window_); |
| 742 | 742 |
| 743 const gfx::Rect window_rect = GetViewportRect(); | 743 const gfx::Rect window_rect = GetViewportRect(); |
| 744 if (point == window_rect.CenterPoint()) | 744 if (point == window_rect.CenterPoint()) |
| 745 return; | 745 return; |
| 746 | 746 |
| 747 if (!is_on_animation_) { | 747 if (!is_on_animation_) { |
| 748 // With animation on panning. | 748 // With animation on panning. |
| 749 RedrawDIP(window_rect.origin() + (point - window_rect.CenterPoint()), | 749 RedrawDIP( |
| 750 scale_, kDefaultAnimationDurationInMs, | 750 gfx::PointF(window_rect.origin() + (point - window_rect.CenterPoint())), |
| 751 kCenterCaretAnimationTweenType); | 751 scale_, kDefaultAnimationDurationInMs, kCenterCaretAnimationTweenType); |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 void MagnificationControllerImpl::MoveMagnifierWindowFollowRect( | 755 void MagnificationControllerImpl::MoveMagnifierWindowFollowRect( |
| 756 const gfx::Rect& rect) { | 756 const gfx::Rect& rect) { |
| 757 DCHECK(root_window_); | 757 DCHECK(root_window_); |
| 758 bool should_pan = false; | 758 bool should_pan = false; |
| 759 | 759 |
| 760 const gfx::Rect viewport_rect = GetViewportRect(); | 760 const gfx::Rect viewport_rect = GetViewportRect(); |
| 761 const int left = viewport_rect.x(); | 761 const int left = viewport_rect.x(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 778 // Panning vertically. | 778 // Panning vertically. |
| 779 y = rect_center.y() - viewport_rect.height() / 2; | 779 y = rect_center.y() - viewport_rect.height() / 2; |
| 780 should_pan = true; | 780 should_pan = true; |
| 781 } | 781 } |
| 782 | 782 |
| 783 if (should_pan) { | 783 if (should_pan) { |
| 784 if (is_on_animation_) { | 784 if (is_on_animation_) { |
| 785 root_window_->layer()->GetAnimator()->StopAnimating(); | 785 root_window_->layer()->GetAnimator()->StopAnimating(); |
| 786 is_on_animation_ = false; | 786 is_on_animation_ = false; |
| 787 } | 787 } |
| 788 RedrawDIP(gfx::Point(x, y), scale_, | 788 RedrawDIP(gfx::PointF(x, y), scale_, |
| 789 0, // No animation on panning. | 789 0, // No animation on panning. |
| 790 kDefaultAnimationTweenType); | 790 kDefaultAnimationTweenType); |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 void MagnificationControllerImpl::OnMoveMagnifierTimer() { | 794 void MagnificationControllerImpl::OnMoveMagnifierTimer() { |
| 795 MoveMagnifierWindowCenterPoint(caret_point_); | 795 MoveMagnifierWindowCenterPoint(caret_point_); |
| 796 } | 796 } |
| 797 | 797 |
| 798 void MagnificationControllerImpl::OnCaretBoundsChanged( | 798 void MagnificationControllerImpl::OnCaretBoundsChanged( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 | 846 |
| 847 //////////////////////////////////////////////////////////////////////////////// | 847 //////////////////////////////////////////////////////////////////////////////// |
| 848 // MagnificationController: | 848 // MagnificationController: |
| 849 | 849 |
| 850 // static | 850 // static |
| 851 MagnificationController* MagnificationController::CreateInstance() { | 851 MagnificationController* MagnificationController::CreateInstance() { |
| 852 return new MagnificationControllerImpl(); | 852 return new MagnificationControllerImpl(); |
| 853 } | 853 } |
| 854 | 854 |
| 855 } // namespace ash | 855 } // namespace ash |
| OLD | NEW |