replace OVERRIDE and FINAL with override and final in ash/
[chromium-blink-merge.git] / ash / magnifier / partial_magnification_controller.h
blobf78f52be9a6885628b2b6dc20f509d5de2f04422
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/events/event_handler.h"
10 #include "ui/gfx/point.h"
11 #include "ui/views/widget/widget_observer.h"
13 namespace ash {
15 const float kDefaultPartialMagnifiedScale = 1.5f;
16 const float kNonPartialMagnifiedScale = 1.0f;
18 // Controls the partial screen magnifier, which is a small area of the screen
19 // which is zoomed in. The zoomed area follows the mouse cursor when enabled.
20 class PartialMagnificationController
21 : public ui::EventHandler,
22 public aura::WindowObserver,
23 public views::WidgetObserver {
24 public:
25 PartialMagnificationController();
26 virtual ~PartialMagnificationController();
28 // Enables (or disables if |enabled| is false) partial screen magnifier
29 // feature.
30 virtual void SetEnabled(bool enabled);
32 bool is_enabled() const { return is_enabled_; }
34 // Sets the magnification ratio. 1.0f means no magnification.
35 void SetScale(float scale);
37 // Returns the current magnification ratio.
38 float GetScale() const { return scale_; }
40 private:
41 void OnMouseMove(const gfx::Point& location_in_root);
43 // Switch PartialMagnified RootWindow to |new_root_window|. This does
44 // following:
45 // - Remove the magnifier from the current root window.
46 // - Create a magnifier in the new root_window |new_root_window|.
47 // - Switch the target window from current window to |new_root_window|.
48 void SwitchTargetRootWindow(aura::Window* new_root_window);
50 // Returns the root window that contains the mouse cursor.
51 aura::Window* GetCurrentRootWindow();
53 // Return true if the magnification scale > kMinPartialMagnifiedScaleThreshold
54 bool IsPartialMagnified() const;
56 // Create the magnifier window.
57 void CreateMagnifierWindow();
59 // Cleans up the window if needed.
60 void CloseMagnifierWindow();
62 // Removes this as an observer of the zoom widget and the root window.
63 void RemoveZoomWidgetObservers();
65 // ui::EventHandler overrides:
66 virtual void OnMouseEvent(ui::MouseEvent* event) override;
68 // Overridden from WindowObserver:
69 virtual void OnWindowDestroying(aura::Window* window) override;
71 // Overridden from WidgetObserver:
72 virtual void OnWidgetDestroying(views::Widget* widget) override;
74 // True if the magnified window is in motion of zooming or un-zooming effect.
75 // Otherwise, false.
76 bool is_on_zooming_;
78 bool is_enabled_;
80 // Current scale, origin (left-top) position of the magnification window.
81 float scale_;
82 gfx::Point origin_;
84 views::Widget* zoom_widget_;
86 DISALLOW_COPY_AND_ASSIGN(PartialMagnificationController);
89 } // namespace ash
91 #endif // ASH_MAGNIFIER_PARTIAL_MAGNIFICATION_CONTROLLER_H_