Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_CONTRO LLER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_CONTRO LLER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "ash/display/window_tree_host_manager.h" | |
| 11 #include "base/time/time.h" | |
| 12 #include "ui/display/display.h" | |
| 13 #include "ui/display/manager/managed_display_info.h" | |
| 14 #include "ui/events/event_handler.h" | |
| 15 | |
| 16 namespace ui { | |
| 17 class KeyEvent; | |
| 18 class TouchEvent; | |
| 19 } | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 class TouchCalibratorView; | |
| 24 | |
| 25 // TouchCalibratorController is responsible for collecting the touch calibration | |
| 26 // associated data from the user. It instantiates TouchCalibratorView classes to | |
| 27 // present an interface the user can interact with for calibration. | |
| 28 // Touch calibration is restricted to calibrate only one display at a time. | |
| 29 class TouchCalibratorController : public ui::EventHandler, | |
| 30 public ash::WindowTreeHostManager::Observer { | |
| 31 public: | |
| 32 using CalibrationPointPairQuad = | |
| 33 display::TouchCalibrationData::CalibrationPointPairQuad; | |
| 34 | |
| 35 TouchCalibratorController(); | |
| 36 ~TouchCalibratorController() override; | |
| 37 | |
| 38 // overrides ui::EventHandler | |
| 39 void OnKeyEvent(ui::KeyEvent* event) override; | |
| 40 void OnTouchEvent(ui::TouchEvent* event) override; | |
| 41 | |
| 42 // WindowTreeHostManager::Observer: | |
|
stevenjb
2016/12/22 01:14:21
nit: Style should be consistent with line 38. I pr
malaykeshav
2016/12/22 11:50:07
Done
| |
| 43 void OnDisplayConfigurationChanged() override; | |
| 44 | |
| 45 // Starts the calibration process for the given |target_display|. | |
| 46 void StartCalibration(const display::Display& target_display); | |
| 47 | |
| 48 // Stops any ongoing calibration process. | |
| 49 void StopCalibration(); | |
| 50 | |
| 51 bool is_calibrating() { return is_calibrating_; } | |
| 52 | |
| 53 private: | |
| 54 friend class TouchCalibratorControllerTest; | |
| 55 FRIEND_TEST_ALL_PREFIXES(TouchCalibratorControllerTest, StartCalibration); | |
| 56 FRIEND_TEST_ALL_PREFIXES(TouchCalibratorControllerTest, KeyEventIntercept); | |
| 57 FRIEND_TEST_ALL_PREFIXES(TouchCalibratorControllerTest, TouchThreshold); | |
| 58 | |
| 59 // A map for TouchCalibrator view with the key as display id of the display | |
| 60 // it is present in. | |
| 61 std::map<int64_t, std::unique_ptr<TouchCalibratorView>> | |
| 62 touch_calibrator_views_; | |
| 63 | |
| 64 // The display which is being calibrated by the touch calibrator controller. | |
| 65 // This is valid only if |is_calibrating| is set to true. | |
| 66 display::Display target_display_; | |
| 67 | |
| 68 // During calibration this stores the timestamp when the previous touch event | |
| 69 // was received. | |
| 70 base::Time last_touch_timestamp_; | |
| 71 | |
| 72 // Is true if a touch calibration is already underprocess. | |
| 73 bool is_calibrating_ = false; | |
| 74 | |
| 75 // An array of Calibration point pairs. This stores all the 4 display and | |
| 76 // touch input point pairs that will be used for calibration. | |
| 77 CalibrationPointPairQuad touch_point_quad_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(TouchCalibratorController); | |
| 80 }; | |
| 81 | |
| 82 } // namespace chromeos | |
| 83 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_CON TROLLER_H_ | |
| OLD | NEW |