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 a7f607da5e433d6c42f89ad864613cc947c1310c..0d74acf9ed8ed459f6e77c276c732a2cfbf6fbf4 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,26 @@ bool SupportsShadow() { |
return true; |
} |
+// An background for a view that appears as a colored rounded rectangle with the |
+// given radius and the same size as the target view. |
+class ColoredRoundRectBackground : public views::Background { |
+ public: |
+ ColoredRoundRectBackground(int corner_radius, SkColor color) |
+ : corner_radius_(corner_radius), color_(color) {}; |
+ virtual ~ColoredRoundRectBackground() {}; |
+ |
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { |
+ SkPaint paint; |
+ paint.setStyle(SkPaint::kFill_Style); |
+ paint.setColor(color_); |
+ canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); |
+ } |
+ |
+ private: |
+ const int corner_radius_; |
+ const SkColor color_; |
+}; |
+ |
} // namespace |
// An animation observer to hide the view at the end of the animation. |
@@ -127,6 +148,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 +216,11 @@ void AppListView::UpdateBounds() { |
SizeToContents(); |
} |
+void AppListView::ShowAppListOverlay(bool visible) { |
+ DCHECK(overlay_view_); |
+ overlay_view_->SetVisible(visible); |
+} |
+ |
bool AppListView::ShouldCenterWindow() const { |
return delegate_->ShouldCenterWindow(); |
} |
@@ -334,6 +361,24 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent, |
GetWidget()->Hide(); |
#endif |
+ // The contents corner radius is 1px smaller than border corner radius. |
calamity
2014/05/20 08:42:06
Mention that this is needed for platforms where th
|
+ const int kOverlayCornerRadius = |
+ GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius() - 1; |
+ const float kOverlayOpacity = 0.75f; |
+ |
+ // To make the overlay view, construct a regular view with a solid white |
+ // background, rather than a white rectangle on it. This is because we need |
+ // overlay_view_ to be drawn to its own layer (so it appears correctly in the |
+ // foreground). |
+ overlay_view_ = new views::View(); |
+ overlay_view_->SetPaintToLayer(true); |
+ overlay_view_->set_background( |
+ new ColoredRoundRectBackground(kOverlayCornerRadius, SK_ColorWHITE)); |
+ overlay_view_->layer()->SetOpacity(kOverlayOpacity); |
+ overlay_view_->SetBoundsRect(bounds()); |
+ overlay_view_->SetVisible(false); |
+ AddChildView(overlay_view_); |
+ |
if (delegate_) |
delegate_->ViewInitialized(); |
} |