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/system/tray/tray_background_view.h" | 5 #include "ash/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/wm_shelf_util.h" | 8 #include "ash/common/shelf/wm_shelf_util.h" |
| 9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 public: | 90 public: |
| 91 const static int kImageTypeDefault = 0; | 91 const static int kImageTypeDefault = 0; |
| 92 const static int kImageTypeOnBlack = 1; | 92 const static int kImageTypeOnBlack = 1; |
| 93 const static int kImageTypePressed = 2; | 93 const static int kImageTypePressed = 2; |
| 94 const static int kNumStates = 3; | 94 const static int kNumStates = 3; |
| 95 | 95 |
| 96 const static int kImageHorizontal = 0; | 96 const static int kImageHorizontal = 0; |
| 97 const static int kImageVertical = 1; | 97 const static int kImageVertical = 1; |
| 98 const static int kNumOrientations = 2; | 98 const static int kNumOrientations = 2; |
| 99 | 99 |
| 100 explicit TrayBackground(TrayBackgroundView* tray_background_view) : | 100 explicit TrayBackground(TrayBackgroundView* tray_background_view) |
| 101 tray_background_view_(tray_background_view) { | 101 : tray_background_view_(tray_background_view), alpha_(0) {} |
| 102 } | |
| 103 | 102 |
| 104 ~TrayBackground() override {} | 103 ~TrayBackground() override {} |
| 105 | 104 |
| 105 void set_alpha(int alpha) { alpha_ = alpha; } | |
| 106 | |
| 106 private: | 107 private: |
| 107 ShelfWidget* GetShelfWidget() const { | 108 ShelfWidget* GetShelfWidget() const { |
| 108 return tray_background_view_->GetShelfLayoutManager()->shelf_widget(); | 109 return tray_background_view_->GetShelfLayoutManager()->shelf_widget(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { | 112 void PaintMaterial(gfx::Canvas* canvas, views::View* view) const { |
| 112 SkColor color = SK_ColorTRANSPARENT; | 113 SkColor color = SkColorSetA(kShelfBaseColor, alpha_); |
| 113 ShelfWidget* shelf_widget = GetShelfWidget(); | |
| 114 if (tray_background_view_->draw_background_as_active()) { | 114 if (tray_background_view_->draw_background_as_active()) { |
| 115 // TODO(bruthig|mohsen): Use of this color is temporary. Draw the active | 115 // TODO(bruthig|mohsen): Use of this color is temporary. Draw the active |
| 116 // state using the material design ripple animation. | 116 // state using the material design ripple animation. |
| 117 color = SK_ColorBLUE; | 117 color = SK_ColorBLUE; |
| 118 } else if (shelf_widget && | |
| 119 shelf_widget->GetBackgroundType() == | |
| 120 ShelfBackgroundType::SHELF_BACKGROUND_DEFAULT) { | |
| 121 color = SkColorSetA(kShelfBaseColor, | |
| 122 GetShelfConstant(SHELF_BACKGROUND_ALPHA)); | |
| 123 } | 118 } |
| 124 | 119 |
| 125 // TODO(bruthig|tdanderson): The background should be changed using a | 120 // TODO(bruthig|tdanderson): The background should be changed using a |
| 126 // fade in/out animation. | 121 // fade in/out animation. |
| 127 const int kCornerRadius = 2; | 122 const int kCornerRadius = 2; |
| 128 SkPaint paint; | 123 SkPaint paint; |
| 129 paint.setFlags(SkPaint::kAntiAlias_Flag); | 124 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 130 paint.setColor(color); | 125 paint.setColor(color); |
| 131 canvas->DrawRoundRect(view->GetLocalBounds(), kCornerRadius, paint); | 126 canvas->DrawRoundRect(view->GetLocalBounds(), kCornerRadius, paint); |
| 132 } | 127 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 void Paint(gfx::Canvas* canvas, views::View* view) const override { | 164 void Paint(gfx::Canvas* canvas, views::View* view) const override { |
| 170 if (MaterialDesignController::IsShelfMaterial()) | 165 if (MaterialDesignController::IsShelfMaterial()) |
| 171 PaintMaterial(canvas, view); | 166 PaintMaterial(canvas, view); |
| 172 else | 167 else |
| 173 PaintNonMaterial(canvas, view); | 168 PaintNonMaterial(canvas, view); |
| 174 } | 169 } |
| 175 | 170 |
| 176 // Reference to the TrayBackgroundView for which this is a background. | 171 // Reference to the TrayBackgroundView for which this is a background. |
| 177 TrayBackgroundView* tray_background_view_; | 172 TrayBackgroundView* tray_background_view_; |
| 178 | 173 |
| 174 int alpha_; | |
| 175 | |
| 179 DISALLOW_COPY_AND_ASSIGN(TrayBackground); | 176 DISALLOW_COPY_AND_ASSIGN(TrayBackground); |
| 180 }; | 177 }; |
| 181 | 178 |
| 182 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) | 179 TrayBackgroundView::TrayContainer::TrayContainer(ShelfAlignment alignment) |
| 183 : alignment_(alignment) { | 180 : alignment_(alignment) { |
| 184 UpdateLayout(); | 181 UpdateLayout(); |
| 185 } | 182 } |
| 186 | 183 |
| 187 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { | 184 void TrayBackgroundView::TrayContainer::SetAlignment(ShelfAlignment alignment) { |
| 188 if (alignment_ == alignment) | 185 if (alignment_ == alignment) |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 368 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 372 SetDrawBackgroundAsActive(true); | 369 SetDrawBackgroundAsActive(true); |
| 373 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 370 } else if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 374 event->type() == ui::ET_GESTURE_TAP_CANCEL) { | 371 event->type() == ui::ET_GESTURE_TAP_CANCEL) { |
| 375 SetDrawBackgroundAsActive(false); | 372 SetDrawBackgroundAsActive(false); |
| 376 } | 373 } |
| 377 } | 374 } |
| 378 ActionableView::OnGestureEvent(event); | 375 ActionableView::OnGestureEvent(event); |
| 379 } | 376 } |
| 380 | 377 |
| 381 void TrayBackgroundView::UpdateBackground(int alpha) { | |
| 382 // The animator should never fire when the alternate shelf layout is used. | |
|
James Cook
2016/06/14 17:50:02
Hooray for eliminating old "alternate shelf layout
| |
| 383 if (!background_ || draw_background_as_active_) | |
| 384 return; | |
| 385 SchedulePaint(); | |
| 386 } | |
| 387 | |
| 388 void TrayBackgroundView::SetContents(views::View* contents) { | 378 void TrayBackgroundView::SetContents(views::View* contents) { |
| 389 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 379 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| 390 AddChildView(contents); | 380 AddChildView(contents); |
| 391 } | 381 } |
| 392 void TrayBackgroundView::SetContentsBackground() { | 382 void TrayBackgroundView::SetContentsBackground() { |
| 393 background_ = new TrayBackground(this); | 383 background_ = new TrayBackground(this); |
| 394 tray_container_->set_background(background_); | 384 tray_container_->set_background(background_); |
| 395 } | 385 } |
| 396 | 386 |
| 397 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { | 387 ShelfLayoutManager* TrayBackgroundView::GetShelfLayoutManager() { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 if (!background_) | 556 if (!background_) |
| 567 return; | 557 return; |
| 568 SchedulePaint(); | 558 SchedulePaint(); |
| 569 } | 559 } |
| 570 | 560 |
| 571 void TrayBackgroundView::UpdateBubbleViewArrow( | 561 void TrayBackgroundView::UpdateBubbleViewArrow( |
| 572 views::TrayBubbleView* bubble_view) { | 562 views::TrayBubbleView* bubble_view) { |
| 573 // Nothing to do here. | 563 // Nothing to do here. |
| 574 } | 564 } |
| 575 | 565 |
| 566 void TrayBackgroundView::UpdateShelfItemBackground(int alpha) { | |
| 567 if (background_) | |
| 568 background_->set_alpha(alpha); | |
| 569 SchedulePaint(); | |
| 570 } | |
| 571 | |
| 576 } // namespace ash | 572 } // namespace ash |
| OLD | NEW |