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

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

Issue 2634553003: Animates touch points on screen tap during touch calibration (Closed)
Patch Set: Animates touch points on screen tap Created 3 years, 11 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIEW_H _ 5 #ifndef CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIEW_H _
6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIEW_H _ 6 #define CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIEW_H _
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/compositor/layer_animation_observer.h"
9 #include "ui/display/display.h" 10 #include "ui/display/display.h"
10 #include "ui/gfx/animation/animation_delegate.h" 11 #include "ui/gfx/animation/animation_delegate.h"
11 #include "ui/views/view.h" 12 #include "ui/views/view.h"
12 13
13 namespace views { 14 namespace views {
14 class Label; 15 class Label;
15 class Widget; 16 class Widget;
16 } 17 }
17 18
18 namespace gfx { 19 namespace gfx {
19 class Animation; 20 class Animation;
20 class LinearAnimation; 21 class LinearAnimation;
21 } 22 }
22 23
24 namespace ui {
25 class LayerAnimationSequence;
26 }
27
23 namespace chromeos { 28 namespace chromeos {
24 29
25 class CircularThrobberView; 30 class CircularThrobberView;
26 31
27 // An overlay view used during touch calibration. This view is responsible for 32 // An overlay view used during touch calibration. This view is responsible for
28 // all animations and UX during touch calibration on all displays currently 33 // all animations and UX during touch calibration on all displays currently
29 // active on the device. The view on the display being calibrated is the primary 34 // active on the device. The view on the display being calibrated is the primary
30 // touch calibration view. 35 // touch calibration view.
31 // |TouchCalibratorView| acts as a state machine and has an API to toggle its 36 // |TouchCalibratorView| acts as a state machine and has an API to toggle its
32 // state or get the current state. 37 // state or get the current state.
33 class TouchCalibratorView : public views::View, public gfx::AnimationDelegate { 38 class TouchCalibratorView : public views::View,
39 public gfx::AnimationDelegate,
40 public ui::LayerAnimationObserver {
34 public: 41 public:
35 // Different states of |TouchCalibratorView| in order. 42 // Different states of |TouchCalibratorView| in order.
36 enum State { 43 enum State {
37 UNKNOWN = 0, 44 UNKNOWN = 0,
38 BACKGROUND_FADING_IN, // Transition state where the background is fading 45 BACKGROUND_FADING_IN, // Transition state where the background is fading
39 // in. 46 // in.
40 DISPLAY_POINT_1, // Static state where the touch point is at its first 47 DISPLAY_POINT_1, // Static state where the touch point is at its first
41 // location. 48 // location.
42 ANIMATING_1_TO_2, // Transition state when the touch point is being moved 49 ANIMATING_1_TO_2, // Transition state when the touch point is being moved
43 // from one location to another. 50 // from one location to another.
(...skipping 17 matching lines...) Expand all
61 68
62 // views::View overrides: 69 // views::View overrides:
63 void OnPaint(gfx::Canvas* canvas) override; 70 void OnPaint(gfx::Canvas* canvas) override;
64 void OnPaintBackground(gfx::Canvas* canvas) override; 71 void OnPaintBackground(gfx::Canvas* canvas) override;
65 72
66 // gfx::AnimationDelegate overrides: 73 // gfx::AnimationDelegate overrides:
67 void AnimationEnded(const gfx::Animation* animation) override; 74 void AnimationEnded(const gfx::Animation* animation) override;
68 void AnimationProgressed(const gfx::Animation* animation) override; 75 void AnimationProgressed(const gfx::Animation* animation) override;
69 void AnimationCanceled(const gfx::Animation* animation) override; 76 void AnimationCanceled(const gfx::Animation* animation) override;
70 77
78 // ui::LayerAnimationObserver
79 void OnLayerAnimationStarted(ui::LayerAnimationSequence* sequence) override;
80 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override;
81 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override;
82 void OnLayerAnimationScheduled(ui::LayerAnimationSequence* sequence) override;
83
71 // Moves the touch calibrator view to its next state. 84 // Moves the touch calibrator view to its next state.
72 void AdvanceToNextState(); 85 void AdvanceToNextState();
73 86
74 // Skips to the final state. Should be used to cancel calibration and hide all 87 // Skips to the final state. Should be used to cancel calibration and hide all
75 // views from the screen with a smooth transition out animation. 88 // views from the screen with a smooth transition out animation.
76 void SkipToFinalState(); 89 void SkipToFinalState();
77 90
78 // Returns true if |location| is set by the end of this function call. If set, 91 // Returns true if |location| is set by the end of this function call. If set,
79 // |location| will point to the center of the circle that the user sees during 92 // |location| will point to the center of the circle that the user sees during
80 // the touch calibration UX. 93 // the touch calibration UX.
81 bool GetDisplayPointLocation(gfx::Point* location); 94 bool GetDisplayPointLocation(gfx::Point* location);
82 95
83 // Skips/cancels any ongoing animation to its end. 96 // Skips/cancels any ongoing animation to its end.
84 void SkipCurrentAnimationForTest(); 97 void SkipCurrentAnimation();
85 98
86 // Returns the current state of the view. 99 // Returns the current state of the view.
87 State state() { return state_; } 100 State state() { return state_; }
88 101
89 private: 102 private:
90 void InitViewContents(); 103 void InitViewContents();
91 104
92 // The target display on which this view is rendered on. 105 // The target display on which this view is rendered on.
93 const display::Display display_; 106 const display::Display display_;
94 107
95 // True if this view is on the display that is being calibrated. 108 // True if this view is on the display that is being calibrated.
96 bool is_primary_view_ = false; 109 bool is_primary_view_ = false;
97 110
98 std::unique_ptr<views::Widget> widget_; 111 std::unique_ptr<views::Widget> widget_;
99 112
100 SkPaint paint_; 113 SkPaint paint_;
101 114
102 // Defines the bounds for the background animation. 115 // Defines the bounds for the background animation.
103 gfx::RectF background_rect_; 116 gfx::RectF background_rect_;
104 117
105 // Text label indicating how to exit the touch calibration. 118 // Text label indicating how to exit the touch calibration.
106 views::Label* exit_label_; 119 views::Label* exit_label_;
120 // Text label indicating the significance of the touch point on screen.
121 views::Label* tap_label_;
107 122
108 // Start and end opacity values used during the fade animation. This is set 123 // Start and end opacity values used during the fade animation. This is set
109 // before the animation begins. 124 // before the animation begins.
110 float start_opacity_value_; 125 float start_opacity_value_;
111 float end_opacity_value_; 126 float end_opacity_value_;
112 127
113 // Linear animation used for various aniations including fade-in, fade out, 128 // Linear animation used for various aniations including fade-in, fade out,
114 // and view translation. 129 // and view translation.
115 std::unique_ptr<gfx::LinearAnimation> animator_; 130 std::unique_ptr<gfx::LinearAnimation> animator_;
116 131
(...skipping 10 matching lines...) Expand all
127 views::View* touch_point_view_; 142 views::View* touch_point_view_;
128 143
129 State state_ = UNKNOWN; 144 State state_ = UNKNOWN;
130 145
131 DISALLOW_COPY_AND_ASSIGN(TouchCalibratorView); 146 DISALLOW_COPY_AND_ASSIGN(TouchCalibratorView);
132 }; 147 };
133 148
134 } // namespace chromeos 149 } // namespace chromeos
135 150
136 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIE W_H_ 151 #endif // CHROME_BROWSER_CHROMEOS_DISPLAY_TOUCH_CALIBRATOR_TOUCH_CALIBRATOR_VIE W_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698