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/close_button_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" |
10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" | 11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" |
12 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" | |
13 #include "chrome/browser/android/vr_shell/ui_elements/button.h" | 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" |
14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" | 13 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" |
15 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" | 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" |
16 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" | 15 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" |
17 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" | 16 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
18 #include "chrome/browser/android/vr_shell/ui_elements/location_access_indicator. h" | |
19 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" | 17 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" |
20 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h " | |
21 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" | 18 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" |
19 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" | |
22 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" | 20 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" |
23 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" | 21 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" |
24 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 22 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
25 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" | 23 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" |
26 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" | 24 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" |
27 #include "chrome/browser/android/vr_shell/ui_elements/video_capture_indicator.h" | |
28 #include "chrome/browser/android/vr_shell/ui_scene.h" | 25 #include "chrome/browser/android/vr_shell/ui_scene.h" |
26 #include "chrome/grit/generated_resources.h" | |
27 #include "components/vector_icons/vector_icons.h" | |
28 #include "ui/vector_icons/vector_icons.h" | |
29 | 29 |
30 namespace vr_shell { | 30 namespace vr_shell { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 static constexpr int kWarningTimeoutSeconds = 30; | 34 static constexpr int kWarningTimeoutSeconds = 30; |
35 static constexpr float kWarningDistance = 0.7; | 35 static constexpr float kWarningDistance = 0.7; |
36 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; | 36 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; |
37 static constexpr float kPermanentWarningHeight = 0.070f; | 37 static constexpr float kPermanentWarningHeight = 0.070f; |
38 static constexpr float kPermanentWarningWidth = 0.224f; | 38 static constexpr float kPermanentWarningWidth = 0.224f; |
(...skipping 23 matching lines...) Expand all Loading... | |
62 | 62 |
63 // Distance-independent milimeter size of the URL bar. | 63 // Distance-independent milimeter size of the URL bar. |
64 static constexpr float kUrlBarWidthDMM = 0.672; | 64 static constexpr float kUrlBarWidthDMM = 0.672; |
65 static constexpr float kUrlBarHeightDMM = 0.088; | 65 static constexpr float kUrlBarHeightDMM = 0.088; |
66 static constexpr float kUrlBarDistance = 2.4; | 66 static constexpr float kUrlBarDistance = 2.4; |
67 static constexpr float kUrlBarWidth = kUrlBarWidthDMM * kUrlBarDistance; | 67 static constexpr float kUrlBarWidth = kUrlBarWidthDMM * kUrlBarDistance; |
68 static constexpr float kUrlBarHeight = kUrlBarHeightDMM * kUrlBarDistance; | 68 static constexpr float kUrlBarHeight = kUrlBarHeightDMM * kUrlBarDistance; |
69 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; | 69 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; |
70 static constexpr float kUrlBarRotationRad = -0.175; | 70 static constexpr float kUrlBarRotationRad = -0.175; |
71 | 71 |
72 static constexpr float kIndicatorContentDistance = 0.1; | 72 static constexpr float kIndicatorHeight = 0.0625; |
amp
2017/06/22 18:34:43
Does this include an implicit distance in it alrea
| |
73 static constexpr float kAudioCaptureIndicatorWidth = 0.5; | 73 static constexpr float kIndicatorGap = 0.05; |
74 static constexpr float kVideoCaptureIndicatorWidth = 0.5; | 74 static constexpr float kIndicatorYOffset = 0.1; |
75 static constexpr float kScreenCaptureIndicatorWidth = 0.4; | 75 static constexpr float kIndicatorZOffset = 0.1; |
amp
2017/06/22 18:34:43
We call it Distance everywhere else. Switching to
cjgrant
2017/06/22 19:16:33
I'm not sure what actions are being suggested here
amp
2017/06/22 20:36:22
Thanks for the explanation. I was used to seeing
cjgrant
2017/06/22 20:58:11
- I'll update the naming to Distance and Vertical
| |
76 static constexpr float kLocationIndicatorWidth = 0.088; | |
77 | |
78 static constexpr float kCaptureIndicatorsVerticalOffset = 0.1; | |
79 static constexpr float kAudioCaptureHorizontalOffset = -0.6; | |
80 static constexpr float kVideoCaptureHorizontalOffset = 0; | |
81 static constexpr float kScreenCaptureHorizontalOffset = 0.6; | |
82 static constexpr float kLocationAccessHorizontalOffset = 1.0; | |
83 | 76 |
84 static constexpr float kTransientUrlBarDistance = 1.4; | 77 static constexpr float kTransientUrlBarDistance = 1.4; |
85 static constexpr float kTransientUrlBarWidth = | 78 static constexpr float kTransientUrlBarWidth = |
86 kUrlBarWidthDMM * kTransientUrlBarDistance; | 79 kUrlBarWidthDMM * kTransientUrlBarDistance; |
87 static constexpr float kTransientUrlBarHeight = | 80 static constexpr float kTransientUrlBarHeight = |
88 kUrlBarHeightDMM * kTransientUrlBarDistance; | 81 kUrlBarHeightDMM * kTransientUrlBarDistance; |
89 static constexpr float kTransientUrlBarVerticalOffset = | 82 static constexpr float kTransientUrlBarVerticalOffset = |
90 -0.2 * kTransientUrlBarDistance; | 83 -0.2 * kTransientUrlBarDistance; |
91 static constexpr int kTransientUrlBarTimeoutSeconds = 6; | 84 static constexpr int kTransientUrlBarTimeoutSeconds = 6; |
92 | 85 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 element->set_visible(false); | 198 element->set_visible(false); |
206 element->set_hit_testable(false); | 199 element->set_hit_testable(false); |
207 element->set_lock_to_fov(true); | 200 element->set_lock_to_fov(true); |
208 exit_warning_ = element.get(); | 201 exit_warning_ = element.get(); |
209 scene_->AddUiElement(std::move(element)); | 202 scene_->AddUiElement(std::move(element)); |
210 } | 203 } |
211 | 204 |
212 void UiSceneManager::CreateSystemIndicators() { | 205 void UiSceneManager::CreateSystemIndicators() { |
213 std::unique_ptr<UiElement> element; | 206 std::unique_ptr<UiElement> element; |
214 | 207 |
215 element = base::MakeUnique<AudioCaptureIndicator>(512); | 208 struct Indicator { |
216 element->set_debug_id(kAudioCaptureIndicator); | 209 UiElement** element; |
217 element->set_id(AllocateId()); | 210 UiElementDebugId debug_id; |
218 element->set_translation({kAudioCaptureHorizontalOffset, | 211 const gfx::VectorIcon& icon; |
219 kCaptureIndicatorsVerticalOffset, | 212 int resource_string; |
220 kIndicatorContentDistance}); | 213 }; |
221 element->set_parent_id(main_content_->id()); | 214 const std::vector<Indicator> indicators = { |
222 element->set_y_anchoring(YAnchoring::YTOP); | 215 {&audio_capture_indicator_, kAudioCaptureIndicator, ui::kMicrophoneIcon, |
223 element->set_size({kAudioCaptureIndicatorWidth, 0, 1}); | 216 IDS_AUDIO_CALL_NOTIFICATION_TEXT_2}, |
224 element->set_visible(false); | 217 {&video_capture_indicator_, kVideoCaptureIndicator, ui::kVideocamIcon, |
225 audio_capture_indicator_ = element.get(); | 218 IDS_VIDEO_CALL_NOTIFICATION_TEXT_2}, |
226 scene_->AddUiElement(std::move(element)); | 219 {&screen_capture_indicator_, kScreenCaptureIndicator, |
220 vector_icons::kScreenShareIcon, IDS_SCREEN_CAPTURE_NOTIFICATION_TEXT_2}, | |
221 {&location_access_indicator_, kLocationAccessIndicator, | |
222 ui::kLocationOnIcon, 0}, | |
223 }; | |
227 | 224 |
228 element = base::MakeUnique<LocationAccessIndicator>(250); | 225 for (const auto& indicator : indicators) { |
229 element->set_debug_id(kLocationAccessIndicator); | 226 element = base::MakeUnique<SystemIndicator>( |
230 element->set_id(AllocateId()); | 227 512, kIndicatorHeight, indicator.icon, indicator.resource_string); |
asimjour1
2017/06/22 14:46:00
I'm not sure if I get this part. Do we use 512 for
cjgrant
2017/06/22 15:51:39
We use 512 for many textures, but the number shoul
asimjour1
2017/06/22 19:18:35
Please use a constant for 512.
cjgrant
2017/06/22 20:58:11
As mentioned offline, all our sizes are hard-coded
| |
231 element->set_translation({kLocationAccessHorizontalOffset, | 228 element->set_debug_id(indicator.debug_id); |
232 kCaptureIndicatorsVerticalOffset, | 229 element->set_id(AllocateId()); |
233 kIndicatorContentDistance}); | 230 element->set_parent_id(main_content_->id()); |
234 element->set_size({kLocationIndicatorWidth, 0, 1}); | 231 element->set_y_anchoring(YAnchoring::YTOP); |
235 element->set_parent_id(main_content_->id()); | 232 element->set_visible(false); |
236 element->set_y_anchoring(YAnchoring::YTOP); | 233 *(indicator.element) = element.get(); |
237 element->set_visible(false); | 234 system_indicators_.push_back(element.get()); |
238 location_access_indicator_ = element.get(); | 235 scene_->AddUiElement(std::move(element)); |
239 scene_->AddUiElement(std::move(element)); | 236 } |
240 | 237 |
241 element = base::MakeUnique<VideoCaptureIndicator>(512); | 238 ConfigureIndicators(); |
242 element->set_debug_id(kVideoCaptureIndicator); | |
243 element->set_id(AllocateId()); | |
244 element->set_translation({kVideoCaptureHorizontalOffset, | |
245 kCaptureIndicatorsVerticalOffset, | |
246 kIndicatorContentDistance}); | |
247 element->set_parent_id(main_content_->id()); | |
248 element->set_y_anchoring(YAnchoring::YTOP); | |
249 element->set_size({kVideoCaptureIndicatorWidth, 0, 1}); | |
250 element->set_visible(false); | |
251 video_capture_indicator_ = element.get(); | |
252 scene_->AddUiElement(std::move(element)); | |
253 | |
254 element = base::MakeUnique<ScreenCaptureIndicator>(512); | |
255 element->set_debug_id(kScreenCaptureIndicator); | |
256 element->set_id(AllocateId()); | |
257 element->set_translation({kScreenCaptureHorizontalOffset, | |
258 kCaptureIndicatorsVerticalOffset, | |
259 kIndicatorContentDistance}); | |
260 element->set_parent_id(main_content_->id()); | |
261 element->set_y_anchoring(YAnchoring::YTOP); | |
262 element->set_size({kScreenCaptureIndicatorWidth, 0, 1}); | |
263 element->set_visible(false); | |
264 screen_capture_indicator_ = element.get(); | |
265 scene_->AddUiElement(std::move(element)); | |
266 } | 239 } |
267 | 240 |
268 void UiSceneManager::CreateContentQuad() { | 241 void UiSceneManager::CreateContentQuad() { |
269 std::unique_ptr<UiElement> element; | 242 std::unique_ptr<UiElement> element; |
270 | 243 |
271 element = base::MakeUnique<UiElement>(); | 244 element = base::MakeUnique<UiElement>(); |
272 element->set_debug_id(kContentQuad); | 245 element->set_debug_id(kContentQuad); |
273 element->set_id(AllocateId()); | 246 element->set_id(AllocateId()); |
274 element->set_fill(vr_shell::Fill::CONTENT); | 247 element->set_fill(vr_shell::Fill::CONTENT); |
275 element->set_size({kContentWidth, kContentHeight, 1}); | 248 element->set_size({kContentWidth, kContentHeight, 1}); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 ConfigureSecurityWarnings(); | 508 ConfigureSecurityWarnings(); |
536 } | 509 } |
537 | 510 |
538 void UiSceneManager::SetIncognito(bool incognito) { | 511 void UiSceneManager::SetIncognito(bool incognito) { |
539 if (incognito == incognito_) | 512 if (incognito == incognito_) |
540 return; | 513 return; |
541 incognito_ = incognito; | 514 incognito_ = incognito; |
542 ConfigureScene(); | 515 ConfigureScene(); |
543 } | 516 } |
544 | 517 |
518 void UiSceneManager::OnGLInitialized() { | |
519 scene_->OnGLInitialized(); | |
520 | |
521 // Indicators don't know their position until they've rendered themselves. | |
522 ConfigureIndicators(); | |
523 } | |
524 | |
545 void UiSceneManager::OnAppButtonClicked() { | 525 void UiSceneManager::OnAppButtonClicked() { |
546 // App button click exits the WebVR presentation and fullscreen. | 526 // App button click exits the WebVR presentation and fullscreen. |
547 browser_->ExitPresent(); | 527 browser_->ExitPresent(); |
548 browser_->ExitFullscreen(); | 528 browser_->ExitFullscreen(); |
549 } | 529 } |
550 | 530 |
551 void UiSceneManager::OnAppButtonGesturePerformed( | 531 void UiSceneManager::OnAppButtonGesturePerformed( |
552 UiInterface::Direction direction) {} | 532 UiInterface::Direction direction) {} |
553 | 533 |
554 void UiSceneManager::SetFullscreen(bool fullscreen) { | 534 void UiSceneManager::SetFullscreen(bool fullscreen) { |
(...skipping 14 matching lines...) Expand all Loading... | |
569 } else { | 549 } else { |
570 security_warning_timer_.Stop(); | 550 security_warning_timer_.Stop(); |
571 } | 551 } |
572 } | 552 } |
573 | 553 |
574 void UiSceneManager::ConfigureIndicators() { | 554 void UiSceneManager::ConfigureIndicators() { |
575 audio_capture_indicator_->set_visible(!web_vr_mode_ && audio_capturing_); | 555 audio_capture_indicator_->set_visible(!web_vr_mode_ && audio_capturing_); |
576 video_capture_indicator_->set_visible(!web_vr_mode_ && video_capturing_); | 556 video_capture_indicator_->set_visible(!web_vr_mode_ && video_capturing_); |
577 screen_capture_indicator_->set_visible(!web_vr_mode_ && screen_capturing_); | 557 screen_capture_indicator_->set_visible(!web_vr_mode_ && screen_capturing_); |
578 location_access_indicator_->set_visible(!web_vr_mode_ && location_access_); | 558 location_access_indicator_->set_visible(!web_vr_mode_ && location_access_); |
559 | |
560 // Position elements dynamically relative to each other, based on which | |
561 // indicators are showing, and how big each one is. | |
562 float total_width = kIndicatorGap * (system_indicators_.size() - 1); | |
563 for (const UiElement* indicator : system_indicators_) { | |
564 if (indicator->visible()) | |
565 total_width += indicator->size().x(); | |
566 } | |
567 float x_position = -total_width / 2; | |
568 for (UiElement* indicator : system_indicators_) { | |
569 if (!indicator->visible()) | |
570 continue; | |
571 float width = indicator->size().x(); | |
572 indicator->set_translation( | |
573 {x_position + width / 2, kIndicatorYOffset, kIndicatorZOffset}); | |
574 x_position += width + kIndicatorGap; | |
575 } | |
579 } | 576 } |
580 | 577 |
581 void UiSceneManager::OnSecurityWarningTimer() { | 578 void UiSceneManager::OnSecurityWarningTimer() { |
582 transient_security_warning_->set_visible(false); | 579 transient_security_warning_->set_visible(false); |
583 } | 580 } |
584 | 581 |
585 void UiSceneManager::ConfigureTransientUrlBar() { | 582 void UiSceneManager::ConfigureTransientUrlBar() { |
586 bool enabled = web_vr_mode_ && web_vr_autopresented_; | 583 bool enabled = web_vr_mode_ && web_vr_autopresented_; |
587 transient_url_bar_->set_visible(enabled); | 584 transient_url_bar_->set_visible(enabled); |
588 if (enabled) { | 585 if (enabled) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
690 if (fullscreen_) | 687 if (fullscreen_) |
691 return ColorScheme::kModeFullscreen; | 688 return ColorScheme::kModeFullscreen; |
692 return ColorScheme::kModeNormal; | 689 return ColorScheme::kModeNormal; |
693 } | 690 } |
694 | 691 |
695 const ColorScheme& UiSceneManager::color_scheme() const { | 692 const ColorScheme& UiSceneManager::color_scheme() const { |
696 return ColorScheme::GetColorScheme(mode()); | 693 return ColorScheme::GetColorScheme(mode()); |
697 } | 694 } |
698 | 695 |
699 } // namespace vr_shell | 696 } // namespace vr_shell |
OLD | NEW |