OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ | |
6 #define ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ | |
7 | |
8 #include "ui/aura/event_filter.h" | |
9 #include "ui/aura/window_observer.h" | |
10 #include "ui/gfx/point.h" | |
11 #include "ui/views/widget/widget_observer.h" | |
12 | |
13 namespace aura { | |
14 class RootWindow; | |
15 } | |
16 | |
17 namespace ash { | |
18 | |
19 const float kDefaultPartialMagnifiedScale = 1.5f; | |
20 const float kNonPartialMagnifiedScale = 1.0f; | |
21 | |
22 // Controls the partial screen magnifier, which is a small area of the screen | |
23 // which is zoomed in. The zoomed area follows the mouse cursor when enabled. | |
24 class PartialMagnificationController | |
25 : public aura::EventFilter, | |
26 public aura::WindowObserver, | |
27 public views::WidgetObserver { | |
28 public: | |
29 PartialMagnificationController(); | |
30 virtual ~PartialMagnificationController(); | |
31 | |
32 // Enables (or disables if |enabled| is false) partial screen magnifier | |
33 // feature. | |
34 void SetEnabled(bool enabled); | |
35 | |
36 bool IsEnabled() const; | |
sky
2012/11/12 15:23:46
is_enabled() and inline.
Zachary Kuznia
2012/11/13 08:16:15
Done.
| |
37 | |
38 // Sets the magnification ratio. 1.0f means no magnification. | |
39 void SetScale(float scale); | |
40 | |
41 // Returns the current magnification ratio. | |
42 float GetScale() const { return scale_; } | |
43 | |
44 private: | |
45 void OnMouseMove(const gfx::Point& location_in_root); | |
46 | |
47 // Switch PartialMagnified RootWindow to |new_root_window|. This does | |
48 // following: | |
49 // - Remove the magnifier from the current root window. | |
50 // - Create a magnifier in the new root_window |new_root_window|. | |
51 // - Switch the target window from current window to |new_root_window|. | |
52 void SwitchTargetRootWindow(aura::RootWindow* new_root_window); | |
53 | |
54 // Returns the root window that contains the mouse cursor. | |
55 aura::RootWindow* GetCurrentRootWindow(); | |
56 | |
57 // Return true if the magnification scale > kMinPartialMagnifiedScaleThreshold | |
58 bool IsPartialMagnified() const; | |
59 | |
60 // Create the magnifier window. | |
61 void CreateMagnifierWindow(); | |
62 | |
63 // Cleans up the window if needed. | |
64 void CloseMagnifierWindow(); | |
65 | |
66 // Removes this as an observer of the zoom widget and the root window. | |
67 void RemoveZoomWidgetObservers(); | |
68 | |
69 // aura::EventFilter overrides: | |
70 virtual bool PreHandleKeyEvent(aura::Window* target, | |
71 ui::KeyEvent* event) OVERRIDE; | |
72 virtual bool PreHandleMouseEvent(aura::Window* target, | |
73 ui::MouseEvent* event) OVERRIDE; | |
74 virtual ui::EventResult PreHandleTouchEvent( | |
75 aura::Window* target, | |
76 ui::TouchEvent* event) OVERRIDE; | |
77 virtual ui::EventResult PreHandleGestureEvent( | |
78 aura::Window* target, | |
79 ui::GestureEvent* event) OVERRIDE; | |
80 | |
81 // Overridden from WindowObserver: | |
82 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | |
83 | |
84 // Overridden from WidgetObserver: | |
85 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | |
86 | |
87 // True if the magnified window is in motion of zooming or un-zooming effect. | |
88 // Otherwise, false. | |
89 bool is_on_zooming_; | |
90 | |
91 bool is_enabled_; | |
92 | |
93 // Current scale, origin (left-top) position of the magnification window. | |
94 float scale_; | |
95 gfx::Point origin_; | |
96 | |
97 views::Widget* zoom_widget_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(PartialMagnificationController); | |
100 }; | |
101 | |
102 } // namespace ash | |
103 | |
104 #endif // ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ | |
OLD | NEW |