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/app_list/app_list.h" | 5 #include "ash/app_list/app_list.h" |
6 | 6 |
7 #include "ash/app_list/app_list_model.h" | 7 #include "ash/app_list/app_list_model.h" |
8 #include "ash/app_list/app_list_view.h" | 8 #include "ash/app_list/app_list_view.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 //////////////////////////////////////////////////////////////////////////////// | 82 //////////////////////////////////////////////////////////////////////////////// |
83 // AppList, private: | 83 // AppList, private: |
84 | 84 |
85 void AppList::SetWidget(views::Widget* widget) { | 85 void AppList::SetWidget(views::Widget* widget) { |
86 DCHECK(widget_ == NULL); | 86 DCHECK(widget_ == NULL); |
87 | 87 |
88 if (is_visible_) { | 88 if (is_visible_) { |
89 widget_ = widget; | 89 widget_ = widget; |
90 widget_->AddObserver(this); | |
91 GetLayer(widget_)->GetAnimator()->AddObserver(this); | 90 GetLayer(widget_)->GetAnimator()->AddObserver(this); |
92 Shell::GetInstance()->AddRootWindowEventFilter(this); | 91 Shell::GetInstance()->AddRootWindowEventFilter(this); |
93 | 92 |
94 widget_->SetBounds(GetPreferredBounds(false)); | 93 widget_->SetBounds(GetPreferredBounds(false)); |
95 widget_->SetOpacity(0); | 94 widget_->SetOpacity(0); |
96 ScheduleAnimation(); | 95 ScheduleAnimation(); |
97 | 96 |
98 widget_->Show(); | 97 widget_->Show(); |
99 } else { | 98 } else { |
100 widget->Close(); | 99 widget->Close(); |
(...skipping 11 matching lines...) Expand all Loading... |
112 } | 111 } |
113 | 112 |
114 void AppList::ScheduleAnimation() { | 113 void AppList::ScheduleAnimation() { |
115 aura::Window* default_container = Shell::GetInstance()->GetContainer( | 114 aura::Window* default_container = Shell::GetInstance()->GetContainer( |
116 internal::kShellWindowId_DefaultContainer); | 115 internal::kShellWindowId_DefaultContainer); |
117 // |default_container| could be NULL during Shell shutdown. | 116 // |default_container| could be NULL during Shell shutdown. |
118 if (!default_container) | 117 if (!default_container) |
119 return; | 118 return; |
120 | 119 |
121 ui::Layer* layer = GetLayer(widget_); | 120 ui::Layer* layer = GetLayer(widget_); |
| 121 |
| 122 // Stop observing previous animation. |
| 123 StopObservingImplicitAnimations(); |
| 124 |
122 ui::ScopedLayerAnimationSettings app_list_animation(layer->GetAnimator()); | 125 ui::ScopedLayerAnimationSettings app_list_animation(layer->GetAnimator()); |
| 126 app_list_animation.AddObserver(this); |
123 layer->SetBounds(GetPreferredBounds(is_visible_)); | 127 layer->SetBounds(GetPreferredBounds(is_visible_)); |
124 layer->SetOpacity(is_visible_ ? 1.0 : 0.0); | 128 layer->SetOpacity(is_visible_ ? 1.0 : 0.0); |
125 | 129 |
126 ui::Layer* default_container_layer = default_container->layer(); | 130 ui::Layer* default_container_layer = default_container->layer(); |
127 ui::ScopedLayerAnimationSettings default_container_animation( | 131 ui::ScopedLayerAnimationSettings default_container_animation( |
128 default_container_layer->GetAnimator()); | 132 default_container_layer->GetAnimator()); |
| 133 app_list_animation.AddObserver(this); |
129 default_container_layer->SetOpacity(is_visible_ ? 0.0 : 1.0); | 134 default_container_layer->SetOpacity(is_visible_ ? 0.0 : 1.0); |
130 } | 135 } |
131 | 136 |
132 //////////////////////////////////////////////////////////////////////////////// | 137 //////////////////////////////////////////////////////////////////////////////// |
133 // AppList, aura::EventFilter implementation: | 138 // AppList, aura::EventFilter implementation: |
134 | 139 |
135 bool AppList::PreHandleKeyEvent(aura::Window* target, | 140 bool AppList::PreHandleKeyEvent(aura::Window* target, |
136 aura::KeyEvent* event) { | 141 aura::KeyEvent* event) { |
137 return false; | 142 return false; |
138 } | 143 } |
(...skipping 13 matching lines...) Expand all Loading... |
152 return ui::TOUCH_STATUS_UNKNOWN; | 157 return ui::TOUCH_STATUS_UNKNOWN; |
153 } | 158 } |
154 | 159 |
155 ui::GestureStatus AppList::PreHandleGestureEvent( | 160 ui::GestureStatus AppList::PreHandleGestureEvent( |
156 aura::Window* target, | 161 aura::Window* target, |
157 aura::GestureEvent* event) { | 162 aura::GestureEvent* event) { |
158 return ui::GESTURE_STATUS_UNKNOWN; | 163 return ui::GESTURE_STATUS_UNKNOWN; |
159 } | 164 } |
160 | 165 |
161 //////////////////////////////////////////////////////////////////////////////// | 166 //////////////////////////////////////////////////////////////////////////////// |
162 // AppList, ui::LayerAnimationObserver implementation: | 167 // AppList, ui::ImplicitAnimationObserver implementation: |
163 | 168 |
164 void AppList::OnLayerAnimationEnded( | 169 void AppList::OnImplicitAnimationsCompleted() { |
165 const ui::LayerAnimationSequence* sequence) { | |
166 if (!is_visible_ ) | 170 if (!is_visible_ ) |
167 widget_->Close(); | 171 widget_->Close(); |
168 } | 172 } |
169 | 173 |
170 void AppList::OnLayerAnimationAborted( | |
171 const ui::LayerAnimationSequence* sequence) { | |
172 } | |
173 | |
174 void AppList::OnLayerAnimationScheduled( | |
175 const ui::LayerAnimationSequence* sequence) { | |
176 } | |
177 | |
178 //////////////////////////////////////////////////////////////////////////////// | 174 //////////////////////////////////////////////////////////////////////////////// |
179 // AppList, views::Widget::Observer implementation: | 175 // AppList, views::Widget::Observer implementation: |
180 | 176 |
181 void AppList::OnWidgetClosing(views::Widget* widget) { | 177 void AppList::OnWidgetClosing(views::Widget* widget) { |
182 DCHECK(widget_ == widget); | 178 DCHECK(widget_ == widget); |
183 if (is_visible_) | 179 if (is_visible_) |
184 SetVisible(false); | 180 SetVisible(false); |
185 ResetWidget(); | 181 ResetWidget(); |
186 } | 182 } |
187 | 183 |
188 void AppList::OnWidgetActivationChanged(views::Widget* widget, bool active) { | 184 void AppList::OnWidgetActivationChanged(views::Widget* widget, bool active) { |
189 DCHECK(widget_ == widget); | 185 DCHECK(widget_ == widget); |
190 if (widget_ && is_visible_ && !active) | 186 if (widget_ && is_visible_ && !active) |
191 SetVisible(false); | 187 SetVisible(false); |
192 } | 188 } |
193 | 189 |
194 } // namespace internal | 190 } // namespace internal |
195 } // namespace ash | 191 } // namespace ash |
OLD | NEW |