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..fa19fdbc6b014767558846d2b1522800f4b7326d 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 |
|
tapted
2014/05/21 03:40:57
nit: An -> A
sashab
2014/05/22 07:20:21
Oops :) Done.
|
| +// 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 { |
|
tapted
2014/05/21 03:40:57
nit: // Overridden from views::Background:
sashab
2014/05/22 07:20:21
Done.
|
| + SkPaint paint; |
| + paint.setStyle(SkPaint::kFill_Style); |
| + paint.setColor(color_); |
|
tapted
2014/05/21 03:40:57
this class is pretty specialized - I don't think t
sashab
2014/05/22 07:20:21
Yup, agreed. Done.
|
| + canvas->DrawRoundRect(view->GetContentsBounds(), corner_radius_, paint); |
| + } |
| + |
| + private: |
| + const int corner_radius_; |
| + const SkColor color_; |
| +}; |
|
tapted
2014/05/21 03:40:57
nit: DISALLOW_COPY_AND_ASSIGN(..)
sashab
2014/05/22 07:20:21
Done.
|
| + |
| } // 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,27 @@ void AppListView::InitAsBubbleInternal(gfx::NativeView parent, |
| GetWidget()->Hide(); |
| #endif |
| + // The contents corner radius is 1px smaller than border corner radius. We |
| + // need this for platforms where the bubble doesn't have a shadow (such as |
| + // Linux aura and Windows XP). When the bubble does have a shadow, the view is |
|
tapted
2014/05/21 03:40:57
I don't really understand this comment - seems to
sashab
2014/05/22 07:20:21
I didn't see SupportsShadow(). Thank you for that
|
| + // modal to the dialog, so a solid background is sufficient. |
| + 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()); |
|
tapted
2014/05/21 03:40:57
Since this is a child view, it shouldn't use the s
sashab
2014/05/22 07:20:21
Ahh yup - this was only working because it was pos
|
| + overlay_view_->SetVisible(false); |
| + AddChildView(overlay_view_); |
| + |
| if (delegate_) |
| delegate_->ViewInitialized(); |
| } |