Add per-day app launcher usage histogram
[chromium-blink-merge.git] / ash / magnifier / partial_magnification_controller.h
blob1b8c8fb77bda3f604979eb4dc53d947bb3b2dddd
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.
5 #ifndef ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_
6 #define ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_
8 #include "ui/aura/window_observer.h"
9 #include "ui/base/events/event_handler.h"
10 #include "ui/gfx/point.h"
11 #include "ui/views/widget/widget_observer.h"
13 namespace aura {
14 class RootWindow;
17 namespace ash {
19 const float kDefaultPartialMagnifiedScale = 1.5f;
20 const float kNonPartialMagnifiedScale = 1.0f;
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 ui::EventHandler,
26 public aura::WindowObserver,
27 public views::WidgetObserver {
28 public:
29 PartialMagnificationController();
30 virtual ~PartialMagnificationController();
32 // Enables (or disables if |enabled| is false) partial screen magnifier
33 // feature.
34 virtual void SetEnabled(bool enabled);
36 bool is_enabled() const { return is_enabled_; }
38 // Sets the magnification ratio. 1.0f means no magnification.
39 void SetScale(float scale);
41 // Returns the current magnification ratio.
42 float GetScale() const { return scale_; }
44 private:
45 void OnMouseMove(const gfx::Point& location_in_root);
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);
54 // Returns the root window that contains the mouse cursor.
55 aura::RootWindow* GetCurrentRootWindow();
57 // Return true if the magnification scale > kMinPartialMagnifiedScaleThreshold
58 bool IsPartialMagnified() const;
60 // Create the magnifier window.
61 void CreateMagnifierWindow();
63 // Cleans up the window if needed.
64 void CloseMagnifierWindow();
66 // Removes this as an observer of the zoom widget and the root window.
67 void RemoveZoomWidgetObservers();
69 // ui::EventHandler overrides:
70 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
72 // Overridden from WindowObserver:
73 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
75 // Overridden from WidgetObserver:
76 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
78 // True if the magnified window is in motion of zooming or un-zooming effect.
79 // Otherwise, false.
80 bool is_on_zooming_;
82 bool is_enabled_;
84 // Current scale, origin (left-top) position of the magnification window.
85 float scale_;
86 gfx::Point origin_;
88 views::Widget* zoom_widget_;
90 DISALLOW_COPY_AND_ASSIGN(PartialMagnificationController);
93 } // namespace ash
95 #endif // ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_