| Index: ash/common/system/tray/tray_background_view.cc
|
| diff --git a/ash/common/system/tray/tray_background_view.cc b/ash/common/system/tray/tray_background_view.cc
|
| index e6393764d72dda2bf251ca1f66e52c3359dffb96..0e0a149d585fd86a113c79650020c7f6d57dbbaf 100644
|
| --- a/ash/common/system/tray/tray_background_view.cc
|
| +++ b/ash/common/system/tray/tray_background_view.cc
|
| @@ -9,6 +9,7 @@
|
| #include "ash/common/shelf/wm_shelf.h"
|
| #include "ash/common/shelf/wm_shelf_util.h"
|
| #include "ash/common/shell_window_ids.h"
|
| +#include "ash/common/system/status_area_widget.h"
|
| #include "ash/common/system/tray/system_tray.h"
|
| #include "ash/common/system/tray/tray_constants.h"
|
| #include "ash/common/system/tray/tray_event_filter.h"
|
| @@ -25,9 +26,11 @@
|
| #include "ui/gfx/animation/tween.h"
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/geometry/rect.h"
|
| +#include "ui/gfx/geometry/size.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/image/image_skia_operations.h"
|
| #include "ui/gfx/nine_image_painter.h"
|
| +#include "ui/gfx/scoped_canvas.h"
|
| #include "ui/gfx/skia_util.h"
|
| #include "ui/gfx/transform.h"
|
| #include "ui/views/background.h"
|
| @@ -46,6 +49,10 @@ const int kAnimationDurationForVisibilityMs = 250;
|
| // TrayBackgroundView.
|
| const int kShowAnimationDelayMs = 100;
|
|
|
| +// Additional padding used to adjust the user-visible size of status tray
|
| +// and overview button dark background.
|
| +const int kBackgroundAdjustPadding = 3;
|
| +
|
| } // namespace
|
|
|
| using views::TrayBubbleView;
|
| @@ -101,15 +108,30 @@ class TrayBackground : public views::Background {
|
| SkPaint background_paint;
|
| background_paint.setFlags(SkPaint::kAntiAlias_Flag);
|
| background_paint.setColor(SkColorSetA(kShelfBaseColor, alpha_));
|
| - canvas->DrawRoundRect(view->GetLocalBounds(), kTrayRoundedBorderRadius,
|
| - background_paint);
|
| + gfx::Rect bounds;
|
| + gfx::Rect local_bounds = view->GetLocalBounds();
|
| +
|
| + // The hit region are padded to the |view| as insets, so they are included
|
| + // in the local bounds. Remove these regions from view because hit region is
|
| + // invisible.
|
| + if (IsHorizontalAlignment(GetShelf()->GetAlignment())) {
|
| + bounds = gfx::Rect(local_bounds.x() + kHitRegionPadding, local_bounds.y(),
|
| + local_bounds.width() - kHitRegionPadding -
|
| + kHitRegionPadding - kSeparatorWidth,
|
| + local_bounds.height());
|
| + } else {
|
| + bounds = gfx::Rect(local_bounds.x(), local_bounds.y() + kHitRegionPadding,
|
| + local_bounds.width(),
|
| + local_bounds.height() - kHitRegionPadding -
|
| + kHitRegionPadding - kSeparatorWidth);
|
| + }
|
| + canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_paint);
|
|
|
| if (tray_background_view_->draw_background_as_active()) {
|
| SkPaint highlight_paint;
|
| highlight_paint.setFlags(SkPaint::kAntiAlias_Flag);
|
| highlight_paint.setColor(kShelfButtonActivatedHighlightColor);
|
| - canvas->DrawRoundRect(view->GetLocalBounds(), kTrayRoundedBorderRadius,
|
| - highlight_paint);
|
| + canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_paint);
|
| }
|
| }
|
|
|
| @@ -206,16 +228,16 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() {
|
| views::BoxLayout::Orientation orientation =
|
| IsHorizontalAlignment(alignment_) ? views::BoxLayout::kHorizontal
|
| : views::BoxLayout::kVertical;
|
| -
|
| - if (!ash::MaterialDesignController::IsShelfMaterial()) {
|
| - // Additional padding used to adjust the user-visible size of status tray
|
| - // dark background.
|
| - const int padding = 3;
|
| - SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(padding) + margin_));
|
| - } else {
|
| - SetBorder(views::Border::CreateEmptyBorder(margin_));
|
| - }
|
| -
|
| + const gfx::Insets insets(
|
| + ash::MaterialDesignController::IsShelfMaterial()
|
| + ? gfx::Insets(IsHorizontalAlignment(alignment_)
|
| + ? gfx::Insets(0, kHitRegionPadding, 0,
|
| + kHitRegionPadding + kSeparatorWidth)
|
| + : gfx::Insets(kHitRegionPadding, 0,
|
| + kHitRegionPadding + kSeparatorWidth,
|
| + 0))
|
| + : gfx::Insets(kBackgroundAdjustPadding));
|
| + SetBorder(views::Border::CreateEmptyBorder(insets + margin_));
|
| views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0);
|
| layout->SetDefaultFlex(1);
|
| views::View::SetLayoutManager(layout);
|
| @@ -231,6 +253,7 @@ TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
|
| shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
|
| background_(NULL),
|
| draw_background_as_active_(false),
|
| + is_separator_visible_(false),
|
| widget_observer_(new TrayWidgetObserver(this)) {
|
| DCHECK(wm_shelf_);
|
| set_notify_enter_exit_on_child(true);
|
| @@ -314,6 +337,7 @@ void TrayBackgroundView::SetVisible(bool visible) {
|
| layer()->SetVisible(false);
|
| HideTransformation();
|
| }
|
| + wm_shelf_->GetStatusAreaWidget()->OnTrayVisibilityChanged(this);
|
| }
|
|
|
| const char* TrayBackgroundView::GetClassName() const {
|
| @@ -508,4 +532,39 @@ void TrayBackgroundView::UpdateShelfItemBackground(int alpha) {
|
| }
|
| }
|
|
|
| +void TrayBackgroundView::SetSeparatorVisibility(bool is_shown) {
|
| + is_separator_visible_ = is_shown;
|
| + SchedulePaint();
|
| +}
|
| +
|
| +void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) {
|
| + if (!MaterialDesignController::IsShelfMaterial() ||
|
| + shelf()->GetBackgroundType() ==
|
| + ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT ||
|
| + !is_separator_visible_) {
|
| + return;
|
| + }
|
| + // In the given |canvas|, draws a 1x32px separator line 4 pixel to the right
|
| + // of the TrayBackgroundView.
|
| + const bool horizontal_shelf = IsHorizontalAlignment(shelf_alignment_);
|
| + const gfx::Rect local_bounds = GetLocalBounds();
|
| + const int height = kTrayItemSize;
|
| + const int width = kSeparatorWidth;
|
| + const int x =
|
| + (horizontal_shelf ? local_bounds.width() : local_bounds.height()) -
|
| + kSeparatorWidth;
|
| + const int y = (GetShelfConstant(SHELF_SIZE) - kTrayItemSize) / 2;
|
| + gfx::ScopedCanvas scoped_canvas(canvas);
|
| + const float scale = canvas->UndoDeviceScaleFactor();
|
| + SkPaint paint;
|
| + paint.setColor(kSeparatorColor);
|
| + paint.setAntiAlias(true);
|
| +
|
| + const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height)
|
| + : gfx::Rect(y, x, height, width);
|
| + gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale));
|
| + canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(),
|
| + rect.bottom_right(), paint);
|
| +}
|
| +
|
| } // namespace ash
|
|
|