Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/system/tray/tray_background_view.h" | 5 #include "ash/common/system/tray/tray_background_view.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "ash/common/shelf/shelf_constants.h" | 8 #include "ash/common/shelf/shelf_constants.h" |
| 9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "ui/gfx/animation/tween.h" | 26 #include "ui/gfx/animation/tween.h" |
| 27 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
| 29 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| 30 #include "ui/gfx/image/image_skia.h" | 30 #include "ui/gfx/image/image_skia.h" |
| 31 #include "ui/gfx/image/image_skia_operations.h" | 31 #include "ui/gfx/image/image_skia_operations.h" |
| 32 #include "ui/gfx/nine_image_painter.h" | 32 #include "ui/gfx/nine_image_painter.h" |
| 33 #include "ui/gfx/scoped_canvas.h" | 33 #include "ui/gfx/scoped_canvas.h" |
| 34 #include "ui/gfx/skia_util.h" | 34 #include "ui/gfx/skia_util.h" |
| 35 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
| 36 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | |
| 37 #include "ui/views/animation/ink_drop_highlight.h" | |
| 36 #include "ui/views/background.h" | 38 #include "ui/views/background.h" |
| 37 #include "ui/views/layout/box_layout.h" | 39 #include "ui/views/layout/box_layout.h" |
| 38 #include "ui/wm/core/window_animations.h" | 40 #include "ui/wm/core/window_animations.h" |
| 39 | 41 |
| 40 namespace { | 42 namespace { |
| 41 | 43 |
| 42 const int kAnimationDurationForPopupMs = 200; | 44 const int kAnimationDurationForPopupMs = 200; |
| 43 | 45 |
| 44 // Duration of opacity animation for visibility changes. | 46 // Duration of opacity animation for visibility changes. |
| 45 const int kAnimationDurationForVisibilityMs = 250; | 47 const int kAnimationDurationForVisibilityMs = 250; |
| 46 | 48 |
| 47 // When becoming visible delay the animation so that StatusAreaWidgetDelegate | 49 // When becoming visible delay the animation so that StatusAreaWidgetDelegate |
| 48 // can animate sibling views out of the position to be occuped by the | 50 // can animate sibling views out of the position to be occuped by the |
| 49 // TrayBackgroundView. | 51 // TrayBackgroundView. |
| 50 const int kShowAnimationDelayMs = 100; | 52 const int kShowAnimationDelayMs = 100; |
| 51 | 53 |
| 52 // Additional padding used to adjust the user-visible size of status tray | 54 // Additional padding used to adjust the user-visible size of status tray |
| 53 // and overview button dark background. | 55 // and overview button dark background. |
| 54 const int kBackgroundAdjustPadding = 3; | 56 const int kBackgroundAdjustPadding = 3; |
| 55 | 57 |
| 58 const gfx::Rect GetBackgroundBounds(const gfx::Rect& local_bounds, | |
| 59 ash::ShelfAlignment shelf_alignment) { | |
| 60 if (IsHorizontalAlignment(shelf_alignment)) { | |
| 61 return gfx::Rect(local_bounds.x() + ash::kHitRegionPadding, | |
| 62 local_bounds.y(), | |
| 63 local_bounds.width() - ash::kHitRegionPadding - | |
| 64 ash::kHitRegionPadding - ash::kSeparatorWidth, | |
| 65 local_bounds.height()); | |
| 66 } | |
| 67 return gfx::Rect(local_bounds.x(), local_bounds.y() + ash::kHitRegionPadding, | |
| 68 local_bounds.width(), | |
| 69 local_bounds.height() - ash::kHitRegionPadding - | |
| 70 ash::kHitRegionPadding - ash::kSeparatorWidth); | |
| 71 } | |
| 56 } // namespace | 72 } // namespace |
| 57 | 73 |
| 58 using views::TrayBubbleView; | 74 using views::TrayBubbleView; |
| 59 | 75 |
| 60 namespace ash { | 76 namespace ash { |
| 61 | 77 |
| 62 // static | 78 // static |
| 63 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; | 79 const char TrayBackgroundView::kViewClassName[] = "tray/TrayBackgroundView"; |
| 64 | 80 |
| 65 // Used to track when the anchor widget changes position on screen so that the | 81 // Used to track when the anchor widget changes position on screen so that the |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 87 public: | 103 public: |
| 88 const static int kImageTypeDefault = 0; | 104 const static int kImageTypeDefault = 0; |
| 89 const static int kImageTypeOnBlack = 1; | 105 const static int kImageTypeOnBlack = 1; |
| 90 const static int kImageTypePressed = 2; | 106 const static int kImageTypePressed = 2; |
| 91 const static int kNumStates = 3; | 107 const static int kNumStates = 3; |
| 92 | 108 |
| 93 const static int kImageHorizontal = 0; | 109 const static int kImageHorizontal = 0; |
| 94 const static int kImageVertical = 1; | 110 const static int kImageVertical = 1; |
| 95 const static int kNumOrientations = 2; | 111 const static int kNumOrientations = 2; |
| 96 | 112 |
| 97 explicit TrayBackground(TrayBackgroundView* tray_background_view) | 113 TrayBackground(TrayBackgroundView* tray_background_view, bool draws_active) |
| 98 : tray_background_view_(tray_background_view), alpha_(0) {} | 114 : tray_background_view_(tray_background_view), |
| 115 draws_active_(draws_active), | |
| 116 alpha_(0) {} | |
| 99 | 117 |
| 100 ~TrayBackground() override {} | 118 ~TrayBackground() override {} |
| 101 | 119 |
| 102 void set_alpha(int alpha) { alpha_ = alpha; } | 120 void set_alpha(int alpha) { alpha_ = alpha; } |
| 103 | 121 |
| 104 private: | 122 private: |
| 105 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } | 123 WmShelf* GetShelf() const { return tray_background_view_->shelf(); } |
| 106 | 124 |
| 107 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { | 125 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { |
| 108 SkPaint background_paint; | 126 SkPaint background_paint; |
| 109 background_paint.setFlags(SkPaint::kAntiAlias_Flag); | 127 background_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 110 background_paint.setColor(SkColorSetA(kShelfBaseColor, alpha_)); | 128 background_paint.setColor(SkColorSetA(kShelfBaseColor, alpha_)); |
| 111 gfx::Rect bounds; | |
| 112 gfx::Rect local_bounds = view->GetLocalBounds(); | 129 gfx::Rect local_bounds = view->GetLocalBounds(); |
| 113 | 130 gfx::Rect bounds = |
| 114 // The hit region are padded to the |view| as insets, so they are included | 131 GetBackgroundBounds(local_bounds, GetShelf()->GetAlignment()); |
| 115 // in the local bounds. Remove these regions from view because hit region is | |
| 116 // invisible. | |
| 117 if (IsHorizontalAlignment(GetShelf()->GetAlignment())) { | |
| 118 bounds = gfx::Rect(local_bounds.x() + kHitRegionPadding, local_bounds.y(), | |
| 119 local_bounds.width() - kHitRegionPadding - | |
| 120 kHitRegionPadding - kSeparatorWidth, | |
| 121 local_bounds.height()); | |
| 122 } else { | |
| 123 bounds = gfx::Rect(local_bounds.x(), local_bounds.y() + kHitRegionPadding, | |
| 124 local_bounds.width(), | |
| 125 local_bounds.height() - kHitRegionPadding - | |
| 126 kHitRegionPadding - kSeparatorWidth); | |
| 127 } | |
| 128 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_paint); | 132 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, background_paint); |
| 129 | 133 |
| 130 if (tray_background_view_->draw_background_as_active()) { | 134 if (draws_active_ && tray_background_view_->is_active()) { |
| 131 SkPaint highlight_paint; | 135 SkPaint highlight_paint; |
| 132 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); | 136 highlight_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 133 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); | 137 highlight_paint.setColor(kShelfButtonActivatedHighlightColor); |
| 134 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_paint); | 138 canvas->DrawRoundRect(bounds, kTrayRoundedBorderRadius, highlight_paint); |
| 135 } | 139 } |
| 136 } | 140 } |
| 137 | 141 |
| 138 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { | 142 void PaintNonMaterial(gfx::Canvas* canvas, views::View* view) const { |
| 139 const int kGridSizeForPainter = 9; | 143 const int kGridSizeForPainter = 9; |
| 140 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { | 144 const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = { |
| 141 { | 145 { |
| 142 // Horizontal | 146 // Horizontal |
| 143 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), | 147 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ), |
| 144 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), | 148 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK), |
| 145 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), | 149 IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED), |
| 146 }, | 150 }, |
| 147 { | 151 { |
| 148 // Vertical | 152 // Vertical |
| 149 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), | 153 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL), |
| 150 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), | 154 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK), |
| 151 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), | 155 IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED), |
| 152 }}; | 156 }}; |
| 153 | 157 |
| 154 WmShelf* shelf = GetShelf(); | 158 WmShelf* shelf = GetShelf(); |
| 155 const int orientation = IsHorizontalAlignment(shelf->GetAlignment()) | 159 const int orientation = IsHorizontalAlignment(shelf->GetAlignment()) |
| 156 ? kImageHorizontal | 160 ? kImageHorizontal |
| 157 : kImageVertical; | 161 : kImageVertical; |
| 158 | 162 |
| 159 int state = kImageTypeDefault; | 163 int state = kImageTypeDefault; |
| 160 if (tray_background_view_->draw_background_as_active()) | 164 if (draws_active_ && tray_background_view_->is_active()) |
| 161 state = kImageTypePressed; | 165 state = kImageTypePressed; |
| 162 else if (shelf->IsDimmed()) | 166 else if (shelf->IsDimmed()) |
| 163 state = kImageTypeOnBlack; | 167 state = kImageTypeOnBlack; |
| 164 else | 168 else |
| 165 state = kImageTypeDefault; | 169 state = kImageTypeDefault; |
| 166 | 170 |
| 167 ui::CreateNineImagePainter(kImages[orientation][state]) | 171 ui::CreateNineImagePainter(kImages[orientation][state]) |
| 168 ->Paint(canvas, view->GetLocalBounds()); | 172 ->Paint(canvas, view->GetLocalBounds()); |
| 169 } | 173 } |
| 170 | 174 |
| 171 // Overridden from views::Background. | 175 // Overridden from views::Background. |
| 172 void Paint(gfx::Canvas* canvas, views::View* view) const override { | 176 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
| 173 if (MaterialDesignController::IsShelfMaterial()) | 177 if (MaterialDesignController::IsShelfMaterial()) |
| 174 PaintMaterial(canvas, view); | 178 PaintMaterial(canvas, view); |
| 175 else | 179 else |
| 176 PaintNonMaterial(canvas, view); | 180 PaintNonMaterial(canvas, view); |
| 177 } | 181 } |
| 178 | 182 |
| 179 // Reference to the TrayBackgroundView for which this is a background. | 183 // Reference to the TrayBackgroundView for which this is a background. |
| 180 TrayBackgroundView* tray_background_view_; | 184 TrayBackgroundView* tray_background_view_; |
| 181 | 185 |
| 186 // Determines whether we should draw an active background for the view when it | |
| 187 // is active. | |
| 188 // TODO(mohsen): This is used in non-MD version. Remove when non-MD code is | |
| 189 // removed (see https://crbug.com/614453). | |
| 190 bool draws_active_; | |
| 191 | |
| 182 int alpha_; | 192 int alpha_; |
| 183 | 193 |
| 184 DISALLOW_COPY_AND_ASSIGN(TrayBackground); | 194 DISALLOW_COPY_AND_ASSIGN(TrayBackground); |
| 185 }; | 195 }; |
| 186 | 196 |
| 187 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) | 197 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) |
| 188 : alignment_(alignment) { | 198 : alignment_(alignment) { |
| 189 UpdateLayout(); | 199 UpdateLayout(); |
| 190 } | 200 } |
| 191 | 201 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 | 259 |
| 250 //////////////////////////////////////////////////////////////////////////////// | 260 //////////////////////////////////////////////////////////////////////////////// |
| 251 // TrayBackgroundView | 261 // TrayBackgroundView |
| 252 | 262 |
| 253 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) | 263 TrayBackgroundView::TrayBackgroundView(WmShelf* wm_shelf) |
| 254 : ActionableView(nullptr), | 264 : ActionableView(nullptr), |
| 255 wm_shelf_(wm_shelf), | 265 wm_shelf_(wm_shelf), |
| 256 tray_container_(NULL), | 266 tray_container_(NULL), |
| 257 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), | 267 shelf_alignment_(SHELF_ALIGNMENT_BOTTOM), |
| 258 background_(NULL), | 268 background_(NULL), |
| 259 draw_background_as_active_(false), | 269 is_active_(false), |
| 260 is_separator_visible_(false), | 270 is_separator_visible_(false), |
| 261 widget_observer_(new TrayWidgetObserver(this)) { | 271 widget_observer_(new TrayWidgetObserver(this)) { |
| 262 DCHECK(wm_shelf_); | 272 DCHECK(wm_shelf_); |
| 263 set_notify_enter_exit_on_child(true); | 273 set_notify_enter_exit_on_child(true); |
| 274 set_ink_drop_base_color(SK_ColorWHITE); | |
|
bruthig
2016/11/11 17:30:40
Can we move this color to a constant in tray_const
mohsen
2016/11/11 22:37:24
Actually, there is a constant for this color! Done
| |
| 275 set_ink_drop_visible_opacity(kShelfInkDropVisibleOpacity); | |
| 264 | 276 |
| 265 tray_container_ = new TrayContainer(shelf_alignment_); | 277 tray_container_ = new TrayContainer(shelf_alignment_); |
| 266 SetContents(tray_container_); | 278 SetContents(tray_container_); |
| 267 tray_event_filter_.reset(new TrayEventFilter); | 279 tray_event_filter_.reset(new TrayEventFilter); |
| 268 | 280 |
| 269 SetPaintToLayer(true); | 281 SetPaintToLayer(true); |
| 270 layer()->SetFillsBoundsOpaquely(false); | 282 layer()->SetFillsBoundsOpaquely(false); |
| 271 // Start the tray items not visible, because visibility changes are animated. | 283 // Start the tray items not visible, because visibility changes are animated. |
| 272 views::View::SetVisible(false); | 284 views::View::SetVisible(false); |
| 273 } | 285 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 node_data->SetName(GetAccessibleNameForTray()); | 369 node_data->SetName(GetAccessibleNameForTray()); |
| 358 } | 370 } |
| 359 | 371 |
| 360 void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { | 372 void TrayBackgroundView::AboutToRequestFocusFromTabTraversal(bool reverse) { |
| 361 // Return focus to the login view. See crbug.com/120500. | 373 // Return focus to the login view. See crbug.com/120500. |
| 362 views::View* v = GetNextFocusableView(); | 374 views::View* v = GetNextFocusableView(); |
| 363 if (v) | 375 if (v) |
| 364 v->AboutToRequestFocusFromTabTraversal(reverse); | 376 v->AboutToRequestFocusFromTabTraversal(reverse); |
| 365 } | 377 } |
| 366 | 378 |
| 379 std::unique_ptr<views::InkDropRipple> TrayBackgroundView::CreateInkDropRipple() | |
| 380 const { | |
| 381 return base::MakeUnique<views::FloodFillInkDropRipple>( | |
| 382 GetBackgroundBounds(GetContentsBounds(), shelf_alignment_), | |
| 383 GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), | |
| 384 ink_drop_visible_opacity()); | |
| 385 } | |
| 386 | |
| 387 std::unique_ptr<views::InkDropHighlight> | |
| 388 TrayBackgroundView::CreateInkDropHighlight() const { | |
| 389 gfx::Rect bounds = GetBackgroundBounds(GetContentsBounds(), shelf_alignment_); | |
| 390 std::unique_ptr<views::InkDropHighlight> highlight( | |
| 391 new views::InkDropHighlight(bounds.size(), 0, | |
| 392 gfx::RectF(bounds).CenterPoint(), | |
| 393 GetInkDropBaseColor())); | |
| 394 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | |
| 395 return highlight; | |
| 396 } | |
| 397 | |
| 398 bool TrayBackgroundView::ShouldEnterPushedState(const ui::Event& event) { | |
| 399 if (is_active_) | |
| 400 return false; | |
| 401 | |
| 402 return ActionableView::ShouldEnterPushedState(event); | |
| 403 } | |
| 404 | |
| 367 bool TrayBackgroundView::PerformAction(const ui::Event& event) { | 405 bool TrayBackgroundView::PerformAction(const ui::Event& event) { |
| 368 return false; | 406 return false; |
| 369 } | 407 } |
| 370 | 408 |
| 409 void TrayBackgroundView::HandlePerformActionResult(bool action_performed, | |
| 410 const ui::Event& event) { | |
| 411 // When an action is performed, ink drop ripple is handled in SetIsActive(). | |
| 412 if (action_performed) | |
| 413 return; | |
| 414 ActionableView::HandlePerformActionResult(action_performed, event); | |
| 415 } | |
| 416 | |
| 371 gfx::Rect TrayBackgroundView::GetFocusBounds() { | 417 gfx::Rect TrayBackgroundView::GetFocusBounds() { |
| 372 // The tray itself expands to the right and bottom edge of the screen to make | 418 // The tray itself expands to the right and bottom edge of the screen to make |
| 373 // sure clicking on the edges brings up the popup. However, the focus border | 419 // sure clicking on the edges brings up the popup. However, the focus border |
| 374 // should be only around the container. | 420 // should be only around the container. |
| 375 return GetContentsBounds(); | 421 return GetContentsBounds(); |
| 376 } | 422 } |
| 377 | 423 |
| 378 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { | 424 void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { |
| 379 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 425 if (ink_drop_mode() == InkDropMode::OFF) { |
| 380 SetDrawBackgroundAsActive(true); | 426 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 381 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 427 SetIsActive(true); |
| 382 event->type() == ui::ET_GESTURE_TAP_CANCEL) { | 428 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 383 SetDrawBackgroundAsActive(false); | 429 event->type() == ui::ET_GESTURE_TAP_CANCEL) { |
| 430 SetIsActive(false); | |
| 431 } | |
| 384 } | 432 } |
| 385 ActionableView::OnGestureEvent(event); | 433 ActionableView::OnGestureEvent(event); |
| 386 } | 434 } |
| 387 | 435 |
| 388 void TrayBackgroundView::SetContents(views::View* contents) { | 436 void TrayBackgroundView::SetContents(views::View* contents) { |
| 389 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 437 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 390 AddChildView(contents); | 438 AddChildView(contents); |
| 391 } | 439 } |
| 392 void TrayBackgroundView::SetContentsBackground() { | 440 void TrayBackgroundView::SetContentsBackground(bool draws_active) { |
| 393 background_ = new TrayBackground(this); | 441 background_ = new TrayBackground(this, draws_active); |
| 394 tray_container_->set_background(background_); | 442 tray_container_->set_background(background_); |
| 395 } | 443 } |
| 396 | 444 |
| 397 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { | 445 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { |
| 398 shelf_alignment_ = alignment; | 446 shelf_alignment_ = alignment; |
| 399 tray_container_->SetAlignment(alignment); | 447 tray_container_->SetAlignment(alignment); |
| 400 } | 448 } |
| 401 | 449 |
| 402 void TrayBackgroundView::OnImplicitAnimationsCompleted() { | 450 void TrayBackgroundView::OnImplicitAnimationsCompleted() { |
| 403 // If there is another animation in the queue, the reverse animation was | 451 // If there is another animation in the queue, the reverse animation was |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 } | 556 } |
| 509 | 557 |
| 510 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { | 558 TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
| 511 if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) | 559 if (shelf_alignment_ == SHELF_ALIGNMENT_LEFT) |
| 512 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; | 560 return TrayBubbleView::ANCHOR_ALIGNMENT_LEFT; |
| 513 if (shelf_alignment_ == SHELF_ALIGNMENT_RIGHT) | 561 if (shelf_alignment_ == SHELF_ALIGNMENT_RIGHT) |
| 514 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; | 562 return TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT; |
| 515 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; | 563 return TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM; |
| 516 } | 564 } |
| 517 | 565 |
| 518 void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { | 566 void TrayBackgroundView::SetIsActive(bool is_active) { |
| 519 if (draw_background_as_active_ == visible) | 567 if (is_active_ == is_active) |
| 520 return; | 568 return; |
| 521 draw_background_as_active_ = visible; | 569 is_active_ = is_active; |
| 570 AnimateInkDrop(is_active_ ? views::InkDropState::ACTIVATED | |
| 571 : views::InkDropState::DEACTIVATED, | |
| 572 nullptr); | |
| 522 if (!background_) | 573 if (!background_) |
| 523 return; | 574 return; |
| 575 // TODO(mohsen): This is needed for non-MD version. Remove when non-MD code is | |
| 576 // removed (see https://crbug.com/614453). | |
| 524 SchedulePaint(); | 577 SchedulePaint(); |
| 525 } | 578 } |
| 526 | 579 |
| 527 void TrayBackgroundView::UpdateBubbleViewArrow( | 580 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 528 views::TrayBubbleView* bubble_view) { | 581 views::TrayBubbleView* bubble_view) { |
| 529 // Nothing to do here. | 582 // Nothing to do here. |
| 530 } | 583 } |
| 531 | 584 |
| 532 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { | 585 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { |
| 533 if (background_) { | 586 if (background_) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 paint.setAntiAlias(true); | 619 paint.setAntiAlias(true); |
| 567 | 620 |
| 568 const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height) | 621 const gfx::Rect bounds = horizontal_shelf ? gfx::Rect(x, y, width, height) |
| 569 : gfx::Rect(y, x, height, width); | 622 : gfx::Rect(y, x, height, width); |
| 570 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); | 623 gfx::RectF rect(gfx::ScaleRect(gfx::RectF(bounds), scale)); |
| 571 canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(), | 624 canvas->DrawLine(horizontal_shelf ? rect.top_right() : rect.bottom_left(), |
| 572 rect.bottom_right(), paint); | 625 rect.bottom_right(), paint); |
| 573 } | 626 } |
| 574 | 627 |
| 575 } // namespace ash | 628 } // namespace ash |
| OLD | NEW |