Chromium Code Reviews| Index: ui/app_list/views/app_list_view.cc |
| diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc |
| index 7857271768cc3a70e5e547a038d37ae606946ccc..a2311d3dc39022d47c9f9163fa986890a352d222 100644 |
| --- a/ui/app_list/views/app_list_view.cc |
| +++ b/ui/app_list/views/app_list_view.cc |
| @@ -28,6 +28,7 @@ |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/layer_animation_observer.h" |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| +#include "ui/gfx/canvas.h" |
| #include "ui/gfx/image/image_skia.h" |
| #include "ui/gfx/insets.h" |
| #include "ui/gfx/path.h" |
| @@ -78,6 +79,28 @@ bool SupportsShadow() { |
| return true; |
| } |
| +// The background for the App List overlay, which appears as a white rounded |
| +// rectangle with the given radius and the same size as the target view. |
| +class AppListOverlayBackground : public views::Background { |
| + public: |
| + AppListOverlayBackground(int corner_radius) |
| + : corner_radius_(corner_radius) {}; |
| + virtual ~AppListOverlayBackground() {}; |
| + |
| + // Overridden from views::Background: |
| + virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
| + SkPaint paint; |
| + paint.setStyle(SkPaint::kFill_Style); |
| + paint.setColor(SK_ColorWHITE); |
| + canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); |
| + } |
| + |
| + private: |
| + const int corner_radius_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppListOverlayBackground); |
| +}; |
| + |
| } // namespace |
| // An animation observer to hide the view at the end of the animation. |
| @@ -127,6 +150,7 @@ AppListView::AppListView(AppListViewDelegate* delegate) |
| app_list_main_view_(NULL), |
| signin_view_(NULL), |
| speech_view_(NULL), |
| + overlay_view_(NULL), |
| animation_observer_(new HideViewAnimationObserver()) { |
| CHECK(delegate); |
| @@ -194,6 +218,11 @@ void AppListView::UpdateBounds() { |
| SizeToContents(); |
| } |
| +void AppListView::SetAppListOverlayVisible(bool visible) { |
| + DCHECK(overlay_view_); |
| + overlay_view_->SetVisible(visible); |
| +} |
| + |
| bool AppListView::ShouldCenterWindow() const { |
| return delegate_->ShouldCenterWindow(); |
| } |
| @@ -334,6 +363,33 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent, |
| GetWidget()->Hide(); |
| #endif |
| + // To make the overlay view, construct a view with a white background, rather |
| + // than a white rectangle in it. This is because we need overlay_view_ to be |
| + // drawn to its own layer (so it appears correctly in the foreground). |
| + const float kOverlayOpacity = 0.75f; |
| + overlay_view_ = new views::View(); |
| + overlay_view_->SetPaintToLayer(true); |
| + overlay_view_->layer()->SetOpacity(kOverlayOpacity); |
| + overlay_view_->SetBoundsRect(GetContentsBounds()); |
| + overlay_view_->SetVisible(false); |
| + |
| + if (SupportsShadow()) { |
| + overlay_view_->set_background( |
| + views::Background::CreateSolidBackground(SK_ColorWHITE)); |
|
tapted
2014/05/23 02:09:21
do you still want rounded corners in this case? Ma
sashab
2014/05/23 06:10:21
Okay, after testing this on all platforms, here's
|
| + } else { |
| + // On platforms that don't support a shadow, the rounded border is |
| + // constructed _inside_ the view, so a rectangular background goes over the |
| + // border in the rounded corners. To fix this, give the background a corner |
| + // radius 1px smaller than the outer border, so it just reaches but doesn't |
| + // cover it. |
| + const int kOverlayCornerRadius = |
| + GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius() - 1; |
| + overlay_view_->set_background( |
| + new AppListOverlayBackground(kOverlayCornerRadius)); |
| + } |
| + |
| + AddChildView(overlay_view_); |
| + |
| if (delegate_) |
| delegate_->ViewInitialized(); |
| } |