summaryrefslogtreecommitdiffstats
path: root/ash/magnifier/magnification_controller.h
blob: fe501689d43ebed47f2479d36b1b76fa589c6869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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_MAGNIFICATION_CONTROLLER_H_
#define ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_
#pragma once

#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"

namespace aura {
class RootWindow;
}

namespace ash {
namespace internal {

class MagnificationController {
 public:
  MagnificationController();

  virtual ~MagnificationController() {}

  // Sets the magnification ratio. 1.0f means no magnification.
  void SetScale(float scale);
  // Returns the current magnification ratio.
  float GetScale() const { return scale_; }

  // Set the top-left point of the magnification window.
  void MoveWindow(int x, int y);
  void MoveWindow(const gfx::Point& point);
  // Returns the current top-left point of the magnification window.
  gfx::Point GetWindowPosition() const { return gfx::Point(x_, y_); }

  // Ensures that the given point/rect is inside the magnification window. If
  // not, the controller moves the window to contain the given point/rect.
  void EnsureShowRect(const gfx::Rect& rect);
  void EnsureShowPoint(const gfx::Point& point, bool animation);

 private:
  aura::RootWindow* root_window_;

  // Current scale, position of the magnification window.
  float scale_;
  int x_;
  int y_;

  // Returns the rect of the magnification window.
  gfx::Rect GetWindowRect();
  // Moves the magnification window to new scale and position. This method
  // should be called internally just after the scale and/or the position are
  // changed.
  void RedrawScreen(bool animation);

  DISALLOW_COPY_AND_ASSIGN(MagnificationController);
};

}  // namespace internal
}  // namespace ash

#endif  // ASH_MAGNIFIER_MAGNIFICATION_CONTROLLER_H_