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

Side by Side Diff: chrome/browser/android/vr_shell/ui_elements/ui_element.h

Issue 2878543002: Refactor VR Shell Input. Locks input to click/scroll targets. (Closed)
Patch Set: Address comments Created 3 years, 7 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_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // possible, and false if the ray is parallel to the plane. 75 // possible, and false if the ray is parallel to the plane.
76 bool GetRayDistance(const gfx::Point3F& ray_origin, 76 bool GetRayDistance(const gfx::Point3F& ray_origin,
77 const gfx::Vector3dF& ray_vector, 77 const gfx::Vector3dF& ray_vector,
78 float* distance) const; 78 float* distance) const;
79 79
80 // Projects a 3D world point onto the X and Y axes of the transformed 80 // Projects a 3D world point onto the X and Y axes of the transformed
81 // rectangle, returning 2D coordinates relative to the un-transformed unit 81 // rectangle, returning 2D coordinates relative to the un-transformed unit
82 // rectangle. This allows beam intersection points to be mapped to sprite 82 // rectangle. This allows beam intersection points to be mapped to sprite
83 // pixel coordinates. Points that fall onto the rectangle will generate X and 83 // pixel coordinates. Points that fall onto the rectangle will generate X and
84 // Y values on the interval [-0.5, 0.5]. 84 // Y values on the interval [-0.5, 0.5].
85 gfx::PointF GetUnitRectangleCoordinates(const gfx::Point3F& world_point); 85 gfx::PointF GetUnitRectangleCoordinates(
86 const gfx::Point3F& world_point) const;
86 87
87 private: 88 private:
88 Transform transform_; 89 Transform transform_;
89 }; 90 };
90 91
91 class UiElement : public WorldRectangle { 92 class UiElement : public WorldRectangle {
92 public: 93 public:
93 UiElement(); 94 UiElement();
94 virtual ~UiElement(); 95 virtual ~UiElement();
95 96
96 void Animate(const base::TimeTicks& time); 97 void Animate(const base::TimeTicks& time);
97 98
98 // Indicates whether the element should be visually rendered. 99 // Indicates whether the element should be visually rendered.
99 bool IsVisible() const; 100 bool IsVisible() const;
100 101
101 // Indicates whether the element should be tested for cursor input. 102 // Indicates whether the element should be tested for cursor input.
102 bool IsHitTestable() const; 103 bool IsHitTestable() const;
103 104
104 virtual void Render(VrShellRenderer* renderer, 105 virtual void Render(VrShellRenderer* renderer,
105 vr::Mat4f view_proj_matrix) const; 106 vr::Mat4f view_proj_matrix) const;
106 107
107 virtual void Initialize(); 108 virtual void Initialize();
108 109
109 // Controller interaction methods. 110 // Controller interaction methods.
110 virtual void OnHoverEnter(); 111 virtual void OnHoverEnter(gfx::PointF position);
111 virtual void OnHoverLeave(); 112 virtual void OnHoverLeave();
112 virtual void OnButtonDown(); 113 virtual void OnMove(gfx::PointF position);
113 virtual void OnButtonUp(); 114 virtual void OnButtonDown(gfx::PointF position);
115 virtual void OnButtonUp(gfx::PointF position);
114 116
115 int id() const { return id_; } 117 int id() const { return id_; }
116 void set_id(int id) { id_ = id; } 118 void set_id(int id) { id_ = id; }
117 119
118 // If a non-negative parent ID is specified, applicable transformations 120 // If a non-negative parent ID is specified, applicable transformations
119 // are applied relative to the parent, rather than absolutely. 121 // are applied relative to the parent, rather than absolutely.
120 int parent_id() const { return parent_id_; } 122 int parent_id() const { return parent_id_; }
121 void set_parent_id(int id) { parent_id_ = id; } 123 void set_parent_id(int id) { parent_id_ = id; }
122 124
123 // If true, this object will be visible. 125 // If true, this object will be visible.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 bool visible_ = true; 233 bool visible_ = true;
232 234
233 // If false, the reticle will not hit the element, even if visible. 235 // If false, the reticle will not hit the element, even if visible.
234 bool hit_testable_ = true; 236 bool hit_testable_ = true;
235 237
236 // If true, transformations will be applied relative to the field of view, 238 // If true, transformations will be applied relative to the field of view,
237 // rather than the world. 239 // rather than the world.
238 bool lock_to_fov_ = false; 240 bool lock_to_fov_ = false;
239 241
240 // The computed lock to the FoV, incorporating lock of parent objects. 242 // The computed lock to the FoV, incorporating lock of parent objects.
241 bool computed_lock_to_fov_; 243 bool computed_lock_to_fov_ = false;
242 244
243 // The size of the object. This does not affect children. 245 // The size of the object. This does not affect children.
244 gfx::Vector3dF size_ = {1.0f, 1.0f, 1.0f}; 246 gfx::Vector3dF size_ = {1.0f, 1.0f, 1.0f};
245 247
246 // The scale of the object, and its children. 248 // The scale of the object, and its children.
247 gfx::Vector3dF scale_ = {1.0f, 1.0f, 1.0f}; 249 gfx::Vector3dF scale_ = {1.0f, 1.0f, 1.0f};
248 250
249 // The rotation of the object, and its children. 251 // The rotation of the object, and its children.
250 vr::RotationAxisAngle rotation_ = {1.0f, 0.0f, 0.0f, 0.0f}; 252 vr::RotationAxisAngle rotation_ = {1.0f, 0.0f, 0.0f, 0.0f};
251 253
252 // The translation of the object, and its children. Translation is applied 254 // The translation of the object, and its children. Translation is applied
253 // after rotation and scaling. 255 // after rotation and scaling.
254 gfx::Vector3dF translation_ = {0.0f, 0.0f, 0.0f}; 256 gfx::Vector3dF translation_ = {0.0f, 0.0f, 0.0f};
255 257
256 // The opacity of the object (between 0.0 and 1.0). 258 // The opacity of the object (between 0.0 and 1.0).
257 float opacity_ = 1.0f; 259 float opacity_ = 1.0f;
258 260
259 // The computed opacity, incorporating opacity of parent objects. 261 // The computed opacity, incorporating opacity of parent objects.
260 float computed_opacity_; 262 float computed_opacity_ = 1.0f;
261 263
262 // If anchoring is specified, the translation will be relative to the 264 // If anchoring is specified, the translation will be relative to the
263 // specified edge(s) of the parent, rather than the center. A parent object 265 // specified edge(s) of the parent, rather than the center. A parent object
264 // must be specified when using anchoring. 266 // must be specified when using anchoring.
265 XAnchoring x_anchoring_ = XAnchoring::XNONE; 267 XAnchoring x_anchoring_ = XAnchoring::XNONE;
266 YAnchoring y_anchoring_ = YAnchoring::YNONE; 268 YAnchoring y_anchoring_ = YAnchoring::YNONE;
267 269
268 // Animations that affect the properties of the object over time. 270 // Animations that affect the properties of the object over time.
269 std::vector<std::unique_ptr<Animation>> animations_; 271 std::vector<std::unique_ptr<Animation>> animations_;
270 272
271 Fill fill_ = Fill::NONE; 273 Fill fill_ = Fill::NONE;
272 274
273 vr::Colorf edge_color_ = {1.0f, 1.0f, 1.0f, 1.0f}; 275 vr::Colorf edge_color_ = {1.0f, 1.0f, 1.0f, 1.0f};
274 vr::Colorf center_color_ = {1.0f, 1.0f, 1.0f, 1.0f}; 276 vr::Colorf center_color_ = {1.0f, 1.0f, 1.0f, 1.0f};
275 277
276 int gridline_count_ = 1; 278 int gridline_count_ = 1;
277 279
278 int draw_phase_ = 1; 280 int draw_phase_ = 1;
279 281
280 // This transform can be used by children to derive position of its parent. 282 // This transform can be used by children to derive position of its parent.
281 Transform inheritable_transform_; 283 Transform inheritable_transform_;
282 284
283 // A flag usable during transformation calculates to avoid duplicate work. 285 // A flag usable during transformation calculates to avoid duplicate work.
284 bool dirty_; 286 bool dirty_ = false;
285 287
286 Transform transform_; 288 Transform transform_;
287 289
288 DISALLOW_COPY_AND_ASSIGN(UiElement); 290 DISALLOW_COPY_AND_ASSIGN(UiElement);
289 }; 291 };
290 292
291 } // namespace vr_shell 293 } // namespace vr_shell
292 294
293 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_ 295 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_elements/close_button.cc ('k') | chrome/browser/android/vr_shell/ui_elements/ui_element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698