OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_scene_manager.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
10 #include "chrome/browser/android/vr_shell/ui_elements/close_button.h" | 10 #include "chrome/browser/android/vr_shell/ui_elements/close_button.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 namespace { | 22 namespace { |
23 | 23 |
24 static constexpr int kWarningTimeoutSeconds = 30; | 24 static constexpr int kWarningTimeoutSeconds = 30; |
25 static constexpr float kWarningDistance = 0.7; | 25 static constexpr float kWarningDistance = 0.7; |
26 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; | 26 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; |
27 static constexpr float kPermanentWarningHeight = 0.070f; | 27 static constexpr float kPermanentWarningHeight = 0.070f; |
28 static constexpr float kPermanentWarningWidth = 0.224f; | 28 static constexpr float kPermanentWarningWidth = 0.224f; |
29 static constexpr float kTransientWarningHeight = 0.160; | 29 static constexpr float kTransientWarningHeight = 0.160; |
30 static constexpr float kTransientWarningWidth = 0.512; | 30 static constexpr float kTransientWarningWidth = 0.512; |
31 | 31 |
32 static constexpr float kContentWidth = 2.4; | |
33 static constexpr float kContentHeight = 1.6; | |
34 static constexpr float kContentDistance = 2.5; | 32 static constexpr float kContentDistance = 2.5; |
35 static constexpr float kContentVerticalOffset = -0.26; | 33 static constexpr float kContentWidth = 0.96 * kContentDistance; |
34 static constexpr float kContentHeight = 0.64 * kContentDistance; | |
35 static constexpr float kContentVerticalOffset = -0.1 * kContentDistance; | |
36 static constexpr float kBackplaneSize = 1000.0; | 36 static constexpr float kBackplaneSize = 1000.0; |
37 static constexpr float kBackgroundDistanceMultiplier = 1.414; | 37 static constexpr float kBackgroundDistanceMultiplier = 1.414; |
38 | 38 |
39 static constexpr float kUrlBarDistance = 2.4; | |
cjgrant
2017/05/16 14:07:23
Not in this CL, but what do you think of Josh's ap
mthiesse
2017/05/16 18:11:02
For now I'd like to land as-is, we have some think
| |
40 static constexpr float kUrlBarWidth = 0.672 * kUrlBarDistance; | |
41 static constexpr float kUrlBarHeight = 0.088 * kUrlBarDistance; | |
42 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; | |
43 | |
44 static constexpr float kLoadingIndicatorWidth = 0.24 * kUrlBarDistance; | |
45 static constexpr float kLoadingIndicatorHeight = 0.008 * kUrlBarDistance; | |
46 static constexpr float kLoadingIndicatorOffset = -0.020 * kUrlBarDistance; | |
cjgrant
2017/05/16 14:07:23
Worth it to do (0.016 + kLoadingIndicatorHeight /
mthiesse
2017/05/16 18:11:02
Done.
| |
47 | |
39 static constexpr float kFullscreenWidth = 2.88; | 48 static constexpr float kFullscreenWidth = 2.88; |
40 static constexpr float kFullscreenHeight = 1.62; | 49 static constexpr float kFullscreenHeight = 1.62; |
41 static constexpr float kFullscreenDistance = 3; | 50 static constexpr float kFullscreenDistance = 3; |
42 static constexpr float kFullscreenVerticalOffset = -0.26; | 51 static constexpr float kFullscreenVerticalOffset = -0.26; |
43 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0}; | 52 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0}; |
44 | 53 |
45 static constexpr float kSceneSize = 25.0; | 54 static constexpr float kSceneSize = 25.0; |
46 static constexpr float kSceneHeight = 4.0; | 55 static constexpr float kSceneHeight = 4.0; |
47 static constexpr int kFloorGridlineCount = 40; | 56 static constexpr int kFloorGridlineCount = 40; |
48 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; | 57 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 control_elements_.push_back(element.get()); | 192 control_elements_.push_back(element.get()); |
184 scene_->AddUiElement(std::move(element)); | 193 scene_->AddUiElement(std::move(element)); |
185 | 194 |
186 scene_->SetBackgroundColor(kBackgroundHorizonColor); | 195 scene_->SetBackgroundColor(kBackgroundHorizonColor); |
187 } | 196 } |
188 | 197 |
189 void UiSceneManager::CreateUrlBar() { | 198 void UiSceneManager::CreateUrlBar() { |
190 // TODO(cjgrant): Incorporate final size and position. | 199 // TODO(cjgrant): Incorporate final size and position. |
191 auto url_bar = base::MakeUnique<UrlBar>(512); | 200 auto url_bar = base::MakeUnique<UrlBar>(512); |
192 url_bar->set_id(AllocateId()); | 201 url_bar->set_id(AllocateId()); |
193 url_bar->set_translation({0, -0.9, -1.8}); | 202 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); |
194 url_bar->set_size({0.9, 0, 1}); | 203 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); |
195 url_bar->SetBackButtonCallback( | 204 url_bar->SetBackButtonCallback( |
196 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); | 205 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); |
197 url_bar_ = url_bar.get(); | 206 url_bar_ = url_bar.get(); |
198 control_elements_.push_back(url_bar.get()); | 207 control_elements_.push_back(url_bar.get()); |
199 scene_->AddUiElement(std::move(url_bar)); | 208 scene_->AddUiElement(std::move(url_bar)); |
200 | 209 |
201 auto indicator = base::MakeUnique<LoadingIndicator>(256); | 210 auto indicator = base::MakeUnique<LoadingIndicator>(256); |
202 indicator->set_id(AllocateId()); | 211 indicator->set_id(AllocateId()); |
203 indicator->set_translation({0, -0.8, -1.8}); | 212 indicator->set_translation({0, 0, kLoadingIndicatorOffset}); |
204 indicator->set_size({0.4, 0, 1}); | 213 indicator->set_size({kLoadingIndicatorWidth, kLoadingIndicatorHeight, 1}); |
214 indicator->set_parent_id(url_bar_->id()); | |
215 indicator->set_y_anchoring(YAnchoring::YTOP); | |
205 loading_indicator_ = indicator.get(); | 216 loading_indicator_ = indicator.get(); |
206 control_elements_.push_back(indicator.get()); | 217 control_elements_.push_back(indicator.get()); |
207 scene_->AddUiElement(std::move(indicator)); | 218 scene_->AddUiElement(std::move(indicator)); |
208 } | 219 } |
209 | 220 |
210 void UiSceneManager::CreateCloseButton() { | 221 void UiSceneManager::CreateCloseButton() { |
211 std::unique_ptr<CloseButton> element = | 222 std::unique_ptr<CloseButton> element = |
212 base::MakeUnique<CloseButton>(base::Bind( | 223 base::MakeUnique<CloseButton>(base::Bind( |
213 &UiSceneManager::OnCloseButtonClicked, base::Unretained(this))); | 224 &UiSceneManager::OnCloseButtonClicked, base::Unretained(this))); |
214 element->set_id(AllocateId()); | 225 element->set_id(AllocateId()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 335 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
325 bool can_go_forward) {} | 336 bool can_go_forward) {} |
326 | 337 |
327 void UiSceneManager::OnCloseButtonClicked() {} | 338 void UiSceneManager::OnCloseButtonClicked() {} |
328 | 339 |
329 int UiSceneManager::AllocateId() { | 340 int UiSceneManager::AllocateId() { |
330 return next_available_id_++; | 341 return next_available_id_++; |
331 } | 342 } |
332 | 343 |
333 } // namespace vr_shell | 344 } // namespace vr_shell |
OLD | NEW |