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 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 5 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 const vr::Mat4f& WorldRectangle::TransformMatrix() const { | 67 const vr::Mat4f& WorldRectangle::TransformMatrix() const { |
68 return transform_.to_world; | 68 return transform_.to_world; |
69 } | 69 } |
70 | 70 |
71 gfx::Point3F WorldRectangle::GetCenter() const { | 71 gfx::Point3F WorldRectangle::GetCenter() const { |
72 const gfx::Point3F kOrigin(0.0f, 0.0f, 0.0f); | 72 const gfx::Point3F kOrigin(0.0f, 0.0f, 0.0f); |
73 return kOrigin + vr::GetTranslation(transform_.to_world); | 73 return kOrigin + vr::GetTranslation(transform_.to_world); |
74 } | 74 } |
75 | 75 |
76 gfx::PointF WorldRectangle::GetUnitRectangleCoordinates( | 76 gfx::PointF WorldRectangle::GetUnitRectangleCoordinates( |
77 const gfx::Point3F& world_point) { | 77 const gfx::Point3F& world_point) const { |
78 // TODO(acondor): Simplify the math in this function. | 78 // TODO(acondor): Simplify the math in this function. |
79 const vr::Mat4f& transform = transform_.to_world; | 79 const vr::Mat4f& transform = transform_.to_world; |
80 gfx::Vector3dF origin = | 80 gfx::Vector3dF origin = |
81 vr::MatrixVectorMul(transform, gfx::Vector3dF(0, 0, 0)); | 81 vr::MatrixVectorMul(transform, gfx::Vector3dF(0, 0, 0)); |
82 gfx::Vector3dF x_axis = | 82 gfx::Vector3dF x_axis = |
83 vr::MatrixVectorMul(transform, gfx::Vector3dF(1, 0, 0)); | 83 vr::MatrixVectorMul(transform, gfx::Vector3dF(1, 0, 0)); |
84 gfx::Vector3dF y_axis = | 84 gfx::Vector3dF y_axis = |
85 vr::MatrixVectorMul(transform, gfx::Vector3dF(0, 1, 0)); | 85 vr::MatrixVectorMul(transform, gfx::Vector3dF(0, 1, 0)); |
86 x_axis.Subtract(origin); | 86 x_axis.Subtract(origin); |
87 y_axis.Subtract(origin); | 87 y_axis.Subtract(origin); |
(...skipping 21 matching lines...) Expand all Loading... |
109 | 109 |
110 UiElement::~UiElement() = default; | 110 UiElement::~UiElement() = default; |
111 | 111 |
112 void UiElement::Render(VrShellRenderer* renderer, | 112 void UiElement::Render(VrShellRenderer* renderer, |
113 vr::Mat4f view_proj_matrix) const { | 113 vr::Mat4f view_proj_matrix) const { |
114 NOTREACHED(); | 114 NOTREACHED(); |
115 } | 115 } |
116 | 116 |
117 void UiElement::Initialize() {} | 117 void UiElement::Initialize() {} |
118 | 118 |
119 void UiElement::OnHoverEnter() {} | 119 void UiElement::OnHoverEnter(gfx::PointF position) {} |
120 | 120 |
121 void UiElement::OnHoverLeave() {} | 121 void UiElement::OnHoverLeave() {} |
122 | 122 |
123 void UiElement::OnButtonDown() {} | 123 void UiElement::OnMove(gfx::PointF position) {} |
124 | 124 |
125 void UiElement::OnButtonUp() {} | 125 void UiElement::OnButtonDown(gfx::PointF position) {} |
| 126 |
| 127 void UiElement::OnButtonUp(gfx::PointF position) {} |
126 | 128 |
127 void UiElement::Animate(const base::TimeTicks& time) { | 129 void UiElement::Animate(const base::TimeTicks& time) { |
128 for (auto& it : animations_) { | 130 for (auto& it : animations_) { |
129 Animation& animation = *it; | 131 Animation& animation = *it; |
130 if (time < animation.start) | 132 if (time < animation.start) |
131 continue; | 133 continue; |
132 | 134 |
133 // If |from| is not specified, start at the current values. | 135 // If |from| is not specified, start at the current values. |
134 if (animation.from.size() == 0) { | 136 if (animation.from.size() == 0) { |
135 switch (animation.property) { | 137 switch (animation.property) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 214 |
213 bool UiElement::IsVisible() const { | 215 bool UiElement::IsVisible() const { |
214 return visible_ && computed_opacity_ > 0.0f; | 216 return visible_ && computed_opacity_ > 0.0f; |
215 } | 217 } |
216 | 218 |
217 bool UiElement::IsHitTestable() const { | 219 bool UiElement::IsHitTestable() const { |
218 return IsVisible() && hit_testable_; | 220 return IsVisible() && hit_testable_; |
219 } | 221 } |
220 | 222 |
221 } // namespace vr_shell | 223 } // namespace vr_shell |
OLD | NEW |