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

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

Issue 2914623003: [VrShell] Centralize color handling and enable close button on fullscreen (Closed)
Patch Set: clean up after rebase 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"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 : browser_(browser), 82 : browser_(browser),
83 scene_(scene), 83 scene_(scene),
84 in_cct_(in_cct), 84 in_cct_(in_cct),
85 web_vr_mode_(in_web_vr), 85 web_vr_mode_(in_web_vr),
86 weak_ptr_factory_(this) { 86 weak_ptr_factory_(this) {
87 CreateBackground(); 87 CreateBackground();
88 CreateContentQuad(); 88 CreateContentQuad();
89 CreateSecurityWarnings(); 89 CreateSecurityWarnings();
90 CreateSystemIndicators(); 90 CreateSystemIndicators();
91 CreateUrlBar(); 91 CreateUrlBar();
92 if (in_cct_) 92 CreateCloseButton();
93 CreateCloseButton();
94 CreateScreenDimmer(); 93 CreateScreenDimmer();
95 94
96 ConfigureScene(); 95 ConfigureScene();
97 ConfigureSecurityWarnings(); 96 ConfigureSecurityWarnings();
98 } 97 }
99 98
100 UiSceneManager::~UiSceneManager() {} 99 UiSceneManager::~UiSceneManager() {}
101 100
102 void UiSceneManager::CreateScreenDimmer() { 101 void UiSceneManager::CreateScreenDimmer() {
103 std::unique_ptr<UiElement> element; 102 std::unique_ptr<UiElement> element;
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 std::unique_ptr<Button> element = base::MakeUnique<Button>( 289 std::unique_ptr<Button> element = base::MakeUnique<Button>(
291 base::Bind(&UiSceneManager::OnCloseButtonClicked, base::Unretained(this)), 290 base::Bind(&UiSceneManager::OnCloseButtonClicked, base::Unretained(this)),
292 base::MakeUnique<CloseButtonTexture>()); 291 base::MakeUnique<CloseButtonTexture>());
293 element->set_debug_id(kCloseButton); 292 element->set_debug_id(kCloseButton);
294 element->set_id(AllocateId()); 293 element->set_id(AllocateId());
295 element->set_fill(vr_shell::Fill::NONE); 294 element->set_fill(vr_shell::Fill::NONE);
296 element->set_translation( 295 element->set_translation(
297 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, 296 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3,
298 -kContentDistance + 0.4)); 297 -kContentDistance + 0.4));
299 element->set_size(gfx::Vector3dF(0.2, 0.2, 1)); 298 element->set_size(gfx::Vector3dF(0.2, 0.2, 1));
300 control_elements_.push_back(element.get()); 299 close_button_ = element.get();
301 scene_->AddUiElement(std::move(element)); 300 scene_->AddUiElement(std::move(element));
302 } 301 }
303 302
304 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 303 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
305 return weak_ptr_factory_.GetWeakPtr(); 304 return weak_ptr_factory_.GetWeakPtr();
306 } 305 }
307 306
308 void UiSceneManager::SetWebVrMode(bool web_vr) { 307 void UiSceneManager::SetWebVrMode(bool web_vr) {
309 if (web_vr_mode_ == web_vr) 308 if (web_vr_mode_ == web_vr)
310 return; 309 return;
311 web_vr_mode_ = web_vr; 310 web_vr_mode_ = web_vr;
312 ConfigureScene(); 311 ConfigureScene();
313 ConfigureSecurityWarnings(); 312 ConfigureSecurityWarnings();
314 audio_capture_indicator_->set_visible(!web_vr && audio_capturing_); 313 audio_capture_indicator_->set_visible(!web_vr && audio_capturing_);
315 video_capture_indicator_->set_visible(!web_vr && video_capturing_); 314 video_capture_indicator_->set_visible(!web_vr && video_capturing_);
316 screen_capture_indicator_->set_visible(!web_vr && screen_capturing_); 315 screen_capture_indicator_->set_visible(!web_vr && screen_capturing_);
317 } 316 }
318 317
319 void UiSceneManager::ConfigureScene() { 318 void UiSceneManager::ConfigureScene() {
320 exit_warning_->SetEnabled(scene_->is_exiting()); 319 exit_warning_->SetEnabled(scene_->is_exiting());
321 screen_dimmer_->SetEnabled(scene_->is_exiting()); 320 screen_dimmer_->SetEnabled(scene_->is_exiting());
322 321
323 // Controls (URL bar, loading progress, etc). 322 // Controls (URL bar, loading progress, etc).
324 bool controls_visible = !web_vr_mode_ && !fullscreen_; 323 bool controls_visible = !web_vr_mode_ && !fullscreen_;
325 for (UiElement* element : control_elements_) { 324 for (UiElement* element : control_elements_) {
326 element->SetEnabled(controls_visible); 325 element->SetEnabled(controls_visible);
327 } 326 }
328 327
328 // Close button is a special control element that needs to be hidden when in
329 // WebVR, but it needs to be visible when in cct or fullscreen.
330 close_button_->SetEnabled(!web_vr_mode_ && (fullscreen_ || in_cct_));
331
329 // Content elements. 332 // Content elements.
330 for (UiElement* element : content_elements_) { 333 for (UiElement* element : content_elements_) {
331 element->SetEnabled(!web_vr_mode_); 334 element->SetEnabled(!web_vr_mode_);
332 } 335 }
333 336
334 // Update content quad parameters depending on fullscreen. 337 // Update content quad parameters depending on fullscreen.
335 // TODO(http://crbug.com/642937): Animate fullscreen transitions. 338 // TODO(http://crbug.com/642937): Animate fullscreen transitions.
336 if (fullscreen_) { 339 if (fullscreen_) {
337 main_content_->set_translation( 340 main_content_->set_translation(
338 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); 341 {0, kFullscreenVerticalOffset, -kFullscreenDistance});
339 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); 342 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1});
343
344 close_button_->set_translation(gfx::Vector3dF(
345 0, kFullscreenVerticalOffset - (kFullscreenHeight / 2) - 0.1,
346 -kFullscreenDistance + 0.4));
340 } else { 347 } else {
341 // Note that main_content_ is already visible in this case. 348 // Note that main_content_ is already visible in this case.
342 main_content_->set_translation( 349 main_content_->set_translation(
343 {0, kContentVerticalOffset, -kContentDistance}); 350 {0, kContentVerticalOffset, -kContentDistance});
344 main_content_->set_size({kContentWidth, kContentHeight, 1}); 351 main_content_->set_size({kContentWidth, kContentHeight, 1});
352
353 close_button_->set_translation(
354 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3,
355 -kContentDistance + 0.4));
345 } 356 }
346 357
347 scene_->SetMode(mode()); 358 scene_->SetMode(mode());
348 scene_->SetBackgroundDistance(main_content_->translation().z() * 359 scene_->SetBackgroundDistance(main_content_->translation().z() *
349 -kBackgroundDistanceMultiplier); 360 -kBackgroundDistanceMultiplier);
350 UpdateBackgroundColor(); 361 UpdateBackgroundColor();
351 } 362 }
352 363
353 void UiSceneManager::UpdateBackgroundColor() { 364 void UiSceneManager::UpdateBackgroundColor() {
354 // TODO(vollick): it would be nice if ceiling, floor and the grid were 365 // TODO(vollick): it would be nice if ceiling, floor and the grid were
355 // UiElement subclasses and could respond to the OnSetMode signal. 366 // UiElement subclasses and could respond to the OnSetMode signal.
356 ceiling_->set_center_color(color_scheme().ceiling); 367 ceiling_->set_center_color(color_scheme().ceiling);
357 ceiling_->set_edge_color(color_scheme().horizon); 368 ceiling_->set_edge_color(color_scheme().world_background);
358 floor_->set_center_color(color_scheme().floor); 369 floor_->set_center_color(color_scheme().floor);
359 floor_->set_edge_color(color_scheme().horizon); 370 floor_->set_edge_color(color_scheme().world_background);
360 floor_->set_grid_color(color_scheme().floor_grid); 371 floor_->set_grid_color(color_scheme().floor_grid);
361 } 372 }
362 373
363 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { 374 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
364 audio_capturing_ = enabled; 375 audio_capturing_ = enabled;
365 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); 376 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_);
366 } 377 }
367 378
368 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { 379 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) {
369 video_capturing_ = enabled; 380 video_capturing_ = enabled;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 scene_->set_is_exiting(); 457 scene_->set_is_exiting();
447 ConfigureScene(); 458 ConfigureScene();
448 } 459 }
449 460
450 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, 461 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back,
451 bool can_go_forward) { 462 bool can_go_forward) {
452 url_bar_->SetHistoryButtonsEnabled(can_go_back); 463 url_bar_->SetHistoryButtonsEnabled(can_go_back);
453 } 464 }
454 465
455 void UiSceneManager::OnCloseButtonClicked() { 466 void UiSceneManager::OnCloseButtonClicked() {
456 browser_->ExitCct(); 467 if (fullscreen_) {
468 browser_->ExitFullscreen();
469 }
470 if (in_cct_) {
471 browser_->ExitCct();
472 }
457 } 473 }
458 474
459 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { 475 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) {
460 browser_->OnUnsupportedMode(mode); 476 browser_->OnUnsupportedMode(mode);
461 } 477 }
462 478
463 int UiSceneManager::AllocateId() { 479 int UiSceneManager::AllocateId() {
464 return next_available_id_++; 480 return next_available_id_++;
465 } 481 }
466 482
467 ColorScheme::Mode UiSceneManager::mode() const { 483 ColorScheme::Mode UiSceneManager::mode() const {
468 if (incognito_) 484 if (incognito_)
469 return ColorScheme::kModeIncognito; 485 return ColorScheme::kModeIncognito;
470 if (fullscreen_) 486 if (fullscreen_)
471 return ColorScheme::kModeFullscreen; 487 return ColorScheme::kModeFullscreen;
472 return ColorScheme::kModeNormal; 488 return ColorScheme::kModeNormal;
473 } 489 }
474 490
475 const ColorScheme& UiSceneManager::color_scheme() const { 491 const ColorScheme& UiSceneManager::color_scheme() const {
476 return ColorScheme::GetColorScheme(mode()); 492 return ColorScheme::GetColorScheme(mode());
477 } 493 }
478 494
479 } // namespace vr_shell 495 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698