Commit e1b82558 authored by Ian Vollick's avatar Ian Vollick Committed by Commit Bot

[vr] support visibility transitions

This allows transitions on UiElements to leverage visibility animations.

Bug: None
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I5c362d2d6b90de5fa9702660ef7b3decaa0c0ff2
Reviewed-on: https://chromium-review.googlesource.com/579827
Commit-Queue: Ian Vollick <vollick@chromium.org>
Reviewed-by: default avatarYash Malik <ymalik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488470}
parent 8088b622
...@@ -301,6 +301,93 @@ void AnimationPlayer::TransitionBoundsTo(base::TimeTicks monotonic_time, ...@@ -301,6 +301,93 @@ void AnimationPlayer::TransitionBoundsTo(base::TimeTicks monotonic_time,
cc::TargetProperty::BOUNDS)); cc::TargetProperty::BOUNDS));
} }
void AnimationPlayer::TransitionBackgroundColorTo(
base::TimeTicks monotonic_time,
SkColor current,
SkColor target) {
DCHECK(target_);
if (!transition_.target_properties[cc::TargetProperty::BACKGROUND_COLOR]) {
target_->NotifyClientBackgroundColorAnimated(target, nullptr);
return;
}
cc::Animation* running_animation =
GetRunningAnimationForProperty(cc::TargetProperty::BACKGROUND_COLOR);
if (running_animation) {
const cc::ColorAnimationCurve* curve =
running_animation->curve()->ToColorAnimationCurve();
if (target == curve->GetValue(GetEndTime(running_animation))) {
return;
}
if (target == curve->GetValue(GetStartTime(running_animation))) {
ReverseAnimation(monotonic_time, running_animation);
return;
}
} else if (target == current) {
return;
}
RemoveAnimations(cc::TargetProperty::BACKGROUND_COLOR);
std::unique_ptr<cc::KeyframedColorAnimationCurve> curve(
cc::KeyframedColorAnimationCurve::Create());
curve->AddKeyframe(cc::ColorKeyframe::Create(
base::TimeDelta(), current, CreateTransitionTimingFunction()));
curve->AddKeyframe(cc::ColorKeyframe::Create(
transition_.duration, target, CreateTransitionTimingFunction()));
AddAnimation(cc::Animation::Create(std::move(curve), GetNextAnimationId(),
GetNextGroupId(),
cc::TargetProperty::BACKGROUND_COLOR));
}
void AnimationPlayer::TransitionVisibilityTo(base::TimeTicks monotonic_time,
bool current,
bool target) {
DCHECK(target_);
if (!transition_.target_properties[cc::TargetProperty::VISIBILITY]) {
target_->NotifyClientVisibilityAnimated(target, nullptr);
return;
}
cc::Animation* running_animation =
GetRunningAnimationForProperty(cc::TargetProperty::VISIBILITY);
if (running_animation) {
const cc::BooleanAnimationCurve* curve =
running_animation->curve()->ToBooleanAnimationCurve();
if (target == curve->GetValue(GetEndTime(running_animation))) {
return;
}
if (target == curve->GetValue(GetStartTime(running_animation))) {
ReverseAnimation(monotonic_time, running_animation);
return;
}
} else if (target == current) {
return;
}
RemoveAnimations(cc::TargetProperty::VISIBILITY);
std::unique_ptr<cc::KeyframedBooleanAnimationCurve> curve(
cc::KeyframedBooleanAnimationCurve::Create());
curve->AddKeyframe(cc::BooleanKeyframe::Create(
base::TimeDelta(), current, CreateTransitionTimingFunction()));
curve->AddKeyframe(cc::BooleanKeyframe::Create(
transition_.duration, target, CreateTransitionTimingFunction()));
AddAnimation(cc::Animation::Create(std::move(curve), GetNextAnimationId(),
GetNextGroupId(),
cc::TargetProperty::VISIBILITY));
}
cc::Animation* AnimationPlayer::GetRunningAnimationForProperty( cc::Animation* AnimationPlayer::GetRunningAnimationForProperty(
cc::TargetProperty::Type target_property) const { cc::TargetProperty::Type target_property) const {
for (auto& animation : animations_) { for (auto& animation : animations_) {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "cc/animation/animation.h" #include "cc/animation/animation.h"
#include "cc/trees/target_property.h" #include "cc/trees/target_property.h"
#include "chrome/browser/vr/transition.h" #include "chrome/browser/vr/transition.h"
#include "third_party/skia/include/core/SkColor.h"
namespace cc { namespace cc {
class AnimationTarget; class AnimationTarget;
...@@ -72,6 +73,12 @@ class AnimationPlayer final { ...@@ -72,6 +73,12 @@ class AnimationPlayer final {
void TransitionBoundsTo(base::TimeTicks monotonic_time, void TransitionBoundsTo(base::TimeTicks monotonic_time,
const gfx::SizeF& current, const gfx::SizeF& current,
const gfx::SizeF& target); const gfx::SizeF& target);
void TransitionBackgroundColorTo(base::TimeTicks monotonic_time,
SkColor current,
SkColor target);
void TransitionVisibilityTo(base::TimeTicks monotonic_time,
bool current,
bool target);
bool IsAnimatingProperty(cc::TargetProperty::Type property) const; bool IsAnimatingProperty(cc::TargetProperty::Type property) const;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "chrome/browser/vr/test/animation_utils.h" #include "chrome/browser/vr/test/animation_utils.h"
#include "chrome/browser/vr/transition.h" #include "chrome/browser/vr/transition.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/test/gfx_util.h" #include "ui/gfx/test/gfx_util.h"
namespace vr { namespace vr {
...@@ -24,6 +25,8 @@ class TestAnimationTarget : public cc::AnimationTarget { ...@@ -24,6 +25,8 @@ class TestAnimationTarget : public cc::AnimationTarget {
const gfx::SizeF& size() const { return size_; } const gfx::SizeF& size() const { return size_; }
const cc::TransformOperations& operations() const { return operations_; } const cc::TransformOperations& operations() const { return operations_; }
float opacity() const { return opacity_; } float opacity() const { return opacity_; }
SkColor background_color() const { return background_color_; }
bool visible() const { return visible_; }
void NotifyClientBoundsAnimated(const gfx::SizeF& size, void NotifyClientBoundsAnimated(const gfx::SizeF& size,
cc::Animation* animation) override { cc::Animation* animation) override {
...@@ -41,10 +44,22 @@ class TestAnimationTarget : public cc::AnimationTarget { ...@@ -41,10 +44,22 @@ class TestAnimationTarget : public cc::AnimationTarget {
opacity_ = opacity; opacity_ = opacity;
} }
void NotifyClientBackgroundColorAnimated(SkColor color,
cc::Animation* animation) override {
background_color_ = color;
}
void NotifyClientVisibilityAnimated(bool visible,
cc::Animation* animation) override {
visible_ = visible;
}
private: private:
cc::TransformOperations operations_; cc::TransformOperations operations_;
gfx::SizeF size_ = {10.0f, 10.0f}; gfx::SizeF size_ = {10.0f, 10.0f};
float opacity_ = 1.0f; float opacity_ = 1.0f;
SkColor background_color_ = SK_ColorRED;
bool visible_ = true;
}; };
TEST(AnimationPlayerTest, AddRemoveAnimations) { TEST(AnimationPlayerTest, AddRemoveAnimations) {
...@@ -363,6 +378,135 @@ TEST(AnimationPlayerTest, ReversedBoundsTransitions) { ...@@ -363,6 +378,135 @@ TEST(AnimationPlayerTest, ReversedBoundsTransitions) {
EXPECT_FLOAT_SIZE_EQ(from, target.size()); EXPECT_FLOAT_SIZE_EQ(from, target.size());
} }
TEST(AnimationPlayerTest, BackgroundColorTransitions) {
TestAnimationTarget target;
AnimationPlayer player;
player.set_target(&target);
Transition transition;
transition.target_properties[cc::TargetProperty::BACKGROUND_COLOR] = true;
transition.duration = UsToDelta(10000);
player.set_transition(transition);
base::TimeTicks start_time = UsToTicks(1000000);
player.Tick(start_time);
SkColor from = SK_ColorRED;
SkColor to = SK_ColorGREEN;
player.TransitionBackgroundColorTo(start_time, from, to);
EXPECT_EQ(from, target.background_color());
player.Tick(start_time);
player.Tick(start_time + UsToDelta(5000));
EXPECT_GT(SkColorGetR(from), SkColorGetR(target.background_color()));
EXPECT_LT(SkColorGetR(to), SkColorGetR(target.background_color()));
EXPECT_LT(SkColorGetG(from), SkColorGetG(target.background_color()));
EXPECT_GT(SkColorGetG(to), SkColorGetG(target.background_color()));
EXPECT_EQ(0u, SkColorGetB(target.background_color()));
EXPECT_EQ(255u, SkColorGetA(target.background_color()));
player.Tick(start_time + UsToDelta(10000));
EXPECT_EQ(to, target.background_color());
}
TEST(AnimationPlayerTest, ReversedBackgroundColorTransitions) {
TestAnimationTarget target;
AnimationPlayer player;
player.set_target(&target);
Transition transition;
transition.target_properties[cc::TargetProperty::BACKGROUND_COLOR] = true;
transition.duration = UsToDelta(10000);
player.set_transition(transition);
base::TimeTicks start_time = UsToTicks(1000000);
player.Tick(start_time);
SkColor from = SK_ColorRED;
SkColor to = SK_ColorGREEN;
player.TransitionBackgroundColorTo(start_time, from, to);
EXPECT_EQ(from, target.background_color());
player.Tick(start_time);
player.Tick(start_time + UsToDelta(1000));
SkColor value_before_reversing = target.background_color();
EXPECT_GT(SkColorGetR(from), SkColorGetR(target.background_color()));
EXPECT_LT(SkColorGetR(to), SkColorGetR(target.background_color()));
EXPECT_LT(SkColorGetG(from), SkColorGetG(target.background_color()));
EXPECT_GT(SkColorGetG(to), SkColorGetG(target.background_color()));
EXPECT_EQ(0u, SkColorGetB(target.background_color()));
EXPECT_EQ(255u, SkColorGetA(target.background_color()));
player.TransitionBackgroundColorTo(start_time + UsToDelta(1000),
target.background_color(), from);
player.Tick(start_time + UsToDelta(1000));
EXPECT_EQ(value_before_reversing, target.background_color());
player.Tick(start_time + UsToDelta(2000));
EXPECT_EQ(from, target.background_color());
}
TEST(AnimationPlayerTest, VisibilityTransitions) {
TestAnimationTarget target;
AnimationPlayer player;
player.set_target(&target);
Transition transition;
transition.target_properties[cc::TargetProperty::VISIBILITY] = true;
transition.duration = UsToDelta(10000);
player.set_transition(transition);
base::TimeTicks start_time = UsToTicks(1000000);
player.Tick(start_time);
bool from = true;
bool to = false;
player.TransitionVisibilityTo(start_time, from, to);
EXPECT_EQ(from, target.visible());
player.Tick(start_time);
player.Tick(start_time + UsToDelta(5000));
EXPECT_EQ(from, target.visible());
player.Tick(start_time + UsToDelta(10000));
EXPECT_EQ(to, target.visible());
}
TEST(AnimationPlayerTest, ReversedVisibilityTransitions) {
TestAnimationTarget target;
AnimationPlayer player;
player.set_target(&target);
Transition transition;
transition.target_properties[cc::TargetProperty::VISIBILITY] = true;
transition.duration = UsToDelta(10000);
player.set_transition(transition);
base::TimeTicks start_time = UsToTicks(1000000);
player.Tick(start_time);
bool from = true;
bool to = false;
player.TransitionVisibilityTo(start_time, from, to);
EXPECT_EQ(from, target.visible());
player.Tick(start_time);
EXPECT_EQ(from, target.visible());
player.Tick(start_time);
player.Tick(start_time + UsToDelta(1000));
bool value_before_reversing = target.visible();
EXPECT_EQ(from, value_before_reversing);
player.TransitionVisibilityTo(start_time + UsToDelta(1000), target.visible(),
from);
player.Tick(start_time + UsToDelta(1000));
EXPECT_EQ(value_before_reversing, target.visible());
player.Tick(start_time + UsToDelta(2000));
EXPECT_EQ(from, target.visible());
}
TEST(AnimationPlayerTest, DoubleReversedTransitions) { TEST(AnimationPlayerTest, DoubleReversedTransitions) {
TestAnimationTarget target; TestAnimationTarget target;
AnimationPlayer player; AnimationPlayer player;
......
...@@ -13,7 +13,7 @@ TEST(LinearLayout, HorizontalLayout) { ...@@ -13,7 +13,7 @@ TEST(LinearLayout, HorizontalLayout) {
layout.set_margin(10); layout.set_margin(10);
UiElement rect_a; UiElement rect_a;
rect_a.SetSize(10, 10); rect_a.SetSize(10, 10);
rect_a.set_visible(true); rect_a.SetVisible(true);
layout.AddChild(&rect_a); layout.AddChild(&rect_a);
// One element should require no position adjustment at all. // One element should require no position adjustment at all.
...@@ -23,7 +23,7 @@ TEST(LinearLayout, HorizontalLayout) { ...@@ -23,7 +23,7 @@ TEST(LinearLayout, HorizontalLayout) {
// Two elements should be centered and separated by the margin. // Two elements should be centered and separated by the margin.
UiElement rect_b; UiElement rect_b;
rect_b.SetSize(20, 20); rect_b.SetSize(20, 20);
rect_b.set_visible(true); rect_b.SetVisible(true);
layout.AddChild(&rect_b); layout.AddChild(&rect_b);
layout.LayOutChildren(); layout.LayOutChildren();
...@@ -35,7 +35,7 @@ TEST(LinearLayout, HorizontalLayout) { ...@@ -35,7 +35,7 @@ TEST(LinearLayout, HorizontalLayout) {
EXPECT_FLOAT_EQ(0.0f, rect_b.transform_operations().at(0).translate.y); EXPECT_FLOAT_EQ(0.0f, rect_b.transform_operations().at(0).translate.y);
EXPECT_FLOAT_EQ(0.0f, rect_b.transform_operations().at(0).translate.z); EXPECT_FLOAT_EQ(0.0f, rect_b.transform_operations().at(0).translate.z);
rect_a.set_visible(false); rect_a.SetVisible(false);
layout.LayOutChildren(); layout.LayOutChildren();
// The invisible child should not be accounted for in the layout. // The invisible child should not be accounted for in the layout.
EXPECT_TRUE(rect_b.transform_operations().Apply().IsIdentity()); EXPECT_TRUE(rect_b.transform_operations().Apply().IsIdentity());
...@@ -46,7 +46,7 @@ TEST(LinearLayout, VerticalLayout) { ...@@ -46,7 +46,7 @@ TEST(LinearLayout, VerticalLayout) {
layout.set_margin(10); layout.set_margin(10);
UiElement rect_a; UiElement rect_a;
rect_a.SetSize(10, 10); rect_a.SetSize(10, 10);
rect_a.set_visible(true); rect_a.SetVisible(true);
layout.AddChild(&rect_a); layout.AddChild(&rect_a);
// One element should require no position adjustment at all. // One element should require no position adjustment at all.
...@@ -56,7 +56,7 @@ TEST(LinearLayout, VerticalLayout) { ...@@ -56,7 +56,7 @@ TEST(LinearLayout, VerticalLayout) {
// Two elements should be centered and separated by the margin. // Two elements should be centered and separated by the margin.
UiElement rect_b; UiElement rect_b;
rect_b.SetSize(20, 20); rect_b.SetSize(20, 20);
rect_b.set_visible(true); rect_b.SetVisible(true);
layout.AddChild(&rect_b); layout.AddChild(&rect_b);
layout.LayOutChildren(); layout.LayOutChildren();
...@@ -74,7 +74,7 @@ TEST(LinearLayout, VerticalLayout) { ...@@ -74,7 +74,7 @@ TEST(LinearLayout, VerticalLayout) {
EXPECT_FLOAT_EQ(10.0f, op_b.translate.y); EXPECT_FLOAT_EQ(10.0f, op_b.translate.y);
EXPECT_FLOAT_EQ(0.0f, op_b.translate.z); EXPECT_FLOAT_EQ(0.0f, op_b.translate.z);
rect_a.set_visible(false); rect_a.SetVisible(false);
layout.LayOutChildren(); layout.LayOutChildren();
// The invisible child should not be accounted for in the layout. // The invisible child should not be accounted for in the layout.
EXPECT_TRUE(rect_b.transform_operations().Apply().IsIdentity()); EXPECT_TRUE(rect_b.transform_operations().Apply().IsIdentity());
......
...@@ -12,7 +12,7 @@ namespace vr { ...@@ -12,7 +12,7 @@ namespace vr {
LoadingIndicator::LoadingIndicator(int preferred_width) LoadingIndicator::LoadingIndicator(int preferred_width)
: TexturedElement(preferred_width), : TexturedElement(preferred_width),
texture_(base::MakeUnique<LoadingIndicatorTexture>()) { texture_(base::MakeUnique<LoadingIndicatorTexture>()) {
set_visible(false); SetVisible(false);
} }
LoadingIndicator::~LoadingIndicator() = default; LoadingIndicator::~LoadingIndicator() = default;
...@@ -42,7 +42,7 @@ void LoadingIndicator::SetLoadProgress(float progress) { ...@@ -42,7 +42,7 @@ void LoadingIndicator::SetLoadProgress(float progress) {
} }
void LoadingIndicator::SetVisibility() { void LoadingIndicator::SetVisibility() {
set_visible(enabled_ && loading_); SetVisible(enabled_ && loading_);
} }
} // namespace vr } // namespace vr
...@@ -9,7 +9,7 @@ namespace vr { ...@@ -9,7 +9,7 @@ namespace vr {
TransienceManager::TransienceManager(UiElement* element, TransienceManager::TransienceManager(UiElement* element,
const base::TimeDelta& timeout) const base::TimeDelta& timeout)
: element_(element), timeout_(timeout) { : element_(element), timeout_(timeout) {
element_->set_visible(false); element_->SetVisible(false);
} }
void TransienceManager::SetEnabled(bool enabled) { void TransienceManager::SetEnabled(bool enabled) {
...@@ -17,24 +17,24 @@ void TransienceManager::SetEnabled(bool enabled) { ...@@ -17,24 +17,24 @@ void TransienceManager::SetEnabled(bool enabled) {
return; return;
enabled_ = enabled; enabled_ = enabled;
if (enabled) { if (enabled) {
element_->set_visible(true); element_->SetVisible(true);
StartTimer(); StartTimer();
} else { } else {
element_->set_visible(false); element_->SetVisible(false);
visibility_timer_.Stop(); visibility_timer_.Stop();
} }
} }
void TransienceManager::KickVisibilityIfEnabled() { void TransienceManager::KickVisibilityIfEnabled() {
if (enabled_) { if (enabled_) {
element_->set_visible(true); element_->SetVisible(true);
StartTimer(); StartTimer();
} }
} }
void TransienceManager::EndVisibilityIfEnabled() { void TransienceManager::EndVisibilityIfEnabled() {
if (enabled_) { if (enabled_) {
element_->set_visible(false); element_->SetVisible(false);
visibility_timer_.Stop(); visibility_timer_.Stop();
} }
} }
...@@ -46,7 +46,7 @@ void TransienceManager::StartTimer() { ...@@ -46,7 +46,7 @@ void TransienceManager::StartTimer() {
} }
void TransienceManager::OnTimeout() { void TransienceManager::OnTimeout() {
element_->set_visible(false); element_->SetVisible(false);
} }
} // namespace vr } // namespace vr
...@@ -84,6 +84,10 @@ void UiElement::SetSize(float width, float height) { ...@@ -84,6 +84,10 @@ void UiElement::SetSize(float width, float height) {
gfx::SizeF(width, height)); gfx::SizeF(width, height));
} }
void UiElement::SetVisible(bool visible) {
animation_player_.TransitionVisibilityTo(last_frame_time_, visible_, visible);
}
void UiElement::SetTransformOperations( void UiElement::SetTransformOperations(
const UiElementTransformOperations& ui_element_transform_operations) { const UiElementTransformOperations& ui_element_transform_operations) {
animation_player_.TransitionTransformOperationsTo( animation_player_.TransitionTransformOperationsTo(
...@@ -207,6 +211,11 @@ void UiElement::NotifyClientBoundsAnimated(const gfx::SizeF& size, ...@@ -207,6 +211,11 @@ void UiElement::NotifyClientBoundsAnimated(const gfx::SizeF& size,
size_ = size; size_ = size;
} }
void UiElement::NotifyClientVisibilityAnimated(bool visible,
cc::Animation* animation) {
visible_ = visible;
}
void UiElement::LayOutChildren() { void UiElement::LayOutChildren() {
for (auto* child : children_) { for (auto* child : children_) {
// To anchor a child, use the parent's size to find its edge. // To anchor a child, use the parent's size to find its edge.
......
...@@ -106,7 +106,7 @@ class UiElement : public cc::AnimationTarget { ...@@ -106,7 +106,7 @@ class UiElement : public cc::AnimationTarget {
// If true, this object will be visible. // If true, this object will be visible.
bool visible() const { return visible_; } bool visible() const { return visible_; }
void set_visible(bool visible) { visible_ = visible; } void SetVisible(bool visible);
// If false, the reticle will not hit the element, even if visible. // If false, the reticle will not hit the element, even if visible.
bool hit_testable() const { return hit_testable_; } bool hit_testable() const { return hit_testable_; }
...@@ -261,6 +261,8 @@ class UiElement : public cc::AnimationTarget { ...@@ -261,6 +261,8 @@ class UiElement : public cc::AnimationTarget {
cc::Animation* animation) override; cc::Animation* animation) override;
void NotifyClientBoundsAnimated(const gfx::SizeF& size, void NotifyClientBoundsAnimated(const gfx::SizeF& size,
cc::Animation* animation) override; cc::Animation* animation) override;
void NotifyClientVisibilityAnimated(bool visible,
cc::Animation* animation) override;
// Handles positioning adjustments for children. This will be overridden by // Handles positioning adjustments for children. This will be overridden by
// UiElements providing custom layout modes. See the documentation of the // UiElements providing custom layout modes. See the documentation of the
......
...@@ -167,7 +167,7 @@ void UiSceneManager::CreateScreenDimmer() { ...@@ -167,7 +167,7 @@ void UiSceneManager::CreateScreenDimmer() {
element->set_debug_id(kScreenDimmer); element->set_debug_id(kScreenDimmer);
element->set_id(AllocateId()); element->set_id(AllocateId());
element->set_fill(vr::Fill::NONE); element->set_fill(vr::Fill::NONE);
element->set_visible(false); element->SetVisible(false);
element->set_hit_testable(false); element->set_hit_testable(false);
element->set_is_overlay(true); element->set_is_overlay(true);
screen_dimmer_ = element.get(); screen_dimmer_ = element.get();
...@@ -188,7 +188,7 @@ void UiSceneManager::CreateSecurityWarnings() { ...@@ -188,7 +188,7 @@ void UiSceneManager::CreateSecurityWarnings() {
-kWarningDistance * cos(kWarningAngleRadians)); -kWarningDistance * cos(kWarningAngleRadians));
element->SetRotate(1, 0, 0, kWarningAngleRadians); element->SetRotate(1, 0, 0, kWarningAngleRadians);
element->SetScale(kWarningDistance, kWarningDistance, 1); element->SetScale(kWarningDistance, kWarningDistance, 1);
element->set_visible(false); element->SetVisible(false);
element->set_hit_testable(false); element->set_hit_testable(false);
element->set_lock_to_fov(true); element->set_lock_to_fov(true);
permanent_security_warning_ = element.get(); permanent_security_warning_ = element.get();
...@@ -203,7 +203,7 @@ void UiSceneManager::CreateSecurityWarnings() { ...@@ -203,7 +203,7 @@ void UiSceneManager::CreateSecurityWarnings() {
element->set_fill(vr::Fill::NONE); element->set_fill(vr::Fill::NONE);
element->SetSize(kTransientWarningWidth, kTransientWarningHeight); element->SetSize(kTransientWarningWidth, kTransientWarningHeight);
element->SetTranslate(0, 0, -kWarningDistance); element->SetTranslate(0, 0, -kWarningDistance);
element->set_visible(false); element->SetVisible(false);
element->set_hit_testable(false); element->set_hit_testable(false);
element->set_lock_to_fov(true); element->set_lock_to_fov(true);
scene_->AddUiElement(std::move(element)); scene_->AddUiElement(std::move(element));
...@@ -215,7 +215,7 @@ void UiSceneManager::CreateSecurityWarnings() { ...@@ -215,7 +215,7 @@ void UiSceneManager::CreateSecurityWarnings() {
element->SetSize(kExitWarningWidth, kExitWarningHeight); element->SetSize(kExitWarningWidth, kExitWarningHeight);
element->SetTranslate(0, 0, -kExitWarningDistance); element->SetTranslate(0, 0, -kExitWarningDistance);
element->SetScale(kExitWarningDistance, kExitWarningDistance, 1); element->SetScale(kExitWarningDistance, kExitWarningDistance, 1);
element->set_visible(false); element->SetVisible(false);
element->set_hit_testable(false); element->set_hit_testable(false);
element->set_lock_to_fov(true); element->set_lock_to_fov(true);
exit_warning_ = element.get(); exit_warning_ = element.get();
...@@ -258,8 +258,8 @@ void UiSceneManager::CreateSystemIndicators() { ...@@ -258,8 +258,8 @@ void UiSceneManager::CreateSystemIndicators() {
512, kIndicatorHeight, indicator.icon, indicator.resource_string); 512, kIndicatorHeight, indicator.icon, indicator.resource_string);
element->set_debug_id(indicator.debug_id); element->set_debug_id(indicator.debug_id);
element->set_id(AllocateId()); element->set_id(AllocateId());
element->SetVisible(false);
indicator_layout->AddChild(element.get()); indicator_layout->AddChild(element.get());
element->set_visible(false);
*(indicator.element) = element.get(); *(indicator.element) = element.get();
system_indicators_.push_back(element.get()); system_indicators_.push_back(element.get());
scene_->AddUiElement(std::move(element)); scene_->AddUiElement(std::move(element));
...@@ -279,7 +279,7 @@ void UiSceneManager::CreateContentQuad() { ...@@ -279,7 +279,7 @@ void UiSceneManager::CreateContentQuad() {
element->set_fill(vr::Fill::CONTENT); element->set_fill(vr::Fill::CONTENT);
element->SetSize(kContentWidth, kContentHeight); element->SetSize(kContentWidth, kContentHeight);
element->SetTranslate(0, kContentVerticalOffset, -kContentDistance); element->SetTranslate(0, kContentVerticalOffset, -kContentDistance);
element->set_visible(false); element->SetVisible(false);
element->set_corner_radius(kContentCornerRadius); element->set_corner_radius(kContentCornerRadius);
element->animation_player().SetTransitionedProperties({TRANSFORM, BOUNDS}); element->animation_player().SetTransitionedProperties({TRANSFORM, BOUNDS});
main_content_ = element.get(); main_content_ = element.get();
...@@ -388,7 +388,7 @@ void UiSceneManager::CreateTransientUrlBar() { ...@@ -388,7 +388,7 @@ void UiSceneManager::CreateTransientUrlBar() {
url_bar->set_debug_id(kTransientUrlBar); url_bar->set_debug_id(kTransientUrlBar);
url_bar->set_id(AllocateId()); url_bar->set_id(AllocateId());
url_bar->set_lock_to_fov(true); url_bar->set_lock_to_fov(true);
url_bar->set_visible(false); url_bar->SetVisible(false);
url_bar->set_hit_testable(false); url_bar->set_hit_testable(false);
url_bar->SetTranslate(0, kTransientUrlBarVerticalOffset, url_bar->SetTranslate(0, kTransientUrlBarVerticalOffset,
-kTransientUrlBarDistance); -kTransientUrlBarDistance);
...@@ -428,8 +428,8 @@ void UiSceneManager::CreateExitPrompt() { ...@@ -428,8 +428,8 @@ void UiSceneManager::CreateExitPrompt() {
element->set_fill(vr::Fill::NONE); element->set_fill(vr::Fill::NONE);
element->SetSize(kExitPromptWidth, kExitPromptHeight); element->SetSize(kExitPromptWidth, kExitPromptHeight);
element->SetTranslate(0.0, kExitPromptVerticalOffset, kTextureOffset); element->SetTranslate(0.0, kExitPromptVerticalOffset, kTextureOffset);
element->SetVisible(false);
main_content_->AddChild(element.get()); main_content_->AddChild(element.get());
element->set_visible(false);
scene_->AddUiElement(std::move(element)); scene_->AddUiElement(std::move(element));
// Place an invisible but hittable plane behind the exit prompt, to keep the // Place an invisible but hittable plane behind the exit prompt, to keep the
...@@ -456,7 +456,7 @@ void UiSceneManager::CreateToasts() { ...@@ -456,7 +456,7 @@ void UiSceneManager::CreateToasts() {
element->set_id(AllocateId()); element->set_id(AllocateId());
element->set_fill(vr::Fill::NONE); element->set_fill(vr::Fill::NONE);
element->SetSize(kToastWidthDMM, kToastHeightDMM); element->SetSize(kToastWidthDMM, kToastHeightDMM);
element->set_visible(false); element->SetVisible(false);
element->set_hit_testable(false); element->set_hit_testable(false);
exclusive_screen_toast_ = element.get(); exclusive_screen_toast_ = element.get();
scene_->AddUiElement(std::move(element)); scene_->AddUiElement(std::move(element));
...@@ -679,11 +679,11 @@ void UiSceneManager::ConfigureSecurityWarnings() { ...@@ -679,11 +679,11 @@ void UiSceneManager::ConfigureSecurityWarnings() {
void UiSceneManager::ConfigureIndicators() { void UiSceneManager::ConfigureIndicators() {
bool allowed = !web_vr_mode_ && !fullscreen_; bool allowed = !web_vr_mode_ && !fullscreen_;
audio_capture_indicator_->set_visible(allowed && audio_capturing_); audio_capture_indicator_->SetVisible(allowed && audio_capturing_);
video_capture_indicator_->set_visible(allowed && video_capturing_); video_capture_indicator_->SetVisible(allowed && video_capturing_);
screen_capture_indicator_->set_visible(allowed && screen_capturing_); screen_capture_indicator_->SetVisible(allowed && screen_capturing_);
location_access_indicator_->set_visible(allowed && location_access_); location_access_indicator_->SetVisible(allowed && location_access_);
bluetooth_connected_indicator_->set_visible(allowed && bluetooth_connected_); bluetooth_connected_indicator_->SetVisible(allowed && bluetooth_connected_);
} }
void UiSceneManager::ConfigureExclusiveScreenToast() { void UiSceneManager::ConfigureExclusiveScreenToast() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment