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 10 matching lines...) Expand all Loading... |
21 #include "ui/app_list/views/app_list_view_observer.h" | 21 #include "ui/app_list/views/app_list_view_observer.h" |
22 #include "ui/app_list/views/apps_container_view.h" | 22 #include "ui/app_list/views/apps_container_view.h" |
23 #include "ui/app_list/views/contents_view.h" | 23 #include "ui/app_list/views/contents_view.h" |
24 #include "ui/app_list/views/search_box_view.h" | 24 #include "ui/app_list/views/search_box_view.h" |
25 #include "ui/app_list/views/signin_view.h" | 25 #include "ui/app_list/views/signin_view.h" |
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/canvas.h" |
31 #include "ui/gfx/image/image_skia.h" | 32 #include "ui/gfx/image/image_skia.h" |
32 #include "ui/gfx/insets.h" | 33 #include "ui/gfx/insets.h" |
33 #include "ui/gfx/path.h" | 34 #include "ui/gfx/path.h" |
34 #include "ui/gfx/skia_util.h" | 35 #include "ui/gfx/skia_util.h" |
35 #include "ui/views/bubble/bubble_frame_view.h" | 36 #include "ui/views/bubble/bubble_frame_view.h" |
36 #include "ui/views/bubble/bubble_window_targeter.h" | 37 #include "ui/views/bubble/bubble_window_targeter.h" |
37 #include "ui/views/controls/textfield/textfield.h" | 38 #include "ui/views/controls/textfield/textfield.h" |
38 #include "ui/views/layout/fill_layout.h" | 39 #include "ui/views/layout/fill_layout.h" |
39 #include "ui/views/widget/widget.h" | 40 #include "ui/views/widget/widget.h" |
40 | 41 |
(...skipping 30 matching lines...) Expand all Loading... |
71 switches::kDisableDwmComposition)) { | 72 switches::kDisableDwmComposition)) { |
72 return false; | 73 return false; |
73 } | 74 } |
74 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) | 75 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) |
75 // Shadows are not supported on (non-ChromeOS) Linux. | 76 // Shadows are not supported on (non-ChromeOS) Linux. |
76 return false; | 77 return false; |
77 #endif | 78 #endif |
78 return true; | 79 return true; |
79 } | 80 } |
80 | 81 |
| 82 // The background for the App List overlay, which appears as a white rounded |
| 83 // rectangle with the given radius and the same size as the target view. |
| 84 class AppListOverlayBackground : public views::Background { |
| 85 public: |
| 86 AppListOverlayBackground(int corner_radius) |
| 87 : corner_radius_(corner_radius) {}; |
| 88 virtual ~AppListOverlayBackground() {}; |
| 89 |
| 90 // Overridden from views::Background: |
| 91 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
| 92 SkPaint paint; |
| 93 paint.setStyle(SkPaint::kFill_Style); |
| 94 paint.setColor(SK_ColorWHITE); |
| 95 canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); |
| 96 } |
| 97 |
| 98 private: |
| 99 const int corner_radius_; |
| 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(AppListOverlayBackground); |
| 102 }; |
| 103 |
81 } // namespace | 104 } // namespace |
82 | 105 |
83 // An animation observer to hide the view at the end of the animation. | 106 // An animation observer to hide the view at the end of the animation. |
84 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { | 107 class HideViewAnimationObserver : public ui::ImplicitAnimationObserver { |
85 public: | 108 public: |
86 HideViewAnimationObserver() | 109 HideViewAnimationObserver() |
87 : frame_(NULL), | 110 : frame_(NULL), |
88 target_(NULL) { | 111 target_(NULL) { |
89 } | 112 } |
90 | 113 |
(...skipping 29 matching lines...) Expand all Loading... |
120 }; | 143 }; |
121 | 144 |
122 //////////////////////////////////////////////////////////////////////////////// | 145 //////////////////////////////////////////////////////////////////////////////// |
123 // AppListView: | 146 // AppListView: |
124 | 147 |
125 AppListView::AppListView(AppListViewDelegate* delegate) | 148 AppListView::AppListView(AppListViewDelegate* delegate) |
126 : delegate_(delegate), | 149 : delegate_(delegate), |
127 app_list_main_view_(NULL), | 150 app_list_main_view_(NULL), |
128 signin_view_(NULL), | 151 signin_view_(NULL), |
129 speech_view_(NULL), | 152 speech_view_(NULL), |
| 153 overlay_view_(NULL), |
130 animation_observer_(new HideViewAnimationObserver()) { | 154 animation_observer_(new HideViewAnimationObserver()) { |
131 CHECK(delegate); | 155 CHECK(delegate); |
132 | 156 |
133 delegate_->AddObserver(this); | 157 delegate_->AddObserver(this); |
134 delegate_->GetSpeechUI()->AddObserver(this); | 158 delegate_->GetSpeechUI()->AddObserver(this); |
135 } | 159 } |
136 | 160 |
137 AppListView::~AppListView() { | 161 AppListView::~AppListView() { |
138 delegate_->GetSpeechUI()->RemoveObserver(this); | 162 delegate_->GetSpeechUI()->RemoveObserver(this); |
139 delegate_->RemoveObserver(this); | 163 delegate_->RemoveObserver(this); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 211 |
188 void AppListView::Close() { | 212 void AppListView::Close() { |
189 app_list_main_view_->Close(); | 213 app_list_main_view_->Close(); |
190 delegate_->Dismiss(); | 214 delegate_->Dismiss(); |
191 } | 215 } |
192 | 216 |
193 void AppListView::UpdateBounds() { | 217 void AppListView::UpdateBounds() { |
194 SizeToContents(); | 218 SizeToContents(); |
195 } | 219 } |
196 | 220 |
| 221 void AppListView::SetAppListOverlayVisible(bool visible) { |
| 222 DCHECK(overlay_view_); |
| 223 overlay_view_->SetVisible(visible); |
| 224 } |
| 225 |
197 bool AppListView::ShouldCenterWindow() const { | 226 bool AppListView::ShouldCenterWindow() const { |
198 return delegate_->ShouldCenterWindow(); | 227 return delegate_->ShouldCenterWindow(); |
199 } | 228 } |
200 | 229 |
201 gfx::Size AppListView::GetPreferredSize() const { | 230 gfx::Size AppListView::GetPreferredSize() const { |
202 return app_list_main_view_->GetPreferredSize(); | 231 return app_list_main_view_->GetPreferredSize(); |
203 } | 232 } |
204 | 233 |
205 void AppListView::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { | 234 void AppListView::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { |
206 views::BubbleDelegateView::Paint(canvas, cull_set); | 235 views::BubbleDelegateView::Paint(canvas, cull_set); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 app_list_main_view_)); | 356 app_list_main_view_)); |
328 | 357 |
329 // On non-aura the bubble has two widgets, and it's possible for the border | 358 // On non-aura the bubble has two widgets, and it's possible for the border |
330 // to be shown independently in odd situations. Explicitly hide the bubble | 359 // to be shown independently in odd situations. Explicitly hide the bubble |
331 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the | 360 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the |
332 // window manager do not have the SWP_SHOWWINDOW flag set which would cause | 361 // window manager do not have the SWP_SHOWWINDOW flag set which would cause |
333 // the border to be shown. See http://crbug.com/231687 . | 362 // the border to be shown. See http://crbug.com/231687 . |
334 GetWidget()->Hide(); | 363 GetWidget()->Hide(); |
335 #endif | 364 #endif |
336 | 365 |
| 366 // To make the overlay view, construct a view with a white background, rather |
| 367 // than a white rectangle in it. This is because we need overlay_view_ to be |
| 368 // drawn to its own layer (so it appears correctly in the foreground). |
| 369 const float kOverlayOpacity = 0.75f; |
| 370 overlay_view_ = new views::View(); |
| 371 overlay_view_->SetPaintToLayer(true); |
| 372 overlay_view_->layer()->SetOpacity(kOverlayOpacity); |
| 373 overlay_view_->SetBoundsRect(GetContentsBounds()); |
| 374 overlay_view_->SetVisible(false); |
| 375 |
| 376 // On platforms that don't support a shadow, the rounded border of the app |
| 377 // list is constructed _inside_ the view, so a rectangular background goes |
| 378 // over the border in the rounded corners. To fix this, give the background a |
| 379 // corner radius 1px smaller than the outer border, so it just reaches but |
| 380 // doesn't cover it. |
| 381 const int kOverlayCornerRadius = |
| 382 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(); |
| 383 overlay_view_->set_background(new AppListOverlayBackground( |
| 384 kOverlayCornerRadius - (SupportsShadow() ? 0 : 1))); |
| 385 |
| 386 AddChildView(overlay_view_); |
| 387 |
337 if (delegate_) | 388 if (delegate_) |
338 delegate_->ViewInitialized(); | 389 delegate_->ViewInitialized(); |
339 } | 390 } |
340 | 391 |
341 void AppListView::OnBeforeBubbleWidgetInit( | 392 void AppListView::OnBeforeBubbleWidgetInit( |
342 views::Widget::InitParams* params, | 393 views::Widget::InitParams* params, |
343 views::Widget* widget) const { | 394 views::Widget* widget) const { |
344 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 395 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
345 if (delegate_ && delegate_->ForceNativeDesktop()) | 396 if (delegate_ && delegate_->ForceNativeDesktop()) |
346 params->native_widget = new views::DesktopNativeWidgetAura(widget); | 397 params->native_widget = new views::DesktopNativeWidgetAura(widget); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 #else | 562 #else |
512 speech_view_->SetVisible(recognizing); | 563 speech_view_->SetVisible(recognizing); |
513 app_list_main_view_->SetVisible(!recognizing); | 564 app_list_main_view_->SetVisible(!recognizing); |
514 | 565 |
515 // Needs to schedule paint of AppListView itself, to repaint the background. | 566 // Needs to schedule paint of AppListView itself, to repaint the background. |
516 GetBubbleFrameView()->SchedulePaint(); | 567 GetBubbleFrameView()->SchedulePaint(); |
517 #endif | 568 #endif |
518 } | 569 } |
519 | 570 |
520 } // namespace app_list | 571 } // namespace app_list |
OLD | NEW |