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

Side by Side Diff: chrome/browser/chromeos/display/touch_calibrator/touch_calibrator_view.h

Issue 2596553003: Implements Touch calibrator controller and a skeleton for touch calibrator view. (Closed)
Patch Set: Resolved comments Created 3 years, 12 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 unified diff | Download patch
OLDNEW
(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 // Moves the touch calibrator view to its next state.
64 void AdvanceToNextState();
65
66 // Skips to the final state. Should be used to cancel calibration and hide all
67 // views from the screen with a smooth transition out animation.
68 void SkipToFinalState();
69
70 // Returns true if |location| is set by the end of this function call. If set,
71 // |location| will point to the center of the circle that the user sees during
72 // the touch calibration UX.
73 bool GetDisplayPointLocation(gfx::Point* location);
74
75 // Returns the current state of the view.
76 State state() { return state_; }
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;
88
89 DISALLOW_COPY_AND_ASSIGN(TouchCalibratorView);
90 };
91
92 } // namespace chromeos
93
94 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIE W_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698