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

Side by Side Diff: ash/system/status_area_widget_delegate.cc

Issue 251193004: Animate the OverviewButtonTray (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ash/system/status_area_widget_delegate.h" 5 #include "ash/system/status_area_widget_delegate.h"
6 6
7 #include "ash/ash_export.h" 7 #include "ash/ash_export.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/focus_cycler.h" 9 #include "ash/focus_cycler.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
13 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/compositor/layer.h"
18 #include "ui/compositor/scoped_layer_animation_settings.h"
19 #include "ui/gfx/animation/tween.h"
16 #include "ui/gfx/canvas.h" 20 #include "ui/gfx/canvas.h"
17 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
18 #include "ui/views/accessible_pane_view.h" 22 #include "ui/views/accessible_pane_view.h"
19 #include "ui/views/layout/grid_layout.h" 23 #include "ui/views/layout/grid_layout.h"
20 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
21 25
26 namespace {
27
28 const int kAnimationDuration = 250;
29
30 class StatusAreaWidgetDelegateAnimationSettings
31 : public ui::ScopedLayerAnimationSettings {
32 public:
33 StatusAreaWidgetDelegateAnimationSettings(ui::Layer* layer);
34 virtual ~StatusAreaWidgetDelegateAnimationSettings();
35
36 private:
37 DISALLOW_COPY_AND_ASSIGN(StatusAreaWidgetDelegateAnimationSettings);
38 };
39
40 StatusAreaWidgetDelegateAnimationSettings::
41 StatusAreaWidgetDelegateAnimationSettings(ui::Layer* layer)
42 : ui::ScopedLayerAnimationSettings(layer->GetAnimator()) {
flackr 2014/05/08 17:09:49 nit: I think this should align with the S since it
jonross 2014/05/08 17:24:25 Done.
43 SetTransitionDuration(
44 base::TimeDelta::FromMilliseconds(kAnimationDuration));
45 SetPreemptionStrategy(
46 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
47 SetTweenType(gfx::Tween::EASE_IN_OUT);
48 }
49
50 StatusAreaWidgetDelegateAnimationSettings::
51 ~StatusAreaWidgetDelegateAnimationSettings() {
52 }
53
54 } // namespace
55
22 namespace ash { 56 namespace ash {
23 57
24 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() 58 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate()
25 : focus_cycler_for_testing_(NULL), 59 : focus_cycler_for_testing_(NULL),
26 alignment_(SHELF_ALIGNMENT_BOTTOM) { 60 alignment_(SHELF_ALIGNMENT_BOTTOM) {
27 // Allow the launcher to surrender the focus to another window upon 61 // Allow the launcher to surrender the focus to another window upon
28 // navigation completion by the user. 62 // navigation completion by the user.
29 set_allow_deactivate_on_esc(true); 63 set_allow_deactivate_on_esc(true);
64 SetPaintToLayer(true);
65 SetFillsBoundsOpaquely(false);
30 } 66 }
31 67
32 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() { 68 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() {
33 } 69 }
34 70
35 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( 71 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting(
36 const FocusCycler* focus_cycler) { 72 const FocusCycler* focus_cycler) {
37 focus_cycler_for_testing_ = focus_cycler; 73 focus_cycler_for_testing_ = focus_cycler;
38 } 74 }
39 75
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 views::View* child = child_at(c); 146 views::View* child = child_at(c);
111 if (!child->visible()) 147 if (!child->visible())
112 continue; 148 continue;
113 if (!is_first_visible_child) 149 if (!is_first_visible_child)
114 layout->AddPaddingRow(0, kTraySpacing); 150 layout->AddPaddingRow(0, kTraySpacing);
115 is_first_visible_child = false; 151 is_first_visible_child = false;
116 layout->StartRow(0, 0); 152 layout->StartRow(0, 0);
117 layout->AddView(child); 153 layout->AddView(child);
118 } 154 }
119 } 155 }
156
157 layer()->GetAnimator()->StopAnimating();
158 StatusAreaWidgetDelegateAnimationSettings settings(layer());
159
120 Layout(); 160 Layout();
121 UpdateWidgetSize(); 161 UpdateWidgetSize();
122 } 162 }
123 163
124 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { 164 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) {
125 // Need to resize the window when trays or items are added/removed. 165 // Need to resize the window when trays or items are added/removed.
166 StatusAreaWidgetDelegateAnimationSettings settings(layer());
126 UpdateWidgetSize(); 167 UpdateWidgetSize();
127 } 168 }
128 169
129 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { 170 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) {
130 UpdateLayout(); 171 UpdateLayout();
131 } 172 }
132 173
133 void StatusAreaWidgetDelegate::UpdateWidgetSize() { 174 void StatusAreaWidgetDelegate::UpdateWidgetSize() {
134 if (GetWidget()) 175 if (GetWidget())
135 GetWidget()->SetSize(GetPreferredSize()); 176 GetWidget()->SetSize(GetPreferredSize());
136 } 177 }
137 178
138 } // namespace ash 179 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/tray/tray_background_view.h » ('j') | ash/system/tray/tray_background_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698