OLD | NEW |
---|---|
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 } // namespace | |
31 | |
22 namespace ash { | 32 namespace ash { |
23 | 33 |
24 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() | 34 StatusAreaWidgetDelegate::StatusAreaWidgetDelegate() |
25 : focus_cycler_for_testing_(NULL), | 35 : focus_cycler_for_testing_(NULL), |
26 alignment_(SHELF_ALIGNMENT_BOTTOM) { | 36 alignment_(SHELF_ALIGNMENT_BOTTOM) { |
27 // Allow the launcher to surrender the focus to another window upon | 37 // Allow the launcher to surrender the focus to another window upon |
28 // navigation completion by the user. | 38 // navigation completion by the user. |
29 set_allow_deactivate_on_esc(true); | 39 set_allow_deactivate_on_esc(true); |
40 SetPaintToLayer(true); | |
30 } | 41 } |
31 | 42 |
32 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() { | 43 StatusAreaWidgetDelegate::~StatusAreaWidgetDelegate() { |
33 } | 44 } |
34 | 45 |
35 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( | 46 void StatusAreaWidgetDelegate::SetFocusCyclerForTesting( |
36 const FocusCycler* focus_cycler) { | 47 const FocusCycler* focus_cycler) { |
37 focus_cycler_for_testing_ = focus_cycler; | 48 focus_cycler_for_testing_ = focus_cycler; |
38 } | 49 } |
39 | 50 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 views::View* child = child_at(c); | 121 views::View* child = child_at(c); |
111 if (!child->visible()) | 122 if (!child->visible()) |
112 continue; | 123 continue; |
113 if (!is_first_visible_child) | 124 if (!is_first_visible_child) |
114 layout->AddPaddingRow(0, kTraySpacing); | 125 layout->AddPaddingRow(0, kTraySpacing); |
115 is_first_visible_child = false; | 126 is_first_visible_child = false; |
116 layout->StartRow(0, 0); | 127 layout->StartRow(0, 0); |
117 layout->AddView(child); | 128 layout->AddView(child); |
118 } | 129 } |
119 } | 130 } |
131 | |
132 layer()->GetAnimator()->StopAnimating(); | |
133 scoped_ptr<ui::ScopedLayerAnimationSettings> animation; | |
134 animation.reset(SetupAnimationForLayer(layer())); | |
135 | |
120 Layout(); | 136 Layout(); |
121 UpdateWidgetSize(); | 137 UpdateWidgetSize(); |
122 } | 138 } |
123 | 139 |
124 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { | 140 void StatusAreaWidgetDelegate::ChildPreferredSizeChanged(View* child) { |
125 // Need to resize the window when trays or items are added/removed. | 141 // Need to resize the window when trays or items are added/removed. |
142 scoped_ptr<ui::ScopedLayerAnimationSettings> animation; | |
143 animation.reset(SetupAnimationForLayer(layer())); | |
144 | |
126 UpdateWidgetSize(); | 145 UpdateWidgetSize(); |
127 } | 146 } |
128 | 147 |
129 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { | 148 void StatusAreaWidgetDelegate::ChildVisibilityChanged(View* child) { |
130 UpdateLayout(); | 149 UpdateLayout(); |
131 } | 150 } |
132 | 151 |
133 void StatusAreaWidgetDelegate::UpdateWidgetSize() { | 152 void StatusAreaWidgetDelegate::UpdateWidgetSize() { |
134 if (GetWidget()) | 153 if (GetWidget()) |
135 GetWidget()->SetSize(GetPreferredSize()); | 154 GetWidget()->SetSize(GetPreferredSize()); |
136 } | 155 } |
137 | 156 |
157 ui::ScopedLayerAnimationSettings* | |
158 StatusAreaWidgetDelegate::SetupAnimationForLayer(ui::Layer* layer) { | |
flackr
2014/05/06 15:42:11
Use anonymous namespace, though it'd probably be b
jonross
2014/05/07 13:52:36
Done.
| |
159 if (!layer) | |
160 return NULL; | |
161 ui::ScopedLayerAnimationSettings* settings = | |
162 new ui::ScopedLayerAnimationSettings(layer->GetAnimator()); | |
163 settings->SetTransitionDuration( | |
164 base::TimeDelta::FromMilliseconds(kAnimationDuration)); | |
165 settings->SetPreemptionStrategy( | |
166 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
167 settings->SetTweenType(gfx::Tween::EASE_IN_OUT); | |
168 return settings; | |
169 } | |
170 | |
138 } // namespace ash | 171 } // namespace ash |
OLD | NEW |