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

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene.h

Issue 2807293002: VR: Rename ContentRectangle to UiElement (Closed)
Patch Set: Rebase onto Michael's landed GVR types CL. Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "device/vr/vr_types.h" 12 #include "device/vr/vr_types.h"
13 13
14 namespace base { 14 namespace base {
15 class DictionaryValue; 15 class DictionaryValue;
16 class ListValue; 16 class ListValue;
17 class TimeTicks; 17 class TimeTicks;
18 } 18 }
19 19
20 namespace vr_shell { 20 namespace vr_shell {
21 21
22 class Animation; 22 class Animation;
23 struct ContentRectangle; 23 struct UiElement;
24 24
25 class UiScene { 25 class UiScene {
26 public: 26 public:
27 enum Command { 27 enum Command {
28 ADD_ELEMENT, 28 ADD_ELEMENT,
29 UPDATE_ELEMENT, 29 UPDATE_ELEMENT,
30 REMOVE_ELEMENT, 30 REMOVE_ELEMENT,
31 ADD_ANIMATION, 31 ADD_ANIMATION,
32 REMOVE_ANIMATION, 32 REMOVE_ANIMATION,
33 CONFIGURE_SCENE, 33 CONFIGURE_SCENE,
34 }; 34 };
35 35
36 UiScene(); 36 UiScene();
37 virtual ~UiScene(); 37 virtual ~UiScene();
38 38
39 void AddUiElement(std::unique_ptr<ContentRectangle> element); 39 void AddUiElement(std::unique_ptr<UiElement> element);
40 40
41 // Add a UI element according to a dictionary passed from the UI HTML. 41 // Add a UI element according to a dictionary passed from the UI HTML.
42 void AddUiElementFromDict(const base::DictionaryValue& dict); 42 void AddUiElementFromDict(const base::DictionaryValue& dict);
43 43
44 // Update an existing element with new properties. 44 // Update an existing element with new properties.
45 void UpdateUiElementFromDict(const base::DictionaryValue& dict); 45 void UpdateUiElementFromDict(const base::DictionaryValue& dict);
46 46
47 void RemoveUiElement(int element_id); 47 void RemoveUiElement(int element_id);
48 48
49 // Add an animation to the scene, on element |element_id|. 49 // Add an animation to the scene, on element |element_id|.
50 void AddAnimation(int element_id, std::unique_ptr<Animation> animation); 50 void AddAnimation(int element_id, std::unique_ptr<Animation> animation);
51 51
52 // Add an animation according to a dictionary passed from the UI HTML. 52 // Add an animation according to a dictionary passed from the UI HTML.
53 void AddAnimationFromDict(const base::DictionaryValue& dict, 53 void AddAnimationFromDict(const base::DictionaryValue& dict,
54 const base::TimeTicks& current_time); 54 const base::TimeTicks& current_time);
55 55
56 // Remove |animation_id| from element |element_id|. 56 // Remove |animation_id| from element |element_id|.
57 void RemoveAnimation(int element_id, int animation_id); 57 void RemoveAnimation(int element_id, int animation_id);
58 58
59 // Update the positions of all elements in the scene, according to active 59 // Update the positions of all elements in the scene, according to active
60 // animations and time. The units of time are arbitrary, but must match the 60 // animations and time. The units of time are arbitrary, but must match the
61 // unit used in animations. 61 // unit used in animations.
62 void UpdateTransforms(const base::TimeTicks& current_time); 62 void UpdateTransforms(const base::TimeTicks& current_time);
63 63
64 // Handle a batch of commands passed from the UI HTML. 64 // Handle a batch of commands passed from the UI HTML.
65 void HandleCommands(std::unique_ptr<base::ListValue> commands, 65 void HandleCommands(std::unique_ptr<base::ListValue> commands,
66 const base::TimeTicks& current_time); 66 const base::TimeTicks& current_time);
67 67
68 const std::vector<std::unique_ptr<ContentRectangle>>& GetUiElements() const; 68 const std::vector<std::unique_ptr<UiElement>>& GetUiElements() const;
69 69
70 ContentRectangle* GetUiElementById(int element_id); 70 UiElement* GetUiElementById(int element_id);
71 71
72 std::vector<const ContentRectangle*> GetWorldElements() const; 72 std::vector<const UiElement*> GetWorldElements() const;
73 std::vector<const ContentRectangle*> GetHeadLockedElements() const; 73 std::vector<const UiElement*> GetHeadLockedElements() const;
74 bool HasVisibleHeadLockedElements() const; 74 bool HasVisibleHeadLockedElements() const;
75 75
76 const vr::Colorf& GetBackgroundColor() const; 76 const vr::Colorf& GetBackgroundColor() const;
77 float GetBackgroundDistance() const; 77 float GetBackgroundDistance() const;
78 bool GetWebVrRenderingEnabled() const; 78 bool GetWebVrRenderingEnabled() const;
79 79
80 private: 80 private:
81 void ApplyRecursiveTransforms(ContentRectangle* element); 81 void ApplyRecursiveTransforms(UiElement* element);
82 void ApplyDictToElement(const base::DictionaryValue& dict, 82 void ApplyDictToElement(const base::DictionaryValue& dict,
83 ContentRectangle* element); 83 UiElement* element);
84 84
85 std::vector<std::unique_ptr<ContentRectangle>> ui_elements_; 85 std::vector<std::unique_ptr<UiElement>> ui_elements_;
86 ContentRectangle* content_element_ = nullptr; 86 UiElement* content_element_ = nullptr;
87 vr::Colorf background_color_ = {0.1f, 0.1f, 0.1f, 1.0f}; 87 vr::Colorf background_color_ = {0.1f, 0.1f, 0.1f, 1.0f};
88 float background_distance_ = 10.0f; 88 float background_distance_ = 10.0f;
89 bool webvr_rendering_enabled_ = true; 89 bool webvr_rendering_enabled_ = true;
90 90
91 DISALLOW_COPY_AND_ASSIGN(UiScene); 91 DISALLOW_COPY_AND_ASSIGN(UiScene);
92 }; 92 };
93 93
94 } // namespace vr_shell 94 } // namespace vr_shell
95 95
96 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_ 96 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_SCENE_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_elements_unittest.cc ('k') | chrome/browser/android/vr_shell/ui_scene.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698