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

Side by Side Diff: ui/aura_shell/app_list.cc

Issue 8747021: [Aura] Polish app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura_shell/app_list.h" 5 #include "ui/aura_shell/app_list.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "ui/aura/event.h" 8 #include "ui/aura/event.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura_shell/shell.h" 10 #include "ui/aura_shell/shell.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void AppList::SetVisible(bool visible) { 55 void AppList::SetVisible(bool visible) {
56 if (visible == is_visible_) 56 if (visible == is_visible_)
57 return; 57 return;
58 58
59 is_visible_ = visible; 59 is_visible_ = visible;
60 60
61 if (widget_) { 61 if (widget_) {
62 ScheduleAnimation(); 62 ScheduleAnimation();
63 } else if (is_visible_ && !set_widget_factory_.HasWeakPtrs()) { 63 } else if (is_visible_ && !set_widget_factory_.HasWeakPtrs()) {
64 Shell::GetInstance()->delegate()->RequestAppListWidget( 64 Shell::GetInstance()->delegate()->RequestAppListWidget(
65 GetPreferredBounds(false),
65 base::Bind(&AppList::SetWidget, set_widget_factory_.GetWeakPtr())); 66 base::Bind(&AppList::SetWidget, set_widget_factory_.GetWeakPtr()));
66 } 67 }
67 } 68 }
68 69
69 bool AppList::IsVisible() { 70 bool AppList::IsVisible() {
70 return widget_ && widget_->IsVisible(); 71 return widget_ && widget_->IsVisible();
71 } 72 }
72 73
73 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
74 // AppList, private: 75 // AppList, private:
75 76
76 void AppList::SetWidget(views::Widget* widget) { 77 void AppList::SetWidget(views::Widget* widget) {
77 DCHECK(widget_ == NULL); 78 DCHECK(widget_ == NULL);
78 set_widget_factory_.InvalidateWeakPtrs(); 79 set_widget_factory_.InvalidateWeakPtrs();
79 80
80 if (is_visible_) { 81 if (is_visible_) {
81 widget_ = widget; 82 widget_ = widget;
82 widget_->AddObserver(this); 83 widget_->AddObserver(this);
83 GetLayer(widget_)->GetAnimator()->AddObserver(this); 84 GetLayer(widget_)->GetAnimator()->AddObserver(this);
84 Shell::GetInstance()->AddDesktopEventFilter(this); 85 Shell::GetInstance()->AddDesktopEventFilter(this);
85 86
86 widget_->SetBounds(GetPreferredBounds(false)); 87 widget_->SetBounds(GetPreferredBounds(false));
87 widget_->SetOpacity(0); 88 widget_->SetOpacity(0);
88 ScheduleAnimation(); 89 ScheduleAnimation();
89 90
90 widget_->Show(); 91 widget_->Show();
91 widget_->Activate();
92 } else { 92 } else {
93 widget->Close(); 93 widget->Close();
94 } 94 }
95 } 95 }
96 96
97 void AppList::ResetWidget() { 97 void AppList::ResetWidget() {
98 if (!widget_) 98 if (!widget_)
99 return; 99 return;
100 100
101 widget_->RemoveObserver(this); 101 widget_->RemoveObserver(this);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 void AppList::OnLayerAnimationScheduled( 156 void AppList::OnLayerAnimationScheduled(
157 const ui::LayerAnimationSequence* sequence) { 157 const ui::LayerAnimationSequence* sequence) {
158 } 158 }
159 159
160 //////////////////////////////////////////////////////////////////////////////// 160 ////////////////////////////////////////////////////////////////////////////////
161 // AppList, views::Widget::Observer implementation: 161 // AppList, views::Widget::Observer implementation:
162 162
163 void AppList::OnWidgetClosing(views::Widget* widget) { 163 void AppList::OnWidgetClosing(views::Widget* widget) {
164 DCHECK(widget_ == widget); 164 DCHECK(widget_ == widget);
165 if (is_visible_)
166 SetVisible(false);
165 ResetWidget(); 167 ResetWidget();
166 } 168 }
167 169
168 void AppList::OnWidgetActivationChanged(views::Widget* widget, bool active) { 170 void AppList::OnWidgetActivationChanged(views::Widget* widget, bool active) {
169 DCHECK(widget_ == widget); 171 DCHECK(widget_ == widget);
170 if (widget_ && is_visible_ && !active) 172 if (widget_ && is_visible_ && !active)
171 SetVisible(false); 173 SetVisible(false);
172 } 174 }
173 175
174 } // namespace internal 176 } // namespace internal
175 } // namespace aura_shell 177 } // namespace aura_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698