| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void MoveWindow(int x, int y, bool animate) override; | 86 void MoveWindow(int x, int y, bool animate) override; |
| 87 void MoveWindow(const gfx::Point& point, bool animate) override; | 87 void MoveWindow(const gfx::Point& point, bool animate) override; |
| 88 gfx::Point GetWindowPosition() const override { | 88 gfx::Point GetWindowPosition() const override { |
| 89 return gfx::ToFlooredPoint(origin_); | 89 return gfx::ToFlooredPoint(origin_); |
| 90 } | 90 } |
| 91 void SetScrollDirection(ScrollDirection direction) override; | 91 void SetScrollDirection(ScrollDirection direction) override; |
| 92 gfx::Rect GetViewportRect() const override; | 92 gfx::Rect GetViewportRect() const override; |
| 93 void HandleFocusedNodeChanged( | 93 void HandleFocusedNodeChanged( |
| 94 bool is_editable_node, | 94 bool is_editable_node, |
| 95 const gfx::Rect& node_bounds_in_screen) override; | 95 const gfx::Rect& node_bounds_in_screen) override; |
| 96 void SwitchTargetRootWindow(aura::Window* new_root_window, |
| 97 bool redraw_original_root_window) override; |
| 96 | 98 |
| 97 // For test | 99 // For test |
| 98 gfx::Point GetPointOfInterestForTesting() override { | 100 gfx::Point GetPointOfInterestForTesting() override { |
| 99 return point_of_interest_; | 101 return point_of_interest_; |
| 100 } | 102 } |
| 101 | 103 |
| 102 bool IsOnAnimationForTesting() const override { return is_on_animation_; } | 104 bool IsOnAnimationForTesting() const override { return is_on_animation_; } |
| 103 | 105 |
| 104 private: | 106 private: |
| 105 // ui::ImplicitAnimationObserver overrides: | 107 // ui::ImplicitAnimationObserver overrides: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 130 // other words, zoom (or unzoom) centering around the cursor. | 132 // other words, zoom (or unzoom) centering around the cursor. |
| 131 void RedrawKeepingMousePosition(float scale, bool animate); | 133 void RedrawKeepingMousePosition(float scale, bool animate); |
| 132 | 134 |
| 133 void OnMouseMove(const gfx::Point& location); | 135 void OnMouseMove(const gfx::Point& location); |
| 134 | 136 |
| 135 // Move the mouse cursot to the given point. Actual move will be done when | 137 // Move the mouse cursot to the given point. Actual move will be done when |
| 136 // the animation is completed. This should be called after animation is | 138 // the animation is completed. This should be called after animation is |
| 137 // started. | 139 // started. |
| 138 void AfterAnimationMoveCursorTo(const gfx::Point& location); | 140 void AfterAnimationMoveCursorTo(const gfx::Point& location); |
| 139 | 141 |
| 140 // Switch Magnified RootWindow to |new_root_window|. This does following: | |
| 141 // - Unzoom the current root_window. | |
| 142 // - Zoom the given new root_window |new_root_window|. | |
| 143 // - Switch the target window from current window to |new_root_window|. | |
| 144 void SwitchTargetRootWindow(aura::Window* new_root_window, | |
| 145 bool redraw_original_root_window); | |
| 146 | |
| 147 // Returns if the magnification scale is 1.0 or not (larger then 1.0). | 142 // Returns if the magnification scale is 1.0 or not (larger then 1.0). |
| 148 bool IsMagnified() const; | 143 bool IsMagnified() const; |
| 149 | 144 |
| 150 // Returns the rect of the magnification window. | 145 // Returns the rect of the magnification window. |
| 151 gfx::RectF GetWindowRectDIP(float scale) const; | 146 gfx::RectF GetWindowRectDIP(float scale) const; |
| 152 // Returns the size of the root window. | 147 // Returns the size of the root window. |
| 153 gfx::Size GetHostSizeDIP() const; | 148 gfx::Size GetHostSizeDIP() const; |
| 154 | 149 |
| 155 // Correct the given scale value if necessary. | 150 // Correct the given scale value if necessary. |
| 156 void ValidateScale(float* scale); | 151 void ValidateScale(float* scale); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return; | 375 return; |
| 381 | 376 |
| 382 gfx::Rect node_bounds_in_root = | 377 gfx::Rect node_bounds_in_root = |
| 383 ScreenUtil::ConvertRectFromScreen(root_window_, node_bounds_in_screen); | 378 ScreenUtil::ConvertRectFromScreen(root_window_, node_bounds_in_screen); |
| 384 if (GetViewportRect().Contains(node_bounds_in_root)) | 379 if (GetViewportRect().Contains(node_bounds_in_root)) |
| 385 return; | 380 return; |
| 386 | 381 |
| 387 MoveMagnifierWindowFollowRect(node_bounds_in_root); | 382 MoveMagnifierWindowFollowRect(node_bounds_in_root); |
| 388 } | 383 } |
| 389 | 384 |
| 385 void MagnificationControllerImpl::SwitchTargetRootWindow( |
| 386 aura::Window* new_root_window, |
| 387 bool redraw_original_root_window) { |
| 388 DCHECK(new_root_window); |
| 389 |
| 390 if (new_root_window == root_window_) |
| 391 return; |
| 392 |
| 393 // Stores the previous scale. |
| 394 float scale = GetScale(); |
| 395 |
| 396 // Unmagnify the previous root window. |
| 397 root_window_->RemoveObserver(this); |
| 398 if (redraw_original_root_window) |
| 399 RedrawKeepingMousePosition(1.0f, true); |
| 400 root_window_ = new_root_window; |
| 401 RedrawKeepingMousePosition(scale, true); |
| 402 root_window_->AddObserver(this); |
| 403 } |
| 404 |
| 390 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( | 405 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( |
| 391 const gfx::Point& location) { | 406 const gfx::Point& location) { |
| 392 DCHECK(root_window_); | 407 DCHECK(root_window_); |
| 393 | 408 |
| 394 aura::client::CursorClient* cursor_client = | 409 aura::client::CursorClient* cursor_client = |
| 395 aura::client::GetCursorClient(root_window_); | 410 aura::client::GetCursorClient(root_window_); |
| 396 if (cursor_client) { | 411 if (cursor_client) { |
| 397 // When cursor is invisible, do not move or show the cursor after the | 412 // When cursor is invisible, do not move or show the cursor after the |
| 398 // animation. | 413 // animation. |
| 399 if (!cursor_client->IsCursorVisible()) | 414 if (!cursor_client->IsCursorVisible()) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 486 } |
| 472 } | 487 } |
| 473 | 488 |
| 474 void MagnificationControllerImpl::OnWindowBoundsChanged( | 489 void MagnificationControllerImpl::OnWindowBoundsChanged( |
| 475 aura::Window* window, | 490 aura::Window* window, |
| 476 const gfx::Rect& old_bounds, | 491 const gfx::Rect& old_bounds, |
| 477 const gfx::Rect& new_bounds) { | 492 const gfx::Rect& new_bounds) { |
| 478 // TODO(yoshiki): implement here. crbug.com/230979 | 493 // TODO(yoshiki): implement here. crbug.com/230979 |
| 479 } | 494 } |
| 480 | 495 |
| 481 void MagnificationControllerImpl::SwitchTargetRootWindow( | |
| 482 aura::Window* new_root_window, | |
| 483 bool redraw_original_root_window) { | |
| 484 DCHECK(new_root_window); | |
| 485 | |
| 486 if (new_root_window == root_window_) | |
| 487 return; | |
| 488 | |
| 489 // Stores the previous scale. | |
| 490 float scale = GetScale(); | |
| 491 | |
| 492 // Unmagnify the previous root window. | |
| 493 root_window_->RemoveObserver(this); | |
| 494 if (redraw_original_root_window) | |
| 495 RedrawKeepingMousePosition(1.0f, true); | |
| 496 | |
| 497 root_window_ = new_root_window; | |
| 498 RedrawKeepingMousePosition(scale, true); | |
| 499 root_window_->AddObserver(this); | |
| 500 } | |
| 501 | |
| 502 //////////////////////////////////////////////////////////////////////////////// | 496 //////////////////////////////////////////////////////////////////////////////// |
| 503 // MagnificationControllerImpl: MagnificationController implementation | 497 // MagnificationControllerImpl: MagnificationController implementation |
| 504 | 498 |
| 505 void MagnificationControllerImpl::SetScale(float scale, bool animate) { | 499 void MagnificationControllerImpl::SetScale(float scale, bool animate) { |
| 506 if (!is_enabled_) | 500 if (!is_enabled_) |
| 507 return; | 501 return; |
| 508 | 502 |
| 509 ValidateScale(&scale); | 503 ValidateScale(&scale); |
| 510 Shell::GetInstance()->accessibility_delegate()-> | 504 Shell::GetInstance()->accessibility_delegate()-> |
| 511 SaveScreenMagnifierScale(scale); | 505 SaveScreenMagnifierScale(scale); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 | 738 |
| 745 //////////////////////////////////////////////////////////////////////////////// | 739 //////////////////////////////////////////////////////////////////////////////// |
| 746 // MagnificationController: | 740 // MagnificationController: |
| 747 | 741 |
| 748 // static | 742 // static |
| 749 MagnificationController* MagnificationController::CreateInstance() { | 743 MagnificationController* MagnificationController::CreateInstance() { |
| 750 return new MagnificationControllerImpl(); | 744 return new MagnificationControllerImpl(); |
| 751 } | 745 } |
| 752 | 746 |
| 753 } // namespace ash | 747 } // namespace ash |
| OLD | NEW |