| OLD | NEW |
| 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> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "device/vr/vr_types.h" | 13 #include "device/vr/vr_types.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 class TimeTicks; | 16 class TimeTicks; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace vr_shell { | 19 namespace vr_shell { |
| 20 | 20 |
| 21 class Animation; | 21 class Animation; |
| 22 class VrShellRenderer; | 22 class VrShellRenderer; |
| 23 class VrSurfaceProvider; |
| 23 | 24 |
| 24 enum XAnchoring { | 25 enum XAnchoring { |
| 25 XNONE = 0, | 26 XNONE = 0, |
| 26 XLEFT, | 27 XLEFT, |
| 27 XRIGHT, | 28 XRIGHT, |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 enum YAnchoring { | 31 enum YAnchoring { |
| 31 YNONE = 0, | 32 YNONE = 0, |
| 32 YTOP, | 33 YTOP, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 void Initialize(VrSurfaceProvider* provider); |
| 108 | 109 |
| 109 // Controller interaction methods. | 110 // Controller interaction methods. |
| 110 virtual void OnHoverEnter(); | 111 virtual void OnHoverEnter(); |
| 111 virtual void OnHoverLeave(); | 112 virtual void OnHoverLeave(); |
| 112 virtual void OnButtonDown(); | 113 virtual void OnButtonDown(); |
| 113 virtual void OnButtonUp(); | 114 virtual void OnButtonUp(); |
| 114 | 115 |
| 115 int id() const { return id_; } | 116 int id() const { return id_; } |
| 116 void set_id(int id) { id_ = id; } | 117 void set_id(int id) { id_ = id; } |
| 117 | 118 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 return inheritable_transform_; | 213 return inheritable_transform_; |
| 213 } | 214 } |
| 214 void set_inheritable_transform(const Transform& transform) { | 215 void set_inheritable_transform(const Transform& transform) { |
| 215 inheritable_transform_ = transform; | 216 inheritable_transform_ = transform; |
| 216 } | 217 } |
| 217 | 218 |
| 218 // A flag usable during transformation calculates to avoid duplicate work. | 219 // A flag usable during transformation calculates to avoid duplicate work. |
| 219 bool dirty() const { return dirty_; } | 220 bool dirty() const { return dirty_; } |
| 220 void set_dirty(bool dirty) { dirty_ = dirty; } | 221 void set_dirty(bool dirty) { dirty_ = dirty; } |
| 221 | 222 |
| 223 protected: |
| 224 virtual void Initialize(); |
| 225 |
| 226 // This obtains a GPU-backed surface. Only valid after initialized. |
| 227 VrSurfaceProvider* surface_provider() { return surface_provider_; } |
| 228 |
| 222 private: | 229 private: |
| 223 // Valid IDs are non-negative. | 230 // Valid IDs are non-negative. |
| 224 int id_ = -1; | 231 int id_ = -1; |
| 225 | 232 |
| 226 // If a non-negative parent ID is specified, applicable transformations | 233 // If a non-negative parent ID is specified, applicable transformations |
| 227 // are applied relative to the parent, rather than absolutely. | 234 // are applied relative to the parent, rather than absolutely. |
| 228 int parent_id_ = -1; | 235 int parent_id_ = -1; |
| 229 | 236 |
| 230 // If true, this object will be visible. | 237 // If true, this object will be visible. |
| 231 bool visible_ = true; | 238 bool visible_ = true; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 int draw_phase_ = 1; | 285 int draw_phase_ = 1; |
| 279 | 286 |
| 280 // This transform can be used by children to derive position of its parent. | 287 // This transform can be used by children to derive position of its parent. |
| 281 Transform inheritable_transform_; | 288 Transform inheritable_transform_; |
| 282 | 289 |
| 283 // A flag usable during transformation calculates to avoid duplicate work. | 290 // A flag usable during transformation calculates to avoid duplicate work. |
| 284 bool dirty_; | 291 bool dirty_; |
| 285 | 292 |
| 286 Transform transform_; | 293 Transform transform_; |
| 287 | 294 |
| 295 VrSurfaceProvider* surface_provider_ = nullptr; |
| 296 |
| 288 DISALLOW_COPY_AND_ASSIGN(UiElement); | 297 DISALLOW_COPY_AND_ASSIGN(UiElement); |
| 289 }; | 298 }; |
| 290 | 299 |
| 291 } // namespace vr_shell | 300 } // namespace vr_shell |
| 292 | 301 |
| 293 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_ | 302 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_UI_ELEMENT_H_ |
| OLD | NEW |