Commit 1375b6e1 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Update hosted app origin text animation

This CL updates the opening animation for hosted app titlebars to
match recent UI mocks by:
 - Removing the slide motion but retain the fade animation of the
   origin text.
 - Making the origin text bold.
 - Synchronising the fade durations of the origin text and app menu
   button highlight.

Before: https://bugs.chromium.org/p/chromium/issues/attachment?aid=355048&signed_aid=mI6IiKwlkm5uzn4Cv6Asxg==&inline=1
After: https://bugs.chromium.org/p/chromium/issues/attachment?aid=355049&signed_aid=bfJDeHt7BMIqsW1SYf3DRg==&inline=1

This CL only includes the minimal changes needed to update the
animation to be suitable for merging to M70. Further code clean
ups have been moved to: https://chromium-review.googlesource.com/c/chromium/src/+/1198707/1

Bug: 878187
Change-Id: I0938f124e39ebf113843e62d63d6a0b9dc4417cc
Reviewed-on: https://chromium-review.googlesource.com/1192463Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588223}
parent e94a051c
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h" #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/compositor/layer_animation_element.h" #include "ui/compositor/layer_animation_element.h"
#include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/layer_animation_sequence.h"
...@@ -21,7 +22,7 @@ constexpr base::TimeDelta kOriginSlideInDuration = ...@@ -21,7 +22,7 @@ constexpr base::TimeDelta kOriginSlideInDuration =
constexpr base::TimeDelta kOriginPauseDuration = constexpr base::TimeDelta kOriginPauseDuration =
base::TimeDelta::FromMilliseconds(2500); base::TimeDelta::FromMilliseconds(2500);
constexpr base::TimeDelta kOriginSlideOutDuration = constexpr base::TimeDelta kOriginSlideOutDuration =
base::TimeDelta::FromMilliseconds(500); base::TimeDelta::FromMilliseconds(800);
constexpr gfx::Tween::Type kTweenType = gfx::Tween::FAST_OUT_SLOW_IN_2; constexpr gfx::Tween::Type kTweenType = gfx::Tween::FAST_OUT_SLOW_IN_2;
...@@ -35,7 +36,9 @@ HostedAppOriginText::HostedAppOriginText(Browser* browser) { ...@@ -35,7 +36,9 @@ HostedAppOriginText::HostedAppOriginText(Browser* browser) {
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
label_ = std::make_unique<views::Label>( label_ = std::make_unique<views::Label>(
browser->hosted_app_controller()->GetFormattedUrlOrigin()) browser->hosted_app_controller()->GetFormattedUrlOrigin(),
ChromeTextContext::CONTEXT_BODY_TEXT_SMALL,
ChromeTextStyle::STYLE_EMPHASIZED)
.release(); .release();
label_->SetElideBehavior(gfx::ELIDE_HEAD); label_->SetElideBehavior(gfx::ELIDE_HEAD);
label_->SetSubpixelRenderingEnabled(false); label_->SetSubpixelRenderingEnabled(false);
...@@ -64,13 +67,8 @@ void HostedAppOriginText::StartSlideAnimation() { ...@@ -64,13 +67,8 @@ void HostedAppOriginText::StartSlideAnimation() {
// Current state will become the first animation keyframe. // Current state will become the first animation keyframe.
DCHECK_EQ(label_layer->opacity(), 0); DCHECK_EQ(label_layer->opacity(), 0);
gfx::Transform out_of_frame;
out_of_frame.Translate(
label_->bounds().width() * (base::i18n::IsRTL() ? -1 : 1), 0);
label_layer->SetTransform(out_of_frame);
auto opacity_sequence = std::make_unique<ui::LayerAnimationSequence>(); auto opacity_sequence = std::make_unique<ui::LayerAnimationSequence>();
auto transform_sequence = std::make_unique<ui::LayerAnimationSequence>();
// Slide in. // Slide in.
auto opacity_keyframe = ui::LayerAnimationElement::CreateOpacityElement( auto opacity_keyframe = ui::LayerAnimationElement::CreateOpacityElement(
...@@ -78,16 +76,9 @@ void HostedAppOriginText::StartSlideAnimation() { ...@@ -78,16 +76,9 @@ void HostedAppOriginText::StartSlideAnimation() {
opacity_keyframe->set_tween_type(kTweenType); opacity_keyframe->set_tween_type(kTweenType);
opacity_sequence->AddElement(std::move(opacity_keyframe)); opacity_sequence->AddElement(std::move(opacity_keyframe));
auto transform_keyframe = ui::LayerAnimationElement::CreateTransformElement(
gfx::Transform(), kOriginSlideInDuration);
transform_keyframe->set_tween_type(kTweenType);
transform_sequence->AddElement(std::move(transform_keyframe));
// Pause. // Pause.
opacity_sequence->AddElement( opacity_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(0, kOriginPauseDuration)); ui::LayerAnimationElement::CreatePauseElement(0, kOriginPauseDuration));
transform_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(0, kOriginPauseDuration));
// Slide out. // Slide out.
opacity_keyframe = ui::LayerAnimationElement::CreateOpacityElement( opacity_keyframe = ui::LayerAnimationElement::CreateOpacityElement(
...@@ -95,13 +86,7 @@ void HostedAppOriginText::StartSlideAnimation() { ...@@ -95,13 +86,7 @@ void HostedAppOriginText::StartSlideAnimation() {
opacity_keyframe->set_tween_type(kTweenType); opacity_keyframe->set_tween_type(kTweenType);
opacity_sequence->AddElement(std::move(opacity_keyframe)); opacity_sequence->AddElement(std::move(opacity_keyframe));
transform_keyframe = ui::LayerAnimationElement::CreateTransformElement( label_layer->GetAnimator()->StartAnimation(opacity_sequence.release());
out_of_frame, kOriginSlideOutDuration);
transform_keyframe->set_tween_type(kTweenType);
transform_sequence->AddElement(std::move(transform_keyframe));
label_layer->GetAnimator()->StartTogether(
{opacity_sequence.release(), transform_sequence.release()});
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask( base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, FROM_HERE,
......
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