Skip to content

Commit

Permalink
Update hosted app origin text animation
Browse files Browse the repository at this point in the history
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/1192463
Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#588223}(cherry picked from commit 1375b6e)
Reviewed-on: https://chromium-review.googlesource.com/1203511
Reviewed-by: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/branch-heads/3538@{#17}
Cr-Branched-From: 79f7c91-refs/heads/master@{#587811}
  • Loading branch information
alancutter committed Sep 4, 2018
1 parent d9b097c commit 3a090fd
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions chrome/browser/ui/views/frame/hosted_app_origin_text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "base/i18n/rtl.h"
#include "chrome/browser/ui/browser.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/compositor/layer_animation_element.h"
#include "ui/compositor/layer_animation_sequence.h"
Expand All @@ -21,7 +22,7 @@ constexpr base::TimeDelta kOriginSlideInDuration =
constexpr base::TimeDelta kOriginPauseDuration =
base::TimeDelta::FromMilliseconds(2500);
constexpr base::TimeDelta kOriginSlideOutDuration =
base::TimeDelta::FromMilliseconds(500);
base::TimeDelta::FromMilliseconds(800);

constexpr gfx::Tween::Type kTweenType = gfx::Tween::FAST_OUT_SLOW_IN_2;

Expand All @@ -35,7 +36,9 @@ HostedAppOriginText::HostedAppOriginText(Browser* browser) {
SetLayoutManager(std::make_unique<views::FillLayout>());

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();
label_->SetElideBehavior(gfx::ELIDE_HEAD);
label_->SetSubpixelRenderingEnabled(false);
Expand Down Expand Up @@ -64,44 +67,26 @@ void HostedAppOriginText::StartSlideAnimation() {

// Current state will become the first animation keyframe.
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 transform_sequence = std::make_unique<ui::LayerAnimationSequence>();

// Slide in.
auto opacity_keyframe = ui::LayerAnimationElement::CreateOpacityElement(
1, kOriginSlideInDuration);
opacity_keyframe->set_tween_type(kTweenType);
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.
opacity_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(0, kOriginPauseDuration));
transform_sequence->AddElement(
ui::LayerAnimationElement::CreatePauseElement(0, kOriginPauseDuration));

// Slide out.
opacity_keyframe = ui::LayerAnimationElement::CreateOpacityElement(
0, kOriginSlideOutDuration);
opacity_keyframe->set_tween_type(kTweenType);
opacity_sequence->AddElement(std::move(opacity_keyframe));

transform_keyframe = ui::LayerAnimationElement::CreateTransformElement(
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()});
label_layer->GetAnimator()->StartAnimation(opacity_sequence.release());

base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
Expand Down

0 comments on commit 3a090fd

Please sign in to comment.