| 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_ELEMENT_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_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 | 23 |
| 23 enum XAnchoring { | 24 enum XAnchoring { |
| 24 XNONE = 0, | 25 XNONE = 0, |
| 25 XLEFT, | 26 XLEFT, |
| 26 XRIGHT, | 27 XRIGHT, |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 enum YAnchoring { | 30 enum YAnchoring { |
| 30 YNONE = 0, | 31 YNONE = 0, |
| 31 YTOP, | 32 YTOP, |
| 32 YBOTTOM, | 33 YBOTTOM, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 enum Fill { | 36 enum Fill { |
| 36 NONE = 0, | 37 NONE = 0, |
| 37 SKIA = 1, | 38 // The element is filled with the content web site. Only one content element |
| 39 // may be added to the |
| 40 // scene. |
| 41 CONTENT = 1, |
| 38 // The element is filled with a radial gradient as specified by the edge and | 42 // The element is filled with a radial gradient as specified by the edge and |
| 39 // center color. | 43 // center color. |
| 40 OPAQUE_GRADIENT = 2, | 44 OPAQUE_GRADIENT = 2, |
| 41 // Same as OPAQUE_GRADIENT but the element is drawn as a grid. | 45 // Same as OPAQUE_GRADIENT but the element is drawn as a grid. |
| 42 GRID_GRADIENT = 3, | 46 GRID_GRADIENT = 3, |
| 43 // The element is filled with the content web site. Only one content element | 47 // The element draws itself. |
| 44 // may be added to the | 48 SELF = 4, |
| 45 // scene. | |
| 46 CONTENT = 4, | |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 struct Transform { | 51 struct Transform { |
| 50 Transform(); | 52 Transform(); |
| 51 | 53 |
| 52 void MakeIdentity(); | 54 void MakeIdentity(); |
| 53 void Rotate(const vr::Quatf& quat); | 55 void Rotate(const vr::Quatf& quat); |
| 54 void Rotate(const vr::RotationAxisAngle& axis_angle); | 56 void Rotate(const vr::RotationAxisAngle& axis_angle); |
| 55 void Translate(const gfx::Vector3dF& translation); | 57 void Translate(const gfx::Vector3dF& translation); |
| 56 void Scale(const gfx::Vector3dF& scale); | 58 void Scale(const gfx::Vector3dF& scale); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 79 // pixel coordinates. Points that fall onto the rectangle will generate X and | 81 // pixel coordinates. Points that fall onto the rectangle will generate X and |
| 80 // Y values on the interval [-0.5, 0.5]. | 82 // Y values on the interval [-0.5, 0.5]. |
| 81 gfx::PointF GetUnitRectangleCoordinates(const gfx::Point3F& world_point); | 83 gfx::PointF GetUnitRectangleCoordinates(const gfx::Point3F& world_point); |
| 82 | 84 |
| 83 private: | 85 private: |
| 84 Transform transform_; | 86 Transform transform_; |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 struct UiElement : public WorldRectangle { | 89 struct UiElement : public WorldRectangle { |
| 88 UiElement(); | 90 UiElement(); |
| 89 ~UiElement(); | 91 virtual ~UiElement(); |
| 90 | 92 |
| 91 void Animate(const base::TimeTicks& time); | 93 void Animate(const base::TimeTicks& time); |
| 92 | 94 |
| 93 // Indicates whether the element should be visually rendered. | 95 // Indicates whether the element should be visually rendered. |
| 94 bool IsVisible() const; | 96 bool IsVisible() const; |
| 95 | 97 |
| 96 // Indicates whether the element should be tested for cursor input. | 98 // Indicates whether the element should be tested for cursor input. |
| 97 bool IsHitTestable() const; | 99 bool IsHitTestable() const; |
| 98 | 100 |
| 101 virtual void Render(VrShellRenderer* renderer, |
| 102 vr::Mat4f view_proj_matrix) const; |
| 103 |
| 104 virtual void Initialize(); |
| 105 |
| 99 // Valid IDs are non-negative. | 106 // Valid IDs are non-negative. |
| 100 int id = -1; | 107 int id = -1; |
| 101 | 108 |
| 102 // Name string for debugging and testing purposes. | 109 // Name string for debugging and testing purposes. |
| 103 std::string name; | 110 std::string name; |
| 104 | 111 |
| 105 // If a non-negative parent ID is specified, applicable transformations | 112 // If a non-negative parent ID is specified, applicable transformations |
| 106 // are applied relative to the parent, rather than absolutely. | 113 // are applied relative to the parent, rather than absolutely. |
| 107 int parent_id = -1; | 114 int parent_id = -1; |
| 108 | 115 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // A flag usable during transformation calculates to avoid duplicate work. | 169 // A flag usable during transformation calculates to avoid duplicate work. |
| 163 bool dirty; | 170 bool dirty; |
| 164 | 171 |
| 165 private: | 172 private: |
| 166 DISALLOW_COPY_AND_ASSIGN(UiElement); | 173 DISALLOW_COPY_AND_ASSIGN(UiElement); |
| 167 }; | 174 }; |
| 168 | 175 |
| 169 } // namespace vr_shell | 176 } // namespace vr_shell |
| 170 | 177 |
| 171 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_ | 178 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENT_H_ |
| OLD | NEW |