| 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..7908d97660fca13a979131b248ddf792449bb301
|
| --- /dev/null
|
| +++ b/ash/magnifier/partial_magnification_controller.h
|
| @@ -0,0 +1,99 @@
|
| +// 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/window_observer.h"
|
| +#include "ui/base/events/event_handler.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 ui::EventHandler,
|
| + public aura::WindowObserver,
|
| + public views::WidgetObserver {
|
| + public:
|
| + PartialMagnificationController();
|
| + virtual ~PartialMagnificationController();
|
| +
|
| + // Enables (or disables if |enabled| is false) partial screen magnifier
|
| + // feature.
|
| + virtual void SetEnabled(bool enabled);
|
| +
|
| + bool is_enabled() const { return is_enabled_; }
|
| +
|
| + // 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();
|
| +
|
| + // ui::EventHandler overrides:
|
| + virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
|
| + virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
|
| + virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
|
| + virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
|
| + virtual ui::EventResult OnGestureEvent(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_
|
|
|