Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_manager.cc

Issue 2950173002: VR: System indicator rework. (Closed)
Patch Set: Address comments; increase size slightly for readability, now that position is dynamic. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/presentation_toast.h" 18 #include "chrome/browser/android/vr_shell/ui_elements/presentation_toast.h"
21 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h "
22 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" 19 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h"
20 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h"
23 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" 21 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h"
24 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" 22 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h"
25 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 23 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
26 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" 24 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h"
27 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" 25 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h"
28 #include "chrome/browser/android/vr_shell/ui_elements/video_capture_indicator.h"
29 #include "chrome/browser/android/vr_shell/ui_scene.h" 26 #include "chrome/browser/android/vr_shell/ui_scene.h"
27 #include "chrome/grit/generated_resources.h"
28 #include "components/vector_icons/vector_icons.h"
29 #include "ui/vector_icons/vector_icons.h"
30 30
31 namespace vr_shell { 31 namespace vr_shell {
32 32
33 namespace { 33 namespace {
34 34
35 static constexpr int kWarningTimeoutSeconds = 30; 35 static constexpr int kWarningTimeoutSeconds = 30;
36 static constexpr float kWarningDistance = 0.7; 36 static constexpr float kWarningDistance = 0.7;
37 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; 37 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0;
38 static constexpr float kPermanentWarningHeight = 0.070f; 38 static constexpr float kPermanentWarningHeight = 0.070f;
39 static constexpr float kPermanentWarningWidth = 0.224f; 39 static constexpr float kPermanentWarningWidth = 0.224f;
(...skipping 23 matching lines...) Expand all
63 63
64 // Distance-independent milimeter size of the URL bar. 64 // Distance-independent milimeter size of the URL bar.
65 static constexpr float kUrlBarWidthDMM = 0.672; 65 static constexpr float kUrlBarWidthDMM = 0.672;
66 static constexpr float kUrlBarHeightDMM = 0.088; 66 static constexpr float kUrlBarHeightDMM = 0.088;
67 static constexpr float kUrlBarDistance = 2.4; 67 static constexpr float kUrlBarDistance = 2.4;
68 static constexpr float kUrlBarWidth = kUrlBarWidthDMM * kUrlBarDistance; 68 static constexpr float kUrlBarWidth = kUrlBarWidthDMM * kUrlBarDistance;
69 static constexpr float kUrlBarHeight = kUrlBarHeightDMM * kUrlBarDistance; 69 static constexpr float kUrlBarHeight = kUrlBarHeightDMM * kUrlBarDistance;
70 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance; 70 static constexpr float kUrlBarVerticalOffset = -0.516 * kUrlBarDistance;
71 static constexpr float kUrlBarRotationRad = -0.175; 71 static constexpr float kUrlBarRotationRad = -0.175;
72 72
73 static constexpr float kIndicatorContentDistance = 0.1; 73 static constexpr float kIndicatorHeight = 0.08;
74 static constexpr float kAudioCaptureIndicatorWidth = 0.5; 74 static constexpr float kIndicatorGap = 0.05;
75 static constexpr float kVideoCaptureIndicatorWidth = 0.5; 75 static constexpr float kIndicatorVerticalOffset = 0.1;
76 static constexpr float kScreenCaptureIndicatorWidth = 0.4; 76 static constexpr float kIndicatorDistanceOffset = 0.1;
77 static constexpr float kLocationIndicatorWidth = 0.088;
78
79 static constexpr float kCaptureIndicatorsVerticalOffset = 0.1;
80 static constexpr float kAudioCaptureHorizontalOffset = -0.6;
81 static constexpr float kVideoCaptureHorizontalOffset = 0;
82 static constexpr float kScreenCaptureHorizontalOffset = 0.6;
83 static constexpr float kLocationAccessHorizontalOffset = 1.0;
84 77
85 static constexpr float kTransientUrlBarDistance = 1.4; 78 static constexpr float kTransientUrlBarDistance = 1.4;
86 static constexpr float kTransientUrlBarWidth = 79 static constexpr float kTransientUrlBarWidth =
87 kUrlBarWidthDMM * kTransientUrlBarDistance; 80 kUrlBarWidthDMM * kTransientUrlBarDistance;
88 static constexpr float kTransientUrlBarHeight = 81 static constexpr float kTransientUrlBarHeight =
89 kUrlBarHeightDMM * kTransientUrlBarDistance; 82 kUrlBarHeightDMM * kTransientUrlBarDistance;
90 static constexpr float kTransientUrlBarVerticalOffset = 83 static constexpr float kTransientUrlBarVerticalOffset =
91 -0.2 * kTransientUrlBarDistance; 84 -0.2 * kTransientUrlBarDistance;
92 static constexpr int kTransientUrlBarTimeoutSeconds = 6; 85 static constexpr int kTransientUrlBarTimeoutSeconds = 6;
93 86
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 element->set_visible(false); 205 element->set_visible(false);
213 element->set_hit_testable(false); 206 element->set_hit_testable(false);
214 element->set_lock_to_fov(true); 207 element->set_lock_to_fov(true);
215 exit_warning_ = element.get(); 208 exit_warning_ = element.get();
216 scene_->AddUiElement(std::move(element)); 209 scene_->AddUiElement(std::move(element));
217 } 210 }
218 211
219 void UiSceneManager::CreateSystemIndicators() { 212 void UiSceneManager::CreateSystemIndicators() {
220 std::unique_ptr<UiElement> element; 213 std::unique_ptr<UiElement> element;
221 214
222 element = base::MakeUnique<AudioCaptureIndicator>(512); 215 struct Indicator {
223 element->set_debug_id(kAudioCaptureIndicator); 216 UiElement** element;
224 element->set_id(AllocateId()); 217 UiElementDebugId debug_id;
225 element->set_translation({kAudioCaptureHorizontalOffset, 218 const gfx::VectorIcon& icon;
226 kCaptureIndicatorsVerticalOffset, 219 int resource_string;
227 kIndicatorContentDistance}); 220 };
228 element->set_parent_id(main_content_->id()); 221 const std::vector<Indicator> indicators = {
229 element->set_y_anchoring(YAnchoring::YTOP); 222 {&audio_capture_indicator_, kAudioCaptureIndicator, ui::kMicrophoneIcon,
230 element->set_size({kAudioCaptureIndicatorWidth, 0, 1}); 223 IDS_AUDIO_CALL_NOTIFICATION_TEXT_2},
231 element->set_visible(false); 224 {&video_capture_indicator_, kVideoCaptureIndicator, ui::kVideocamIcon,
232 audio_capture_indicator_ = element.get(); 225 IDS_VIDEO_CALL_NOTIFICATION_TEXT_2},
233 scene_->AddUiElement(std::move(element)); 226 {&screen_capture_indicator_, kScreenCaptureIndicator,
227 vector_icons::kScreenShareIcon, IDS_SCREEN_CAPTURE_NOTIFICATION_TEXT_2},
228 {&location_access_indicator_, kLocationAccessIndicator,
229 ui::kLocationOnIcon, 0},
230 };
234 231
235 element = base::MakeUnique<LocationAccessIndicator>(250); 232 for (const auto& indicator : indicators) {
236 element->set_debug_id(kLocationAccessIndicator); 233 element = base::MakeUnique<SystemIndicator>(
237 element->set_id(AllocateId()); 234 512, kIndicatorHeight, indicator.icon, indicator.resource_string);
238 element->set_translation({kLocationAccessHorizontalOffset, 235 element->set_debug_id(indicator.debug_id);
239 kCaptureIndicatorsVerticalOffset, 236 element->set_id(AllocateId());
240 kIndicatorContentDistance}); 237 element->set_parent_id(main_content_->id());
241 element->set_size({kLocationIndicatorWidth, 0, 1}); 238 element->set_y_anchoring(YAnchoring::YTOP);
242 element->set_parent_id(main_content_->id()); 239 element->set_visible(false);
243 element->set_y_anchoring(YAnchoring::YTOP); 240 *(indicator.element) = element.get();
244 element->set_visible(false); 241 system_indicators_.push_back(element.get());
245 location_access_indicator_ = element.get(); 242 scene_->AddUiElement(std::move(element));
246 scene_->AddUiElement(std::move(element)); 243 }
247 244
248 element = base::MakeUnique<VideoCaptureIndicator>(512); 245 ConfigureIndicators();
249 element->set_debug_id(kVideoCaptureIndicator);
250 element->set_id(AllocateId());
251 element->set_translation({kVideoCaptureHorizontalOffset,
252 kCaptureIndicatorsVerticalOffset,
253 kIndicatorContentDistance});
254 element->set_parent_id(main_content_->id());
255 element->set_y_anchoring(YAnchoring::YTOP);
256 element->set_size({kVideoCaptureIndicatorWidth, 0, 1});
257 element->set_visible(false);
258 video_capture_indicator_ = element.get();
259 scene_->AddUiElement(std::move(element));
260
261 element = base::MakeUnique<ScreenCaptureIndicator>(512);
262 element->set_debug_id(kScreenCaptureIndicator);
263 element->set_id(AllocateId());
264 element->set_translation({kScreenCaptureHorizontalOffset,
265 kCaptureIndicatorsVerticalOffset,
266 kIndicatorContentDistance});
267 element->set_parent_id(main_content_->id());
268 element->set_y_anchoring(YAnchoring::YTOP);
269 element->set_size({kScreenCaptureIndicatorWidth, 0, 1});
270 element->set_visible(false);
271 screen_capture_indicator_ = element.get();
272 scene_->AddUiElement(std::move(element));
273 } 246 }
274 247
275 void UiSceneManager::CreateContentQuad() { 248 void UiSceneManager::CreateContentQuad() {
276 std::unique_ptr<UiElement> element; 249 std::unique_ptr<UiElement> element;
277 250
278 element = base::MakeUnique<UiElement>(); 251 element = base::MakeUnique<UiElement>();
279 element->set_debug_id(kContentQuad); 252 element->set_debug_id(kContentQuad);
280 element->set_id(AllocateId()); 253 element->set_id(AllocateId());
281 element->set_fill(vr_shell::Fill::CONTENT); 254 element->set_fill(vr_shell::Fill::CONTENT);
282 element->set_size({kContentWidth, kContentHeight, 1}); 255 element->set_size({kContentWidth, kContentHeight, 1});
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 ConfigureSecurityWarnings(); 535 ConfigureSecurityWarnings();
563 } 536 }
564 537
565 void UiSceneManager::SetIncognito(bool incognito) { 538 void UiSceneManager::SetIncognito(bool incognito) {
566 if (incognito == incognito_) 539 if (incognito == incognito_)
567 return; 540 return;
568 incognito_ = incognito; 541 incognito_ = incognito;
569 ConfigureScene(); 542 ConfigureScene();
570 } 543 }
571 544
545 void UiSceneManager::OnGLInitialized() {
546 scene_->OnGLInitialized();
547
548 // Indicators don't know their position until they've rendered themselves.
549 ConfigureIndicators();
550 }
551
572 void UiSceneManager::OnAppButtonClicked() { 552 void UiSceneManager::OnAppButtonClicked() {
573 // App button click exits the WebVR presentation and fullscreen. 553 // App button click exits the WebVR presentation and fullscreen.
574 browser_->ExitPresent(); 554 browser_->ExitPresent();
575 browser_->ExitFullscreen(); 555 browser_->ExitFullscreen();
576 } 556 }
577 557
578 void UiSceneManager::OnAppButtonGesturePerformed( 558 void UiSceneManager::OnAppButtonGesturePerformed(
579 UiInterface::Direction direction) {} 559 UiInterface::Direction direction) {}
580 560
581 void UiSceneManager::SetFullscreen(bool fullscreen) { 561 void UiSceneManager::SetFullscreen(bool fullscreen) {
(...skipping 14 matching lines...) Expand all
596 } else { 576 } else {
597 security_warning_timer_.Stop(); 577 security_warning_timer_.Stop();
598 } 578 }
599 } 579 }
600 580
601 void UiSceneManager::ConfigureIndicators() { 581 void UiSceneManager::ConfigureIndicators() {
602 audio_capture_indicator_->set_visible(!web_vr_mode_ && audio_capturing_); 582 audio_capture_indicator_->set_visible(!web_vr_mode_ && audio_capturing_);
603 video_capture_indicator_->set_visible(!web_vr_mode_ && video_capturing_); 583 video_capture_indicator_->set_visible(!web_vr_mode_ && video_capturing_);
604 screen_capture_indicator_->set_visible(!web_vr_mode_ && screen_capturing_); 584 screen_capture_indicator_->set_visible(!web_vr_mode_ && screen_capturing_);
605 location_access_indicator_->set_visible(!web_vr_mode_ && location_access_); 585 location_access_indicator_->set_visible(!web_vr_mode_ && location_access_);
586
587 // Position elements dynamically relative to each other, based on which
588 // indicators are showing, and how big each one is.
589 float total_width = kIndicatorGap * (system_indicators_.size() - 1);
590 for (const UiElement* indicator : system_indicators_) {
591 if (indicator->visible())
592 total_width += indicator->size().x();
593 }
594 float x_position = -total_width / 2;
595 for (UiElement* indicator : system_indicators_) {
596 if (!indicator->visible())
597 continue;
598 float width = indicator->size().x();
599 indicator->set_translation({x_position + width / 2,
600 kIndicatorVerticalOffset,
601 kIndicatorDistanceOffset});
602 x_position += width + kIndicatorGap;
603 }
606 } 604 }
607 605
608 void UiSceneManager::ConfigurePresentationToast() { 606 void UiSceneManager::ConfigurePresentationToast() {
609 presentation_toast_->set_visible(web_vr_show_toast_); 607 presentation_toast_->set_visible(web_vr_show_toast_);
610 if (web_vr_show_toast_) { 608 if (web_vr_show_toast_) {
611 presentation_toast_timer_.Start( 609 presentation_toast_timer_.Start(
612 FROM_HERE, base::TimeDelta::FromSeconds(kToastTimeoutSeconds), this, 610 FROM_HERE, base::TimeDelta::FromSeconds(kToastTimeoutSeconds), this,
613 &UiSceneManager::OnPresentationToastTimer); 611 &UiSceneManager::OnPresentationToastTimer);
614 } else { 612 } else {
615 presentation_toast_timer_.Stop(); 613 presentation_toast_timer_.Stop();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 if (fullscreen_) 730 if (fullscreen_)
733 return ColorScheme::kModeFullscreen; 731 return ColorScheme::kModeFullscreen;
734 return ColorScheme::kModeNormal; 732 return ColorScheme::kModeNormal;
735 } 733 }
736 734
737 const ColorScheme& UiSceneManager::color_scheme() const { 735 const ColorScheme& UiSceneManager::color_scheme() const {
738 return ColorScheme::GetColorScheme(mode()); 736 return ColorScheme::GetColorScheme(mode());
739 } 737 }
740 738
741 } // namespace vr_shell 739 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.h ('k') | chrome/browser/android/vr_shell/vr_gl_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698