| 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 569e939369e26c480a368488596996bd1150bdf7..6dd4ac95656773519c30aec93b6300df5d0f57f1 100644
|
| --- a/ash/common/system/tray/tray_background_view.cc
|
| +++ b/ash/common/system/tray/tray_background_view.cc
|
| @@ -12,6 +12,7 @@
|
| #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"
|
| +#include "ash/common/system/view_observer.h"
|
| #include "ash/common/wm_lookup.h"
|
| #include "ash/common/wm_shell.h"
|
| #include "ash/common/wm_window.h"
|
| @@ -29,6 +30,7 @@
|
| #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"
|
| @@ -109,14 +111,14 @@ class TrayBackground : public views::Background {
|
| SkPaint background_paint;
|
| background_paint.setFlags(SkPaint::kAntiAlias_Flag);
|
| background_paint.setColor(background_color);
|
| - canvas->DrawRoundRect(view->GetLocalBounds(), kTrayRoundedBorderRadius,
|
| + canvas->DrawRoundRect(view->GetContentsBounds(), 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,
|
| + canvas->DrawRoundRect(view->GetContentsBounds(), kTrayRoundedBorderRadius,
|
| highlight_paint);
|
| }
|
| }
|
| @@ -208,14 +210,6 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() {
|
| 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(padding, padding, padding, padding));
|
| - }
|
| -
|
| views::BoxLayout* layout = new views::BoxLayout(orientation, 0, 0, 0);
|
| layout->SetDefaultFlex(1);
|
| views::View::SetLayoutManager(layout);
|
| @@ -225,7 +219,8 @@ void TrayBackgroundView::TrayContainer::UpdateLayout() {
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // TrayBackgroundView
|
|
|
| -TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
|
| +TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf,
|
| + ViewObserver* view_observer)
|
| : wm_shelf_(wm_shelf),
|
| tray_container_(NULL),
|
| shelf_alignment_(SHELF_ALIGNMENT_BOTTOM),
|
| @@ -238,11 +233,14 @@ TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf)
|
| tray_container_ = new TrayContainer(shelf_alignment_);
|
| SetContents(tray_container_);
|
| tray_event_filter_.reset(new TrayEventFilter);
|
| + view_observer_ = view_observer;
|
| + is_separator_visible_ = false;
|
|
|
| SetPaintToLayer(true);
|
| layer()->SetFillsBoundsOpaquely(false);
|
| // Start the tray items not visible, because visibility changes are animated.
|
| views::View::SetVisible(false);
|
| + CalculateAndSetTrayContainerBorder();
|
| }
|
|
|
| TrayBackgroundView::~TrayBackgroundView() {
|
| @@ -269,6 +267,9 @@ void TrayBackgroundView::InitializeBubbleAnimations(
|
| void TrayBackgroundView::SetVisible(bool visible) {
|
| if (visible == layer()->GetTargetVisibility())
|
| return;
|
| + // OnVisibilityChange will only be called if the visibility of the tray item
|
| + // is changed.
|
| + view_observer_->OnVisibilityChange(this);
|
|
|
| if (visible) {
|
| // The alignment of the shelf can change while the TrayBackgroundView is
|
| @@ -377,9 +378,26 @@ void TrayBackgroundView::SetContentsBackground() {
|
|
|
| void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
|
| shelf_alignment_ = alignment;
|
| + CalculateAndSetTrayContainerBorder();
|
| tray_container_->SetAlignment(alignment);
|
| }
|
|
|
| +void TrayBackgroundView::CalculateAndSetTrayContainerBorder() {
|
| + if (!MaterialDesignController::IsShelfMaterial()) {
|
| + tray_container()->SetBorder(views::Border::NullBorder());
|
| + return;
|
| + }
|
| + if (IsHorizontalAlignment(shelf()->GetAlignment())) {
|
| + // Extend hit region horizontally when horizontally aligned.
|
| + tray_container()->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(
|
| + 0, kHitRegionPadding, 0, kHitRegionPadding + kSeparatorWidth)));
|
| + } else {
|
| + // Extend hit region vertically when vertically aligned.
|
| + tray_container()->SetBorder(views::Border::CreateEmptyBorder(gfx::Insets(
|
| + kHitRegionPadding, 0, kHitRegionPadding + kSeparatorWidth, 0)));
|
| + }
|
| +}
|
| +
|
| void TrayBackgroundView::OnImplicitAnimationsCompleted() {
|
| // If there is another animation in the queue, the reverse animation was
|
| // triggered before the completion of animating to invisible. Do not turn off
|
| @@ -510,4 +528,35 @@ void TrayBackgroundView::UpdateBubbleViewArrow(
|
| // Nothing to do here.
|
| }
|
|
|
| +void TrayBackgroundView::SetSeparatorVisibility(bool is_show) {
|
| + if (is_separator_visible_ != is_show)
|
| + is_separator_visible_ = is_show;
|
| +}
|
| +
|
| +void TrayBackgroundView::OnPaint(gfx::Canvas* canvas) {
|
| + if (!MaterialDesignController::IsShelfMaterial() ||
|
| + shelf()->GetBackgroundType() ==
|
| + ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT)
|
| + return;
|
| +
|
| + if (is_separator_visible_) {
|
| + const int height = GetTrayConstant(TRAY_ITEM_HEIGHT_LEGACY);
|
| + const int width = kSeparatorWidth;
|
| + const int x = height + kHitRegionPadding + kHitRegionPadding;
|
| + const int y = (GetShelfConstant(SHELF_SIZE) - height) / 2;
|
| + const float scale = canvas->UndoDeviceScaleFactor();
|
| + SkPaint paint;
|
| + paint.setColor(kSeparatorColor);
|
| + paint.setAntiAlias(true);
|
| + const bool horizontal_shelf =
|
| + IsHorizontalAlignment(shelf()->GetAlignment());
|
| + const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height)
|
| + : gfx::Rect(y, x, height, width);
|
| + gfx::ScopedCanvas scoped_canvas(canvas);
|
| + 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
|
|
|