Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: ash/magnifier/magnification_controller.cc

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/launcher/launcher_view_unittest.cc ('k') | ash/system/tray/tray_bubble_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/aura/event.h"
9 #include "ui/aura/event_filter.h" 8 #include "ui/aura/event_filter.h"
10 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.h"
11 #include "ui/aura/shared/compound_event_filter.h" 10 #include "ui/aura/shared/compound_event_filter.h"
12 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
13 #include "ui/aura/window_property.h" 12 #include "ui/aura/window_property.h"
13 #include "ui/base/event.h"
14 #include "ui/gfx/point3.h" 14 #include "ui/gfx/point3.h"
15 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
16 #include "ui/compositor/dip_util.h" 16 #include "ui/compositor/dip_util.h"
17 #include "ui/compositor/layer.h" 17 #include "ui/compositor/layer.h"
18 #include "ui/compositor/layer_animation_observer.h" 18 #include "ui/compositor/layer_animation_observer.h"
19 #include "ui/compositor/scoped_layer_animation_settings.h" 19 #include "ui/compositor/scoped_layer_animation_settings.h"
20 20
21 namespace { 21 namespace {
22 22
23 const float kMaxMagnifiedScale = 4.0f; 23 const float kMaxMagnifiedScale = 4.0f;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Returns the rect of the magnification window. 92 // Returns the rect of the magnification window.
93 gfx::Rect GetWindowRectDIP(float scale) const; 93 gfx::Rect GetWindowRectDIP(float scale) const;
94 // Returns the size of the root window. 94 // Returns the size of the root window.
95 gfx::Size GetHostSizeDIP() const; 95 gfx::Size GetHostSizeDIP() const;
96 96
97 // Correct the givin scale value if nessesary. 97 // Correct the givin scale value if nessesary.
98 void ValidateScale(float* scale); 98 void ValidateScale(float* scale);
99 99
100 // aura::EventFilter overrides: 100 // aura::EventFilter overrides:
101 virtual bool PreHandleKeyEvent(aura::Window* target, 101 virtual bool PreHandleKeyEvent(aura::Window* target,
102 aura::KeyEvent* event) OVERRIDE; 102 ui::KeyEvent* event) OVERRIDE;
103 virtual bool PreHandleMouseEvent(aura::Window* target, 103 virtual bool PreHandleMouseEvent(aura::Window* target,
104 aura::MouseEvent* event) OVERRIDE; 104 ui::MouseEvent* event) OVERRIDE;
105 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, 105 virtual ui::TouchStatus PreHandleTouchEvent(
106 aura::TouchEvent* event) OVERRIDE; 106 aura::Window* target,
107 ui::TouchEventImpl* event) OVERRIDE;
107 virtual ui::GestureStatus PreHandleGestureEvent( 108 virtual ui::GestureStatus PreHandleGestureEvent(
108 aura::Window* target, 109 aura::Window* target,
109 aura::GestureEvent* event) OVERRIDE; 110 ui::GestureEventImpl* event) OVERRIDE;
110 111
111 aura::RootWindow* root_window_; 112 aura::RootWindow* root_window_;
112 113
113 // True if the magnified window is in motion of zooming or un-zooming effect. 114 // True if the magnified window is in motion of zooming or un-zooming effect.
114 // Otherwise, false. 115 // Otherwise, false.
115 bool is_on_zooming_; 116 bool is_on_zooming_;
116 117
117 bool is_enabled_; 118 bool is_enabled_;
118 119
119 // Current scale, origin (left-top) position of the magnification window. 120 // Current scale, origin (left-top) position of the magnification window.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } else { 410 } else {
410 SetScale(kNonMagnifiedScale, true); 411 SetScale(kNonMagnifiedScale, true);
411 is_enabled_ = enabled; 412 is_enabled_ = enabled;
412 } 413 }
413 } 414 }
414 415
415 //////////////////////////////////////////////////////////////////////////////// 416 ////////////////////////////////////////////////////////////////////////////////
416 // MagnificationControllerImpl: aura::EventFilter implementation 417 // MagnificationControllerImpl: aura::EventFilter implementation
417 418
418 bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target, 419 bool MagnificationControllerImpl::PreHandleKeyEvent(aura::Window* target,
419 aura::KeyEvent* event) { 420 ui::KeyEvent* event) {
420 return false; 421 return false;
421 } 422 }
422 423
423 bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target, 424 bool MagnificationControllerImpl::PreHandleMouseEvent(aura::Window* target,
424 aura::MouseEvent* event) { 425 ui::MouseEvent* event) {
425 if (event->type() == ui::ET_SCROLL && event->IsAltDown()) { 426 if (event->type() == ui::ET_SCROLL && event->IsAltDown()) {
426 aura::ScrollEvent* scroll_event = static_cast<aura::ScrollEvent*>(event); 427 ui::ScrollEvent* scroll_event = static_cast<ui::ScrollEvent*>(event);
427 float scale = GetScale(); 428 float scale = GetScale();
428 scale += scroll_event->y_offset() * kScrollScaleChangeFactor; 429 scale += scroll_event->y_offset() * kScrollScaleChangeFactor;
429 SetScale(scale, true); 430 SetScale(scale, true);
430 return true; 431 return true;
431 } 432 }
432 433
433 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) { 434 if (IsMagnified() && event->type() == ui::ET_MOUSE_MOVED) {
434 aura::RootWindow* current_root = target->GetRootWindow(); 435 aura::RootWindow* current_root = target->GetRootWindow();
435 gfx::Rect root_bounds = current_root->bounds(); 436 gfx::Rect root_bounds = current_root->bounds();
436 437
437 if (root_bounds.Contains(event->root_location())) { 438 if (root_bounds.Contains(event->root_location())) {
438 if (current_root != root_window_) 439 if (current_root != root_window_)
439 SwitchTargetRootWindow(current_root); 440 SwitchTargetRootWindow(current_root);
440 441
441 OnMouseMove(event->root_location()); 442 OnMouseMove(event->root_location());
442 } 443 }
443 } 444 }
444 445
445 return false; 446 return false;
446 } 447 }
447 448
448 ui::TouchStatus MagnificationControllerImpl::PreHandleTouchEvent( 449 ui::TouchStatus MagnificationControllerImpl::PreHandleTouchEvent(
449 aura::Window* target, 450 aura::Window* target,
450 aura::TouchEvent* event) { 451 ui::TouchEventImpl* event) {
451 return ui::TOUCH_STATUS_UNKNOWN; 452 return ui::TOUCH_STATUS_UNKNOWN;
452 } 453 }
453 454
454 ui::GestureStatus MagnificationControllerImpl::PreHandleGestureEvent( 455 ui::GestureStatus MagnificationControllerImpl::PreHandleGestureEvent(
455 aura::Window* target, 456 aura::Window* target,
456 aura::GestureEvent* event) { 457 ui::GestureEventImpl* event) {
457 return ui::GESTURE_STATUS_UNKNOWN; 458 return ui::GESTURE_STATUS_UNKNOWN;
458 } 459 }
459 460
460 //////////////////////////////////////////////////////////////////////////////// 461 ////////////////////////////////////////////////////////////////////////////////
461 // MagnificationController: 462 // MagnificationController:
462 463
463 // static 464 // static
464 MagnificationController* MagnificationController::CreateInstance() { 465 MagnificationController* MagnificationController::CreateInstance() {
465 return new MagnificationControllerImpl(); 466 return new MagnificationControllerImpl();
466 } 467 }
467 468
468 } // namespace internal 469 } // namespace internal
469 } // namespace ash 470 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_view_unittest.cc ('k') | ash/system/tray/tray_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698