Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Unified Diff: ash/magnifier/magnification_controller.cc

Issue 2641733002: Initial patch set to implement improved touch support for screen magnification (Closed)
Patch Set: Run git cl format. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/magnifier/magnification_controller.cc
diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc
index c677caae5c56b2b741f3a8ae9c87dffc785470b0..9a324193d751978d3dffb85701ed6335d733a958 100644
--- a/ash/magnifier/magnification_controller.cc
+++ b/ash/magnifier/magnification_controller.cc
@@ -20,6 +20,7 @@
#include "base/command_line.h"
#include "base/synchronization/waitable_event.h"
#include "base/timer/timer.h"
+#include "chromeos/chromeos_switches.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
@@ -34,6 +35,7 @@
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_handler.h"
+#include "ui/events/gesture_event_details.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/point_f.h"
@@ -191,6 +193,7 @@ class MagnificationControllerImpl : public MagnificationController,
void OnMouseEvent(ui::MouseEvent* event) override;
void OnScrollEvent(ui::ScrollEvent* event) override;
void OnTouchEvent(ui::TouchEvent* event) override;
+ void OnGestureEvent(ui::GestureEvent* event) override;
// Moves the view port when |point| is located within
// |x_panning_margin| and |y_pannin_margin| to the edge of the visible
@@ -690,6 +693,33 @@ void MagnificationControllerImpl::OnTouchEvent(ui::TouchEvent* event) {
}
}
+void MagnificationControllerImpl::OnGestureEvent(ui::GestureEvent* event) {
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableTouchSupportForScreenMagnifier)) {
+ return;
+ }
+
+ const ui::GestureEventDetails& details = event->details();
+ if (details.type() == ui::ET_GESTURE_SCROLL_UPDATE &&
+ details.touch_points() == 2) {
+ gfx::Rect viewport_rect_in_dip = GetViewportRect();
+ viewport_rect_in_dip.Offset(-details.scroll_x(), -details.scroll_y());
+ gfx::Rect viewport_rect_in_pixel =
+ ui::ConvertRectToPixel(root_window_->layer(), viewport_rect_in_dip);
+ MoveWindow(viewport_rect_in_pixel.origin(), false);
+ event->SetHandled();
+ } else if (details.type() == ui::ET_GESTURE_PINCH_UPDATE &&
+ details.touch_points() == 3) {
+ float scale = GetScale() * details.scale();
+ scale = std::max(scale, kMinMagnifiedScaleThreshold);
+ scale = std::min(scale, kMaxMagnifiedScaleThreshold);
+
+ point_of_interest_ = event->root_location();
+ SetScale(scale, false);
+ event->SetHandled();
+ }
+}
+
void MagnificationControllerImpl::MoveMagnifierWindowFollowPoint(
const gfx::Point& point,
int x_panning_margin,
« no previous file with comments | « no previous file | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698