| 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/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
| 10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
| 11 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
| 12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_property.h" | 14 #include "ui/aura/window_property.h" |
| 15 #include "ui/base/events/event.h" | 15 #include "ui/base/events/event.h" |
| 16 #include "ui/base/events/event_handler.h" | 16 #include "ui/base/events/event_handler.h" |
| 17 #include "ui/compositor/dip_util.h" | 17 #include "ui/compositor/dip_util.h" |
| 18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
| 19 #include "ui/compositor/layer_animation_observer.h" | 19 #include "ui/compositor/layer_animation_observer.h" |
| 20 #include "ui/compositor/scoped_layer_animation_settings.h" | 20 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 21 #include "ui/gfx/point3_f.h" |
| 21 #include "ui/gfx/point_conversions.h" | 22 #include "ui/gfx/point_conversions.h" |
| 22 #include "ui/gfx/point_f.h" | 23 #include "ui/gfx/point_f.h" |
| 23 #include "ui/gfx/rect_conversions.h" | 24 #include "ui/gfx/rect_conversions.h" |
| 24 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
| 25 #include "ui/views/corewm/compound_event_filter.h" | 26 #include "ui/views/corewm/compound_event_filter.h" |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 const float kMaxMagnifiedScale = 4.0f; | 30 const float kMaxMagnifiedScale = 4.0f; |
| 30 const float kMaxMagnifiedScaleThreshold = 4.0f; | 31 const float kMaxMagnifiedScaleThreshold = 4.0f; |
| 31 const float kMinMagnifiedScaleThreshold = 1.1f; | 32 const float kMinMagnifiedScaleThreshold = 1.1f; |
| 32 const float kNonMagnifiedScale = 1.0f; | 33 const float kNonMagnifiedScale = 1.0f; |
| 33 | 34 |
| 34 const float kInitialMagnifiedScale = 2.0f; | 35 const float kInitialMagnifiedScale = 2.0f; |
| 35 const float kScrollScaleChangeFactor = 0.05f; | 36 const float kScrollScaleChangeFactor = 0.05f; |
| 36 | 37 |
| 37 // Threadshold of panning. If the cursor moves to within pixels (in DIP) of | 38 // Threadshold of panning. If the cursor moves to within pixels (in DIP) of |
| 38 // |kPanningMergin| from the edge, the view-port moves. | 39 // |kPanningMergin| from the edge, the view-port moves. |
| 39 const int kPanningMergin = 100; | 40 const int kPanningMergin = 100; |
| 40 | 41 |
| 42 void MoveCursorTo(aura::RootWindow* root_window, |
| 43 const gfx::Point root_location) { |
| 44 gfx::Point3F host_location_3f(root_location); |
| 45 root_window->layer()->transform().TransformPoint(host_location_3f); |
| 46 root_window->MoveCursorToInHost( |
| 47 gfx::ToCeiledPoint(host_location_3f.AsPointF())); |
| 48 } |
| 49 |
| 41 } // namespace | 50 } // namespace |
| 42 | 51 |
| 43 namespace ash { | 52 namespace ash { |
| 44 | 53 |
| 45 //////////////////////////////////////////////////////////////////////////////// | 54 //////////////////////////////////////////////////////////////////////////////// |
| 46 // MagnificationControllerImpl: | 55 // MagnificationControllerImpl: |
| 47 | 56 |
| 48 class MagnificationControllerImpl : virtual public MagnificationController, | 57 class MagnificationControllerImpl : virtual public MagnificationController, |
| 49 public ui::EventHandler, | 58 public ui::EventHandler, |
| 50 public ui::ImplicitAnimationObserver, | 59 public ui::ImplicitAnimationObserver, |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 y = top + y_diff; | 360 y = top + y_diff; |
| 352 | 361 |
| 353 if (start_zoom && !is_on_animation_) { | 362 if (start_zoom && !is_on_animation_) { |
| 354 // No animation on panning. | 363 // No animation on panning. |
| 355 bool animate = false; | 364 bool animate = false; |
| 356 bool ret = RedrawDIP(gfx::Point(x, y), scale_, animate); | 365 bool ret = RedrawDIP(gfx::Point(x, y), scale_, animate); |
| 357 | 366 |
| 358 if (ret) { | 367 if (ret) { |
| 359 // If the magnified region is moved, hides the mouse cursor and moves it. | 368 // If the magnified region is moved, hides the mouse cursor and moves it. |
| 360 if (x_diff != 0 || y_diff != 0) | 369 if (x_diff != 0 || y_diff != 0) |
| 361 root_window_->MoveCursorTo(mouse); | 370 MoveCursorTo(root_window_, mouse); |
| 362 } | 371 } |
| 363 } | 372 } |
| 364 } | 373 } |
| 365 | 374 |
| 366 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( | 375 void MagnificationControllerImpl::AfterAnimationMoveCursorTo( |
| 367 const gfx::Point& location) { | 376 const gfx::Point& location) { |
| 368 DCHECK(root_window_); | 377 DCHECK(root_window_); |
| 369 | 378 |
| 370 aura::client::CursorClient* cursor_client = | 379 aura::client::CursorClient* cursor_client = |
| 371 aura::client::GetCursorClient(root_window_); | 380 aura::client::GetCursorClient(root_window_); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 *scale = kMaxMagnifiedScale; | 420 *scale = kMaxMagnifiedScale; |
| 412 | 421 |
| 413 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); | 422 DCHECK(kNonMagnifiedScale <= *scale && *scale <= kMaxMagnifiedScale); |
| 414 } | 423 } |
| 415 | 424 |
| 416 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { | 425 void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { |
| 417 if (!is_on_animation_) | 426 if (!is_on_animation_) |
| 418 return; | 427 return; |
| 419 | 428 |
| 420 if (move_cursor_after_animation_) { | 429 if (move_cursor_after_animation_) { |
| 421 root_window_->MoveCursorTo(position_after_animation_); | 430 MoveCursorTo(root_window_, position_after_animation_); |
| 422 move_cursor_after_animation_ = false; | 431 move_cursor_after_animation_ = false; |
| 423 | 432 |
| 424 aura::client::CursorClient* cursor_client = | 433 aura::client::CursorClient* cursor_client = |
| 425 aura::client::GetCursorClient(root_window_); | 434 aura::client::GetCursorClient(root_window_); |
| 426 if (cursor_client) | 435 if (cursor_client) |
| 427 cursor_client->EnableMouseEvents(); | 436 cursor_client->EnableMouseEvents(); |
| 428 } | 437 } |
| 429 | 438 |
| 430 is_on_animation_ = false; | 439 is_on_animation_ = false; |
| 431 } | 440 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 605 |
| 597 //////////////////////////////////////////////////////////////////////////////// | 606 //////////////////////////////////////////////////////////////////////////////// |
| 598 // MagnificationController: | 607 // MagnificationController: |
| 599 | 608 |
| 600 // static | 609 // static |
| 601 MagnificationController* MagnificationController::CreateInstance() { | 610 MagnificationController* MagnificationController::CreateInstance() { |
| 602 return new MagnificationControllerImpl(); | 611 return new MagnificationControllerImpl(); |
| 603 } | 612 } |
| 604 | 613 |
| 605 } // namespace ash | 614 } // namespace ash |
| OLD | NEW |