diff options
author | yoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-24 19:58:25 +0000 |
---|---|---|
committer | yoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-24 19:58:25 +0000 |
commit | 5d10702862e58fb78cf1b207281cc2d71ce63cc0 (patch) | |
tree | cc9a43d2659ef83087282faa5bc330b1a83e156e /ash/magnifier | |
parent | fca856514e362bb7c09947e848abceb2f110728b (diff) | |
download | chromium_src-5d10702862e58fb78cf1b207281cc2d71ce63cc0.zip chromium_src-5d10702862e58fb78cf1b207281cc2d71ce63cc0.tar.gz chromium_src-5d10702862e58fb78cf1b207281cc2d71ce63cc0.tar.bz2 |
Screen Magnifier: Adds option UI and enables accelerators.
Add option UI on chrome://settings to enable & disable screen magnifier, and enable the accelerators of screen magnifier "Ctrl + brightness keys (F6/F7)".
Option UI part is almost same as the patch of high contrast mode. https://chromiumcodereview.appspot.com/10408085.
BUG=126880
TEST=manual test
Review URL: https://chromiumcodereview.appspot.com/10635019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143841 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/magnifier')
-rw-r--r-- | ash/magnifier/magnification_controller.cc | 61 | ||||
-rw-r--r-- | ash/magnifier/magnification_controller.h | 3 |
2 files changed, 49 insertions, 15 deletions
diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc index dc15483..602e95a 100644 --- a/ash/magnifier/magnification_controller.cc +++ b/ash/magnifier/magnification_controller.cc @@ -19,10 +19,12 @@ namespace { -const float kMaximumMagnifiScale = 4.0f; -const float kMaximumMagnifiScaleThreshold = 4.0f; -const float kMinimumMagnifiScale = 1.0f; -const float kMinimumMagnifiScaleThreshold = 1.1f; +const float kMaxMagnifiedScale = 4.0f; +const float kMaxMagnifiedScaleThreshold = 4.0f; +const float kMinMagnifiedScaleThreshold = 1.1f; +const float kNonMagnifiedScale = 1.0f; + +const float kInitialMagnifiedScale = 2.0f; } // namespace @@ -40,6 +42,7 @@ class MagnificationControllerImpl : virtual public MagnificationController, virtual ~MagnificationControllerImpl(); // MagnificationController overrides: + virtual void SetEnabled(bool enabled) OVERRIDE; virtual void SetScale(float scale, bool animate) OVERRIDE; virtual float GetScale() const OVERRIDE { return scale_; } virtual void MoveWindow(int x, int y, bool animate) OVERRIDE; @@ -103,6 +106,8 @@ class MagnificationControllerImpl : virtual public MagnificationController, // Otherwise, false. bool is_on_zooming_; + bool is_enabled_; + // Current scale, origin (left-top) position of the magnification window. float scale_; gfx::Point origin_; @@ -116,7 +121,8 @@ class MagnificationControllerImpl : virtual public MagnificationController, MagnificationControllerImpl::MagnificationControllerImpl() : root_window_(ash::Shell::GetPrimaryRootWindow()), is_on_zooming_(false), - scale_(1.0f) { + is_enabled_(false), + scale_(kNonMagnifiedScale) { Shell::GetInstance()->AddEnvEventFilter(this); } @@ -306,19 +312,19 @@ gfx::Rect MagnificationControllerImpl::GetWindowRectDIP(float scale) const { } bool MagnificationControllerImpl::IsMagnified() const { - return scale_ >= kMinimumMagnifiScaleThreshold; + return scale_ >= kMinMagnifiedScaleThreshold; } void MagnificationControllerImpl::ValidateScale(float* scale) { - // Adjust the scale to just |kMinimumMagnifiScale| if scale is smaller than - // |kMinimumMagnifiScaleThreshold|; - if (*scale < kMinimumMagnifiScaleThreshold) - *scale = kMinimumMagnifiScale; - - // Adjust the scale to just |kMinimumMagnifiScale| if scale is bigger than - // |kMinimumMagnifiScaleThreshold|; - if (*scale > kMaximumMagnifiScaleThreshold) - *scale = kMaximumMagnifiScale; + // Adjust the scale to just |kNonMagnifiedScale| if scale is smaller than + // |kMinMagnifiedScaleThreshold|; + if (*scale < kMinMagnifiedScaleThreshold) + *scale = kNonMagnifiedScale; + + // Adjust the scale to just |kMinMagnifiedScale| if scale is bigger than + // |kMinMagnifiedScaleThreshold|; + if (*scale > kMaxMagnifiedScaleThreshold) + *scale = kMaxMagnifiedScale; } void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { @@ -330,6 +336,9 @@ void MagnificationControllerImpl::OnImplicitAnimationsCompleted() { // MagnificationControllerImpl: MagnificationController implementation void MagnificationControllerImpl::SetScale(float scale, bool animate) { + if (!is_enabled_) + return; + ValidateScale(&scale); // Try not to change the point which the mouse cursor indicates to. @@ -341,26 +350,48 @@ void MagnificationControllerImpl::SetScale(float scale, bool animate) { } void MagnificationControllerImpl::MoveWindow(int x, int y, bool animate) { + if (!is_enabled_) + return; + Redraw(gfx::Point(x, y), scale_, animate); } void MagnificationControllerImpl::MoveWindow(const gfx::Point& point, bool animate) { + if (!is_enabled_) + return; + Redraw(point, scale_, animate); } void MagnificationControllerImpl::EnsureRectIsVisible( const gfx::Rect& target_rect, bool animate) { + if (!is_enabled_) + return; + EnsureRectIsVisibleWithScale(target_rect, scale_, animate); } void MagnificationControllerImpl::EnsurePointIsVisible( const gfx::Point& point, bool animate) { + if (!is_enabled_) + return; + EnsurePointIsVisibleWithScale(point, scale_, animate); } +void MagnificationControllerImpl::SetEnabled(bool enabled) { + if (enabled) { + is_enabled_ = enabled; + SetScale(kInitialMagnifiedScale, true); + } else { + SetScale(kNonMagnifiedScale, true); + is_enabled_ = enabled; + } +} + //////////////////////////////////////////////////////////////////////////////// // MagnificationControllerImpl: aura::EventFilter implementation diff --git a/ash/magnifier/magnification_controller.h b/ash/magnifier/magnification_controller.h index a97d171..f392a9b 100644 --- a/ash/magnifier/magnification_controller.h +++ b/ash/magnifier/magnification_controller.h @@ -28,6 +28,9 @@ class MagnificationController { // returned object. static MagnificationController* CreateInstance(); + // Enables (or disables if |enabled| is false) screen magnifier feature. + virtual void SetEnabled(bool enabled) = 0; + // Sets the magnification ratio. 1.0f means no magnification. virtual void SetScale(float scale, bool animate) = 0; // Returns the current magnification ratio. |