| OLD | NEW |
| 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/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/root_window_transformers.h" | 10 #include "ash/display/root_window_transformers.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
| 69 // MagnificationControllerImpl: | 69 // MagnificationControllerImpl: |
| 70 | 70 |
| 71 class MagnificationControllerImpl : virtual public MagnificationController, | 71 class MagnificationControllerImpl : virtual public MagnificationController, |
| 72 public ui::EventHandler, | 72 public ui::EventHandler, |
| 73 public ui::ImplicitAnimationObserver, | 73 public ui::ImplicitAnimationObserver, |
| 74 public aura::WindowObserver, | 74 public aura::WindowObserver, |
| 75 public ui::InputMethodObserver { | 75 public ui::InputMethodObserver { |
| 76 public: | 76 public: |
| 77 MagnificationControllerImpl(); | 77 MagnificationControllerImpl(); |
| 78 virtual ~MagnificationControllerImpl(); | 78 ~MagnificationControllerImpl() override; |
| 79 | 79 |
| 80 // MagnificationController overrides: | 80 // MagnificationController overrides: |
| 81 virtual void SetEnabled(bool enabled) override; | 81 void SetEnabled(bool enabled) override; |
| 82 virtual bool IsEnabled() const override; | 82 bool IsEnabled() const override; |
| 83 virtual void SetScale(float scale, bool animate) override; | 83 void SetScale(float scale, bool animate) override; |
| 84 virtual float GetScale() const override { return scale_; } | 84 float GetScale() const override { return scale_; } |
| 85 virtual void MoveWindow(int x, int y, bool animate) override; | 85 void MoveWindow(int x, int y, bool animate) override; |
| 86 virtual void MoveWindow(const gfx::Point& point, bool animate) override; | 86 void MoveWindow(const gfx::Point& point, bool animate) override; |
| 87 virtual gfx::Point GetWindowPosition() const override { | 87 gfx::Point GetWindowPosition() const override { |
| 88 return gfx::ToFlooredPoint(origin_); | 88 return gfx::ToFlooredPoint(origin_); |
| 89 } | 89 } |
| 90 virtual void SetScrollDirection(ScrollDirection direction) override; | 90 void SetScrollDirection(ScrollDirection direction) override; |
| 91 | 91 |
| 92 // For test | 92 // For test |
| 93 virtual gfx::Point GetPointOfInterestForTesting() override { | 93 gfx::Point GetPointOfInterestForTesting() override { |
| 94 return point_of_interest_; | 94 return point_of_interest_; |
| 95 } | 95 } |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 // ui::ImplicitAnimationObserver overrides: | 98 // ui::ImplicitAnimationObserver overrides: |
| 99 virtual void OnImplicitAnimationsCompleted() override; | 99 void OnImplicitAnimationsCompleted() override; |
| 100 | 100 |
| 101 // aura::WindowObserver overrides: | 101 // aura::WindowObserver overrides: |
| 102 virtual void OnWindowDestroying(aura::Window* root_window) override; | 102 void OnWindowDestroying(aura::Window* root_window) override; |
| 103 virtual void OnWindowBoundsChanged(aura::Window* window, | 103 void OnWindowBoundsChanged(aura::Window* window, |
| 104 const gfx::Rect& old_bounds, | 104 const gfx::Rect& old_bounds, |
| 105 const gfx::Rect& new_bounds) override; | 105 const gfx::Rect& new_bounds) override; |
| 106 | 106 |
| 107 // Redraws the magnification window with the given origin position and the | 107 // Redraws the magnification window with the given origin position and the |
| 108 // given scale. Returns true if the window is changed; otherwise, false. | 108 // given scale. Returns true if the window is changed; otherwise, false. |
| 109 // These methods should be called internally just after the scale and/or | 109 // These methods should be called internally just after the scale and/or |
| 110 // the position are changed to redraw the window. | 110 // the position are changed to redraw the window. |
| 111 bool Redraw(const gfx::PointF& position, float scale, bool animate); | 111 bool Redraw(const gfx::PointF& position, float scale, bool animate); |
| 112 bool RedrawDIP(const gfx::PointF& position, float scale, bool animate); | 112 bool RedrawDIP(const gfx::PointF& position, float scale, bool animate); |
| 113 | 113 |
| 114 // 1) If the screen is scrolling (i.e. animating) and should scroll further, | 114 // 1) If the screen is scrolling (i.e. animating) and should scroll further, |
| 115 // it does nothing. | 115 // it does nothing. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 142 | 142 |
| 143 // Returns the rect of the magnification window. | 143 // Returns the rect of the magnification window. |
| 144 gfx::RectF GetWindowRectDIP(float scale) const; | 144 gfx::RectF GetWindowRectDIP(float scale) const; |
| 145 // Returns the size of the root window. | 145 // Returns the size of the root window. |
| 146 gfx::Size GetHostSizeDIP() const; | 146 gfx::Size GetHostSizeDIP() const; |
| 147 | 147 |
| 148 // Correct the givin scale value if nessesary. | 148 // Correct the givin scale value if nessesary. |
| 149 void ValidateScale(float* scale); | 149 void ValidateScale(float* scale); |
| 150 | 150 |
| 151 // ui::EventHandler overrides: | 151 // ui::EventHandler overrides: |
| 152 virtual void OnMouseEvent(ui::MouseEvent* event) override; | 152 void OnMouseEvent(ui::MouseEvent* event) override; |
| 153 virtual void OnScrollEvent(ui::ScrollEvent* event) override; | 153 void OnScrollEvent(ui::ScrollEvent* event) override; |
| 154 virtual void OnTouchEvent(ui::TouchEvent* event) override; | 154 void OnTouchEvent(ui::TouchEvent* event) override; |
| 155 | 155 |
| 156 // Moves the view port when |point| is located within | 156 // Moves the view port when |point| is located within |
| 157 // |x_panning_margin| and |y_pannin_margin| to the edge of the visible | 157 // |x_panning_margin| and |y_pannin_margin| to the edge of the visible |
| 158 // window region. The view port will be moved so that the |point| will be | 158 // window region. The view port will be moved so that the |point| will be |
| 159 // moved to the point where it has |x_target_margin| and |y_target_margin| | 159 // moved to the point where it has |x_target_margin| and |y_target_margin| |
| 160 // to the edge of the visible region. | 160 // to the edge of the visible region. |
| 161 void MoveMagnifierWindow(const gfx::Point& point, | 161 void MoveMagnifierWindow(const gfx::Point& point, |
| 162 int x_panning_margin, | 162 int x_panning_margin, |
| 163 int y_panning_margin, | 163 int y_panning_margin, |
| 164 int x_target_margin, | 164 int x_target_margin, |
| 165 int y_target_margin); | 165 int y_target_margin); |
| 166 | 166 |
| 167 // ui::InputMethodObserver: | 167 // ui::InputMethodObserver: |
| 168 virtual void OnTextInputTypeChanged( | 168 void OnTextInputTypeChanged(const ui::TextInputClient* client) override {} |
| 169 const ui::TextInputClient* client) override {} | 169 void OnFocus() override {} |
| 170 virtual void OnFocus() override {} | 170 void OnBlur() override {} |
| 171 virtual void OnBlur() override {} | 171 void OnTextInputStateChanged(const ui::TextInputClient* client) override {} |
| 172 virtual void OnTextInputStateChanged( | 172 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override {} |
| 173 const ui::TextInputClient* client) override {} | 173 void OnShowImeIfNeeded() override {} |
| 174 virtual void OnInputMethodDestroyed( | 174 void OnCaretBoundsChanged(const ui::TextInputClient* client) override; |
| 175 const ui::InputMethod* input_method) override {} | |
| 176 virtual void OnShowImeIfNeeded() override {} | |
| 177 virtual void OnCaretBoundsChanged(const ui::TextInputClient* client) override; | |
| 178 | 175 |
| 179 // Target root window. This must not be NULL. | 176 // Target root window. This must not be NULL. |
| 180 aura::Window* root_window_; | 177 aura::Window* root_window_; |
| 181 | 178 |
| 182 // True if the magnified window is currently animating a change. Otherwise, | 179 // True if the magnified window is currently animating a change. Otherwise, |
| 183 // false. | 180 // false. |
| 184 bool is_on_animation_; | 181 bool is_on_animation_; |
| 185 | 182 |
| 186 bool is_enabled_; | 183 bool is_enabled_; |
| 187 | 184 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 680 |
| 684 //////////////////////////////////////////////////////////////////////////////// | 681 //////////////////////////////////////////////////////////////////////////////// |
| 685 // MagnificationController: | 682 // MagnificationController: |
| 686 | 683 |
| 687 // static | 684 // static |
| 688 MagnificationController* MagnificationController::CreateInstance() { | 685 MagnificationController* MagnificationController::CreateInstance() { |
| 689 return new MagnificationControllerImpl(); | 686 return new MagnificationControllerImpl(); |
| 690 } | 687 } |
| 691 | 688 |
| 692 } // namespace ash | 689 } // namespace ash |
| OLD | NEW |