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 "ui/app_list/views/app_list_view.h" | 5 #include "ui/app_list/views/app_list_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
12 #include "ui/app_list/app_list_constants.h" | 12 #include "ui/app_list/app_list_constants.h" |
13 #include "ui/app_list/app_list_model.h" | 13 #include "ui/app_list/app_list_model.h" |
14 #include "ui/app_list/app_list_view_delegate.h" | 14 #include "ui/app_list/app_list_view_delegate.h" |
15 #include "ui/app_list/pagination_model.h" | |
16 #include "ui/app_list/speech_ui_model.h" | 15 #include "ui/app_list/speech_ui_model.h" |
17 #include "ui/app_list/views/app_list_background.h" | 16 #include "ui/app_list/views/app_list_background.h" |
18 #include "ui/app_list/views/app_list_folder_view.h" | 17 #include "ui/app_list/views/app_list_folder_view.h" |
19 #include "ui/app_list/views/app_list_main_view.h" | 18 #include "ui/app_list/views/app_list_main_view.h" |
20 #include "ui/app_list/views/app_list_view_observer.h" | 19 #include "ui/app_list/views/app_list_view_observer.h" |
21 #include "ui/app_list/views/apps_container_view.h" | 20 #include "ui/app_list/views/apps_container_view.h" |
22 #include "ui/app_list/views/contents_view.h" | 21 #include "ui/app_list/views/contents_view.h" |
23 #include "ui/app_list/views/search_box_view.h" | 22 #include "ui/app_list/views/search_box_view.h" |
24 #include "ui/app_list/views/speech_view.h" | 23 #include "ui/app_list/views/speech_view.h" |
25 #include "ui/base/ui_base_switches.h" | 24 #include "ui/base/ui_base_switches.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 AppListView::~AppListView() { | 157 AppListView::~AppListView() { |
159 delegate_->GetSpeechUI()->RemoveObserver(this); | 158 delegate_->GetSpeechUI()->RemoveObserver(this); |
160 delegate_->RemoveObserver(this); | 159 delegate_->RemoveObserver(this); |
161 animation_observer_.reset(); | 160 animation_observer_.reset(); |
162 // Remove child views first to ensure no remaining dependencies on delegate_. | 161 // Remove child views first to ensure no remaining dependencies on delegate_. |
163 RemoveAllChildViews(true); | 162 RemoveAllChildViews(true); |
164 } | 163 } |
165 | 164 |
166 void AppListView::InitAsBubbleAttachedToAnchor( | 165 void AppListView::InitAsBubbleAttachedToAnchor( |
167 gfx::NativeView parent, | 166 gfx::NativeView parent, |
168 PaginationModel* pagination_model, | 167 int initial_apps_page, |
169 views::View* anchor, | 168 views::View* anchor, |
170 const gfx::Vector2d& anchor_offset, | 169 const gfx::Vector2d& anchor_offset, |
171 views::BubbleBorder::Arrow arrow, | 170 views::BubbleBorder::Arrow arrow, |
172 bool border_accepts_events) { | 171 bool border_accepts_events) { |
173 SetAnchorView(anchor); | 172 SetAnchorView(anchor); |
174 InitAsBubbleInternal( | 173 InitAsBubbleInternal( |
175 parent, pagination_model, arrow, border_accepts_events, anchor_offset); | 174 parent, initial_apps_page, arrow, border_accepts_events, anchor_offset); |
176 } | 175 } |
177 | 176 |
178 void AppListView::InitAsBubbleAtFixedLocation( | 177 void AppListView::InitAsBubbleAtFixedLocation( |
179 gfx::NativeView parent, | 178 gfx::NativeView parent, |
180 PaginationModel* pagination_model, | 179 int initial_apps_page, |
181 const gfx::Point& anchor_point_in_screen, | 180 const gfx::Point& anchor_point_in_screen, |
182 views::BubbleBorder::Arrow arrow, | 181 views::BubbleBorder::Arrow arrow, |
183 bool border_accepts_events) { | 182 bool border_accepts_events) { |
184 SetAnchorView(NULL); | 183 SetAnchorView(NULL); |
185 SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size())); | 184 SetAnchorRect(gfx::Rect(anchor_point_in_screen, gfx::Size())); |
186 InitAsBubbleInternal( | 185 InitAsBubbleInternal( |
187 parent, pagination_model, arrow, border_accepts_events, gfx::Vector2d()); | 186 parent, initial_apps_page, arrow, border_accepts_events, gfx::Vector2d()); |
188 } | 187 } |
189 | 188 |
190 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { | 189 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { |
191 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); | 190 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); |
192 SizeToContents(); // Recalcuates with new border. | 191 SizeToContents(); // Recalcuates with new border. |
193 GetBubbleFrameView()->SchedulePaint(); | 192 GetBubbleFrameView()->SchedulePaint(); |
194 } | 193 } |
195 | 194 |
196 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) { | 195 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) { |
197 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); | 196 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 #if defined(USE_AURA) | 276 #if defined(USE_AURA) |
278 gfx::NativeWindow window = | 277 gfx::NativeWindow window = |
279 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 278 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
280 return window->GetHost()->GetAcceleratedWidget(); | 279 return window->GetHost()->GetAcceleratedWidget(); |
281 #else | 280 #else |
282 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 281 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
283 #endif | 282 #endif |
284 } | 283 } |
285 #endif | 284 #endif |
286 | 285 |
| 286 PaginationModel* AppListView::GetAppsPaginationModel() { |
| 287 return app_list_main_view_->contents_view() |
| 288 ->apps_container_view() |
| 289 ->apps_grid_view() |
| 290 ->pagination_model(); |
| 291 } |
| 292 |
287 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, | 293 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, |
288 PaginationModel* pagination_model, | 294 int initial_apps_page, |
289 views::BubbleBorder::Arrow arrow, | 295 views::BubbleBorder::Arrow arrow, |
290 bool border_accepts_events, | 296 bool border_accepts_events, |
291 const gfx::Vector2d& anchor_offset) { | 297 const gfx::Vector2d& anchor_offset) { |
292 app_list_main_view_ = new AppListMainView(delegate_.get(), | 298 app_list_main_view_ = |
293 pagination_model, | 299 new AppListMainView(delegate_.get(), initial_apps_page, parent); |
294 parent); | |
295 AddChildView(app_list_main_view_); | 300 AddChildView(app_list_main_view_); |
296 #if defined(USE_AURA) | 301 #if defined(USE_AURA) |
297 app_list_main_view_->SetPaintToLayer(true); | 302 app_list_main_view_->SetPaintToLayer(true); |
298 app_list_main_view_->SetFillsBoundsOpaquely(false); | 303 app_list_main_view_->SetFillsBoundsOpaquely(false); |
299 app_list_main_view_->layer()->SetMasksToBounds(true); | 304 app_list_main_view_->layer()->SetMasksToBounds(true); |
300 #endif | 305 #endif |
301 | 306 |
302 // Speech recognition is available only when the start page exists. | 307 // Speech recognition is available only when the start page exists. |
303 if (delegate_ && delegate_->GetSpeechRecognitionContents()) { | 308 if (delegate_ && delegate_->GetSpeechRecognitionContents()) { |
304 speech_view_ = new SpeechView(delegate_.get()); | 309 speech_view_ = new SpeechView(delegate_.get()); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 #else | 548 #else |
544 speech_view_->SetVisible(recognizing); | 549 speech_view_->SetVisible(recognizing); |
545 app_list_main_view_->SetVisible(!recognizing); | 550 app_list_main_view_->SetVisible(!recognizing); |
546 | 551 |
547 // Needs to schedule paint of AppListView itself, to repaint the background. | 552 // Needs to schedule paint of AppListView itself, to repaint the background. |
548 GetBubbleFrameView()->SchedulePaint(); | 553 GetBubbleFrameView()->SchedulePaint(); |
549 #endif | 554 #endif |
550 } | 555 } |
551 | 556 |
552 } // namespace app_list | 557 } // namespace app_list |
OLD | NEW |