| 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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "ui/views/bubble/bubble_frame_view.h" | 38 #include "ui/views/bubble/bubble_frame_view.h" |
| 39 #include "ui/views/controls/image_view.h" | 39 #include "ui/views/controls/image_view.h" |
| 40 #include "ui/views/controls/textfield/textfield.h" | 40 #include "ui/views/controls/textfield/textfield.h" |
| 41 #include "ui/views/layout/fill_layout.h" | 41 #include "ui/views/layout/fill_layout.h" |
| 42 #include "ui/views/widget/widget.h" | 42 #include "ui/views/widget/widget.h" |
| 43 | 43 |
| 44 #if defined(USE_AURA) | 44 #if defined(USE_AURA) |
| 45 #include "ui/aura/window.h" | 45 #include "ui/aura/window.h" |
| 46 #include "ui/aura/window_tree_host.h" | 46 #include "ui/aura/window_tree_host.h" |
| 47 #include "ui/views/bubble/bubble_window_targeter.h" | 47 #include "ui/views/bubble/bubble_window_targeter.h" |
| 48 #include "ui/wm/core/masked_window_targeter.h" |
| 48 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 49 #include "ui/base/win/shell.h" | 50 #include "ui/base/win/shell.h" |
| 50 #endif | 51 #endif |
| 51 #if !defined(OS_CHROMEOS) | 52 #if !defined(OS_CHROMEOS) |
| 52 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 53 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 53 #endif | 54 #endif |
| 54 #endif // defined(USE_AURA) | 55 #endif // defined(USE_AURA) |
| 55 | 56 |
| 56 namespace app_list { | 57 namespace app_list { |
| 57 | 58 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 paint.setColor(SK_ColorWHITE); | 103 paint.setColor(SK_ColorWHITE); |
| 103 canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, paint); | 104 canvas->DrawRoundRect(GetContentsBounds(), corner_radius_, paint); |
| 104 } | 105 } |
| 105 | 106 |
| 106 private: | 107 private: |
| 107 const int corner_radius_; | 108 const int corner_radius_; |
| 108 | 109 |
| 109 DISALLOW_COPY_AND_ASSIGN(AppListOverlayView); | 110 DISALLOW_COPY_AND_ASSIGN(AppListOverlayView); |
| 110 }; | 111 }; |
| 111 | 112 |
| 113 #if defined(USE_AURA) |
| 114 // An event targeter for the search box widget which will ignore events that |
| 115 // are on the search box's shadow. |
| 116 class SearchBoxWindowTargeter : public wm::MaskedWindowTargeter { |
| 117 public: |
| 118 explicit SearchBoxWindowTargeter(views::View* search_box) |
| 119 : wm::MaskedWindowTargeter(search_box->GetWidget()->GetNativeWindow()), |
| 120 search_box_(search_box) {} |
| 121 ~SearchBoxWindowTargeter() override {} |
| 122 |
| 123 private: |
| 124 // wm::MaskedWindowTargeter: |
| 125 bool GetHitTestMask(aura::Window* window, gfx::Path* mask) const override { |
| 126 mask->addRect(gfx::RectToSkRect(search_box_->GetContentsBounds())); |
| 127 return true; |
| 128 } |
| 129 |
| 130 views::View* search_box_; |
| 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(SearchBoxWindowTargeter); |
| 133 }; |
| 134 #endif |
| 135 |
| 112 } // namespace | 136 } // namespace |
| 113 | 137 |
| 114 // An animation observer to hide the view at the end of the animation. | 138 // An animation observer to hide the view at the end of the animation. |
| 115 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { | 139 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { |
| 116 public: | 140 public: |
| 117 HideViewAnimationObserver() | 141 HideViewAnimationObserver() |
| 118 : frame_(NULL), | 142 : frame_(NULL), |
| 119 target_(NULL) { | 143 target_(NULL) { |
| 120 } | 144 } |
| 121 | 145 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 search_box_widget_params.opacity = | 443 search_box_widget_params.opacity = |
| 420 views::Widget::InitParams::TRANSLUCENT_WINDOW; | 444 views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 421 | 445 |
| 422 // Create a widget for the SearchBoxView to live in. This allows the | 446 // Create a widget for the SearchBoxView to live in. This allows the |
| 423 // SearchBoxView to be on top of the custom launcher page's WebContents | 447 // SearchBoxView to be on top of the custom launcher page's WebContents |
| 424 // (otherwise the search box events will be captured by the WebContents). | 448 // (otherwise the search box events will be captured by the WebContents). |
| 425 search_box_widget_ = new views::Widget; | 449 search_box_widget_ = new views::Widget; |
| 426 search_box_widget_->Init(search_box_widget_params); | 450 search_box_widget_->Init(search_box_widget_params); |
| 427 search_box_widget_->SetContentsView(search_box_view_); | 451 search_box_widget_->SetContentsView(search_box_view_); |
| 428 | 452 |
| 453 #if defined(USE_AURA) |
| 454 // Mouse events on the search box shadow should not be captured. |
| 455 aura::Window* window = search_box_widget_->GetNativeWindow(); |
| 456 window->SetEventTargeter(scoped_ptr<ui::EventTargeter>( |
| 457 new SearchBoxWindowTargeter(search_box_view_))); |
| 458 #endif |
| 459 |
| 429 app_list_main_view_->contents_view()->Layout(); | 460 app_list_main_view_->contents_view()->Layout(); |
| 430 } | 461 } |
| 431 | 462 |
| 432 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, | 463 void AppListView::InitAsBubbleInternal(gfx::NativeView parent, |
| 433 int initial_apps_page, | 464 int initial_apps_page, |
| 434 views::BubbleBorder::Arrow arrow, | 465 views::BubbleBorder::Arrow arrow, |
| 435 bool border_accepts_events, | 466 bool border_accepts_events, |
| 436 const gfx::Vector2d& anchor_offset) { | 467 const gfx::Vector2d& anchor_offset) { |
| 437 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. | 468 // TODO(vadimt): Remove ScopedTracker below once crbug.com/431326 is fixed. |
| 438 tracked_objects::ScopedTracker tracking_profile1( | 469 tracked_objects::ScopedTracker tracking_profile1( |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 | 757 |
| 727 if (will_appear) { | 758 if (will_appear) { |
| 728 speech_view_->SetVisible(true); | 759 speech_view_->SetVisible(true); |
| 729 } else { | 760 } else { |
| 730 app_list_main_view_->SetVisible(true); | 761 app_list_main_view_->SetVisible(true); |
| 731 search_box_view_->search_box()->RequestFocus(); | 762 search_box_view_->search_box()->RequestFocus(); |
| 732 } | 763 } |
| 733 } | 764 } |
| 734 | 765 |
| 735 } // namespace app_list | 766 } // namespace app_list |
| OLD | NEW |