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

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

Issue 2878543002: Refactor VR Shell Input. Locks input to click/scroll targets. (Closed)
Patch Set: Address comments Created 3 years, 7 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/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
8 #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/close_button.h"
9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" 11 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h"
10 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" 12 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h"
11 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 13 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
12 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" 14 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h"
13 #include "chrome/browser/android/vr_shell/ui_scene.h" 15 #include "chrome/browser/android/vr_shell/ui_scene.h"
14 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" 16 #include "chrome/browser/android/vr_shell/vr_browser_interface.h"
15 #include "chrome/browser/android/vr_shell/vr_shell.h" 17 #include "chrome/browser/android/vr_shell/vr_shell.h"
16 18
17 namespace vr_shell { 19 namespace vr_shell {
18 20
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool in_web_vr) 62 bool in_web_vr)
61 : browser_(browser), 63 : browser_(browser),
62 scene_(scene), 64 scene_(scene),
63 in_cct_(in_cct), 65 in_cct_(in_cct),
64 web_vr_mode_(in_web_vr), 66 web_vr_mode_(in_web_vr),
65 weak_ptr_factory_(this) { 67 weak_ptr_factory_(this) {
66 CreateBackground(); 68 CreateBackground();
67 CreateContentQuad(); 69 CreateContentQuad();
68 CreateSecurityWarnings(); 70 CreateSecurityWarnings();
69 CreateUrlBar(); 71 CreateUrlBar();
72
73 if (in_cct_)
74 CreateCloseButton();
70 } 75 }
71 76
72 UiSceneManager::~UiSceneManager() {} 77 UiSceneManager::~UiSceneManager() {}
73 78
74 void UiSceneManager::CreateSecurityWarnings() { 79 void UiSceneManager::CreateSecurityWarnings() {
75 std::unique_ptr<UiElement> element; 80 std::unique_ptr<UiElement> element;
76 81
77 // TODO(mthiesse): Programatically compute the proper texture size for these 82 // TODO(mthiesse): Programatically compute the proper texture size for these
78 // textured UI elements. 83 // textured UI elements.
79 element = base::MakeUnique<PermanentSecurityWarning>(512); 84 element = base::MakeUnique<PermanentSecurityWarning>(512);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 element->set_draw_phase(0); 188 element->set_draw_phase(0);
184 browser_ui_elements_.push_back(element.get()); 189 browser_ui_elements_.push_back(element.get());
185 scene_->AddUiElement(std::move(element)); 190 scene_->AddUiElement(std::move(element));
186 191
187 scene_->SetBackgroundColor(horizon); 192 scene_->SetBackgroundColor(horizon);
188 } 193 }
189 194
190 void UiSceneManager::CreateUrlBar() { 195 void UiSceneManager::CreateUrlBar() {
191 // TODO(cjgrant): Incorporate final size and position. 196 // TODO(cjgrant): Incorporate final size and position.
192 // TODO(cjgrant): Add the loading progress indicator element. 197 // TODO(cjgrant): Add the loading progress indicator element.
193 auto element = base::MakeUnique<UrlBar>(512); 198 std::unique_ptr<UrlBar> element = base::MakeUnique<UrlBar>(512);
194 element->set_id(AllocateId()); 199 element->set_id(AllocateId());
195 element->set_translation({0, -0.9, -1.8}); 200 element->set_translation({0, -0.9, -1.8});
196 element->set_size({0.9, 0, 1}); 201 element->set_size({0.9, 0, 1});
197 element->SetBackButtonCallback( 202 element->SetBackButtonCallback(
198 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); 203 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this)));
199 url_bar_ = element.get(); 204 url_bar_ = element.get();
200 browser_ui_elements_.push_back(element.get()); 205 browser_ui_elements_.push_back(element.get());
201 scene_->AddUiElement(std::move(element)); 206 scene_->AddUiElement(std::move(element));
202 } 207 }
203 208
209 void UiSceneManager::CreateCloseButton() {
210 std::unique_ptr<CloseButton> element =
211 base::MakeUnique<CloseButton>(base::Bind(
212 &UiSceneManager::OnCloseButtonClicked, base::Unretained(this)));
213 element->set_id(AllocateId());
214 element->set_fill(vr_shell::Fill::NONE);
215 element->set_translation(
216 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3,
217 -kContentDistance + 0.4));
218 element->set_size(gfx::Vector3dF(0.2, 0.2, 1));
219 browser_ui_elements_.push_back(element.get());
220 scene_->AddUiElement(std::move(element));
221 }
222
204 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 223 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
205 return weak_ptr_factory_.GetWeakPtr(); 224 return weak_ptr_factory_.GetWeakPtr();
206 } 225 }
207 226
208 void UiSceneManager::SetWebVrMode(bool web_vr) { 227 void UiSceneManager::SetWebVrMode(bool web_vr) {
209 web_vr_mode_ = web_vr; 228 web_vr_mode_ = web_vr;
210 229
211 // Make all VR scene UI elements visible if not in WebVR. 230 // Make all VR scene UI elements visible if not in WebVR.
212 for (UiElement* element : browser_ui_elements_) { 231 for (UiElement* element : browser_ui_elements_) {
213 element->set_visible(!web_vr_mode_); 232 element->set_visible(!web_vr_mode_);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 url_bar_->SetSecurityLevel(level); 308 url_bar_->SetSecurityLevel(level);
290 } 309 }
291 310
292 void UiSceneManager::SetLoading(bool loading) {} 311 void UiSceneManager::SetLoading(bool loading) {}
293 312
294 void UiSceneManager::SetLoadProgress(double progress) {} 313 void UiSceneManager::SetLoadProgress(double progress) {}
295 314
296 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, 315 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back,
297 bool can_go_forward) {} 316 bool can_go_forward) {}
298 317
318 void UiSceneManager::OnCloseButtonClicked() {}
319
299 int UiSceneManager::AllocateId() { 320 int UiSceneManager::AllocateId() {
300 return next_available_id_++; 321 return next_available_id_++;
301 } 322 }
302 323
303 } // namespace vr_shell 324 } // 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_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698