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

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

Issue 2957173002: Update toast behavior and apperance according to UX requirement (Closed)
Patch Set: review Created 3 years, 5 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
« no previous file with comments | « chrome/browser/android/vr_shell/ui_elements/simple_textured_element.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/button.h" 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h"
13 #include "chrome/browser/android/vr_shell/ui_elements/exclusive_screen_toast.h"
13 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h"
14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" 15 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h"
15 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" 16 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h"
16 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" 17 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h"
17 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" 18 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h"
18 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" 19 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h"
19 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 20 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
20 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" 21 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h"
21 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" 22 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h"
22 #include "chrome/browser/android/vr_shell/ui_scene.h" 23 #include "chrome/browser/android/vr_shell/ui_scene.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 74
74 static constexpr float kTransientUrlBarDistance = 1.4; 75 static constexpr float kTransientUrlBarDistance = 1.4;
75 static constexpr float kTransientUrlBarWidth = 76 static constexpr float kTransientUrlBarWidth =
76 kUrlBarWidthDMM * kTransientUrlBarDistance; 77 kUrlBarWidthDMM * kTransientUrlBarDistance;
77 static constexpr float kTransientUrlBarHeight = 78 static constexpr float kTransientUrlBarHeight =
78 kUrlBarHeightDMM * kTransientUrlBarDistance; 79 kUrlBarHeightDMM * kTransientUrlBarDistance;
79 static constexpr float kTransientUrlBarVerticalOffset = 80 static constexpr float kTransientUrlBarVerticalOffset =
80 -0.2 * kTransientUrlBarDistance; 81 -0.2 * kTransientUrlBarDistance;
81 static constexpr int kTransientUrlBarTimeoutSeconds = 6; 82 static constexpr int kTransientUrlBarTimeoutSeconds = 6;
82 83
83 static constexpr float kToastDistance = 1.4; 84 static constexpr float kWebVrToastDistance = 1.0;
84 static constexpr float kToastWidth = 0.512 * kToastDistance; 85 static constexpr float kFullscreenToastDistance = kFullscreenDistance;
85 static constexpr float kToastHeight = 0.16 * kToastDistance; 86 static constexpr float kToastWidthDMM = 0.512;
87 static constexpr float kToastHeightDMM = 0.064;
88 static constexpr float kToastOffsetDMM = 0.004;
89 // When changing the value here, make sure it doesn't collide with
90 // kWarningAngleRadians.
91 static constexpr float kWebVrAngleRadians = 9.88 * M_PI / 180.0;
86 static constexpr int kToastTimeoutSeconds = kTransientUrlBarTimeoutSeconds; 92 static constexpr int kToastTimeoutSeconds = kTransientUrlBarTimeoutSeconds;
87 93
88 static constexpr float kSplashScreenDistance = 1; 94 static constexpr float kSplashScreenDistance = 1;
89 static constexpr float kSplashScreenIconDMM = 0.12; 95 static constexpr float kSplashScreenIconDMM = 0.12;
90 static constexpr float kSplashScreenIconHeight = 96 static constexpr float kSplashScreenIconHeight =
91 kSplashScreenIconDMM * kSplashScreenDistance; 97 kSplashScreenIconDMM * kSplashScreenDistance;
92 static constexpr float kSplashScreenIconWidth = 98 static constexpr float kSplashScreenIconWidth =
93 kSplashScreenIconDMM * kSplashScreenDistance; 99 kSplashScreenIconDMM * kSplashScreenDistance;
94 static constexpr float kSplashScreenIconVerticalOffset = 100 static constexpr float kSplashScreenIconVerticalOffset =
95 0.2 * kSplashScreenDistance; 101 0.2 * kSplashScreenDistance;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 content_elements_.push_back(element.get()); 429 content_elements_.push_back(element.get());
424 scene_->AddUiElement(std::move(element)); 430 scene_->AddUiElement(std::move(element));
425 } 431 }
426 432
427 void UiSceneManager::CreateToasts() { 433 void UiSceneManager::CreateToasts() {
428 std::unique_ptr<UiElement> element = 434 std::unique_ptr<UiElement> element =
429 base::MakeUnique<ExclusiveScreenToast>(512); 435 base::MakeUnique<ExclusiveScreenToast>(512);
430 element->set_debug_id(kExclusiveScreenToast); 436 element->set_debug_id(kExclusiveScreenToast);
431 element->set_id(AllocateId()); 437 element->set_id(AllocateId());
432 element->set_fill(vr_shell::Fill::NONE); 438 element->set_fill(vr_shell::Fill::NONE);
433 element->set_size({kToastWidth, kToastHeight, 1}); 439 element->set_size({kToastWidthDMM, kToastHeightDMM, 1});
434 element->set_translation({0, 0, -kToastDistance});
435 element->set_visible(false); 440 element->set_visible(false);
436 element->set_hit_testable(false); 441 element->set_hit_testable(false);
437 element->set_lock_to_fov(true);
438 exclusive_screen_toast_ = element.get(); 442 exclusive_screen_toast_ = element.get();
439 scene_->AddUiElement(std::move(element)); 443 scene_->AddUiElement(std::move(element));
440 } 444 }
441 445
442 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 446 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
443 return weak_ptr_factory_.GetWeakPtr(); 447 return weak_ptr_factory_.GetWeakPtr();
444 } 448 }
445 449
446 void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) { 450 void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) {
447 if (web_vr_mode_ == web_vr && web_vr_show_toast_ == show_toast) { 451 if (web_vr_mode_ == web_vr && web_vr_show_toast_ == show_toast) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 switch (toast_state_) { 659 switch (toast_state_) {
656 case SET_FOR_WEB_VR: 660 case SET_FOR_WEB_VR:
657 toast_visible = web_vr_show_toast_; 661 toast_visible = web_vr_show_toast_;
658 break; 662 break;
659 case SET_FOR_FULLSCREEN: 663 case SET_FOR_FULLSCREEN:
660 toast_visible = fullscreen_; 664 toast_visible = fullscreen_;
661 break; 665 break;
662 case UNCHANGED: 666 case UNCHANGED:
663 return; 667 return;
664 } 668 }
669 if (fullscreen_ && !web_vr_mode_) {
670 // Do not set size again. The size might have been changed by the backing
671 // texture size in UpdateElementSize.
672 exclusive_screen_toast_->set_scale(
673 {kFullscreenToastDistance, kFullscreenToastDistance, 1});
674 exclusive_screen_toast_->set_translation(
675 {0,
676 kFullscreenVerticalOffset + kFullscreenHeight / 2 +
677 (kToastOffsetDMM + kToastHeightDMM) * kFullscreenToastDistance,
678 -kFullscreenToastDistance});
679 exclusive_screen_toast_->set_rotation(
680 gfx::Quaternion(gfx::Vector3dF(1, 0, 0), 0.0));
681 exclusive_screen_toast_->set_lock_to_fov(false);
682 } else if (web_vr_mode_ && web_vr_show_toast_) {
683 exclusive_screen_toast_->set_scale(
684 {kWebVrToastDistance, kWebVrToastDistance, 1});
685 exclusive_screen_toast_->set_translation(
686 gfx::Vector3dF(0, kWebVrToastDistance * sin(kWebVrAngleRadians),
687 -kWebVrToastDistance * cos(kWebVrAngleRadians)));
688 exclusive_screen_toast_->set_rotation(
689 gfx::Quaternion(gfx::Vector3dF(1, 0, 0), kWebVrAngleRadians));
690 exclusive_screen_toast_->set_lock_to_fov(true);
691 }
665 exclusive_screen_toast_->set_visible(toast_visible); 692 exclusive_screen_toast_->set_visible(toast_visible);
666 if (toast_visible) { 693 if (toast_visible) {
667 exclusive_screen_toast_timer_.Start( 694 exclusive_screen_toast_timer_.Start(
668 FROM_HERE, base::TimeDelta::FromSeconds(kToastTimeoutSeconds), this, 695 FROM_HERE, base::TimeDelta::FromSeconds(kToastTimeoutSeconds), this,
669 &UiSceneManager::OnExclusiveScreenToastTimer); 696 &UiSceneManager::OnExclusiveScreenToastTimer);
670 } else { 697 } else {
671 exclusive_screen_toast_timer_.Stop(); 698 exclusive_screen_toast_timer_.Stop();
672 } 699 }
673 toast_state_ = UNCHANGED; 700 toast_state_ = UNCHANGED;
674 } 701 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 if (fullscreen_) 816 if (fullscreen_)
790 return ColorScheme::kModeFullscreen; 817 return ColorScheme::kModeFullscreen;
791 return ColorScheme::kModeNormal; 818 return ColorScheme::kModeNormal;
792 } 819 }
793 820
794 const ColorScheme& UiSceneManager::color_scheme() const { 821 const ColorScheme& UiSceneManager::color_scheme() const {
795 return ColorScheme::GetColorScheme(mode()); 822 return ColorScheme::GetColorScheme(mode());
796 } 823 }
797 824
798 } // namespace vr_shell 825 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_elements/simple_textured_element.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698