summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-11 09:53:04 +0000
committeryoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-11 09:53:04 +0000
commitecdc6d2a917ed7791a525b48ee975d33f7e5beb9 (patch)
tree00e6d010cb9f3f1c8a2cd0cbda9091d9a6526884 /ash
parent24c556e210e82763ca5bfbce6737be20f24577f2 (diff)
downloadchromium_src-ecdc6d2a917ed7791a525b48ee975d33f7e5beb9.zip
chromium_src-ecdc6d2a917ed7791a525b48ee975d33f7e5beb9.tar.gz
chromium_src-ecdc6d2a917ed7791a525b48ee975d33f7e5beb9.tar.bz2
Magnifier: make view-port panning smoothly along the cursor movement
Previously, on panning, the view-port moves by the fixed amount but this way is not good from the view point of UX. With this patch, the view-port moves same amount as the cursor moves, and the user can move the view-port toward the arbitrary demanded place. BUG=161222 TEST=manual R=zork@chromium.org TBR=derat@chromium.org # TBRing for only magnifier changes. Review URL: https://chromiumcodereview.appspot.com/11783083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/magnifier/magnification_controller.cc43
1 files changed, 26 insertions, 17 deletions
diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc
index 9ee22de..33379c5 100644
--- a/ash/magnifier/magnification_controller.cc
+++ b/ash/magnifier/magnification_controller.cc
@@ -33,6 +33,10 @@ const float kNonMagnifiedScale = 1.0f;
const float kInitialMagnifiedScale = 2.0f;
const float kScrollScaleChangeFactor = 0.05f;
+// Threadshold of panning. If the cursor moves to within pixels (in DIP) of
+// |kPanningMergin| from the edge, the view-port moves.
+const int kPanningMergin = 100;
+
} // namespace
namespace ash {
@@ -296,40 +300,45 @@ void MagnificationControllerImpl::OnMouseMove(const gfx::Point& location) {
const gfx::Rect window_rect = gfx::ToEnclosingRect(GetWindowRectDIP(scale_));
const int left = window_rect.x();
const int right = window_rect.right();
- const int width_margin = static_cast<int>(0.1f * window_rect.width());
- const int width_offset = static_cast<int>(0.5f * window_rect.width());
+ int margin = kPanningMergin / scale_; // No need to consider DPI.
+
+ int x_diff = 0;
- if (mouse.x() < left + width_margin) {
- x -= width_offset;
+ if (mouse.x() < left + margin) {
+ // Panning left.
+ x_diff = mouse.x() - (left + margin);
start_zoom = true;
- } else if (right - width_margin < mouse.x()) {
- x += width_offset;
+ } else if (right - margin < mouse.x()) {
+ // Panning right.
+ x_diff = mouse.x() - (right - margin);
start_zoom = true;
}
+ x = left + x_diff;
const int top = window_rect.y();
const int bottom = window_rect.bottom();
- // Uses same margin with x-axis's one.
- const int height_margin = width_margin;
- const int height_offset = static_cast<int>(0.5f * window_rect.height());
- if (mouse.y() < top + height_margin) {
- y -= height_offset;
+ int y_diff = 0;
+ if (mouse.y() < top + margin) {
+ // Panning up.
+ y_diff = mouse.y() - (top + margin);
start_zoom = true;
- } else if (bottom - height_margin < mouse.y()) {
- y += height_offset;
+ } else if (bottom - margin < mouse.y()) {
+ // Panning down.
+ y_diff = mouse.y() - (bottom - margin);
start_zoom = true;
}
+ y = top + y_diff;
if (start_zoom && !is_on_animation_) {
- bool ret = RedrawDIP(gfx::Point(x, y), scale_, true);
+ // No animation on panning.
+ bool animate = false;
+ bool ret = RedrawDIP(gfx::Point(x, y), scale_, animate);
if (ret) {
- int x_diff = origin_.x() - window_rect.x();
- int y_diff = origin_.y() - window_rect.y();
// If the magnified region is moved, hides the mouse cursor and moves it.
if (x_diff != 0 || y_diff != 0)
- AfterAnimationMoveCursorTo(mouse);
+ root_window_->MoveCursorTo(mouse);
}
}
}