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_VIEW_H _ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIEW_H _ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "ui/display/display.h" | |
| 10 #include "ui/gfx/animation/animation_delegate.h" | |
| 11 #include "ui/views/view.h" | |
| 12 | |
| 13 namespace views { | |
| 14 class Widget; | |
| 15 } | |
| 16 | |
| 17 namespace chromeos { | |
| 18 | |
| 19 // An overlay view used during touch calibration. This view is responsible for | |
| 20 // all animations and UX during touch calibration on all displays currently | |
| 21 // active on the device. The view on the display being calibrated is the primary | |
| 22 // touch calibration view. | |
| 23 // |TouchCalibratorView| acts as a state machine and has an API to toggle its | |
| 24 // state or get the current state. | |
| 25 class TouchCalibratorView : public views::View, public gfx::AnimationDelegate { | |
| 26 public: | |
| 27 // Different states of |TouchCalibratorView| in order. | |
| 28 enum State { | |
| 29 UNKNOWN = 0, | |
| 30 BACKGROUND_FADING_IN, // Transition state where the background is fading | |
| 31 // in. | |
| 32 DISPLAY_POINT_1, // Static state where the touch point is at its first | |
| 33 // location. | |
| 34 ANIMATING_1_TO_2, // Transition state when the touch point is being moved | |
| 35 // from one location to another. | |
| 36 DISPLAY_POINT_2, // Static state where the touch point is at its second | |
| 37 // location. | |
| 38 ANIMATING_2_TO_3, | |
| 39 DISPLAY_POINT_3, // Static state where the touch point is at its third | |
| 40 // location. | |
| 41 ANIMATING_3_TO_4, | |
| 42 DISPLAY_POINT_4, // Static state where the touch point is at its final | |
| 43 // location. | |
| 44 CALIBRATION_COMPLETE, // Static state when the calibration complete message | |
| 45 // is displayed to the user. | |
| 46 BACKGROUND_FADING_OUT // Transition state where the background is fading | |
| 47 // out | |
| 48 }; | |
| 49 | |
| 50 TouchCalibratorView(const display::Display& target_display, | |
| 51 bool is_primary_view); | |
| 52 ~TouchCalibratorView() override; | |
| 53 | |
| 54 // views::View overrides: | |
| 55 void OnPaint(gfx::Canvas* canvas) override; | |
| 56 void OnPaintBackground(gfx::Canvas* canvas) override; | |
| 57 | |
| 58 // gfx::AnimationDelegate overrides: | |
| 59 void AnimationEnded(const gfx::Animation* animation) override; | |
| 60 void AnimationProgressed(const gfx::Animation* animation) override; | |
| 61 void AnimationCanceled(const gfx::Animation* animation) override; | |
| 62 | |
| 63 // Returns the current state of the view. | |
| 64 State GetState() { return state_; } | |
|
stevenjb
2016/12/22 01:14:21
state()
malaykeshav
2016/12/22 11:50:07
Done
| |
| 65 | |
| 66 // Moves the touch calibrator view to its next state. | |
| 67 void NextState(); | |
|
stevenjb
2016/12/22 01:14:21
AdvanceToNextState()
malaykeshav
2016/12/22 11:50:07
Done
| |
| 68 | |
| 69 // Skips to the final state. Should be used to cancel calibration and hide all | |
| 70 // views from the screen with a smooth transition out animation. | |
| 71 void SkipToFinalState(); | |
| 72 | |
| 73 // Returns true if |location| is set by the end of this function call. If set, | |
| 74 // |location| will point to the center of the circle that the user sees during | |
| 75 // the touch calibration UX. | |
| 76 bool GetTouchPointLocation(gfx::Point* location); | |
| 77 | |
| 78 private: | |
| 79 // The target display on which this view is rendered on. | |
| 80 const display::Display display_; | |
| 81 | |
| 82 // True if this view is on the display that is being calibrated. | |
| 83 bool is_primary_view_ = false; | |
| 84 | |
| 85 std::unique_ptr<views::Widget> widget_; | |
| 86 | |
| 87 State state_ = UNKNOWN; | |
|
stevenjb
2016/12/22 01:14:21
blank line
malaykeshav
2016/12/22 11:50:08
Done
| |
| 88 DISALLOW_COPY_AND_ASSIGN(TouchCalibratorView); | |
| 89 }; | |
| 90 } // namespace chromeos | |
| 91 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIE W_H_ | |
| OLD | NEW |