add pagination info to DistilledPageProto
[chromium-blink-merge.git] / ui / app_list / views / folder_background_view.cc
blob2f62f1cada6a35f7c3237381efa897f7a2834deb
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/app_list/views/folder_background_view.h"
7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/app_list/views/app_list_folder_view.h"
9 #include "ui/app_list/views/apps_container_view.h"
10 #include "ui/compositor/scoped_layer_animation_settings.h"
11 #include "ui/gfx/canvas.h"
12 #include "ui/gfx/transform_util.h"
14 namespace app_list {
16 namespace {
18 const float kFolderInkBubbleScale = 1.2f;
19 const int kBubbleTransitionDurationMs = 200;
21 } // namespace
23 FolderBackgroundView::FolderBackgroundView()
24 : folder_view_(NULL),
25 show_state_(NO_BUBBLE) {
26 SetPaintToLayer(true);
27 SetFillsBoundsOpaquely(false);
30 FolderBackgroundView::~FolderBackgroundView() {
33 void FolderBackgroundView::UpdateFolderContainerBubble(ShowState state) {
34 if (show_state_ == state ||
35 (state == HIDE_BUBBLE && show_state_ == NO_BUBBLE)) {
36 return;
39 show_state_ = state;
41 // Set the initial state before the animation starts.
42 const gfx::Rect bounds(layer()->bounds().size());
43 gfx::Transform transform =
44 gfx::GetScaleTransform(bounds.CenterPoint(), kFolderInkBubbleScale);
45 if (show_state_ == SHOW_BUBBLE) {
46 layer()->SetOpacity(0.0f);
47 layer()->SetTransform(transform);
48 } else {
49 layer()->SetOpacity(1.0f);
50 layer()->SetTransform(gfx::Transform());
53 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
54 settings.AddObserver(this);
55 settings.SetTransitionDuration(
56 base::TimeDelta::FromMilliseconds((kBubbleTransitionDurationMs)));
57 if (show_state_ == SHOW_BUBBLE) {
58 settings.SetTweenType(gfx::Tween::LINEAR_OUT_SLOW_IN);
59 layer()->SetOpacity(1.0f);
60 layer()->SetTransform(gfx::Transform());
61 } else {
62 settings.SetTweenType(gfx::Tween::FAST_OUT_LINEAR_IN);
63 layer()->SetOpacity(0.0f);
64 layer()->SetTransform(transform);
67 SchedulePaint();
70 int FolderBackgroundView::GetFolderContainerBubbleRadius() const {
71 return std::max(GetContentsBounds().width(), GetContentsBounds().height()) /
75 void FolderBackgroundView::OnPaint(gfx::Canvas* canvas) {
76 if (show_state_ == NO_BUBBLE)
77 return;
79 // Draw ink bubble that shows the folder boundary.
80 SkPaint paint;
81 paint.setStyle(SkPaint::kFill_Style);
82 paint.setAntiAlias(true);
83 paint.setColor(kFolderBubbleColor);
84 canvas->DrawCircle(GetContentsBounds().CenterPoint(),
85 GetFolderContainerBubbleRadius(),
86 paint);
89 void FolderBackgroundView::OnImplicitAnimationsCompleted() {
90 // Show folder name after the ink bubble disappears.
91 if (show_state_ == HIDE_BUBBLE) {
92 static_cast<AppsContainerView*>(parent())->app_list_folder_view()->
93 UpdateFolderNameVisibility(true);
97 } // namespace app_list