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/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Returns the rect of the magnification window. | 108 // Returns the rect of the magnification window. |
109 gfx::RectF GetWindowRectDIP(float scale) const; | 109 gfx::RectF GetWindowRectDIP(float scale) const; |
110 // Returns the size of the root window. | 110 // Returns the size of the root window. |
111 gfx::Size GetHostSizeDIP() const; | 111 gfx::Size GetHostSizeDIP() const; |
112 | 112 |
113 // Correct the givin scale value if nessesary. | 113 // Correct the givin scale value if nessesary. |
114 void ValidateScale(float* scale); | 114 void ValidateScale(float* scale); |
115 | 115 |
116 // ui::EventHandler overrides: | 116 // ui::EventHandler overrides: |
117 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 117 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
118 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 118 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
119 | 119 |
120 aura::RootWindow* root_window_; | 120 aura::RootWindow* root_window_; |
121 | 121 |
122 // True if the magnified window is currently animating a change. Otherwise, | 122 // True if the magnified window is currently animating a change. Otherwise, |
123 // false. | 123 // false. |
124 bool is_on_animation_; | 124 bool is_on_animation_; |
125 | 125 |
126 bool is_enabled_; | 126 bool is_enabled_; |
127 | 127 |
128 // True if the cursor needs to move the given position after the animation | 128 // True if the cursor needs to move the given position after the animation |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (current_root != root_window_) | 499 if (current_root != root_window_) |
500 SwitchTargetRootWindow(current_root); | 500 SwitchTargetRootWindow(current_root); |
501 | 501 |
502 OnMouseMove(event->root_location()); | 502 OnMouseMove(event->root_location()); |
503 } | 503 } |
504 } | 504 } |
505 | 505 |
506 return ui::ER_UNHANDLED; | 506 return ui::ER_UNHANDLED; |
507 } | 507 } |
508 | 508 |
509 ui::EventResult MagnificationControllerImpl::OnScrollEvent( | 509 void MagnificationControllerImpl::OnScrollEvent( |
510 ui::ScrollEvent* event) { | 510 ui::ScrollEvent* event) { |
511 if (event->IsAltDown() && event->IsControlDown()) { | 511 if (event->IsAltDown() && event->IsControlDown()) { |
512 if (event->type() == ui::ET_SCROLL_FLING_START || | 512 if (event->type() == ui::ET_SCROLL_FLING_START || |
513 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 513 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
514 return ui::ER_CONSUMED; | 514 event->StopPropagation(); |
| 515 return; |
515 } | 516 } |
516 | 517 |
517 if (event->type() == ui::ET_SCROLL) { | 518 if (event->type() == ui::ET_SCROLL) { |
518 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); | 519 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event); |
519 float scale = GetScale(); | 520 float scale = GetScale(); |
520 scale += scroll_event->y_offset() * kScrollScaleChangeFactor; | 521 scale += scroll_event->y_offset() * kScrollScaleChangeFactor; |
521 SetScale(scale, true); | 522 SetScale(scale, true); |
522 return ui::ER_CONSUMED; | 523 event->StopPropagation(); |
| 524 return; |
523 } | 525 } |
524 } | 526 } |
525 | |
526 return ui::ER_UNHANDLED; | |
527 } | 527 } |
528 | 528 |
529 //////////////////////////////////////////////////////////////////////////////// | 529 //////////////////////////////////////////////////////////////////////////////// |
530 // MagnificationController: | 530 // MagnificationController: |
531 | 531 |
532 // static | 532 // static |
533 MagnificationController* MagnificationController::CreateInstance() { | 533 MagnificationController* MagnificationController::CreateInstance() { |
534 return new MagnificationControllerImpl(); | 534 return new MagnificationControllerImpl(); |
535 } | 535 } |
536 | 536 |
537 } // namespace ash | 537 } // namespace ash |
OLD | NEW |