OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
6 | 6 |
7 #include "ash/animation/animation_change_type.h" | 7 #include "ash/animation/animation_change_type.h" |
8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
9 #include "ash/public/cpp/window_properties.h" | 9 #include "ash/public/cpp/window_properties.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
11 #include "ash/session/session_controller.h" | 11 #include "ash/session/session_controller.h" |
12 #include "ash/shelf/app_list_button.h" | 12 #include "ash/shelf/app_list_button.h" |
| 13 #include "ash/shelf/shelf.h" |
13 #include "ash/shelf/shelf_background_animator_observer.h" | 14 #include "ash/shelf/shelf_background_animator_observer.h" |
14 #include "ash/shelf/shelf_constants.h" | 15 #include "ash/shelf/shelf_constants.h" |
15 #include "ash/shelf/shelf_layout_manager.h" | 16 #include "ash/shelf/shelf_layout_manager.h" |
16 #include "ash/shelf/shelf_view.h" | 17 #include "ash/shelf/shelf_view.h" |
17 #include "ash/shelf/wm_shelf.h" | |
18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
19 #include "ash/system/status_area_layout_manager.h" | 19 #include "ash/system/status_area_layout_manager.h" |
20 #include "ash/system/status_area_widget.h" | 20 #include "ash/system/status_area_widget.h" |
21 #include "ash/wm_window.h" | 21 #include "ash/wm_window.h" |
22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
23 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
24 #include "ui/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/compositor/scoped_layer_animation_settings.h" |
25 #include "ui/gfx/skbitmap_operations.h" | 25 #include "ui/gfx/skbitmap_operations.h" |
26 #include "ui/views/accessible_pane_view.h" | 26 #include "ui/views/accessible_pane_view.h" |
27 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 115 |
116 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 116 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
117 opaque_background_.SetBounds(GetLocalBounds()); | 117 opaque_background_.SetBounds(GetLocalBounds()); |
118 opaque_foreground_.SetBounds(GetLocalBounds()); | 118 opaque_foreground_.SetBounds(GetLocalBounds()); |
119 } | 119 } |
120 | 120 |
121 void ShelfWidget::DelegateView::UpdateShelfBackground(SkColor color) { | 121 void ShelfWidget::DelegateView::UpdateShelfBackground(SkColor color) { |
122 opaque_background_.SetColor(color); | 122 opaque_background_.SetColor(color); |
123 } | 123 } |
124 | 124 |
125 ShelfWidget::ShelfWidget(WmWindow* shelf_container, WmShelf* wm_shelf) | 125 ShelfWidget::ShelfWidget(WmWindow* shelf_container, Shelf* shelf) |
126 : wm_shelf_(wm_shelf), | 126 : shelf_(shelf), |
127 status_area_widget_(nullptr), | 127 status_area_widget_(nullptr), |
128 delegate_view_(new DelegateView(this)), | 128 delegate_view_(new DelegateView(this)), |
129 shelf_view_(new ShelfView(Shell::Get()->shelf_model(), wm_shelf_, this)), | 129 shelf_view_(new ShelfView(Shell::Get()->shelf_model(), shelf_, this)), |
130 background_animator_(SHELF_BACKGROUND_DEFAULT, | 130 background_animator_(SHELF_BACKGROUND_DEFAULT, |
131 wm_shelf_, | 131 shelf_, |
132 Shell::Get()->wallpaper_controller()), | 132 Shell::Get()->wallpaper_controller()), |
133 activating_as_fallback_(false) { | 133 activating_as_fallback_(false) { |
134 DCHECK(shelf_container); | 134 DCHECK(shelf_container); |
135 DCHECK(wm_shelf_); | 135 DCHECK(shelf_); |
136 | 136 |
137 views::Widget::InitParams params( | 137 views::Widget::InitParams params( |
138 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 138 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
139 params.name = "ShelfWidget"; | 139 params.name = "ShelfWidget"; |
140 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 140 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
141 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 141 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
142 params.delegate = delegate_view_; | 142 params.delegate = delegate_view_; |
143 shelf_container->GetRootWindowController() | 143 shelf_container->GetRootWindowController() |
144 ->ConfigureWidgetInitParamsForContainer( | 144 ->ConfigureWidgetInitParamsForContainer( |
145 this, shelf_container->aura_window()->id(), ¶ms); | 145 this, shelf_container->aura_window()->id(), ¶ms); |
146 Init(params); | 146 Init(params); |
147 | 147 |
148 // The shelf should not take focus when initially shown. | 148 // The shelf should not take focus when initially shown. |
149 set_focus_on_creation(false); | 149 set_focus_on_creation(false); |
150 SetContentsView(delegate_view_); | 150 SetContentsView(delegate_view_); |
151 delegate_view_->SetParentLayer(GetLayer()); | 151 delegate_view_->SetParentLayer(GetLayer()); |
152 | 152 |
153 // The shelf view observes the shelf model and creates icons as items are | 153 // The shelf view observes the shelf model and creates icons as items are |
154 // added to the model. | 154 // added to the model. |
155 shelf_view_->Init(); | 155 shelf_view_->Init(); |
156 GetContentsView()->AddChildView(shelf_view_); | 156 GetContentsView()->AddChildView(shelf_view_); |
157 | 157 |
158 shelf_layout_manager_ = new ShelfLayoutManager(this, wm_shelf_); | 158 shelf_layout_manager_ = new ShelfLayoutManager(this, shelf_); |
159 shelf_layout_manager_->AddObserver(this); | 159 shelf_layout_manager_->AddObserver(this); |
160 shelf_container->aura_window()->SetLayoutManager(shelf_layout_manager_); | 160 shelf_container->aura_window()->SetLayoutManager(shelf_layout_manager_); |
161 background_animator_.PaintBackground( | 161 background_animator_.PaintBackground( |
162 shelf_layout_manager_->GetShelfBackgroundType(), | 162 shelf_layout_manager_->GetShelfBackgroundType(), |
163 AnimationChangeType::IMMEDIATE); | 163 AnimationChangeType::IMMEDIATE); |
164 | 164 |
165 views::Widget::AddObserver(this); | 165 views::Widget::AddObserver(this); |
166 | 166 |
167 // Calls back into |this| and depends on |shelf_view_|. | 167 // Calls back into |this| and depends on |shelf_view_|. |
168 background_animator_.AddObserver(this); | 168 background_animator_.AddObserver(this); |
169 background_animator_.AddObserver(delegate_view_); | 169 background_animator_.AddObserver(delegate_view_); |
170 } | 170 } |
171 | 171 |
172 ShelfWidget::~ShelfWidget() { | 172 ShelfWidget::~ShelfWidget() { |
173 // Must call Shutdown() before destruction. | 173 // Must call Shutdown() before destruction. |
174 DCHECK(!status_area_widget_); | 174 DCHECK(!status_area_widget_); |
175 background_animator_.RemoveObserver(delegate_view_); | 175 background_animator_.RemoveObserver(delegate_view_); |
176 background_animator_.RemoveObserver(this); | 176 background_animator_.RemoveObserver(this); |
177 Shell::Get()->focus_cycler()->RemoveWidget(this); | 177 Shell::Get()->focus_cycler()->RemoveWidget(this); |
178 SetFocusCycler(nullptr); | 178 SetFocusCycler(nullptr); |
179 RemoveObserver(this); | 179 RemoveObserver(this); |
180 } | 180 } |
181 | 181 |
182 void ShelfWidget::CreateStatusAreaWidget(WmWindow* status_container) { | 182 void ShelfWidget::CreateStatusAreaWidget(WmWindow* status_container) { |
183 DCHECK(status_container); | 183 DCHECK(status_container); |
184 DCHECK(!status_area_widget_); | 184 DCHECK(!status_area_widget_); |
185 status_area_widget_ = | 185 status_area_widget_ = |
186 new StatusAreaWidget(status_container->aura_window(), wm_shelf_); | 186 new StatusAreaWidget(status_container->aura_window(), shelf_); |
187 status_area_widget_->CreateTrayViews(); | 187 status_area_widget_->CreateTrayViews(); |
188 // NOTE: Container may be hidden depending on login/display state. | 188 // NOTE: Container may be hidden depending on login/display state. |
189 status_area_widget_->Show(); | 189 status_area_widget_->Show(); |
190 Shell::Get()->focus_cycler()->AddWidget(status_area_widget_); | 190 Shell::Get()->focus_cycler()->AddWidget(status_area_widget_); |
191 background_animator_.AddObserver(status_area_widget_); | 191 background_animator_.AddObserver(status_area_widget_); |
192 status_container->aura_window()->SetLayoutManager( | 192 status_container->aura_window()->SetLayoutManager( |
193 new StatusAreaLayoutManager(this)); | 193 new StatusAreaLayoutManager(this)); |
194 } | 194 } |
195 | 195 |
196 void ShelfWidget::SetPaintsBackground(ShelfBackgroundType background_type, | 196 void ShelfWidget::SetPaintsBackground(ShelfBackgroundType background_type, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 void ShelfWidget::UpdateShelfItemBackground(SkColor color) { | 327 void ShelfWidget::UpdateShelfItemBackground(SkColor color) { |
328 shelf_view_->UpdateShelfItemBackground(color); | 328 shelf_view_->UpdateShelfItemBackground(color); |
329 } | 329 } |
330 | 330 |
331 void ShelfWidget::WillDeleteShelfLayoutManager() { | 331 void ShelfWidget::WillDeleteShelfLayoutManager() { |
332 shelf_layout_manager_->RemoveObserver(this); | 332 shelf_layout_manager_->RemoveObserver(this); |
333 shelf_layout_manager_ = nullptr; | 333 shelf_layout_manager_ = nullptr; |
334 } | 334 } |
335 | 335 |
336 } // namespace ash | 336 } // namespace ash |
OLD | NEW |