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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ui/app_list/views/speech_view.h" | 26 #include "ui/app_list/views/speech_view.h" |
27 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
28 #include "ui/compositor/layer.h" | 28 #include "ui/compositor/layer.h" |
29 #include "ui/compositor/layer_animation_observer.h" | 29 #include "ui/compositor/layer_animation_observer.h" |
30 #include "ui/compositor/scoped_layer_animation_settings.h" | 30 #include "ui/compositor/scoped_layer_animation_settings.h" |
31 #include "ui/gfx/image/image_skia.h" | 31 #include "ui/gfx/image/image_skia.h" |
32 #include "ui/gfx/insets.h" | 32 #include "ui/gfx/insets.h" |
33 #include "ui/gfx/path.h" | 33 #include "ui/gfx/path.h" |
34 #include "ui/gfx/skia_util.h" | 34 #include "ui/gfx/skia_util.h" |
35 #include "ui/views/bubble/bubble_frame_view.h" | 35 #include "ui/views/bubble/bubble_frame_view.h" |
36 #include "ui/views/bubble/bubble_window_targeter.h" | |
37 #include "ui/views/controls/textfield/textfield.h" | 36 #include "ui/views/controls/textfield/textfield.h" |
38 #include "ui/views/layout/fill_layout.h" | 37 #include "ui/views/layout/fill_layout.h" |
39 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
40 | 39 |
41 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
42 #include "ui/aura/window.h" | 41 #include "ui/aura/window.h" |
43 #include "ui/aura/window_tree_host.h" | 42 #include "ui/aura/window_tree_host.h" |
| 43 #include "ui/views/bubble/bubble_window_targeter.h" |
44 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
45 #include "ui/base/win/shell.h" | 45 #include "ui/base/win/shell.h" |
46 #endif | 46 #endif |
47 #if !defined(OS_CHROMEOS) | 47 #if !defined(OS_CHROMEOS) |
48 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 48 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
49 #endif | 49 #endif |
50 #endif // defined(USE_AURA) | 50 #endif // defined(USE_AURA) |
51 | 51 |
52 namespace app_list { | 52 namespace app_list { |
53 | 53 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 observers_.RemoveObserver(observer); | 247 observers_.RemoveObserver(observer); |
248 } | 248 } |
249 | 249 |
250 // static | 250 // static |
251 void AppListView::SetNextPaintCallback(const base::Closure& callback) { | 251 void AppListView::SetNextPaintCallback(const base::Closure& callback) { |
252 next_paint_callback_ = callback; | 252 next_paint_callback_ = callback; |
253 } | 253 } |
254 | 254 |
255 #if defined(OS_WIN) | 255 #if defined(OS_WIN) |
256 HWND AppListView::GetHWND() const { | 256 HWND AppListView::GetHWND() const { |
257 #if defined(USE_AURA) | |
258 gfx::NativeWindow window = | 257 gfx::NativeWindow window = |
259 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | 258 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); |
260 return window->GetHost()->GetAcceleratedWidget(); | 259 return window->GetHost()->GetAcceleratedWidget(); |
261 #else | |
262 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); | |
263 #endif | |
264 } | 260 } |
265 #endif | 261 #endif |
266 | 262 |
267 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, | 263 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, |
268 PaginationModel* pagination_model, | 264 PaginationModel* pagination_model, |
269 views::BubbleBorder::Arrow arrow, | 265 views::BubbleBorder::Arrow arrow, |
270 bool border_accepts_events, | 266 bool border_accepts_events, |
271 const gfx::Vector2d& anchor_offset) { | 267 const gfx::Vector2d& anchor_offset) { |
272 app_list_main_view_ = new AppListMainView(delegate_.get(), | 268 app_list_main_view_ = new AppListMainView(delegate_.get(), |
273 pagination_model, | 269 pagination_model, |
274 parent); | 270 parent); |
275 AddChildView(app_list_main_view_); | 271 AddChildView(app_list_main_view_); |
276 #if defined(USE_AURA) | |
277 app_list_main_view_->SetPaintToLayer(true); | 272 app_list_main_view_->SetPaintToLayer(true); |
278 app_list_main_view_->SetFillsBoundsOpaquely(false); | 273 app_list_main_view_->SetFillsBoundsOpaquely(false); |
279 app_list_main_view_->layer()->SetMasksToBounds(true); | 274 app_list_main_view_->layer()->SetMasksToBounds(true); |
280 #endif | |
281 | 275 |
282 signin_view_ = | 276 signin_view_ = |
283 new SigninView(delegate_->GetSigninDelegate(), | 277 new SigninView(delegate_->GetSigninDelegate(), |
284 app_list_main_view_->GetPreferredSize().width()); | 278 app_list_main_view_->GetPreferredSize().width()); |
285 AddChildView(signin_view_); | 279 AddChildView(signin_view_); |
286 | 280 |
287 // Speech recognition is available only when the start page exists. | 281 // Speech recognition is available only when the start page exists. |
288 if (delegate_ && delegate_->GetSpeechRecognitionContents()) { | 282 if (delegate_ && delegate_->GetSpeechRecognitionContents()) { |
289 speech_view_ = new SpeechView(delegate_.get()); | 283 speech_view_ = new SpeechView(delegate_.get()); |
290 speech_view_->SetVisible(false); | 284 speech_view_->SetVisible(false); |
291 #if defined(USE_AURA) | |
292 speech_view_->SetPaintToLayer(true); | 285 speech_view_->SetPaintToLayer(true); |
293 speech_view_->SetFillsBoundsOpaquely(false); | 286 speech_view_->SetFillsBoundsOpaquely(false); |
294 speech_view_->layer()->SetOpacity(0.0f); | 287 speech_view_->layer()->SetOpacity(0.0f); |
295 #endif | |
296 AddChildView(speech_view_); | 288 AddChildView(speech_view_); |
297 } | 289 } |
298 | 290 |
299 OnProfilesChanged(); | 291 OnProfilesChanged(); |
300 set_color(kContentsBackgroundColor); | 292 set_color(kContentsBackgroundColor); |
301 set_margins(gfx::Insets()); | 293 set_margins(gfx::Insets()); |
302 set_parent_window(parent); | 294 set_parent_window(parent); |
303 set_close_on_deactivate(false); | 295 set_close_on_deactivate(false); |
304 set_close_on_esc(false); | 296 set_close_on_esc(false); |
305 set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(), | 297 set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(), |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 456 |
465 bool recognizing = (new_state == SPEECH_RECOGNITION_RECOGNIZING || | 457 bool recognizing = (new_state == SPEECH_RECOGNITION_RECOGNIZING || |
466 new_state == SPEECH_RECOGNITION_IN_SPEECH); | 458 new_state == SPEECH_RECOGNITION_IN_SPEECH); |
467 // No change for this class. | 459 // No change for this class. |
468 if (speech_view_->visible() == recognizing) | 460 if (speech_view_->visible() == recognizing) |
469 return; | 461 return; |
470 | 462 |
471 if (recognizing) | 463 if (recognizing) |
472 speech_view_->Reset(); | 464 speech_view_->Reset(); |
473 | 465 |
474 #if defined(USE_AURA) | |
475 animation_observer_->set_frame(GetBubbleFrameView()); | 466 animation_observer_->set_frame(GetBubbleFrameView()); |
476 gfx::Transform speech_transform; | 467 gfx::Transform speech_transform; |
477 speech_transform.Translate( | 468 speech_transform.Translate( |
478 0, SkFloatToMScalar(kSpeechUIAppearingPosition)); | 469 0, SkFloatToMScalar(kSpeechUIAppearingPosition)); |
479 if (recognizing) | 470 if (recognizing) |
480 speech_view_->layer()->SetTransform(speech_transform); | 471 speech_view_->layer()->SetTransform(speech_transform); |
481 | 472 |
482 { | 473 { |
483 ui::ScopedLayerAnimationSettings main_settings( | 474 ui::ScopedLayerAnimationSettings main_settings( |
484 app_list_main_view_->layer()->GetAnimator()); | 475 app_list_main_view_->layer()->GetAnimator()); |
(...skipping 16 matching lines...) Expand all Loading... |
501 if (recognizing) | 492 if (recognizing) |
502 speech_view_->layer()->SetTransform(gfx::Transform()); | 493 speech_view_->layer()->SetTransform(gfx::Transform()); |
503 else | 494 else |
504 speech_view_->layer()->SetTransform(speech_transform); | 495 speech_view_->layer()->SetTransform(speech_transform); |
505 } | 496 } |
506 | 497 |
507 if (recognizing) | 498 if (recognizing) |
508 speech_view_->SetVisible(true); | 499 speech_view_->SetVisible(true); |
509 else | 500 else |
510 app_list_main_view_->SetVisible(true); | 501 app_list_main_view_->SetVisible(true); |
511 #else | |
512 speech_view_->SetVisible(recognizing); | |
513 app_list_main_view_->SetVisible(!recognizing); | |
514 | |
515 // Needs to schedule paint of AppListView itself, to repaint the background. | |
516 GetBubbleFrameView()->SchedulePaint(); | |
517 #endif | |
518 } | 502 } |
519 | 503 |
520 } // namespace app_list | 504 } // namespace app_list |
OLD | NEW |