Index: ash/magnifier/partial_magnification_controller.h |
diff --git a/ash/magnifier/partial_magnification_controller.h b/ash/magnifier/partial_magnification_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc96f51e7d2ee3172fa470dd9d3ee092e415f3ea |
--- /dev/null |
+++ b/ash/magnifier/partial_magnification_controller.h |
@@ -0,0 +1,104 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ |
+#define ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ |
+ |
+#include "ui/aura/event_filter.h" |
+#include "ui/aura/window_observer.h" |
+#include "ui/gfx/point.h" |
+#include "ui/views/widget/widget_observer.h" |
+ |
+namespace aura { |
+class RootWindow; |
+} |
+ |
+namespace ash { |
+ |
+const float kDefaultPartialMagnifiedScale = 1.5f; |
+const float kNonPartialMagnifiedScale = 1.0f; |
+ |
+// Controls the partial screen magnifier, which is a small area of the screen |
+// which is zoomed in. The zoomed area follows the mouse cursor when enabled. |
+class PartialMagnificationController |
+ : public aura::EventFilter, |
+ public aura::WindowObserver, |
+ public views::WidgetObserver { |
+ public: |
+ PartialMagnificationController(); |
+ virtual ~PartialMagnificationController(); |
+ |
+ // Enables (or disables if |enabled| is false) partial screen magnifier |
+ // feature. |
+ void SetEnabled(bool enabled); |
+ |
+ bool IsEnabled() const; |
sky
2012/11/12 15:23:46
is_enabled() and inline.
Zachary Kuznia
2012/11/13 08:16:15
Done.
|
+ |
+ // Sets the magnification ratio. 1.0f means no magnification. |
+ void SetScale(float scale); |
+ |
+ // Returns the current magnification ratio. |
+ float GetScale() const { return scale_; } |
+ |
+ private: |
+ void OnMouseMove(const gfx::Point& location_in_root); |
+ |
+ // Switch PartialMagnified RootWindow to |new_root_window|. This does |
+ // following: |
+ // - Remove the magnifier from the current root window. |
+ // - Create a magnifier in the new root_window |new_root_window|. |
+ // - Switch the target window from current window to |new_root_window|. |
+ void SwitchTargetRootWindow(aura::RootWindow* new_root_window); |
+ |
+ // Returns the root window that contains the mouse cursor. |
+ aura::RootWindow* GetCurrentRootWindow(); |
+ |
+ // Return true if the magnification scale > kMinPartialMagnifiedScaleThreshold |
+ bool IsPartialMagnified() const; |
+ |
+ // Create the magnifier window. |
+ void CreateMagnifierWindow(); |
+ |
+ // Cleans up the window if needed. |
+ void CloseMagnifierWindow(); |
+ |
+ // Removes this as an observer of the zoom widget and the root window. |
+ void RemoveZoomWidgetObservers(); |
+ |
+ // aura::EventFilter overrides: |
+ virtual bool PreHandleKeyEvent(aura::Window* target, |
+ ui::KeyEvent* event) OVERRIDE; |
+ virtual bool PreHandleMouseEvent(aura::Window* target, |
+ ui::MouseEvent* event) OVERRIDE; |
+ virtual ui::EventResult PreHandleTouchEvent( |
+ aura::Window* target, |
+ ui::TouchEvent* event) OVERRIDE; |
+ virtual ui::EventResult PreHandleGestureEvent( |
+ aura::Window* target, |
+ ui::GestureEvent* event) OVERRIDE; |
+ |
+ // Overridden from WindowObserver: |
+ virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
+ |
+ // Overridden from WidgetObserver: |
+ virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; |
+ |
+ // True if the magnified window is in motion of zooming or un-zooming effect. |
+ // Otherwise, false. |
+ bool is_on_zooming_; |
+ |
+ bool is_enabled_; |
+ |
+ // Current scale, origin (left-top) position of the magnification window. |
+ float scale_; |
+ gfx::Point origin_; |
+ |
+ views::Widget* zoom_widget_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PartialMagnificationController); |
+}; |
+ |
+} // namespace ash |
+ |
+#endif // ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_ |