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/audio_capture_indicator.h" | 10 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace { | 24 namespace { |
25 | 25 |
26 static constexpr int kWarningTimeoutSeconds = 30; | 26 static constexpr int kWarningTimeoutSeconds = 30; |
27 static constexpr float kWarningDistance = 0.7; | 27 static constexpr float kWarningDistance = 0.7; |
28 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; | 28 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; |
29 static constexpr float kPermanentWarningHeight = 0.070f; | 29 static constexpr float kPermanentWarningHeight = 0.070f; |
30 static constexpr float kPermanentWarningWidth = 0.224f; | 30 static constexpr float kPermanentWarningWidth = 0.224f; |
31 static constexpr float kTransientWarningHeight = 0.160; | 31 static constexpr float kTransientWarningHeight = 0.160; |
32 static constexpr float kTransientWarningWidth = 0.512; | 32 static constexpr float kTransientWarningWidth = 0.512; |
33 | 33 |
34 static constexpr float kContentWidth = 2.4; | |
35 static constexpr float kContentHeight = 1.6; | |
36 static constexpr float kContentDistance = 2.5; | 34 static constexpr float kContentDistance = 2.5; |
37 static constexpr float kContentVerticalOffset = -0.26; | 35 static constexpr float kContentWidth = 0.96 * kContentDistance; |
| 36 static constexpr float kContentHeight = 0.64 * kContentDistance; |
| 37 static constexpr float kContentVerticalOffset = -0.1 * kContentDistance; |
38 static constexpr float kBackplaneSize = 1000.0; | 38 static constexpr float kBackplaneSize = 1000.0; |
39 static constexpr float kBackgroundDistanceMultiplier = 1.414; | 39 static constexpr float kBackgroundDistanceMultiplier = 1.414; |
40 | 40 |
| 41 static constexpr float kUrlBarDistance = 2.4; |
| 42 static constexpr float kUrlBarWidth = 0.672 * kUrlBarDistance; |
| 43 static constexpr float kUrlBarHeight = 0.088 * kUrlBarDistance; |
| 44 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; |
| 45 |
| 46 static constexpr float kLoadingIndicatorWidth = 0.24 * kUrlBarDistance; |
| 47 static constexpr float kLoadingIndicatorHeight = 0.008 * kUrlBarDistance; |
| 48 static constexpr float kLoadingIndicatorOffset = |
| 49 -0.016 * kUrlBarDistance - kLoadingIndicatorHeight / 2; |
| 50 |
41 static constexpr float kFullscreenWidth = 2.88; | 51 static constexpr float kFullscreenWidth = 2.88; |
42 static constexpr float kFullscreenHeight = 1.62; | 52 static constexpr float kFullscreenHeight = 1.62; |
43 static constexpr float kFullscreenDistance = 3; | 53 static constexpr float kFullscreenDistance = 3; |
44 static constexpr float kFullscreenVerticalOffset = -0.26; | 54 static constexpr float kFullscreenVerticalOffset = -0.26; |
45 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0}; | 55 static constexpr vr::Colorf kFullscreenBackgroundColor = {0.1, 0.1, 0.1, 1.0}; |
46 | 56 |
47 static constexpr float kSceneSize = 25.0; | 57 static constexpr float kSceneSize = 25.0; |
48 static constexpr float kSceneHeight = 4.0; | 58 static constexpr float kSceneHeight = 4.0; |
49 static constexpr int kFloorGridlineCount = 40; | 59 static constexpr int kFloorGridlineCount = 40; |
50 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; | 60 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 control_elements_.push_back(element.get()); | 218 control_elements_.push_back(element.get()); |
209 scene_->AddUiElement(std::move(element)); | 219 scene_->AddUiElement(std::move(element)); |
210 | 220 |
211 scene_->SetBackgroundColor(kBackgroundHorizonColor); | 221 scene_->SetBackgroundColor(kBackgroundHorizonColor); |
212 } | 222 } |
213 | 223 |
214 void UiSceneManager::CreateUrlBar() { | 224 void UiSceneManager::CreateUrlBar() { |
215 // TODO(cjgrant): Incorporate final size and position. | 225 // TODO(cjgrant): Incorporate final size and position. |
216 auto url_bar = base::MakeUnique<UrlBar>(512); | 226 auto url_bar = base::MakeUnique<UrlBar>(512); |
217 url_bar->set_id(AllocateId()); | 227 url_bar->set_id(AllocateId()); |
218 url_bar->set_translation({0, -0.9, -1.8}); | 228 url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); |
219 url_bar->set_size({0.9, 0, 1}); | 229 url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); |
220 url_bar->SetBackButtonCallback( | 230 url_bar->SetBackButtonCallback( |
221 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); | 231 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); |
222 url_bar_ = url_bar.get(); | 232 url_bar_ = url_bar.get(); |
223 control_elements_.push_back(url_bar.get()); | 233 control_elements_.push_back(url_bar.get()); |
224 scene_->AddUiElement(std::move(url_bar)); | 234 scene_->AddUiElement(std::move(url_bar)); |
225 | 235 |
226 auto indicator = base::MakeUnique<LoadingIndicator>(256); | 236 auto indicator = base::MakeUnique<LoadingIndicator>(256); |
227 indicator->set_id(AllocateId()); | 237 indicator->set_id(AllocateId()); |
228 indicator->set_translation({0, -0.8, -1.8}); | 238 indicator->set_translation({0, 0, kLoadingIndicatorOffset}); |
229 indicator->set_size({0.4, 0, 1}); | 239 indicator->set_size({kLoadingIndicatorWidth, kLoadingIndicatorHeight, 1}); |
| 240 indicator->set_parent_id(url_bar_->id()); |
| 241 indicator->set_y_anchoring(YAnchoring::YTOP); |
230 loading_indicator_ = indicator.get(); | 242 loading_indicator_ = indicator.get(); |
231 control_elements_.push_back(indicator.get()); | 243 control_elements_.push_back(indicator.get()); |
232 scene_->AddUiElement(std::move(indicator)); | 244 scene_->AddUiElement(std::move(indicator)); |
233 } | 245 } |
234 | 246 |
235 void UiSceneManager::CreateCloseButton() { | 247 void UiSceneManager::CreateCloseButton() { |
236 std::unique_ptr<CloseButton> element = | 248 std::unique_ptr<CloseButton> element = |
237 base::MakeUnique<CloseButton>(base::Bind( | 249 base::MakeUnique<CloseButton>(base::Bind( |
238 &UiSceneManager::OnCloseButtonClicked, base::Unretained(this))); | 250 &UiSceneManager::OnCloseButtonClicked, base::Unretained(this))); |
239 element->set_id(AllocateId()); | 251 element->set_id(AllocateId()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 361 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
350 bool can_go_forward) {} | 362 bool can_go_forward) {} |
351 | 363 |
352 void UiSceneManager::OnCloseButtonClicked() {} | 364 void UiSceneManager::OnCloseButtonClicked() {} |
353 | 365 |
354 int UiSceneManager::AllocateId() { | 366 int UiSceneManager::AllocateId() { |
355 return next_available_id_++; | 367 return next_available_id_++; |
356 } | 368 } |
357 | 369 |
358 } // namespace vr_shell | 370 } // namespace vr_shell |
OLD | NEW |